/* ================= Fonts (self-hosted, OFL) ================= */
@font-face { font-family: "Plex Arabic"; font-style: normal; font-display: swap; font-weight: 400; src: url(fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "Plex Arabic"; font-style: normal; font-display: swap; font-weight: 500; src: url(fonts/ibm-plex-sans-arabic-arabic-500-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "Plex Arabic"; font-style: normal; font-display: swap; font-weight: 600; src: url(fonts/ibm-plex-sans-arabic-arabic-600-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "Plex Arabic"; font-style: normal; font-display: swap; font-weight: 700; src: url(fonts/ibm-plex-sans-arabic-arabic-700-normal.woff2) format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "Plex Arabic"; font-style: normal; font-display: swap; font-weight: 400; src: url(fonts/ibm-plex-sans-arabic-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Arabic"; font-style: normal; font-display: swap; font-weight: 500; src: url(fonts/ibm-plex-sans-arabic-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Arabic"; font-style: normal; font-display: swap; font-weight: 600; src: url(fonts/ibm-plex-sans-arabic-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Plex Arabic"; font-style: normal; font-display: swap; font-weight: 700; src: url(fonts/ibm-plex-sans-arabic-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* ================= Tokens ================= */
:root {
  --font: "Plex Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #f1f3f8;
  --border: #e6e8f0;
  --border-strong: #d7dbe6;
  --ink: #101828;
  --ink-2: #475467;
  --muted: #8a94a7;
  --accent: #5b4ee6;
  --accent-2: #7c6cf5;
  --accent-soft: #f0eefe;
  --accent-ink: #4636d1;
  --success: #0f9f5a;  --success-soft: #e6f7ee;
  --warning: #d97706;  --warning-soft: #fff4e2;
  --danger: #e0393e;   --danger-soft: #fdeced;
  --info: #0b84e3;     --info-soft: #e7f3fd;
  --elec: #f5a524;
  --water: #1aa5d8;
  --grid: #eef0f5;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 12px rgba(16, 24, 40, .05);
  --shadow-lg: 0 24px 60px rgba(16, 24, 40, .18);
  --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-xl: 20px;
  --sidebar: 268px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b0e17;
  --surface: #121624;
  --surface-2: #161b2c;
  --surface-3: #1c2235;
  --border: #232a3d;
  --border-strong: #2e3650;
  --ink: #e8ebf4;
  --ink-2: #b2b9cc;
  --muted: #7a839a;
  --accent: #8b80ff;
  --accent-2: #a49bff;
  --accent-soft: rgba(139, 128, 255, .14);
  --accent-ink: #b4acff;
  --success: #3ccf8e;  --success-soft: rgba(60, 207, 142, .13);
  --warning: #f5b546;  --warning-soft: rgba(245, 181, 70, .13);
  --danger: #ff6b6f;   --danger-soft: rgba(255, 107, 111, .13);
  --info: #4db3ff;     --info-soft: rgba(77, 179, 255, .13);
  --elec: #f7b84b;
  --water: #3cc3f0;
  --grid: #1f2638;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .25), 0 6px 20px rgba(0, 0, 0, .25);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* ================= Base ================= */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.35; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ico { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; display: inline-block; vertical-align: middle; }
i[data-icon] { display: inline-flex; }

/* ================= Buttons & inputs ================= */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--ink); font: 500 14px var(--font); cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s, transform .05s; box-shadow: var(--shadow-sm); }
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn .ico { width: 17px; height: 17px; }
.btn.primary { background: linear-gradient(180deg, var(--accent-2), var(--accent)); border-color: transparent; color: #fff; box-shadow: 0 1px 2px rgba(70, 54, 209, .25), 0 4px 14px rgba(91, 78, 230, .28); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-3); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: transparent; }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.lg { height: 46px; font-size: 15px; border-radius: 12px; }
.btn.block { width: 100%; }
.icon-btn { width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--ink-2); cursor: pointer; box-shadow: var(--shadow-sm); }
.icon-btn:hover { color: var(--ink); background: var(--surface-2); }

input, select, textarea { font: 400 14px var(--font); color: var(--ink); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; padding: 0 12px; height: 40px; width: 100%; transition: border-color .15s, box-shadow .15s; }
textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.6; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238a94a7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: left 10px center; padding-left: 32px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--ink-2); }
input[type="date"], input[type="month"] { direction: ltr; text-align: right; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field .req { color: var(--danger); }
.field .hint { font-size: 12px; color: var(--muted); }
.field.full { grid-column: 1 / -1; }
.input-icon { position: relative; }
.input-icon > i { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon > input { padding-inline-start: 40px; }
.form-error { color: var(--danger); background: var(--danger-soft); padding: 9px 12px; border-radius: 10px; font-size: 13px; }

/* ================= Brand ================= */
.brand-logo { width: 36px; height: 36px; border-radius: 11px; background: linear-gradient(135deg, #8b7bff, #5b4ee6 55%, #3d2fc0); display: grid; place-items: center; box-shadow: 0 6px 16px rgba(91, 78, 230, .35); flex: none; }
.brand-logo span { width: 14px; height: 14px; border-radius: 4px; border: 2.5px solid #fff; transform: rotate(45deg); }
.brand-logo.lg { width: 56px; height: 56px; border-radius: 16px; }
.brand-logo.lg span { width: 22px; height: 22px; border-width: 3.5px; border-radius: 6px; }

/* ================= Login ================= */
.login { min-height: 100vh; display: grid; grid-template-columns: 1fr 1.1fr; background: var(--surface); }
.login-pane { display: grid; place-items: center; padding: 32px 16px; }
.login-card { width: min(380px, 100%); display: grid; gap: 16px; }
.login-card h1 { font-size: 28px; margin-top: 18px; }
.login-card .muted { margin-top: -10px; }
.brand-row { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.login-art { position: relative; overflow: hidden; background: radial-gradient(120% 90% at 100% 0%, #7d6cff 0%, #4b3bd6 45%, #1d1650 100%); color: #fff; display: grid; place-items: center; padding: 48px; }
.login-art::before { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,.14) 1px, transparent 1px); background-size: 22px 22px; mask-image: linear-gradient(180deg, transparent, #000 30%, #000 70%, transparent); }
.login-art::after { content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%; background: radial-gradient(circle, rgba(255,255,255,.18), transparent 65%); bottom: -240px; left: -160px; }
.login-art-inner { position: relative; z-index: 1; max-width: 440px; display: grid; gap: 18px; }
.login-art h2 { font-size: 34px; line-height: 1.3; }
.login-art p { color: rgba(255,255,255,.82); font-size: 16px; }
.login-points { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 12px; }
.login-points li { display: flex; gap: 12px; align-items: center; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.16); padding: 12px 14px; border-radius: 14px; backdrop-filter: blur(6px); font-size: 14px; }
.login-points .ico { width: 20px; height: 20px; }

/* ================= Shell ================= */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--surface); border-inline-end: 1px solid var(--border); padding: 18px 14px 14px; }
.side-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 20px; }
.side-brand strong { display: block; font-size: 16px; }
.side-brand small { color: var(--muted); font-size: 12px; }
nav { flex: 1; overflow-y: auto; display: grid; align-content: start; gap: 2px; }
.nav-label { font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 14px 12px 6px; letter-spacing: .2px; }
nav a { position: relative; display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 10px; color: var(--ink-2); font-weight: 500; font-size: 14.5px; transition: background .15s, color .15s; }
nav a:hover { background: var(--surface-3); color: var(--ink); }
nav a.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
nav a.active::before { content: ""; position: absolute; inset-inline-start: -14px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
nav a .ico { width: 19px; height: 19px; }
nav a .count { margin-inline-start: auto; font-size: 12px; color: var(--muted); background: var(--surface-3); padding: 0 8px; border-radius: 99px; }
nav a.active .count { background: var(--surface); color: var(--accent-ink); }
nav a.disabled { opacity: .55; cursor: default; }
nav a.disabled:hover { background: none; color: var(--ink-2); }
.soon { margin-inline-start: auto; font-size: 11px; padding: 1px 8px; border-radius: 99px; border: 1px dashed var(--border-strong); color: var(--muted); }
.side-foot { position: relative; border-top: 1px solid var(--border); padding-top: 12px; margin-top: 8px; }
.side-user { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; border: 0; background: none; color: var(--ink); cursor: pointer; font: inherit; text-align: start; }
.side-user:hover { background: var(--surface-3); }
.side-user-text { flex: 1; min-width: 0; }
.side-user-text strong { display: block; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-text small { color: var(--muted); font-size: 12px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #fff; background: linear-gradient(135deg, #f59e0b, #ef4444); flex: none; }
.menu { position: absolute; bottom: calc(100% + 6px); inset-inline: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 30; }
.menu button { width: 100%; display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 8px; border: 0; background: none; color: var(--ink); font: 500 14px var(--font); cursor: pointer; text-align: start; }
.menu button:hover { background: var(--surface-3); }
.menu button.danger { color: var(--danger); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 14px; padding: 18px 32px; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid transparent; }
.topbar.scrolled { border-bottom-color: var(--border); }
.page-head { flex: 1; min-width: 0; }
.page-head h1 { font-size: 22px; }
.page-head p { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.menu-btn { display: none; }
.content { padding: 8px 32px 40px; display: grid; gap: 20px; width: 100%; max-width: 1440px; }

/* ================= Cards ================= */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 0; }
.card-head h3 { font-size: 16px; font-weight: 600; flex: 1; display: flex; align-items: center; gap: 10px; }
.card-head .tag { font-size: 12px; color: var(--muted); font-weight: 500; }
.card-body { padding: 16px 20px 20px; }
.head-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-2); }
.head-icon .ico { width: 17px; height: 17px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3-1 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; }

/* Hero banner */
.hero { position: relative; overflow: hidden; border-radius: var(--r-xl); padding: 26px 28px; color: #fff; background: radial-gradient(120% 140% at 0% 0%, #8f80ff 0%, #5b4ee6 40%, #2c2190 100%); box-shadow: 0 14px 40px rgba(76, 61, 214, .28); display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.hero::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,.12) 1px, transparent 1px); background-size: 20px 20px; mask-image: linear-gradient(90deg, #000, transparent 70%); pointer-events: none; }
.hero-text { flex: 1; min-width: 240px; position: relative; z-index: 1; }
.hero h2 { font-size: 24px; }
.hero p { color: rgba(255,255,255,.85); margin-top: 6px; }
.hero-stats { display: flex; gap: 10px; position: relative; z-index: 1; flex-wrap: wrap; }
.hero-chip { background: rgba(255,255,255,.13); border: 1px solid rgba(255,255,255,.2); border-radius: 14px; padding: 10px 16px; min-width: 120px; backdrop-filter: blur(6px); }
.hero-chip b { display: block; font-size: 22px; }
.hero-chip span { font-size: 12.5px; color: rgba(255,255,255,.8); }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.kpi { padding: 18px; display: grid; gap: 14px; align-content: start; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kpi-label { color: var(--ink-2); font-size: 13.5px; font-weight: 500; }
.kpi-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.kpi-icon .ico { width: 20px; height: 20px; }
.kpi-value { font-size: 30px; font-weight: 700; line-height: 1; letter-spacing: -.5px; }
.kpi-value small { font-size: 14px; font-weight: 500; color: var(--muted); margin-inline-start: 4px; letter-spacing: 0; }
.kpi-foot { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.tone-danger .kpi-icon { background: var(--danger-soft); color: var(--danger); }
.tone-warning .kpi-icon { background: var(--warning-soft); color: var(--warning); }
.tone-success .kpi-icon { background: var(--success-soft); color: var(--success); }
.tone-info .kpi-icon { background: var(--info-soft); color: var(--info); }
.tone-danger .kpi-value { color: var(--danger); }

/* Lists (alerts, visits) */
.list { display: grid; }
.list-item { display: flex; align-items: center; gap: 14px; padding: 13px 20px; border-top: 1px solid var(--border); cursor: pointer; transition: background .12s; }
.list-item:first-child { border-top: 0; }
.list-item:hover { background: var(--surface-2); }
.li-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--ink-2); }
.li-icon.danger { background: var(--danger-soft); color: var(--danger); }
.li-icon.warning { background: var(--warning-soft); color: var(--warning); }
.li-icon.info { background: var(--info-soft); color: var(--info); }
.li-main { flex: 1; min-width: 0; }
.li-title { font-weight: 600; font-size: 14.5px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.li-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.li-side { text-align: end; display: grid; gap: 4px; justify-items: end; }
.li-date { font-size: 13px; color: var(--ink-2); }
.code { font: 500 12.5px ui-monospace, "Cascadia Mono", Consolas, monospace; background: var(--surface-3); color: var(--ink-2); padding: 1px 7px; border-radius: 6px; direction: ltr; unicode-bidi: isolate; }

/* Summary rows */
.stat-rows { display: grid; gap: 4px; }
.stat-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px dashed var(--border); }
.stat-row:first-child { border-top: 0; }
.stat-row .dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.stat-row span { flex: 1; color: var(--ink-2); }
.stat-row b { font-size: 16px; }
.bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; display: flex; margin: 6px 0 4px; }
.bar i { display: block; height: 100%; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.expired { background: var(--danger-soft); color: var(--danger); }
.badge.soon { background: var(--warning-soft); color: var(--warning); }
.badge.ok { background: var(--success-soft); color: var(--success); }
.badge.none { background: var(--surface-3); color: var(--muted); }
.badge.plain::before { display: none; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 500; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.pill .ico { width: 14px; height: 14px; }
.pill.elec { background: color-mix(in srgb, var(--elec) 16%, transparent); color: color-mix(in srgb, var(--elec) 70%, var(--ink)); }
.pill.water { background: color-mix(in srgb, var(--water) 16%, transparent); color: color-mix(in srgb, var(--water) 70%, var(--ink)); }

/* Charts */
.chart-box { position: relative; height: 290px; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }

/* Empty states */
.empty { display: grid; justify-items: center; gap: 10px; padding: 36px 16px; text-align: center; color: var(--muted); }
.empty-icon { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.empty-icon .ico { width: 24px; height: 24px; }
.empty-icon.ok { background: var(--success-soft); color: var(--success); }
.empty strong { color: var(--ink); font-size: 15px; }

/* ================= Data pages ================= */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px; }
.toolbar .search { position: relative; flex: 1 1 260px; max-width: 360px; }
.toolbar .search > .ico { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.toolbar .search input { padding-inline-start: 38px; background: var(--surface-2); border-color: var(--border); }
.toolbar select { width: auto; min-width: 160px; background-color: var(--surface-2); border-color: var(--border); }
.toolbar .spacer { flex: 1; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; font: 500 13px var(--font); color: var(--ink-2); padding: 6px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
thead th { position: sticky; top: 0; text-align: start; font-size: 12.5px; font-weight: 600; color: var(--muted); background: var(--surface-2); padding: 11px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
thead th:first-child { border-start-start-radius: 0; }
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { cursor: pointer; transition: background .12s; }
tbody tr:hover td { background: var(--surface-2); }
td .sub { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
td.strong { font-weight: 600; }
.table-foot { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.fac { display: inline-flex; align-items: center; gap: 8px; }
.fac-dot { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--accent-ink); background: var(--accent-soft); flex: none; }

/* ================= Sheet (side panel) & modal ================= */
dialog { border: 0; padding: 0; color: var(--ink); background: var(--surface); }
dialog::backdrop { background: rgba(10, 12, 24, .45); backdrop-filter: blur(3px); }
.sheet { margin: 0; margin-inline-start: auto; width: min(540px, 100vw); height: 100vh; max-height: 100vh; max-width: 100vw; box-shadow: var(--shadow-lg); }
.sheet[open] { animation: sheet-in .22s cubic-bezier(.2, .8, .2, 1); }
@keyframes sheet-in { from { transform: translateX(-24px); opacity: 0; } }
.sheet > div, .sheet form { height: 100%; display: flex; flex-direction: column; }
.modal { width: min(560px, calc(100vw - 32px)); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); }
.modal[open] { animation: modal-in .18s ease-out; }
@keyframes modal-in { from { transform: scale(.97) translateY(6px); opacity: 0; } }
.dlg-head { display: flex; align-items: flex-start; gap: 14px; padding: 22px 24px 18px; border-bottom: 1px solid var(--border); }
.dlg-head .head-icon { width: 42px; height: 42px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }
.dlg-head .head-icon .ico { width: 20px; height: 20px; }
.dlg-head .head-icon.danger { background: var(--danger-soft); color: var(--danger); }
.dlg-title { flex: 1; }
.dlg-title h3 { font-size: 18px; }
.dlg-title p { color: var(--muted); font-size: 13px; margin-top: 2px; }
.dlg-body { padding: 20px 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; overflow-y: auto; align-content: start; }
.sheet .dlg-body { flex: 1; }
.dlg-foot { display: flex; gap: 10px; align-items: center; padding: 16px 24px; border-top: 1px solid var(--border); background: var(--surface-2); }
.dlg-foot .spacer { flex: 1; }
.meta { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--muted); padding-top: 4px; border-top: 1px dashed var(--border); margin-top: 4px; }
.import-errors { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 300px; overflow: auto; grid-column: 1 / -1; }
.import-errors li { display: flex; gap: 10px; font-size: 13px; background: var(--danger-soft); border-radius: 10px; padding: 10px 12px; }
.import-errors b { color: var(--danger); white-space: nowrap; }

/* Toast */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; background: #111827; color: #fff; padding: 12px 18px; border-radius: 14px; z-index: 100; box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px); font-size: 14px; animation: toast-in .2s ease-out; }
.toast .ico { color: #4ade80; }
.toast.err .ico { color: #fb7185; }
@keyframes toast-in { from { transform: translate(-50%, 10px); opacity: 0; } }

/* Skeleton */
.skeleton { display: grid; gap: 16px; }
.sk { border-radius: var(--r-lg); background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%); background-size: 200% 100%; animation: sk 1.2s infinite linear; }
@keyframes sk { to { background-position: -200% 0; } }

/* ================= Responsive ================= */
@media (max-width: 1100px) {
  .grid-2, .grid-3-1 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; width: 280px; z-index: 40; transform: translateX(105%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(10, 12, 24, .45); z-index: 35; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 12px 16px; }
  .page-head h1 { font-size: 18px; }
  .content { padding: 4px 16px 32px; gap: 16px; }
  .hero { padding: 20px; gap: 16px; }
  .hero h2 { font-size: 20px; }
  .hero-stats { width: 100%; flex-wrap: nowrap; gap: 8px; }
  .hero-chip { min-width: 0; flex: 1; padding: 8px 12px; }
  .hero-chip b { font-size: 18px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .kpi-value { font-size: 24px; }
  .toolbar .search { max-width: none; }
  .dlg-body { grid-template-columns: 1fr; }
  .list-item { padding: 12px 16px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
