/* ============================================================
   SwadiPOS License Dashboard – Design System v2.0
   Professional RTL Arabic Admin Panel
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800&display=swap');

/* ─── CUSTOM PROPERTIES ──────────────────────────────────── */
:root {
  --c-primary:       #1a56db;
  --c-primary-hover: #1349c5;
  --c-primary-light: #ebf5ff;
  --c-primary-dark:  #1e3a8a;
  --c-success:       #057a55;
  --c-success-bg:    #def7ec;
  --c-warning:       #c27803;
  --c-warning-bg:    #fdf6b2;
  --c-danger:        #c81e1e;
  --c-danger-bg:     #fde8e8;
  --c-info:          #0369a1;
  --c-info-bg:       #e0f2fe;
  --c-purple:        #7e3af2;
  --c-purple-bg:     #f0e9ff;
  --c-gray-900:#111928; --c-gray-800:#1f2a37; --c-gray-700:#374151;
  --c-gray-600:#4b5563; --c-gray-500:#6b7280; --c-gray-400:#9ca3af;
  --c-gray-300:#d1d5db; --c-gray-200:#e5e7eb; --c-gray-100:#f3f4f6;
  --c-gray-50:#f9fafb;  --c-white:#ffffff;
  --sidebar-bg:          #111928;
  --sidebar-text:        #9ca3af;
  --sidebar-active-bg:   rgba(26,86,219,0.18);
  --sidebar-active-text: #93c5fd;
  --sidebar-hover-bg:    rgba(255,255,255,0.06);
  --sidebar-border:      rgba(255,255,255,0.08);
  --sidebar-width: 240px;
  --page-bg:      #f3f4f6;
  --card-bg:      #ffffff;
  --card-border:  1px solid #e5e7eb;
  --card-shadow:  0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
  --card-radius:  14px;
  --topbar-h:     62px;
  --gap: 18px;
  --font: 'Tajawal', 'Segoe UI', system-ui, sans-serif;
  --text-primary:   #111928;
  --text-secondary: #4b5563;
  --text-muted:     #9ca3af;
}

