/* ==========================================================================
   Anmat Platform: control panel and sign-in
   Plain CSS (no build step). Arabic-first, RTL, light and dark themes.
   ========================================================================== */

@font-face { font-family: "Plex Arabic"; src: url("fonts/plex-arabic-regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Plex Arabic"; src: url("fonts/plex-arabic-medium.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Plex Arabic"; src: url("fonts/plex-arabic-semibold.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Plex Arabic"; src: url("fonts/plex-arabic-bold.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }

/* ---------- Design tokens ---------- */
:root {
  --font: "Plex Arabic", "IBM Plex Sans Arabic", system-ui, "Segoe UI", Tahoma, sans-serif;

  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --surface-3: #eef2f5;
  --line: #e3e8ec;
  --line-strong: #d2d9df;
  --ink: #111518;
  --ink-2: #3f4850;
  --ink-3: #66717b;
  --ink-4: #97a1aa;

  --brand: #029ecf;
  --brand-ink: #0279a1;
  --brand-soft: rgba(2, 158, 207, .10);
  --brand-ring: rgba(2, 158, 207, .28);
  --graphite: #15181b;
  --graphite-2: #1d2125;

  --ok: #10805b;     --ok-soft: rgba(16, 128, 91, .10);
  --warn: #a8640a;   --warn-soft: rgba(196, 122, 14, .12);
  --danger: #bf3328; --danger-soft: rgba(191, 51, 40, .09);

  --mark-base: #2d3135;
  --mark-accent: #029ecf;

  --shadow-xs: 0 1px 2px rgba(17, 24, 31, .05);
  --shadow-sm: 0 1px 2px rgba(17, 24, 31, .05), 0 2px 6px -2px rgba(17, 24, 31, .06);
  --shadow-md: 0 10px 28px -12px rgba(17, 24, 31, .18), 0 3px 8px -3px rgba(17, 24, 31, .06);
  --shadow-lg: 0 28px 60px -20px rgba(17, 24, 31, .30), 0 8px 18px -6px rgba(17, 24, 31, .10);

  --r-xs: 8px;
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;

  --ease: cubic-bezier(.2, .7, .2, 1);
  --t: .22s var(--ease);
  --shell: 1280px;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0b0d0f;
  --surface: #121518;
  --surface-2: #161a1d;
  --surface-3: #1c2125;
  --line: #22282d;
  --line-strong: #2d343a;
  --ink: #eef2f4;
  --ink-2: #b6bec5;
  --ink-3: #8b949c;
  --ink-4: #626b73;

  --brand: #2bb8e6;
  --brand-ink: #62cbef;
  --brand-soft: rgba(43, 184, 230, .12);
  --brand-ring: rgba(43, 184, 230, .32);

  --ok: #43cf9b;     --ok-soft: rgba(67, 207, 155, .12);
  --warn: #f0b14a;   --warn-soft: rgba(240, 177, 74, .12);
  --danger: #ff7e72; --danger-soft: rgba(255, 126, 114, .11);

  --mark-base: #e8ecef;
  --mark-accent: #2bb8e6;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4), 0 2px 8px -2px rgba(0, 0, 0, .35);
  --shadow-md: 0 14px 32px -12px rgba(0, 0, 0, .6), 0 3px 8px -3px rgba(0, 0, 0, .4);
  --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, .75), 0 8px 18px -6px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
body.hub-body {
  background:
    radial-gradient(1200px 520px at 85% -10%, var(--brand-soft), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
img, svg { display: block; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--brand-ring); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.num { font-variant-numeric: tabular-nums; }

.ic { width: 20px; height: 20px; flex: none; }
.ic-sm { width: 16px; height: 16px; }
.ic-lg { width: 26px; height: 26px; }

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  font: 600 11px/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
  color: var(--ink-3);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  direction: ltr;
}

.skip {
  position: absolute;
  inset-inline-start: 1rem;
  top: -100px;
  z-index: 100;
  padding: .6rem 1rem;
  background: var(--graphite);
  color: #fff;
  border-radius: var(--r-sm);
}
.skip:focus { top: 1rem; }

/* ---------- Brand mark ---------- */
.mark .mark-base { fill: var(--mark-base); }
.mark .mark-accent { fill: var(--mark-accent); }
.on-dark { --mark-base: #ffffff; --mark-accent: #2bb8e6; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  height: 40px;
  padding: 0 1rem;
  font-size: .875rem;
  font-weight: 600;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--t), border-color var(--t), color var(--t), box-shadow var(--t), transform var(--t);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  color: #fff;
  background: linear-gradient(180deg, #0a97c6, #0279a1);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .18) inset, 0 6px 16px -8px rgba(2, 121, 161, .7);
}
.btn-primary:hover { background: linear-gradient(180deg, #0aa3d6, #0284b0); }
.btn-ghost { color: var(--ink-2); background: var(--surface); border-color: var(--line); box-shadow: var(--shadow-xs); }
.btn-ghost:hover { border-color: var(--line-strong); color: var(--ink); }
.btn-ghost .ic { transition: transform var(--t); }
.btn-ghost:hover .ic { transform: translateX(-3px); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: background var(--t), color var(--t), border-color var(--t);
}
.icon-btn:hover { background: var(--surface); border-color: var(--line); color: var(--ink); }
.badge {
  position: absolute;
  top: 5px;
  inset-inline-end: 5px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  background: var(--danger);
  border: 2px solid var(--bg);
  border-radius: 999px;
}

/* theme toggle icons */
.theme-sun, [data-theme="dark"] .theme-moon { display: none; }
[data-theme="dark"] .theme-sun { display: block; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(1.5) blur(14px);
  -webkit-backdrop-filter: saturate(1.5) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
}
.topbar-in {
  max-width: var(--shell);
  margin: 0 auto;
  height: 66px;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.brand { display: flex; align-items: center; gap: .75rem; flex: none; }
.brand-mark { width: 44px; height: auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 1rem; font-weight: 700; letter-spacing: -.01em; }
.brand-text small { font-size: .7rem; color: var(--ink-3); letter-spacing: .08em; text-transform: uppercase; font-family: system-ui, "Segoe UI", sans-serif; }

.search {
  margin-inline-start: auto;
  margin-inline-end: auto;
  display: flex;
  align-items: center;
  gap: .6rem;
  width: min(420px, 100%);
  height: 42px;
  padding: 0 .75rem 0 .6rem;
  padding-inline: .85rem .5rem;
  color: var(--ink-3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: border-color var(--t), box-shadow var(--t), color var(--t);
}
.search:hover { border-color: var(--line-strong); color: var(--ink-2); box-shadow: var(--shadow-sm); }
.search span { flex: 1; text-align: start; font-size: .875rem; }
.search-kbd { min-width: auto; padding: 0 7px; }

.top-actions { display: flex; align-items: center; gap: .35rem; flex: none; }

/* user menu */
.user { position: relative; }
.user-btn {
  display: flex;
  align-items: center;
  gap: .6rem;
  height: 44px;
  padding: 0 .4rem;
  padding-inline-start: .3rem;
  margin-inline-start: .35rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: background var(--t), border-color var(--t);
}
.user-btn:hover, .user-btn[aria-expanded="true"] { background: var(--surface); border-color: var(--line); }
.user-btn .ic { color: var(--ink-4); transition: transform var(--t); }
.user-btn[aria-expanded="true"] .ic { transform: rotate(180deg); }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; text-align: start; }
.user-meta strong { font-size: .85rem; font-weight: 600; }
.user-meta small { font-size: .72rem; color: var(--ink-3); }
.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: .8rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(140deg, #2a3036, #15181b);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
  flex: none;
  letter-spacing: .02em;
}
.avatar-lg { width: 42px; height: 42px; border-radius: 12px; font-size: .95rem; }
[data-theme="dark"] .avatar { background: linear-gradient(140deg, #0a97c6, #0279a1); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2); }

.menu {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  width: 270px;
  padding: .4rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  transform-origin: top left;
  animation: pop .16s var(--ease);
}
.menu-head { display: flex; align-items: center; gap: .7rem; padding: .7rem .7rem .8rem; border-bottom: 1px solid var(--line); margin-bottom: .35rem; }
.menu-head div { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.menu-head strong { font-size: .9rem; }
.menu-head small { font-size: .75rem; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: start; }
.menu a, .menu button {
  display: flex;
  align-items: center;
  gap: .65rem;
  width: 100%;
  padding: .6rem .7rem;
  font-size: .875rem;
  color: var(--ink-2);
  background: transparent;
  border: 0;
  border-radius: var(--r-xs);
  cursor: pointer;
  text-align: start;
}
.menu a:hover, .menu button:hover, .menu a:focus-visible, .menu button:focus-visible { background: var(--surface-3); color: var(--ink); outline: none; }
.menu .ic { color: var(--ink-4); }
.menu-sep { height: 1px; background: var(--line); margin: .35rem .2rem; }
.menu .menu-danger { color: var(--danger); }
.menu .menu-danger .ic { color: currentColor; }
.menu .menu-danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ---------- Layout ---------- */
.shell {
  width: 100%;
  max-width: var(--shell);
  margin: 0 auto;
  padding: 1.75rem 1.5rem 3rem;
  flex: 1;
}
.section { margin-top: 2.5rem; }
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.section-head h2 { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; }
.section-head p { font-size: .85rem; color: var(--ink-3); margin-top: .15rem; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 2rem;
  padding: 2.25rem 2.25rem 2.1rem;
  color: #fff;
  border-radius: var(--r-lg);
  background:
    radial-gradient(700px 300px at 0% 0%, rgba(43, 184, 230, .30), transparent 60%),
    radial-gradient(500px 260px at 100% 120%, rgba(2, 158, 207, .18), transparent 60%),
    linear-gradient(160deg, #1b1f23 0%, #121518 100%);
  box-shadow: var(--shadow-md), inset 0 0 0 1px rgba(255, 255, 255, .06);
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(120% 120% at 0% 0%, #000 0%, transparent 70%);
  mask-image: radial-gradient(120% 120% at 0% 0%, #000 0%, transparent 70%);
}
.hero-motif {
  position: absolute;
  z-index: -1;
  inset-inline-end: -40px;
  top: 50%;
  width: 560px;
  max-width: 70%;
  transform: translateY(-50%);
  opacity: .9;
  pointer-events: none;
}
.hero-date {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  font-size: .82rem;
  color: rgba(255, 255, 255, .72);
  padding: .3rem .75rem .3rem .65rem;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .10);
  border-radius: 999px;
}
.hero-date .ic { color: #7fd6f3; }
.hero-date .sep { opacity: .4; }
.hero h1 {
  margin-top: 1rem;
  font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.35rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.015em;
}
.hero h1 .wave { color: #7fd6f3; }
.hero-lead { margin-top: .6rem; max-width: 56ch; color: rgba(255, 255, 255, .72); font-size: .95rem; }
.hero-lead kbd { color: rgba(255, 255, 255, .85); background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .18); }
.hero-side { display: flex; flex-direction: column; align-items: flex-end; gap: .9rem; text-align: end; }
.clock { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.clock-time { font-size: 2.4rem; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.clock-label { margin-top: .35rem; font-size: .75rem; color: rgba(255, 255, 255, .55); }
.hero-tags { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }
.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .75rem;
  color: rgba(255, 255, 255, .78);
  padding: .3rem .65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .10);
}
.hero-tag b { color: #fff; font-weight: 600; }

/* ---------- System tiles ---------- */
.systems {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1rem;
}
.systems > .tile { grid-column: span 2; }
.systems > .tile--soon { grid-column: span 3; }
.tile {
  --mx: 50%;
  --my: 0%;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 300px;
  padding: 1.35rem 1.35rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  transition: transform .35s var(--ease), box-shadow .35s var(--ease), border-color .35s var(--ease);
}
.tile::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(380px circle at var(--mx) var(--my), var(--brand-soft), transparent 55%);
  opacity: 0;
  transition: opacity .35s var(--ease);
}
.tile::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
  transform: scaleX(0);
  transition: transform .5s var(--ease);
}
a.tile:hover, a.tile:focus-visible {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--brand) 40%, var(--line));
  box-shadow: var(--shadow-md), 0 0 0 4px var(--brand-soft);
  outline: none;
}
a.tile:hover::before, a.tile:focus-visible::before { opacity: 1; }
a.tile:hover::after, a.tile:focus-visible::after { transform: scaleX(1); }

.tile-top { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; }
.tile-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 16px;
  color: var(--ink-3);
  background: var(--surface-3);
  border: 1px solid var(--line);
  transition: transform .35s var(--ease), box-shadow .35s var(--ease);
}
.tile.is-open .tile-icon {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(145deg, #12b2e6 0%, #0279a1 100%);
  box-shadow: 0 10px 22px -10px rgba(2, 121, 161, .8), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.tile.is-open.tile--building .tile-icon {
  background: linear-gradient(145deg, #353c43 0%, #15181b 100%);
  box-shadow: 0 10px 22px -12px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 255, 255, .12);
}
a.tile:hover .tile-icon { transform: translateY(-2px) scale(1.04); }

.tile-body h3 { font-size: 1.1rem; font-weight: 700; line-height: 1.45; letter-spacing: -.01em; }
.tile-en { margin-top: .1rem; font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-4); font-family: system-ui, "Segoe UI", sans-serif; text-align: right; }
.tile-desc { margin-top: .65rem; font-size: .88rem; line-height: 1.85; color: var(--ink-3); }

.tile-meta {
  list-style: none;
  margin: 0;
  padding: .65rem .2rem 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .5rem;
  border-top: 1px dashed var(--line);
}
.tile-meta li { display: flex; flex-direction: column; line-height: 1.2; }
.tile-meta span { font-size: .72rem; color: var(--ink-4); }
.tile-meta b { margin-top: .2rem; font-size: 1rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }

.tile-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding-top: .85rem;
  border-top: 1px solid var(--line);
}
.tile-cta { display: inline-flex; align-items: center; gap: .45rem; font-size: .875rem; font-weight: 600; color: var(--brand-ink); }
.tile-cta .ic { transition: transform .35s var(--ease); }
a.tile:hover .tile-cta .ic { transform: translateX(-4px); }
.tile-note { display: inline-flex; align-items: center; gap: .45rem; font-size: .8rem; color: var(--ink-4); }

.tile.is-soon, .tile.is-locked { background: var(--surface-2); box-shadow: none; }
.tile.is-soon { border-style: dashed; border-color: var(--line-strong); }
.tile.is-soon .tile-body h3, .tile.is-locked .tile-body h3 { color: var(--ink-2); }
.tile.is-soon .tile-desc, .tile.is-locked .tile-desc { color: var(--ink-4); }

/* chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  height: 26px;
  padding: 0 .65rem;
  font-size: .74rem;
  font-weight: 600;
  border-radius: 999px;
  white-space: nowrap;
  color: var(--ink-3);
  background: var(--surface-3);
}
.chip i { position: relative; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip--active { color: var(--ok); background: var(--ok-soft); }
.chip--active i::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid currentColor;
  opacity: 0;
  animation: ping 2.2s var(--ease) infinite;
}
.chip--building { color: var(--warn); background: var(--warn-soft); }
.chip--soon { color: var(--ink-3); background: var(--surface-3); }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.kpi {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "label icon" "value icon" "hint hint";
  align-items: start;
  column-gap: .75rem;
  padding: 1.1rem 1.2rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--t), box-shadow var(--t), transform var(--t);
}
.kpi:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); transform: translateY(-2px); }
.kpi-label { grid-area: label; font-size: .82rem; font-weight: 500; color: var(--ink-3); }
.kpi-value { grid-area: value; font-size: 2rem; font-weight: 700; line-height: 1.15; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: .3rem; }
.kpi-hint { grid-area: hint; margin-top: .55rem; font-size: .76rem; color: var(--ink-4); }
.kpi-icon {
  grid-area: icon;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  color: var(--ink-2);
  background: var(--surface-3);
}
.kpi--brand .kpi-icon { color: var(--brand-ink); background: var(--brand-soft); }
.kpi--warn .kpi-icon { color: var(--warn); background: var(--warn-soft); }
.kpi--danger .kpi-icon { color: var(--danger); background: var(--danger-soft); }
.kpi--danger.has-value .kpi-value { color: var(--danger); }
.kpi--warn.has-value .kpi-value { color: var(--warn); }

/* ---------- Panels / lists ---------- */
.panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1rem; }
.panel {
  display: flex;
  flex-direction: column;
  min-height: 280px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .95rem 1.2rem;
  border-bottom: 1px solid var(--line);
}
.panel-head h3 { display: flex; align-items: center; gap: .55rem; font-size: .95rem; font-weight: 700; }
.panel-head h3 .ic { color: var(--ink-4); }
.panel-head a { font-size: .8rem; font-weight: 600; color: var(--brand-ink); }
.panel-head a:hover { text-decoration: underline; text-underline-offset: 3px; }

.rows { list-style: none; margin: 0; padding: .35rem; }
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .7rem .85rem;
  border-radius: var(--r-sm);
  transition: background var(--t);
}
.row:hover { background: var(--surface-3); }
.row-main { display: flex; flex-direction: column; min-width: 0; }
.row-title { font-size: .88rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: .76rem; color: var(--ink-4); margin-top: .1rem; }
.row-sub.is-late { color: var(--danger); }

.pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 .6rem;
  font-size: .72rem;
  font-weight: 600;
  border-radius: 999px;
  color: var(--ink-3);
  background: var(--surface-3);
}
.pill--critical, .pill--rejected { color: var(--danger); background: var(--danger-soft); }
.pill--high, .pill--pending_approval { color: var(--warn); background: var(--warn-soft); }
.pill--medium { color: var(--brand-ink); background: var(--brand-soft); }
.pill--approved { color: var(--ok); background: var(--ok-soft); }

.empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: .35rem;
  padding: 2rem 1.5rem;
  color: var(--ink-3);
  font-size: .85rem;
}
.empty-ic {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin-bottom: .5rem;
  border-radius: 16px;
  color: var(--ink-4);
  background: var(--surface-3);
  box-shadow: inset 0 0 0 1px var(--line);
}
.empty-title { font-size: .95rem; font-weight: 600; color: var(--ink-2); }
.empty .btn { margin-top: .85rem; }

/* ---------- Footer ---------- */
.foot {
  max-width: var(--shell);
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem 1.5rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: .78rem;
  color: var(--ink-4);
  border-top: 1px solid var(--line);
}
.foot-keys { display: flex; align-items: center; gap: .4rem; }

/* ---------- Command palette ---------- */
.palette {
  width: min(640px, calc(100vw - 2rem));
  max-height: min(560px, calc(100dvh - 4rem));
  margin: 12vh auto auto;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.palette[open] { display: flex; flex-direction: column; animation: pop .18s var(--ease); }
.palette::backdrop { background: rgba(10, 12, 14, .45); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fade .18s var(--ease); }
.palette-input {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 0 1.1rem;
  height: 60px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.palette-input .ic { color: var(--ink-4); }
.palette-input input {
  flex: 1;
  min-width: 0;
  height: 100%;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: none;
}
.palette-input input::placeholder { color: var(--ink-4); }
.palette-list { flex: 1; overflow-y: auto; padding: .4rem; overscroll-behavior: contain; }
.palette-group { padding: .7rem .75rem .35rem; font-size: .7rem; font-weight: 600; color: var(--ink-4); letter-spacing: .02em; }
.palette-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: .75rem;
  width: 100%;
  padding: .55rem .75rem;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  text-align: start;
  cursor: pointer;
}
.palette-item .pi-ic {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  color: var(--ink-3);
  background: var(--surface-3);
  flex: none;
}
.palette-item .pi-label { flex: 1; min-width: 0; font-size: .9rem; font-weight: 500; }
.palette-item .pi-hint { font-size: .74rem; color: var(--ink-4); font-family: system-ui, "Segoe UI", sans-serif; direction: ltr; }
.palette-item .pi-go { color: var(--ink-4); opacity: 0; }
.palette-item[aria-selected="true"] { background: var(--brand-soft); }
.palette-item[aria-selected="true"] .pi-ic { color: var(--brand-ink); background: var(--surface); box-shadow: var(--shadow-xs); }
.palette-item[aria-selected="true"] .pi-go { opacity: 1; }
.palette-empty { padding: 2.5rem 1rem; text-align: center; color: var(--ink-3); font-size: .9rem; }
.palette-foot {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: .6rem 1rem;
  font-size: .74rem;
  color: var(--ink-4);
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  flex: none;
}
.palette-foot span { display: inline-flex; align-items: center; gap: .35rem; }
.palette-foot kbd { height: 20px; min-width: 20px; font-size: 10px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  z-index: 60;
  top: 82px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .7rem 1rem .7rem 1.1rem;
  font-size: .875rem;
  font-weight: 500;
  color: #fff;
  background: var(--graphite);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  animation: toast-in .35s var(--ease);
}
.toast .ic { color: #5fe0b0; }
.toast.is-leaving { animation: toast-out .3s var(--ease) forwards; }

/* ---------- Access matrix ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; gap: .45rem; font-size: .8rem; color: var(--ink-4); margin-bottom: .6rem; }
.crumbs a:hover { color: var(--brand-ink); }
.page-head h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.015em; }
.page-head p { margin-top: .35rem; color: var(--ink-3); font-size: .92rem; max-width: 70ch; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-xs); overflow: hidden; }
.table-wrap { overflow-x: auto; }
.matrix { width: 100%; border-collapse: collapse; min-width: 640px; }
.matrix th, .matrix td { padding: .9rem 1.1rem; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
.matrix thead th { font-size: .76rem; font-weight: 600; color: var(--ink-3); background: var(--surface-2); white-space: nowrap; }
.matrix thead th.sys { text-align: center; }
.matrix thead th .th-sys { display: inline-flex; align-items: center; gap: .45rem; }
.matrix tbody tr:last-child td { border-bottom: 0; }
.matrix tbody tr:hover td { background: var(--surface-2); }
.matrix td.sys { text-align: center; }
.who { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.who div { display: flex; flex-direction: column; line-height: 1.35; min-width: 0; }
.who strong { font-size: .9rem; font-weight: 600; }
.who small { font-size: .76rem; color: var(--ink-4); direction: ltr; text-align: right; }
.is-inactive .who, .is-inactive td.sys { opacity: .5; }

.switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: inherit; }
.switch .track {
  width: 40px;
  height: 24px;
  padding: 3px;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background var(--t);
}
.switch .thumb {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform var(--t);
}
.switch input:checked + .track { background: var(--brand-ink); }
.switch input:checked + .track .thumb { transform: translateX(-16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch input:disabled + .track { opacity: .55; }
.switch.is-locked { cursor: not-allowed; }

.savebar {
  position: sticky;
  bottom: 1rem;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  padding: .75rem .9rem .75rem 1.1rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-md);
}
.savebar p { font-size: .85rem; color: var(--ink-3); }
.savebar.is-dirty p { color: var(--ink); font-weight: 600; }
.note { display: flex; gap: .6rem; align-items: flex-start; margin-top: 1rem; padding: .85rem 1rem; font-size: .84rem; color: var(--ink-3); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); }
.note .ic { color: var(--brand-ink); margin-top: .15rem; }

/* ==========================================================================
   Sign-in
   ========================================================================== */
.auth-body { min-height: 100dvh; background: var(--bg); }
.auth {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr);
}
.auth-main {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 1.5rem clamp(1.25rem, 4vw, 3.5rem);
}
.auth-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.auth-top .brand-text small { letter-spacing: .06em; }
.auth-form-wrap { flex: 1; display: grid; place-items: center; padding: 2.5rem 0; }
.auth-form { width: min(400px, 100%); }
.auth-form h1 { font-size: 1.85rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.3; }
.auth-form .sub { margin-top: .45rem; color: var(--ink-3); font-size: .95rem; }
.auth-fields { margin-top: 2rem; display: grid; gap: 1.1rem; }

.field label { display: block; margin-bottom: .45rem; font-size: .85rem; font-weight: 600; color: var(--ink-2); }
.input {
  position: relative;
  display: flex;
  align-items: center;
}
.input > .ic {
  position: absolute;
  inset-inline-start: 14px;
  color: var(--ink-4);
  pointer-events: none;
  transition: color var(--t);
}
.input input {
  width: 100%;
  height: 50px;
  padding-inline: 44px 14px;
  font: inherit;
  font-size: .95rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  outline: none;
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
}
.input input[dir="ltr"] { text-align: right; padding-right: 44px; padding-left: 14px; }
.input.has-toggle input[dir="ltr"] { padding-left: 48px; }
.input input::placeholder { color: var(--ink-4); }
.input input:hover { border-color: color-mix(in srgb, var(--ink-4) 60%, var(--line-strong)); }
.input input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.input:focus-within > .ic { color: var(--brand-ink); }
.input.has-toggle input { padding-inline-end: 48px; }
.input input[aria-invalid="true"] { border-color: var(--danger); }
.input input[aria-invalid="true"]:focus { box-shadow: 0 0 0 4px var(--danger-soft); }
.pw-toggle {
  position: absolute;
  inset-inline-end: 6px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-4);
  cursor: pointer;
}
.pw-toggle:hover { color: var(--ink-2); background: var(--surface-3); }
.caps { display: flex; align-items: center; gap: .4rem; margin-top: .45rem; font-size: .78rem; color: var(--warn); }

.auth-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: .1rem; }
.check { display: inline-flex; align-items: center; gap: .55rem; font-size: .87rem; color: var(--ink-2); cursor: pointer; user-select: none; }
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check .box {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  border: 1.5px solid var(--line-strong);
  background: var(--surface);
  color: transparent;
  transition: background var(--t), border-color var(--t), color var(--t);
}
.check input:checked + .box { background: var(--brand-ink); border-color: var(--brand-ink); color: #fff; }
.check input:focus-visible + .box { outline: 2px solid var(--brand); outline-offset: 2px; }
.help { font-size: .8rem; color: var(--ink-4); }

.btn-block { width: 100%; height: 52px; font-size: .98rem; border-radius: 12px; margin-top: .6rem; }
.btn .spinner { display: none; width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: spin .7s linear infinite; }
.btn.is-loading .spinner { display: block; }
.btn.is-loading .btn-label-idle { display: none; }
.btn .btn-label-busy { display: none; }
.btn.is-loading .btn-label-busy { display: inline; }
.btn-block .ic { transition: transform var(--t); }
.btn-block:hover .ic { transform: translateX(-4px); }

.alert {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  margin-top: 1.5rem;
  padding: .8rem 1rem;
  font-size: .87rem;
  line-height: 1.6;
  border-radius: 12px;
  border: 1px solid transparent;
}
.alert .ic { margin-top: .1rem; }
.alert-error { color: var(--danger); background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 22%, transparent); }
.alert-ok { color: var(--ok); background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 22%, transparent); }

.auth-foot { display: flex; align-items: center; justify-content: space-between; gap: 1rem; font-size: .78rem; color: var(--ink-4); }

/* art side */
.auth-art {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  margin: .75rem;
  margin-inline-start: 0;
  padding: clamp(2rem, 4vw, 3.5rem);
  display: flex;
  flex-direction: column;
  color: #fff;
  border-radius: 24px;
  background:
    radial-gradient(70% 55% at 15% 0%, rgba(43, 184, 230, .32), transparent 60%),
    radial-gradient(55% 45% at 100% 100%, rgba(2, 158, 207, .16), transparent 60%),
    linear-gradient(165deg, #1b1f23 0%, #0f1214 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .06);
}
.auth-art::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: radial-gradient(90% 70% at 30% 20%, #000, transparent 75%);
  mask-image: radial-gradient(90% 70% at 30% 20%, #000, transparent 75%);
}
.auth-motif {
  position: absolute;
  z-index: -1;
  width: 140%;
  max-width: none;
  left: -30%;
  bottom: -18%;
  opacity: .9;
  animation: drift 22s ease-in-out infinite alternate;
}
.auth-art-top { display: flex; align-items: center; gap: .75rem; }
.auth-art-top .brand-mark { width: 54px; }
.auth-art-top .brand-text small { color: rgba(255, 255, 255, .55); }
.auth-art-body { margin-top: auto; max-width: 460px; }
.eyebrow { display: inline-flex; align-items: center; gap: .5rem; font-size: .78rem; font-weight: 600; color: #7fd6f3; letter-spacing: .02em; }
.eyebrow::before { content: ""; width: 18px; height: 2px; border-radius: 2px; background: currentColor; }
.auth-art h2 { margin-top: .9rem; font-size: clamp(1.75rem, 1.2rem + 1.6vw, 2.5rem); font-weight: 700; line-height: 1.3; letter-spacing: -.02em; }
.auth-art h2 span { color: #7fd6f3; }
.auth-art-body > p { margin-top: .8rem; font-size: .98rem; color: rgba(255, 255, 255, .68); line-height: 1.85; }
.auth-systems { list-style: none; margin: 1.75rem 0 0; padding: 0; display: grid; gap: .55rem; }
.auth-systems li {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .65rem .8rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, .045);
  border: 1px solid rgba(255, 255, 255, .08);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.auth-systems .as-ic { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: rgba(255, 255, 255, .07); color: #9fe1f7; flex: none; }
.auth-systems .as-name { flex: 1; font-size: .9rem; font-weight: 500; }
.auth-systems .chip { height: 22px; font-size: .7rem; }
.auth-systems .chip--active { color: #5fe0b0; background: rgba(95, 224, 176, .12); }
.auth-systems .chip--building { color: #f3c06b; background: rgba(243, 192, 107, .12); }
.auth-systems .chip--soon { color: rgba(255, 255, 255, .55); background: rgba(255, 255, 255, .07); }
.auth-art-foot { margin-top: 2rem; display: flex; justify-content: space-between; gap: 1rem; font-size: .78rem; color: rgba(255, 255, 255, .45); }

/* ---------- Motion ---------- */
.reveal { animation: rise .6s var(--ease) both; animation-delay: calc(var(--i, 0) * 55ms); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ping { 0% { transform: scale(.6); opacity: .7; } 80%, 100% { transform: scale(1.9); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes drift { from { transform: translate3d(0, 0, 0) rotate(0deg); } to { transform: translate3d(-3%, -2%, 0) rotate(-2deg); } }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes toast-out { to { opacity: 0; transform: translate(-50%, -8px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .systems { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .systems > .tile, .systems > .tile--soon { grid-column: auto; }
  .tile { min-height: 260px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .panels { grid-template-columns: 1fr; }
  .user-meta { display: none; }
  .search { width: auto; flex: 1; max-width: 360px; }
}
@media (max-width: 720px) {
  .topbar-in { padding: 0 1rem; gap: .5rem; height: 60px; }
  .brand-text small { display: none; }
  .brand-mark { width: 38px; }
  .search { flex: none; width: 40px; height: 40px; padding: 0; justify-content: center; margin-inline: auto .1rem; border-color: transparent; box-shadow: none; background: transparent; }
  .search span, .search-kbd { display: none; }
  .shell { padding: 1.1rem 1rem 2.5rem; }
  .hero { grid-template-columns: 1fr; padding: 1.5rem 1.35rem; gap: 1.1rem; }
  .hero-side { flex-direction: row; align-items: center; justify-content: space-between; text-align: start; }
  .clock { align-items: flex-start; }
  .clock-time { font-size: 1.6rem; }
  .hero-lead .kbd-hint { display: none; }
  .hero-motif { width: 380px; inset-inline-end: -120px; opacity: .6; }
  .section { margin-top: 1.9rem; }
  .systems { grid-template-columns: 1fr; gap: .75rem; }
  .tile { min-height: 0; }
  .tile-foot kbd { display: none; }
  .kpis { gap: .75rem; }
  .kpi { padding: .95rem 1rem .9rem; }
  .kpi-value { font-size: 1.6rem; }
  .kpi-icon { width: 34px; height: 34px; }
  .section-head { align-items: flex-start; flex-wrap: wrap; }
  .section-head .btn { height: 36px; font-size: .82rem; }
  .foot { flex-direction: column; text-align: center; }
  .foot-keys { display: none; }
  .toast { top: 72px; width: calc(100vw - 2rem); justify-content: center; }
  .palette { margin-top: 8vh; }
  .palette-foot { display: none; }
  .savebar { flex-direction: column; align-items: stretch; text-align: center; }
}
@media (max-width: 380px) {
  .kpis { grid-template-columns: 1fr; }
}
