/* Visual style modelled on shadcn/ui "new-york" dark (slate) — clean, monochrome, thin borders. */
:root {
  --bg: #020817;
  --card: #020817;
  --muted-bg: #0f172a;
  --hover: #1e293b;
  --line: #1e293b;
  --line-strong: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --primary: #f8fafc;
  --primary-fg: #0f172a;
  --mint: #3DDC97;
  --mint-dim: rgba(61, 220, 151, .12);
  --amber: #f59e0b;
  --amber-dim: rgba(245, 158, 11, .12);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, .12);
  --radius: 12px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; min-height: 100dvh; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--text); }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; font-weight: 700; }
h1 { font-size: 24px; }
h2 { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

.center-screen { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.spinner { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--text); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Shell ── */
.shell { display: flex; min-height: 100vh; min-height: 100dvh; }
.side-nav { width: 248px; flex-shrink: 0; border-inline-end: 1px solid var(--line); padding: 12px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; height: 100dvh; background: var(--bg); }
.brand { display: flex; align-items: center; gap: 10px; padding: 8px; margin-bottom: 14px; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--primary); color: var(--primary-fg); display: grid; place-items: center; font-size: 16px; flex-shrink: 0; }
.brand-name { font-weight: 600; font-size: 14px; line-height: 1.2; }
.brand-sub { color: var(--muted); font-size: 12px; }
.nav-group { color: var(--muted); font-size: 12px; font-weight: 500; padding: 14px 8px 6px; }
.nav-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none; color: var(--text); cursor: pointer; text-align: start; font-size: 14px; }
.nav-btn:hover { background: var(--hover); }
.nav-btn.active { background: var(--hover); font-weight: 500; }
.nav-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; }
.avatar { width: 32px; height: 32px; border-radius: 8px; background: var(--hover); display: grid; place-items: center; font-size: 12px; font-weight: 600; flex-shrink: 0; text-transform: uppercase; }
.avatar.round { border-radius: 50%; width: 36px; height: 36px; }
.user-chip .li-body { min-width: 0; }

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 60px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 16px; padding: 0 28px; position: sticky; top: 0; background: rgba(2, 8, 23, .85); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); z-index: 10; }
.topbar .crumbs { color: var(--muted); font-size: 14px; }
.topbar .crumbs b { color: var(--text); font-weight: 500; }
.topbar .spacer { flex: 1; }
.app-main { padding: 24px 28px 48px; width: 100%; max-width: 1280px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.tab-bar { display: none; }

.seg { display: inline-flex; background: var(--muted-bg); border-radius: 10px; padding: 4px; gap: 2px; margin-bottom: 18px; }
.seg button { border: 0; background: none; color: var(--muted); padding: 6px 12px; border-radius: 7px; cursor: pointer; font-size: 13.5px; font-weight: 500; }
.seg button.active { background: var(--bg); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .4); }

@media (max-width: 760px) {
  .side-nav, .topbar { display: none; }
  .app-main { padding: 18px 16px calc(92px + env(safe-area-inset-bottom)); }
  .tab-bar { display: flex; position: fixed; inset-inline: 0; bottom: 0; background: rgba(2, 8, 23, .94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); z-index: 20; }
  .tab-bar .nav-btn { flex-direction: column; gap: 4px; font-size: 11px; padding: 7px 4px; justify-content: center; align-items: center; text-align: center; color: var(--muted); }
  .tab-bar .nav-btn.active { background: none; color: var(--text); }
  .tab-bar .nav-btn svg { width: 20px; height: 20px; }
  .mobile-head { display: flex !important; }
  h1 { font-size: 22px; }
}
.mobile-head { display: none; align-items: center; justify-content: space-between; margin-bottom: 16px; }

/* ── Cards ── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 4fr) minmax(0, 3fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-main { grid-template-columns: 1fr; } }
@media (max-width: 560px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } .grid-4 { grid-template-columns: 1fr 1fr; gap: 10px; } }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }

.kpi .kpi-top { display: flex; align-items: center; justify-content: space-between; color: var(--text); font-size: 14px; font-weight: 500; margin-bottom: 10px; }
.kpi .kpi-top svg { width: 16px; height: 16px; color: var(--muted); }
.kpi .kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.kpi .kpi-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
@media (max-width: 560px) { .kpi { padding: 14px; } .kpi .kpi-value { font-size: 20px; } .kpi .kpi-top { font-size: 12.5px; } }
/* legacy names used in a few places */
.stat-label { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.stat-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* chart */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .grid-line { stroke: var(--line); stroke-dasharray: 3 4; }
.chart .bar { fill: #e2e8f0; }
.chart .bar.zero { fill: var(--line-strong); }
.chart-empty { position: absolute; inset: 0 0 24px 40px; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 13px; pointer-events: none; }
.chart-empty span { background: var(--bg); padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); }

.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; background: var(--muted-bg); color: var(--text); border: 1px solid var(--line); font-size: 13.5px; line-height: 1.5; }
.banner svg { color: var(--amber); }
.banner.ok { background: var(--mint-dim); color: var(--mint); border-color: rgba(61, 220, 151, .25); }
.banner.err { background: var(--red-dim); color: #fca5a5; border-color: rgba(239, 68, 68, .3); }

.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--line); cursor: pointer; background: none; border-inline: 0; border-top: 0; width: 100%; text-align: start; color: var(--text); }
.list-item:last-child { border-bottom: 0; }
button.list-item:hover { background: rgba(30, 41, 59, .4); }
.li-icon { width: 36px; height: 36px; border-radius: 50%; background: var(--hover); display: grid; place-items: center; flex-shrink: 0; color: var(--text); }
.li-icon svg { width: 16px; height: 16px; }
.li-body { flex: 1; min-width: 0; }
.li-title { font-weight: 500; font-size: 14px; }
.li-sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.on { color: var(--mint); border-color: rgba(61, 220, 151, .3); }
.pill.wait { color: var(--amber); border-color: rgba(245, 158, 11, .3); }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: start; color: var(--muted); font-weight: 500; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover td { background: rgba(30, 41, 59, .4); }
.tbl .num { text-align: end; font-variant-numeric: tabular-nums; }

.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.empty svg { width: 28px; height: 28px; margin-bottom: 8px; color: var(--line-strong); }

/* ── Forms & buttons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-weight: 500; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
.btn.primary:hover { background: #e2e8f0; }
.btn.danger { color: #f87171; }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 16px; height: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13.5px; font-weight: 500; }
.field input, .field select { height: 38px; background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; outline: none; width: 100%; }
.field input:focus, .field select:focus { border-color: var(--line-strong); box-shadow: 0 0 0 2px rgba(148, 163, 184, .25); }
.field input::placeholder { color: #64748b; }
.field .hint { font-size: 12px; color: var(--muted); }
input[type="date"], input[type="month"] { color-scheme: dark; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand { justify-content: center; margin-bottom: 20px; }

.lang-switch { display: inline-flex; background: var(--muted-bg); border-radius: 8px; padding: 3px; }
.lang-switch button { border: 0; background: none; color: var(--muted); padding: 4px 9px; border-radius: 6px; cursor: pointer; font-size: 12px; font-weight: 500; }
.lang-switch button.active { background: var(--bg); color: var(--text); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: end; word-break: break-word; }
.copy-box { display: flex; gap: 8px; margin-top: 10px; }
.copy-box input { flex: 1; min-width: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; color: var(--text); font-size: 12px; }

.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--bg); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; font-size: 13.5px; z-index: 50; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }

[dir="rtl"] .back-arrow { transform: scaleX(-1); }