/* ─── BASE ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--page-bg);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.6;
}
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── SIDEBAR ────────────────────────────────────────────── */
.app-sidebar {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: var(--sidebar-width); background: var(--sidebar-bg);
  display: flex; flex-direction: column; z-index: 200; overflow-y: auto;
}
.sidebar-brand { padding: 20px 16px 16px; border-bottom: 1px solid var(--sidebar-border); }
.sidebar-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.sidebar-logo:hover { text-decoration: none; }
.sidebar-logo-icon { width: 36px; height: 36px; background: var(--c-primary); border-radius: 9px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sidebar-app-name    { font-size: 14.5px; font-weight: 800; color: #fff; display: block; line-height: 1.2; }
.sidebar-app-version { font-size: 11px; color: var(--sidebar-text); }
.sidebar-nav { flex: 1; padding: 10px; }
.nav-group-label { font-size: 10px; font-weight: 700; color: #4b5563; text-transform: uppercase; letter-spacing: 0.1em; padding: 12px 8px 5px; }
.nav-item { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 9px; color: var(--sidebar-text); font-size: 13.5px; font-weight: 500; margin-bottom: 2px; text-decoration: none; transition: background 0.12s, color 0.12s; }
.nav-item:hover  { background: var(--sidebar-hover-bg); color: #e5e7eb; text-decoration: none; }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); font-weight: 700; }
.nav-item svg { flex-shrink: 0; width: 17px; height: 17px; opacity: 0.85; }
.nav-badge { margin-right: auto; background: var(--c-danger); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 99px; min-width: 18px; text-align: center; }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--sidebar-border); }
.admin-chip { display: flex; align-items: center; gap: 9px; padding: 8px; border-radius: 9px; transition: background 0.12s; }
.admin-chip:hover { background: var(--sidebar-hover-bg); }
.admin-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--c-primary); color: white; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; flex-shrink: 0; }
.admin-name { font-size: 13px; font-weight: 600; color: #e5e7eb; }
.admin-role { font-size: 11px; color: var(--sidebar-text); }

/* ─── MAIN AREA ──────────────────────────────────────────── */
.app-main     { margin-right: var(--sidebar-width); min-height: 100vh; display: flex; flex-direction: column; }
.page-content { flex: 1; padding: 22px 24px; }

/* ─── TOPBAR ─────────────────────────────────────────────── */
.topbar { height: var(--topbar-h); background: var(--card-bg); border-bottom: var(--card-border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 100; gap: 14px; }
.topbar-left  { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }
.topbar-title { font-size: 17px; font-weight: 800; line-height: 1.2; }
.topbar-sub   { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.hamburger-btn { display: none; align-items: center; justify-content: center; width: 36px; height: 36px; background: none; border: 1px solid var(--c-gray-200); border-radius: 8px; cursor: pointer; color: var(--text-primary); }
.mobile-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 150; }
.mobile-backdrop.open { display: block; }

/* ─── CARDS ──────────────────────────────────────────────── */
.card { background: var(--card-bg); border-radius: var(--card-radius); border: var(--card-border); box-shadow: var(--card-shadow); padding: 22px; margin-bottom: var(--gap); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.card-title    { font-size: 15px; font-weight: 800; color: var(--text-primary); }
.card-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.card-actions  { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.section-nested { background: var(--c-gray-50); border: 1px solid var(--c-gray-200); border-radius: 11px; padding: 18px; margin-top: 14px; }

/* ─── STATS GRID ─────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 12px; margin-bottom: var(--gap); }
.stat-card { display: block; background: var(--card-bg); border-radius: 12px; border: var(--card-border); border-right: 4px solid var(--c-gray-300); padding: 15px 17px; text-decoration: none; box-shadow: var(--card-shadow); transition: transform 0.13s, box-shadow 0.13s; cursor: default; }
a.stat-card { cursor: pointer; }
a.stat-card:hover { transform: translateY(-2px); box-shadow: 0 5px 18px rgba(0,0,0,0.09); text-decoration: none; }
.stat-card.c-blue   { border-right-color: var(--c-primary); }
.stat-card.c-green  { border-right-color: var(--c-success); }
.stat-card.c-yellow { border-right-color: var(--c-warning); }
.stat-card.c-red    { border-right-color: var(--c-danger); }
.stat-card.c-purple { border-right-color: var(--c-purple); }
.stat-card.c-info   { border-right-color: var(--c-info); }
.stat-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 7px; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--text-primary); line-height: 1.1; }
.stat-value.c-blue   { color: var(--c-primary); }
.stat-value.c-green  { color: var(--c-success); }
.stat-value.c-yellow { color: var(--c-warning); }
.stat-value.c-red    { color: var(--c-danger); }
.stat-value.c-purple { color: var(--c-purple); }
.stat-value.c-info   { color: var(--c-info); }

/* ─── HEALTH DOTS ────────────────────────────────────────── */
.h-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.h-dot.green  { background: var(--c-success); box-shadow: 0 0 0 3px rgba(5,122,85,0.18); }
.h-dot.yellow { background: var(--c-warning); box-shadow: 0 0 0 3px rgba(194,120,3,0.18); }
.h-dot.red    { background: var(--c-danger);  box-shadow: 0 0 0 3px rgba(200,30,30,0.18); }
.h-dot.gray   { background: var(--c-gray-300); }

/* ─── BADGES ─────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge.success { background: var(--c-success-bg); color: var(--c-success); }
.badge.warning { background: var(--c-warning-bg); color: var(--c-warning); }
.badge.danger  { background: var(--c-danger-bg);  color: var(--c-danger); }
.badge.info    { background: var(--c-info-bg);    color: var(--c-info); }
.badge.purple  { background: var(--c-purple-bg);  color: var(--c-purple); }
.badge.neutral { background: var(--c-gray-100); color: var(--c-gray-600); border: 1px solid var(--c-gray-200); }
.badge.plan-premium { background: var(--c-purple-bg); color: var(--c-purple); }
.badge.plan-pro     { background: var(--c-primary-light); color: var(--c-primary-dark); }
.badge.plan-plus    { background: var(--c-success-bg); color: var(--c-success); }
.badge.plan-lite    { background: var(--c-gray-100); color: var(--c-gray-600); border: 1px solid var(--c-gray-200); }
.badge.sev-critical { background: var(--c-danger-bg);  color: var(--c-danger); }
.badge.sev-warning  { background: var(--c-warning-bg); color: var(--c-warning); }
.badge.sev-info     { background: var(--c-info-bg);    color: var(--c-info); }
.tag-pill { display: inline-flex; align-items: center; gap: 3px; padding: 2px 7px; border-radius: 99px; font-size: 11px; font-weight: 700; color: white; }

/* ─── BUTTONS ────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: 9px; border: none; cursor: pointer; font-family: var(--font); font-size: 13.5px; font-weight: 700; transition: background 0.13s, transform 0.1s; text-decoration: none; white-space: nowrap; line-height: 1.4; }
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--c-primary); color: #fff; }
.btn.primary:hover  { background: var(--c-primary-hover); }
.btn.success { background: var(--c-success); color: #fff; }
.btn.success:hover  { background: #046c4e; }
.btn.danger  { background: var(--c-danger);  color: #fff; }
.btn.danger:hover   { background: #a41a1a; }
.btn.warning { background: var(--c-warning); color: #fff; }
.btn.warning:hover  { background: #9e6002; }
.btn.ghost   { background: var(--c-gray-100); color: var(--text-primary); border: 1px solid var(--c-gray-200); }
.btn.ghost:hover    { background: var(--c-gray-200); }
.btn.link    { background: transparent; color: var(--c-primary); padding: 5px 8px; }
.btn.link:hover     { background: var(--c-primary-light); }
.btn.sm { padding: 6px 12px; font-size: 12.5px; border-radius: 7px; }
.btn.xs { padding: 3px 9px;  font-size: 11.5px; border-radius: 6px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; pointer-events: none; }

/* ─── FORMS ──────────────────────────────────────────────── */
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--text-secondary); margin-bottom: 5px; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--c-gray-300); border-radius: 9px; padding: 9px 12px; font-family: var(--font); font-size: 14px; color: var(--text-primary); background: #fff; box-sizing: border-box; outline: none; transition: border-color 0.13s, box-shadow 0.13s; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(26,86,219,0.1); }
.field textarea { min-height: 100px; resize: vertical; line-height: 1.6; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }

/* ─── FILTER BAR ─────────────────────────────────────────── */
.filter-bar { background: var(--card-bg); border: var(--card-border); border-radius: var(--card-radius); padding: 16px 20px; margin-bottom: var(--gap); box-shadow: var(--card-shadow); }
.filter-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filter-row .field { min-width: 130px; flex: 1; }
.filter-row .field label { font-size: 11px; color: var(--text-muted); }
.filter-row .field input, .filter-row .field select { padding: 7px 10px; font-size: 13px; border-radius: 7px; }
.active-pills { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.filter-pill { display: inline-flex; align-items: center; gap: 5px; background: var(--c-primary-light); color: var(--c-primary-dark); border-radius: 99px; padding: 3px 10px; font-size: 11.5px; font-weight: 700; }
.filter-pill a { color: var(--c-primary); font-size: 14px; text-decoration: none; line-height: 1; opacity: 0.7; }
.filter-pill a:hover { opacity: 1; }

/* ─── TABLE ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { padding: 9px 12px; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; text-align: right; background: var(--c-gray-50); border-bottom: 1px solid var(--c-gray-200); white-space: nowrap; }
tbody td { padding: 12px 12px; border-bottom: 1px solid var(--c-gray-100); text-align: right; vertical-align: middle; font-size: 13.5px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--c-gray-50); }
.sortable-th { cursor: pointer; user-select: none; transition: color 0.12s; }
.sortable-th:hover { color: var(--c-primary); }
.sort-arrows { display: inline-flex; flex-direction: column; margin-right: 4px; vertical-align: middle; gap: 1px; }
.sort-arrows span { font-size: 8px; line-height: 1; color: var(--c-gray-300); display: block; }
.sort-arrows span.on { color: var(--c-primary); }
.row-cb { width: 15px; height: 15px; cursor: pointer; accent-color: var(--c-primary); }

/* ─── BULK BAR ───────────────────────────────────────────── */
.bulk-bar { display: none; align-items: center; gap: 10px; padding: 9px 16px; background: var(--c-primary); color: white; border-radius: 9px; margin-bottom: 10px; flex-wrap: wrap; animation: slideDown 0.2s ease; }
.bulk-bar.on { display: flex; }
.bulk-count { font-weight: 800; font-size: 13.5px; }
@keyframes slideDown { from{opacity:0;transform:translateY(-8px);}to{opacity:1;transform:translateY(0);} }

/* ─── PAGINATION ─────────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 14px 0 0; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--c-gray-100); margin-top: 4px; }
.pagination-info { font-size: 12.5px; color: var(--text-muted); }
.pagination-links { display: flex; gap: 4px; flex-wrap: wrap; }
.plink { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 8px; border-radius: 7px; border: 1px solid var(--c-gray-200); font-size: 12.5px; font-weight: 600; color: var(--text-secondary); background: var(--card-bg); text-decoration: none; transition: all 0.12s; }
.plink:hover  { border-color: var(--c-primary); color: var(--c-primary); text-decoration: none; }
.plink.active { background: var(--c-primary); border-color: var(--c-primary); color: white; }
.plink.disabled { opacity: 0.4; pointer-events: none; }

/* ─── FLASH / TOAST ──────────────────────────────────────── */
.flash { display: flex; align-items: center; gap: 9px; padding: 11px 16px; border-radius: 9px; margin-bottom: 14px; font-weight: 600; font-size: 13.5px; }
.flash.success { background: var(--c-success-bg); color: var(--c-success); }
.flash.error   { background: var(--c-danger-bg);  color: var(--c-danger); }
.toast-wrap { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: var(--c-gray-900); color: #fff; padding: 11px 18px; border-radius: 11px; font-size: 13.5px; font-weight: 600; box-shadow: 0 8px 28px rgba(0,0,0,0.22); pointer-events: auto; display: flex; align-items: center; gap: 9px; min-width: 260px; max-width: 420px; animation: toastIn 0.25s ease; }
.toast.success { background: var(--c-success); }
.toast.error   { background: var(--c-danger); }
.toast.warning { background: var(--c-warning); }
@keyframes toastIn { from{opacity:0;transform:translateY(-12px);}to{opacity:1;transform:translateY(0);} }

/* ─── MODAL ──────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(17,25,40,0.6); z-index: 800; display: none; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(3px); }
.modal-overlay.open { display: flex; }
.modal { background: var(--card-bg); border-radius: 18px; padding: 26px; width: min(460px,95vw); max-height: 88vh; overflow-y: auto; animation: modalIn 0.18s ease; box-shadow: 0 20px 50px rgba(0,0,0,0.25); }
@keyframes modalIn { from{opacity:0;transform:scale(0.94);}to{opacity:1;transform:scale(1);} }
.modal-head  { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-title { font-size: 16px; font-weight: 800; }
.modal-x { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); border-radius: 6px; padding: 3px 7px; line-height: 1; }
.modal-x:hover { background: var(--c-gray-100); }

/* ─── CHARTS ─────────────────────────────────────────────── */
.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.chart-box { position: relative; height: 190px; }

/* ─── DEVICE CARDS ───────────────────────────────────────── */
.device-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 13px; }
.device-card { background: var(--card-bg); border: var(--card-border); border-radius: 13px; padding: 16px; box-shadow: var(--card-shadow); transition: transform 0.12s, box-shadow 0.12s; }
.device-card:hover { transform: translateY(-2px); box-shadow: 0 5px 18px rgba(0,0,0,0.09); }
.dc-head  { display: flex; align-items: center; gap: 11px; margin-bottom: 11px; }
.dc-avatar{ width: 42px; height: 42px; border-radius: 11px; display: flex; align-items: center; justify-content: center; font-size: 19px; font-weight: 800; color: white; flex-shrink: 0; }
.dc-id    { font-size: 11px; color: var(--text-muted); font-family: monospace; }
.dc-name  { font-size: 14px; font-weight: 700; }
.dc-row   { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; }
.dc-row .dc-label { color: var(--text-muted); }
.dc-foot  { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.av-0{background:#1a56db}.av-1{background:#057a55}.av-2{background:#7e3af2}.av-3{background:#c27803}
.av-4{background:#c81e1e}.av-5{background:#0369a1}.av-6{background:#15803d}.av-7{background:#9333ea}
.av-8{background:#b45309}.av-9{background:#0891b2}

/* ─── LATEST DEVICES WIDGET ──────────────────────────────── */
.latest-list { display: flex; flex-direction: column; gap: 7px; }
.latest-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; border: 1px solid var(--c-gray-100); background: var(--c-gray-50); transition: background 0.12s; text-decoration: none; color: inherit; }
.latest-item:hover { background: var(--c-primary-light); text-decoration: none; }
.latest-item-info { flex: 1; min-width: 0; }
.latest-name { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.latest-sub  { font-size: 11px; color: var(--text-muted); }
.latest-time { font-size: 11px; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }

/* ─── TIMELINE ───────────────────────────────────────────── */
.timeline { position: relative; padding-right: 26px; }
.timeline::before { content: ''; position: absolute; right: 9px; top: 0; bottom: 0; width: 2px; background: var(--c-gray-200); }
.tl-item   { display: flex; margin-bottom: 16px; position: relative; }
.tl-dot    { position: absolute; right: -26px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--c-primary); border: 3px solid white; box-shadow: 0 0 0 2px var(--c-primary); z-index: 1; }
.tl-dot.success { background: var(--c-success); box-shadow: 0 0 0 2px var(--c-success); }
.tl-dot.warning { background: var(--c-warning); box-shadow: 0 0 0 2px var(--c-warning); }
.tl-dot.danger  { background: var(--c-danger);  box-shadow: 0 0 0 2px var(--c-danger); }
.tl-dot.gray    { background: var(--c-gray-400); box-shadow: 0 0 0 2px var(--c-gray-400); }
.tl-body   { flex: 1; background: var(--c-gray-50); border: 1px solid var(--c-gray-200); border-radius: 9px; padding: 9px 12px; }
.tl-action { font-size: 13px; font-weight: 700; }
.tl-detail { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.tl-time   { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ─── MSG CARDS ──────────────────────────────────────────── */
.msg-card  { border: 1px solid var(--c-gray-200); border-radius: 11px; padding: 14px 16px; margin-bottom: 10px; }
.msg-head  { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.msg-title { font-size: 14px; font-weight: 700; }
.msg-body  { font-size: 13px; color: var(--text-secondary); white-space: pre-wrap; }
.msg-meta  { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; font-size: 11.5px; color: var(--text-muted); }
.message-log-card { border: 1px solid var(--c-gray-200); border-radius: 11px; padding: 14px 16px; background: var(--card-bg); margin-bottom: 10px; }

/* ─── COPY BUTTON ────────────────────────────────────────── */
.copy-btn { background: none; border: 1px solid var(--c-gray-200); border-radius: 6px; padding: 3px 8px; font-size: 12px; cursor: pointer; color: var(--text-muted); transition: all 0.12s; font-family: var(--font); }
.copy-btn:hover  { border-color: var(--c-primary); color: var(--c-primary); }
.copy-btn.copied { border-color: var(--c-success); color: var(--c-success); background: var(--c-success-bg); }

/* ─── MISC CONTROLS ──────────────────────────────────────── */
.refresh-toggle { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-muted); cursor: pointer; padding: 5px 10px; border-radius: 7px; border: 1px solid var(--c-gray-200); background: var(--card-bg); transition: all 0.12s; white-space: nowrap; font-family: var(--font); }
.refresh-toggle:hover { border-color: var(--c-primary); color: var(--c-primary); }
.refresh-toggle.on    { border-color: var(--c-success); color: var(--c-success); background: var(--c-success-bg); }
.refresh-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c-gray-300); }
.refresh-toggle.on .refresh-dot { background: var(--c-success); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%,100%{opacity:1;}50%{opacity:0.4;} }
.view-toggle { display: flex; border: 1px solid var(--c-gray-200); border-radius: 8px; overflow: hidden; }
.vt-btn { padding: 5px 10px; background: none; border: none; cursor: pointer; font-size: 16px; color: var(--text-muted); transition: background 0.12s; }
.vt-btn.active, .vt-btn:hover { background: var(--c-gray-100); color: var(--text-primary); }

/* ─── EMPTY STATE / LOGIN ────────────────────────────────── */
.empty-state { text-align: center; padding: 44px 24px; color: var(--text-muted); }
.empty-icon  { font-size: 40px; margin-bottom: 10px; }
.empty-title { font-size: 16px; font-weight: 700; color: var(--text-secondary); margin-bottom: 6px; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(145deg, #0c1526 0%, #1a2d4a 55%, #0c1526 100%); }
.login-card  { width: min(420px, 100%); background: var(--card-bg); border-radius: 22px; padding: 36px 32px; box-shadow: 0 24px 60px rgba(0,0,0,0.3); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.login-icon  { width: 48px; height: 48px; background: var(--c-primary); border-radius: 13px; display: flex; align-items: center; justify-content: center; }
.login-title { font-size: 20px; font-weight: 800; }
.login-sub   { font-size: 13px; color: var(--text-muted); margin-top: 1px; }

/* ─── UTILITIES ──────────────────────────────────────────── */
.muted { color: var(--text-muted); }
.text-sm { font-size: 13px; } .text-xs { font-size: 11.5px; }
.mono { font-family: 'Courier New', monospace; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; display: inline-block; }
.divider { border: none; border-top: 1px solid var(--c-gray-100); margin: 18px 0; }
.flex { display: flex; } .flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-10 { gap: 10px; }
.mt-4 { margin-top: 16px; } .mb-4 { margin-bottom: 16px; } .w-full { width: 100%; }

/* ─── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 860px) {
  /* Sidebar: slide off-screen right */
  .app-sidebar {
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
    width: 260px;
    box-shadow: none;
  }
  .app-sidebar.open {
    transform: translateX(0);
    box-shadow: -8px 0 30px rgba(0,0,0,0.25);
  }
  .app-main { margin-right: 0 !important; }
  .hamburger-btn { display: flex; }
  .page-content { padding: 14px 12px; }

  /* Topbar */
  .topbar { padding: 0 12px; height: 54px; }
  .topbar-title { font-size: 15px; }
  .topbar-sub { display: none; }
  .topbar-right { gap: 6px; }
  .topbar-right .btn { padding: 6px 10px; font-size: 12px; }

  /* Stats */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card { padding: 12px 13px; }
  .stat-value { font-size: 22px; }
  .stat-label { font-size: 10px; }

  /* Charts */
  .charts-grid { grid-template-columns: 1fr; }
  .chart-box { height: 160px; }

  /* Forms */
  .form-grid { grid-template-columns: 1fr !important; }

  /* Device grid (detail page) — stack columns */
  .device-grid {
    grid-template-columns: 1fr !important;
  }

  /* Cards */
  .card { padding: 16px; border-radius: 12px; }
  .card-header { margin-bottom: 14px; }

  /* Filter bar */
  .filter-bar { padding: 12px 14px; }
  .filter-row { gap: 8px; }
  .filter-row .field { min-width: 100px; }

  /* Table */
  table { font-size: 12.5px; }
  thead th { padding: 7px 8px; font-size: 10px; }
  tbody td { padding: 10px 8px; font-size: 12.5px; }
  .truncate { max-width: 120px; }

  /* Device cards */
  .device-cards { grid-template-columns: 1fr; }

  /* Pagination */
  .pagination { flex-direction: column; align-items: flex-start; gap: 8px; }

  /* Bulk bar */
  .bulk-bar { padding: 8px 12px; font-size: 12px; }

  /* Badges */
  .badge { font-size: 11px; padding: 2px 7px; }

  /* Buttons */
  .btn { padding: 7px 12px; font-size: 12.5px; }
  .btn.sm { padding: 5px 10px; font-size: 11.5px; }

  /* Modal */
  .modal { padding: 20px; border-radius: 14px; }

  /* Timeline */
  .timeline { padding-right: 22px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .stat-card { padding: 10px 11px; }
  .stat-value { font-size: 20px; }
  .login-card { padding: 26px 20px; }
  .page-content { padding: 10px 8px; }
  .topbar { padding: 0 10px; }
  .card { padding: 13px; margin-bottom: 10px; }
  .card-title { font-size: 14px; }
  .form-grid { gap: 10px !important; }
  .field input, .field select, .field textarea { padding: 8px 10px; font-size: 13px; }
  .field label { font-size: 11.5px; }

  /* Device header card — stack vertically */
  .card > div[style*="display:flex"][style*="gap:16px"] {
    flex-direction: column;
    text-align: center;
  }

  /* Mono text wrapping */
  .mono { word-break: break-all; }
  .truncate { max-width: 100%; }

  /* Table horizontal scroll */
  .table-wrap { margin: 0 -13px; padding: 0 13px; }

  /* Messages */
  .msg-card { padding: 11px 13px; }
  .msg-head { flex-direction: column; gap: 6px; }
  .msg-meta { gap: 6px; }

  /* Copy button */
  .copy-btn { padding: 2px 6px; font-size: 11px; }
}
/* End of stylesheet */
