:root {
  --bg: #f3f6fb; --bg-2: #f7f9fc; --card: #fff; --card-2: #f6f8fb;
  --line: #e4e9f1; --line-strong: #d7deea; --text: #172033; --muted: #6f7c91;
  --brand: #4f46e5; --brand-2: #6d5dfc; --brand-soft: #eeecff;
  --ok: #0f9f6e; --warn: #d98506; --crit: #dc3f4f; --info: #2484d8;
  --accent: #4f46e5; --danger: #dc3f4f;
  --sidebar: #111827; --sidebar-2: #182235; --sidebar-text: #eef2ff; --sidebar-muted: #96a2b8;
  --radius: 16px; --radius-sm: 11px;
  --shadow: 0 16px 44px rgba(22,32,51,.08); --shadow-sm: 0 5px 18px rgba(22,32,51,.06);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body { font-family: "Segoe UI", Tahoma, Arial, system-ui, sans-serif; color: var(--text); background: var(--bg); direction: rtl; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
::selection { background: #dcd8ff; color: #241f64; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 78% 14%,rgba(79,70,229,.15),transparent 25%),radial-gradient(circle at 20% 85%,rgba(20,184,166,.11),transparent 28%),#f5f7fc; }
.login-card { width: min(440px,100%); padding: 34px; background: rgba(255,255,255,.94); border: 1px solid rgba(215,222,234,.9); border-radius: 24px; box-shadow: 0 30px 80px rgba(30,41,59,.13); }
.login-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 30px; }
.login-brand .logo, .brand .mark { display: grid; place-items: center; background: linear-gradient(145deg,var(--brand),#7668ff); color: #fff; font-weight: 850; box-shadow: 0 8px 22px rgba(79,70,229,.27); }
.login-brand .logo { width: 50px; height: 50px; border-radius: 15px; font-size: 22px; }
.login-card h1 { font-size: 23px; line-height: 1.15; letter-spacing: -.4px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.login-intro { display: flex; flex-direction: column; gap: 4px; margin-bottom: 22px; }
.login-intro b { font-size: 18px; }
.login-intro span { color: var(--muted); font-size: 13.5px; line-height: 1.7; }
.login-safe { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; }

/* Controls */
label { display: block; margin: 14px 0 7px; color: #58657a; font-size: 12.5px; font-weight: 650; }
input, select, textarea { width: 100%; color: var(--text); background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 11px 13px; font-size: 13.5px; transition: border-color .16s,box-shadow .16s,background .16s; }
input:hover, select:hover, textarea:hover { border-color: #c6cfdd; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.11); }
input:disabled, select:disabled, textarea:disabled { opacity: .62; cursor: not-allowed; background: #eef1f6; }
textarea { min-height: 96px; resize: vertical; line-height: 1.7; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 9px 16px; border: 1px solid transparent; border-radius: 10px; background: var(--brand); color: #fff; font-size: 13px; font-weight: 700; box-shadow: 0 5px 14px rgba(79,70,229,.16); transition: transform .14s,box-shadow .14s,background .14s; }
.btn:hover { background: #4338ca; box-shadow: 0 8px 20px rgba(79,70,229,.22); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.block { width: 100%; margin-top: 20px; }
.btn.ghost { background: #fff; color: #465268; border-color: var(--line-strong); box-shadow: none; }
.btn.ghost:hover { background: var(--card-2); color: var(--text); box-shadow: none; }
.btn.sm { min-height: 32px; padding: 6px 10px; font-size: 11.8px; border-radius: 8px; }
.btn.danger { background: #fff1f2; color: #c93648; border-color: #ffd8dd; box-shadow: none; }
.btn.danger:hover { background: #ffe5e8; }
.btn.ok { background: var(--ok); box-shadow: 0 5px 14px rgba(15,159,110,.16); }
.error-msg { min-height: 18px; margin-top: 11px; color: var(--crit); font-size: 12.5px; }

/* Shell and navigation */
.app { min-height: 100vh; display: grid; grid-template-columns: 268px minmax(0,1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 19px 14px 15px; color: var(--sidebar-text); background: linear-gradient(180deg,var(--sidebar-2),var(--sidebar)); border-left: 1px solid #273248; overflow-y: auto; scrollbar-width: thin; scrollbar-color: #334158 transparent; }
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 17px; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand .mark { width: 39px; height: 39px; border-radius: 12px; font-size: 17px; }
.brand b { display: block; font-size: 16px; }
.brand small { display: block; margin-top: 2px; color: var(--sidebar-muted); font-size: 10.5px; }
.sidebar-nav { padding-top: 13px; }
.nav-primary { display: grid; gap: 3px; margin-bottom: 10px; }
.nav-group { border-top: 1px solid rgba(255,255,255,.055); padding-top: 8px; margin-top: 8px; }
.nav-group summary { list-style: none; display: flex; align-items: center; justify-content: space-between; padding: 8px 11px; color: #75839b; font-size: 10.5px; font-weight: 800; letter-spacing: .25px; cursor: pointer; user-select: none; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary i { font-style: normal; transition: transform .18s; }
.nav-group[open] summary i { transform: rotate(180deg); }
.nav-group-items { display: grid; gap: 3px; }
.nav-item { min-height: 42px; display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 10px; color: var(--sidebar-muted); font-size: 12.8px; font-weight: 600; cursor: pointer; transition: color .14s,background .14s,transform .14s; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.06); transform: translateX(-2px); }
.nav-item.active { color: #fff; background: linear-gradient(135deg,rgba(99,102,241,.30),rgba(79,70,229,.18)); box-shadow: inset -3px 0 0 #8b83ff; }
.nav-item .ic { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 7px; color: #b6c0d2; background: rgba(255,255,255,.055); font-size: 13px; font-weight: 800; }
.nav-item.active .ic { color: #fff; background: rgba(129,119,255,.25); }
.nav-item .badge { margin-inline-start: auto; padding: 1px 7px; border-radius: 20px; background: #ef4b5d; color: #fff; font-size: 10px; }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.08); }
.workspace-state { display: flex; align-items: center; gap: 9px; padding: 8px 11px 12px; }
.workspace-state > span { width: 8px; height: 8px; border-radius: 50%; background: #32d296; box-shadow: 0 0 0 4px rgba(50,210,150,.11); }
.workspace-state b { display: block; font-size: 11.5px; color: #dce4f2; }
.workspace-state small { display: block; color: #748197; font-size: 9.5px; }
.nav-item.logout { color: #c7d0df; }
.main { min-width: 0; padding: 0 30px 34px; }
.workspace-header { position: sticky; top: 0; z-index: 45; margin: 0 -30px 24px; padding: 20px 30px 16px; background: rgba(243,246,251,.90); border-bottom: 1px solid rgba(228,233,241,.92); backdrop-filter: blur(14px); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.view-heading { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar h2 { font-size: 20px; line-height: 1.25; letter-spacing: -.25px; }
.topbar .sub { margin-top: 3px; color: var(--muted); font-size: 12px; }
#topActions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.global-search { position: relative; width: min(560px,100%); margin-top: 15px; }
.global-search .gs-ic { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); color: #6d7890; font-size: 19px; z-index: 1; }
.global-search input { height: 42px; padding-inline: 43px 108px; background: rgba(255,255,255,.94); border-color: var(--line); box-shadow: var(--shadow-sm); }
.global-search kbd { position: absolute; inset-inline-end: 10px; top: 50%; transform: translateY(-50%); padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; color: #8a94a6; background: #f8fafc; font-size: 9.5px; font-family: inherit; }
.gs-results { position: absolute; top: 49px; inset-inline: 0; z-index: 60; max-height: 60vh; overflow-y: auto; padding: 7px; background: #fff; border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 22px 55px rgba(22,32,51,.16); }
.gs-group { padding: 7px 9px 4px; color: var(--muted); font-size: 10.5px; font-weight: 800; }
.gs-item { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 12.8px; }
.gs-item:hover { background: var(--card-2); }
.gs-item .gs-sub { margin-inline-start: auto; color: var(--muted); font-size: 11px; }
.menu-btn { display: none; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text); font-size: 18px; }
.sidebar-overlay { display: none; }

/* Content, cards, dashboard */
.grid { display: grid; gap: 14px; }
.grid.stats { grid-template-columns: repeat(4,minmax(0,1fr)); margin-bottom: 18px; }
.stat { position: relative; min-width: 0; padding: 18px; overflow: hidden; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.stat::after { content: ''; position: absolute; inset-inline-start: 0; top: 15px; bottom: 15px; width: 3px; border-radius: 3px; background: var(--brand); }
.stat.ok::after { background: var(--ok); } .stat.warn::after { background: var(--warn); } .stat.crit::after { background: var(--crit); } .stat.info::after { background: var(--info); }
.stat .k { display: flex; align-items: center; gap: 7px; margin-bottom: 9px; color: var(--muted); font-size: 11.8px; font-weight: 650; }
.stat .v { overflow: hidden; text-overflow: ellipsis; font-size: 25px; font-weight: 820; letter-spacing: -.6px; }
.stat .v small { color: var(--muted); font-size: 12px; font-weight: 550; }
.card { margin-bottom: 16px; padding: 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h3 { font-size: 14px; }
.card-head .tools { display: flex; gap: 7px; flex-wrap: wrap; }
.dashboard-hero { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 19px 20px; border: 0; color: #fff; background: linear-gradient(120deg,#3f38bb,#5b50df 62%,#4f46e5); box-shadow: 0 16px 35px rgba(79,70,229,.19); }
.dashboard-hero h3 { font-size: 17px; margin-bottom: 4px; }
.dashboard-hero p { color: #dcd9ff; font-size: 12.5px; }
.quick-actions { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.quick-actions .btn { color: #29236a; background: #fff; border-color: rgba(255,255,255,.4); box-shadow: none; }
.quick-actions .btn:hover { background: #f1efff; }
.secondary-metrics { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; margin: -4px 0 18px; }
.mini-metric { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.62); }
.mini-metric span { color: var(--muted); font-size: 11px; } .mini-metric b { font-size: 13px; }
.dashboard-panels { display: grid; grid-template-columns: minmax(0,1.35fr) minmax(300px,.9fr); gap: 16px; align-items: start; }
.dashboard-panels .card { margin-bottom: 0; }

/* Tables */
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { padding: 11px 12px; text-align: right; white-space: nowrap; }
thead { background: #f7f9fc; }
thead th { color: #69758a; border-bottom: 1px solid var(--line); font-size: 10.8px; font-weight: 800; }
tbody tr { border-bottom: 1px solid #edf0f5; transition: background .12s; }
tbody tr:last-child { border-bottom: 0; }
tbody tr:hover { background: #fafbfe; }
td .mono, .mono { color: #3474a9; font-family: Consolas,monospace; font-size: 11.8px; direction: ltr; }
.empty { padding: 38px 18px !important; text-align: center; color: var(--muted); font-size: 12.5px; }

/* Status */
.badge-s { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 20px; font-size: 10.8px; font-weight: 750; }
.b-ok { color: #087b55; background: #e2f7ef; } .b-warn { color: #a46000; background: #fff2d9; }
.b-crit { color: #b82f40; background: #ffe5e8; } .b-mut { color: #69758a; background: #edf1f6; } .b-info { color: #1b6eaa; background: #e4f2fd; }
.pill { padding: 3px 9px; border-radius: 8px; font-size: 11px; font-weight: 700; }
.cap { display: flex; align-items: center; gap: 8px; min-width: 125px; }
.cap-bar { flex: 1; height: 6px; overflow: hidden; border-radius: 20px; background: #e8ecf3; }
.cap-fill { height: 100%; border-radius: 20px; background: linear-gradient(90deg,var(--brand),#8b7fff); }
.cap-fill.full { background: linear-gradient(90deg,#ef4b5d,#f28a39); }
.cap small { color: var(--muted); font-size: 10.5px; }

/* Helpers */
.hint { margin-bottom: 14px; padding: 12px 14px; color: #637086; background: #f6f8fc; border: 1px solid var(--line); border-radius: 11px; font-size: 11.8px; line-height: 1.7; }
.hint b { color: var(--text); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.65); }
.filters input, .filters select { width: auto; min-width: 150px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.check-label { display: flex; align-items: center; gap: 7px; color: #536074; font-size: 12px; }
.check-label input, input[type="checkbox"] { width: auto; accent-color: var(--brand); }
.bulkbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; padding: 9px 11px; background: #f1f0ff; border: 1px solid #d9d5ff; border-radius: 11px; }
.kv { display: grid; grid-template-columns: 135px 1fr; gap: 8px 12px; font-size: 12.5px; }
.kv .k2 { color: var(--muted); }
.checkbox-cell { width: 34px; text-align: center; }

/* Modal and notices */
.modal-bg { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: rgba(15,23,42,.55); backdrop-filter: blur(6px); }
.modal { width: min(540px,100%); max-height: 90vh; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 30px 80px rgba(15,23,42,.24); }
.modal-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 17px 20px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); backdrop-filter: blur(8px); }
.modal-head h3 { font-size: 15px; }
.modal-head .x { width: 34px; height: 34px; border: 0; border-radius: 9px; background: #f1f3f7; color: var(--muted); font-size: 19px; }
.modal-body { padding: 20px; }
.modal-foot { position: sticky; bottom: 0; display: flex; gap: 8px; padding: 14px 20px; background: rgba(255,255,255,.97); border-top: 1px solid var(--line); backdrop-filter: blur(8px); }
.toast-wrap { position: fixed; bottom: 18px; left: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { max-width: 350px; padding: 12px 15px; color: #fff; background: #1e293b; border-radius: 11px; box-shadow: 0 12px 32px rgba(15,23,42,.22); font-size: 12.5px; animation: slide .22s; }
.toast.ok { border-inline-start: 4px solid #32d296; } .toast.err { border-inline-start: 4px solid #fb7185; }
@keyframes slide { from { opacity: 0; transform: translateX(-14px); } to { opacity: 1; transform: none; } }

/* Automation, mail and details */
.wa-status { display: flex; align-items: center; gap: 9px; font-size: 12.5px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #9aa5b5; }
.dot.ready { background: var(--ok); box-shadow: 0 0 0 4px rgba(15,159,110,.1); }
.dot.qr, .dot.authenticating { background: var(--warn); } .dot.error { background: var(--crit); }
.qr-box { display: grid; place-items: center; width: fit-content; margin: 15px auto; padding: 20px; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.qr-box img { display: block; }
.automation-master { border-color: #d8d4ff; background: linear-gradient(145deg,#fff,#faf9ff); }
.automation-switches { display: grid; grid-template-columns: repeat(auto-fit,minmax(190px,1fr)); gap: 9px; }
.automation-switches label { display: flex; align-items: center; gap: 9px; margin: 0; padding: 11px; background: #fff; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.automation-switches span { display: flex; flex-direction: column; gap: 2px; }
.automation-switches small { color: var(--muted); font-size: 10.5px; line-height: 1.45; }
.section-tabs { position: sticky; top: 132px; z-index: 35; display: flex; gap: 5px; width: fit-content; max-width: 100%; margin: 0 0 14px; padding: 5px; overflow-x: auto; background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-sm); backdrop-filter: blur(10px); }
.section-tabs button { flex: 0 0 auto; padding: 8px 12px; color: var(--muted); background: transparent; border: 0; border-radius: 8px; font-size: 11.5px; font-weight: 750; }
.section-tabs button:hover { color: var(--text); background: #f5f7fb; }
.section-tabs button.active { color: #fff; background: var(--brand); box-shadow: 0 4px 12px rgba(79,70,229,.18); }
.automation-panel > .card:last-child { margin-bottom: 0; }
.mail-full { margin-top: 11px; padding-top: 9px; border-top: 1px solid var(--line); }
.mail-full summary { color: var(--brand); font-size: 12px; font-weight: 750; cursor: pointer; user-select: none; }
.mail-body { margin-top: 10px; padding: 13px; overflow-wrap: anywhere; color: var(--text); background: #f7f9fc; border: 1px solid var(--line); border-radius: 9px; font-size: 12px; line-height: 1.8; white-space: pre-wrap; direction: auto; text-align: start; }
.mail-links { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.mail-link { display: inline-flex; align-items: center; gap: 5px; padding: 7px 10px; color: var(--brand); background: #f2f0ff; border: 1px solid #d9d5ff; border-radius: 8px; font-size: 11.5px; font-weight: 750; }
.domain-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(255px,1fr)); gap: 11px; margin: 13px 0; }
.domain-card { margin: 0; } .domain-card.domain-off { opacity: .62; }
.domain-meta { margin: 9px 0; color: var(--muted); font-size: 11.5px; }
.domain-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.setup-guide { border-color: #d8d4ff; background: #fbfaff; }
.setup-disclosure { padding: 0; overflow: hidden; }
.setup-disclosure > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding: 15px 17px; cursor: pointer; }
.setup-disclosure > summary::-webkit-details-marker { display: none; }
.setup-disclosure > summary span { display: flex; flex-direction: column; gap: 2px; }
.setup-disclosure > summary b { font-size: 13px; }
.setup-disclosure > summary small { color: var(--muted); font-size: 10.8px; }
.setup-disclosure > summary i { padding: 6px 9px; color: var(--brand); background: #efedff; border-radius: 8px; font-size: 10.5px; font-style: normal; font-weight: 800; }
.setup-disclosure[open] > summary { border-bottom: 1px solid var(--line); }
.setup-disclosure[open] > summary i { font-size: 0; }
.setup-disclosure[open] > summary i::after { content: 'إخفاء الشرح'; font-size: 10.5px; }
.setup-content { padding: 4px 17px 16px; }
.setup-steps { display: grid; grid-template-columns: repeat(4,1fr); gap: 9px; margin: 11px 0; }
.setup-steps > div { display: flex; gap: 8px; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.setup-steps > div > b { flex: 0 0 auto; display: grid; place-items: center; width: 25px; height: 25px; color: #fff; background: var(--brand); border-radius: 50%; font-size: 11px; }
.setup-steps span { display: flex; flex-direction: column; gap: 2px; }
.setup-steps small { color: var(--muted); font-size: 10.5px; line-height: 1.45; }
.ad-source { color: var(--brand); }

/* Timeline and health */
.timeline { position: relative; margin-top: 7px; padding-inline-start: 21px; }
.timeline::before { content: ''; position: absolute; inset-inline-start: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 16px; }
.tl-item::before { content: ''; position: absolute; inset-inline-start: -19px; top: 3px; width: 11px; height: 11px; border: 2px solid #fff; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 1px var(--line); }
.tl-item.t-created::before { background: var(--info); } .tl-item.t-paid::before, .tl-item.t-renewed::before { background: var(--ok); }
.tl-item.t-expired::before { background: var(--crit); } .tl-item.t-code::before { background: var(--warn); }
.tl-item .tl-head { font-size: 12.5px; font-weight: 700; } .tl-item .tl-meta { margin-top: 2px; color: var(--muted); font-size: 10.5px; }
.hcard { display: flex; align-items: center; gap: 11px; }
.hdot { flex-shrink: 0; width: 10px; height: 10px; border-radius: 50%; }
.hdot.up { background: var(--ok); box-shadow: 0 0 0 4px rgba(15,159,110,.1); } .hdot.idle { background: var(--warn); } .hdot.down { background: var(--crit); box-shadow: 0 0 0 4px rgba(220,63,79,.09); }
.hcard .hname { font-size: 12.5px; font-weight: 750; } .hcard .hmeta { color: var(--muted); font-size: 10.8px; }
.live-pulse { display: inline-flex; align-items: center; gap: 6px; color: var(--ok); font-size: 10.8px; }
.live-pulse::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

@media (max-width:1180px) {
  .grid.stats { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .secondary-metrics { grid-template-columns: repeat(2,1fr); }
  .dashboard-panels { grid-template-columns: 1fr; }
}
@media (max-width:860px) {
  .app { grid-template-columns: 1fr; }
  .main { padding: 0 14px 24px; }
  .workspace-header { margin: 0 -14px 16px; padding: 14px; }
  .menu-btn { display: inline-grid; place-items: center; flex: 0 0 auto; }
  .sidebar { position: fixed; top: 0; right: 0; z-index: 70; width: min(310px,86vw); height: 100vh; transform: translateX(105%); transition: transform .23s ease; box-shadow: -18px 0 50px rgba(15,23,42,.25); }
  body.nav-open .sidebar { transform: translateX(0); }
  .sidebar-overlay { display: block; position: fixed; inset: 0; z-index: 65; background: rgba(15,23,42,.45); opacity: 0; pointer-events: none; transition: opacity .2s; }
  body.nav-open .sidebar-overlay { opacity: 1; pointer-events: auto; }
  .topbar { align-items: flex-start; }
  .topbar h2 { font-size: 17px; }
  .topbar .sub { max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #topActions { max-width: 45%; }
  .global-search { width: 100%; margin-top: 12px; }
  .global-search input { padding-inline-end: 13px; }
  .global-search kbd { display: none; }
  .section-tabs { top: 112px; width: 100%; }
  .dashboard-hero { align-items: flex-start; flex-direction: column; }
  .quick-actions { justify-content: flex-start; }
  .row2, .setup-steps, .kv { grid-template-columns: 1fr; }
  .card { padding: 14px; margin-bottom: 12px; }
  .card-head { flex-wrap: wrap; }
  .filters { padding: 8px; }
  .filters input, .filters select { min-width: 130px; flex: 1; }
  .modal { width: 96vw !important; max-width: 96vw !important; max-height: 93vh; }
  th, td { padding: 9px; font-size: 11.8px; }
}
@media (max-width:520px) {
  .login-card { padding: 25px 20px; border-radius: 19px; }
  .grid.stats { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
  .stat { padding: 14px 13px; } .stat .k { font-size: 10.5px; } .stat .v { font-size: 20px; }
  .secondary-metrics { grid-template-columns: 1fr 1fr; gap: 7px; }
  .mini-metric { padding: 9px 10px; flex-direction: column; align-items: flex-start; }
  .dashboard-hero { padding: 16px; }
  .quick-actions .btn { flex: 1; }
  #topActions .btn { padding: 7px 9px; min-height: 34px; font-size: 11px; }
  .automation-switches { grid-template-columns: 1fr; }
  .toast-wrap { right: 12px; left: 12px; bottom: 12px; } .toast { max-width: none; }
}
