/* Shared console shell for the admin pages (index / reports / metrics): sidebar nav, top bar, sign-in
   card, role chips, and the common controls. Page-specific styles stay in each page's <style>. */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap');
:root {
  color-scheme: dark;
  --bg: #191817; --side: #1d1b19; --card: #211f1d; --raise: #262422; --line: #2c2a26; --line2: #3a3732;
  --ink: #f4f2ee; --ink2: #ddd7cc; --muted: #a3a097; --faint: #6f6c64;
  --accent: #88b6bf; --accent-ink: #10272c; --accent-soft: rgba(136,182,191,.15);
  --tenant: #2dd4bf; --tenant-soft: rgba(45,212,191,.13);
  --danger: #f87171; --danger-soft: rgba(248,113,113,.12);
  --radius: 12px;
  --disp: "Alpha Lyrae", "Space Grotesk", "Inter", system-ui, sans-serif;
}
.brand b, .top h1, .login h2, .modal h2 { font-family: var(--disp); letter-spacing: -0.01em; }
* { box-sizing: border-box; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
body { margin: 0; font: 14px Inter, system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--accent); }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 16px; }
.brand .mark { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), #4b7d88); display: grid; place-items: center; color: var(--accent-ink); flex: 0 0 auto; }
.brand .mark svg { width: 18px; height: 18px; }
.brand b { font-size: 16px; letter-spacing: .01em; }
.brand small { display: block; font-size: 11px; color: var(--faint); font-weight: 500; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; }
.nav .h { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 10px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 500; }
.nav a svg { width: 17px; height: 17px; flex: 0 0 auto; }
.nav a:hover { background: var(--raise); color: var(--ink); }
.nav a.on { background: var(--accent-soft); color: var(--ink); }
.nav a.on svg { color: var(--accent); }
.role-tenant .nav a.on { background: var(--tenant-soft); }
.role-tenant .nav a.on svg { color: var(--tenant); }
.role-tenant .super-only { display: none !important; }
/* pin shell icon sizes so a page's own `svg {}` rules (e.g. Reports' chart svgs) can't stretch them */
.side svg, .login svg { width: 17px !important; height: 17px !important; flex: 0 0 auto; display: inline-block; overflow: visible; }
.brand .mark svg { width: 18px !important; height: 18px !important; }
.me .btn { white-space: nowrap; justify-content: center; }
.me-acts { display: grid; grid-template-columns: auto 1fr; gap: 6px; }
.me-acts #sh-pw { padding: 0 10px; }
.side .me { margin-top: auto; padding: 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.me .who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.me .av { width: 32px; height: 32px; border-radius: 50%; background: var(--raise); border: 1px solid var(--line2); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: 0 0 auto; }
.me .nm { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; border-radius: 999px; padding: 3px 9px; white-space: nowrap; }
.chip i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.super { background: var(--accent-soft); color: #6ee7b7; }
.chip.tenant { background: var(--tenant-soft); color: #99f6e4; }
.chip.readonly { background: rgba(167,139,250,.14); color: #c4b5fd; }   /* supervisor / auditor */

.page { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 24px; border-bottom: 1px solid var(--line); background: rgba(18,15,12,.88); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 5; min-height: 62px; }
.top h1 { font-size: 17px; margin: 0; font-weight: 700; }
.top .crumb { font-size: 12px; color: var(--faint); }
.top .sp { flex: 1; }
.content { padding: 20px 24px 40px; }

/* ---------- controls ---------- */
.btn, .top button, .top select, .top input, .field input, .field select { height: 34px; border-radius: 9px; font: 600 13px Inter, system-ui, sans-serif; }
.btn, .top button { border: 0; padding: 0 14px; cursor: pointer; background: var(--accent); color: var(--accent-ink); display: inline-flex; align-items: center; gap: 6px; }
.btn.ghost, .top button.ghost { background: var(--raise); color: var(--ink); border: 1px solid var(--line2); }
.btn.ghost:hover, .top button.ghost:hover { border-color: var(--faint); }
.top select, .top input { background: var(--card); border: 1px solid var(--line2); color: var(--ink); padding: 0 10px; font-weight: 500; }
.top label.auto { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.sep { width: 1px; height: 22px; background: var(--line2); margin: 0 2px; }

/* ---------- sign-in ---------- */
.login { display: none; min-height: 100vh; place-items: center; padding: 24px;
  background: radial-gradient(1200px 500px at 50% -10%, rgba(136,182,191,.10), transparent 60%), var(--bg); }
.signed-out .login { display: grid; }
.signed-out .shell { display: none; }
.login .box { width: 380px; max-width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: 0 24px 70px rgba(0,0,0,.45); }
.login .brand { padding: 0 0 18px; }
.login h2 { margin: 0 0 4px; font-size: 20px; }
.login p { margin: 0 0 20px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field span { font-size: 12px; color: var(--muted); font-weight: 600; }
.field input { width: 100%; background: var(--bg); border: 1px solid var(--line2); color: var(--ink); padding: 0 12px; height: 40px; font-weight: 500; font-size: 14px; }
.login .btn { width: 100%; height: 42px; justify-content: center; font-size: 14px; margin-top: 4px; }
.login .err { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 12px; }
.login .roles { display: grid; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--faint); }
.login .roles .chip { margin-right: 6px; }

/* ---------- default-password banner + change-password modal ---------- */
.banner { display: none; align-items: center; gap: 14px; justify-content: space-between; flex-wrap: wrap; background: var(--danger-soft); border: 1px solid rgba(248,113,113,.4); color: #fecaca; border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; font-size: 13px; }
.banner.show { display: flex; }
.modal { display: none; position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.55); place-items: center; padding: 20px; }
.modal.open { display: grid; }
.modal .box { width: 400px; max-width: 100%; background: var(--card); border: 1px solid var(--line2); border-radius: 16px; padding: 24px; box-shadow: 0 24px 70px rgba(0,0,0,.5); }
.modal h2 { margin: 0 0 4px; font-size: 18px; } .modal p { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.modal .err { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 10px; }
.modal .row { display: flex; gap: 8px; justify-content: flex-end; }
.banner.imp { background: rgba(167,139,250,.12); border-color: rgba(167,139,250,.5); color: #ddd6fe; }
.banner.soft { background: rgba(251,191,36,.08); border-color: rgba(251,191,36,.35); color: #fde68a; }
.modal .box.sec { width: 460px; max-height: 88vh; overflow: auto; }
.sec-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.sec-h h2 { margin: 0; }
.modal .x { background: none; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; }
.modal section { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.modal section h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 10px; }
.modal section p { margin: 0 0 12px; }
.mfa-on { color: #6ee7b7 !important; }
.mfa-steps { margin: 0 0 8px; padding-left: 18px; color: var(--ink2); font-size: 13px; display: flex; flex-direction: column; gap: 12px; }
.mfa-key { display: flex; gap: 8px; align-items: center; margin: 8px 0 4px; }
.mfa-key code { font-size: 15px; letter-spacing: .06em; background: var(--bg); border: 1px solid var(--line2); border-radius: 8px; padding: 6px 10px; }
.mfa-steps input, .field input#sh-code { height: 38px; margin-top: 8px; width: 140px; background: var(--bg); border: 1px solid var(--line2); color: var(--ink); border-radius: 9px; padding: 0 12px; font: 600 16px ui-monospace, monospace; letter-spacing: .2em; }
.field input#sh-code { width: 100%; }
.hint { font-size: 12px; color: var(--faint); }
.btn.danger { background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(248,113,113,.45); }
.okmsg { color: #6ee7b7; }
.linkbtn { background: none; border: 0; color: var(--muted); font-size: 12.5px; margin-top: 10px; cursor: pointer; width: 100%; text-decoration: underline; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; margin-bottom: 10px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .nav { flex-direction: row; padding: 0 8px; } .nav .h { display: none; }
  .side .me { margin: 0 0 0 auto; border: 0; flex-direction: row; align-items: center; }
  .top, .content { padding-left: 16px; padding-right: 16px; }
}
@media print { .side, .top, .login { display: none !important; } .shell { display: block; } .content { padding: 0; } }

/* ---------- Arabic / RTL ---------- */
.langbtn { width: 100%; justify-content: center; }
.login-lang { display: flex; justify-content: flex-end; margin: -10px -10px 4px 0; }
.login-lang .langbtn { width: auto; height: 28px; font-size: 12px; }
[dir=rtl] body { font-family: 'Segoe UI', Tahoma, 'Noto Sans Arabic', 'Geeza Pro', system-ui, sans-serif; }
[dir=rtl] .side { border-right: 0; border-left: 1px solid var(--line); }
[dir=rtl] th, [dir=rtl] td { text-align: right; }
[dir=rtl] td[style*="text-align:right"] { text-align: left !important; }
[dir=rtl] .mono, [dir=rtl] code, [dir=rtl] .kv dd, [dir=rtl] input[type=number], [dir=rtl] .mfa-key code { direction: ltr; unicode-bidi: isolate; }
[dir=rtl] .kv dd { text-align: right; }
[dir=rtl] .stat::before { inset: 0 0 0 auto; }
[dir=rtl] #tenants button.on { box-shadow: inset -3px 0 0 var(--accent); }
[dir=rtl] .drawer { inset: 0 auto 0 0; border-left: 0; border-right: 1px solid var(--line2); transform: translateX(-105%); box-shadow: 20px 0 60px rgba(0,0,0,.45); }
[dir=rtl] .drawer.open { transform: none; }
[dir=rtl] .login-lang { justify-content: flex-start; margin: -10px 0 4px -10px; }
[dir=rtl] .mfa-steps { padding-left: 0; padding-right: 18px; }
