/* =====================================================================
   Alaris admin console
   Tokens follow the Alaris design system: one confident cobalt on cool
   grey and white, Obvia for content, Power Grotesk for titles and labels,
   soft cool shadows, calm motion. Sentence case everywhere.
   ===================================================================== */

/* ---------- Fonts ---------------------------------------------------- */
@font-face { font-family: "Obvia"; src: url("../fonts/Obvia-Light.otf") format("opentype"); font-weight: 300; font-display: swap; }
@font-face { font-family: "Obvia"; src: url("../fonts/Obvia-Book.otf") format("opentype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Obvia"; src: url("../fonts/Obvia-Medium.otf") format("opentype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Obvia"; src: url("../fonts/Obvia-Bold.otf") format("opentype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Power Grotesk"; src: url("../fonts/PowerGrotesk-Regular.otf") format("opentype"); font-weight: 400; font-display: swap; }

/* ---------- Tokens --------------------------------------------------- */
:root {
  --cobalt-900: #081C7A; --cobalt-800: #0C28A6; --cobalt-700: #0D2FB8; --cobalt-600: #1640D6;
  --cobalt-500: #2456E6; --cobalt-400: #5C82F0; --cobalt-200: #C3D2FB; --cobalt-100: #E2E9FD; --cobalt-50: #F1F5FE;

  --ink-900: #0E1118; --ink-800: #181C26; --ink-700: #2A2F3B; --ink-600: #444B59; --ink-500: #646C7B;
  --ink-400: #8A93A3; --ink-300: #B4BCC9; --ink-200: #D6DCE4; --ink-150: #E4E9EF; --ink-100: #EFF2F6;
  --ink-50: #F6F8FA; --paper: #FFFFFF;

  --success-600: #1E8A5B; --success-100: #DCF1E7;
  --warning-600: #B5790C; --warning-100: #FBEFD3;
  --danger-600: #C2392F; --danger-500: #DE4B40; --danger-100: #FBE2E0;

  --brand: var(--cobalt-600);
  --text-strong: var(--ink-900); --text-body: var(--ink-700); --text-muted: var(--ink-500); --text-faint: var(--ink-400);
  --surface-page: var(--ink-50); --surface-card: var(--paper); --surface-sunken: var(--ink-100);
  --border-subtle: var(--ink-150); --border-default: var(--ink-200); --border-strong: var(--ink-300);
  --ring-focus: 0 0 0 3px rgba(22, 64, 214, 0.28);

  --font-title: "Power Grotesk", "Obvia", "Open Sans", Arial, sans-serif;
  --font-body: "Obvia", "Open Sans", "Helvetica Neue", Arial, sans-serif;
  --font-label: "Power Grotesk", "Obvia", sans-serif;

  --radius-sm: 6px; --radius-md: 10px; --radius-lg: 16px; --radius-xl: 24px; --radius-full: 999px;

  --shadow-xs: 0 1px 2px rgba(14, 17, 24, 0.05);
  --shadow-sm: 0 1px 3px rgba(14, 17, 24, 0.06), 0 1px 2px rgba(14, 17, 24, 0.04);
  --shadow-md: 0 4px 12px rgba(14, 17, 24, 0.07), 0 2px 4px rgba(14, 17, 24, 0.04);
  --shadow-lg: 0 12px 32px rgba(14, 17, 24, 0.10), 0 4px 8px rgba(14, 17, 24, 0.04);
  --shadow-xl: 0 24px 60px rgba(14, 17, 24, 0.14), 0 8px 16px rgba(14, 17, 24, 0.05);
  --shadow-brand: 0 12px 32px rgba(22, 64, 214, 0.22);

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast: 140ms; --dur-base: 220ms; --dur-slow: 360ms;

  --sidebar-w: 264px;
}

/* ---------- Base ----------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--surface-page);
  color: var(--text-body);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 { font-family: var(--font-title); font-weight: 400; color: var(--text-strong); margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--cobalt-700); text-decoration: underline; }
[hidden] { display: none !important; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }
.eyebrow {
  font-family: var(--font-label); font-size: 11px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--text-muted);
}
.muted { color: var(--text-muted); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Buttons -------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--radius-md);
  border: 1px solid transparent; background: transparent;
  font: 500 14px/1 var(--font-body); color: var(--text-strong);
  cursor: pointer; white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.btn:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: var(--paper); box-shadow: var(--shadow-xs); }
.btn-primary:hover:not(:disabled) { background: var(--cobalt-700); }
.btn-primary:active:not(:disabled) { background: var(--cobalt-900); transform: translateY(1px); }
.btn-secondary { background: var(--paper); border-color: var(--border-default); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-sunken); }
.btn-ghost { color: var(--ink-600); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-sunken); color: var(--text-strong); }
.btn-danger { background: var(--paper); border-color: var(--border-default); color: var(--danger-600); }
.btn-danger:hover:not(:disabled) { background: var(--danger-100); border-color: transparent; }
.btn-block { width: 100%; height: 46px; font-size: 15px; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn .spinner { display: none; }
.btn.is-busy .spinner { display: inline-block; }
.btn.is-busy .btn-label { opacity: 0.8; }

.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Form fields ---------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field { margin-top: 16px; }
.field label { font-size: 13px; font-weight: 500; color: var(--text-strong); }
.field .hint { font-size: 12.5px; color: var(--text-muted); }
.input {
  height: 44px; width: 100%; padding: 0 14px;
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  background: var(--paper); color: var(--text-strong);
  font: 400 15px var(--font-body);
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.input::placeholder { color: var(--text-faint); }
.input:hover { border-color: var(--border-strong); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring-focus); }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 44px; }
.input-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-faint); cursor: pointer; display: grid; place-items: center;
}
.input-toggle:hover { color: var(--text-strong); background: var(--surface-sunken); }

.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius-md);
  font-size: 14px; line-height: 1.45;
}
.alert-error { background: var(--danger-100); color: var(--danger-600); }
.alert-info { background: var(--cobalt-50); color: var(--cobalt-800); }
.alert .icon { margin-top: 1px; }

/* =====================================================================
   Login
   ===================================================================== */
.login {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(380px, 1fr) minmax(0, 1.15fr);
  background: var(--paper);
}
.login-panel {
  display: flex; flex-direction: column;
  padding: 40px clamp(24px, 6vw, 88px);
}
.login-panel .logo { height: 22px; width: auto; align-self: flex-start; }
.login-form-wrap {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  width: 100%; max-width: 400px; margin: 0 auto;
  animation: rise var(--dur-slow) var(--ease-out) both;
}
.login-form-wrap h1 { font-size: 40px; line-height: 1.1; margin: 12px 0 10px; }
.login-form-wrap .lede { color: var(--text-muted); margin-bottom: 32px; }
.login-form-wrap .alert { margin-bottom: 20px; }
.login-form-wrap .btn-block { margin-top: 28px; }
.login-foot { font-size: 12.5px; color: var(--text-faint); }

.login-visual {
  position: relative; overflow: hidden;
  margin: 16px 16px 16px 0; border-radius: var(--radius-xl);
  background: #E9EDF1 url("../img/login-lens.jpg") center / cover no-repeat;
}
.login-visual figcaption {
  position: absolute; left: 32px; right: 32px; bottom: 32px;
  max-width: 420px; padding: 20px 22px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: var(--shadow-md);
  animation: rise 520ms var(--ease-out) 120ms both;
}
.login-visual figcaption p { font-family: var(--font-title); font-size: 22px; line-height: 1.25; color: var(--text-strong); margin-top: 8px; }

@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login-visual { display: none; }
}

/* =====================================================================
   App shell
   ===================================================================== */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex: none;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 22px 16px 18px;
  background: var(--paper); border-right: 1px solid var(--border-subtle);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 10px 26px; }
.brand img { height: 18px; width: auto; }
.brand .tag {
  font-family: var(--font-label); font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--cobalt-700); background: var(--cobalt-100);
  padding: 4px 8px; border-radius: var(--radius-full);
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section { margin: 18px 12px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  height: 40px; padding: 0 12px; border: 0; border-radius: var(--radius-md);
  background: transparent; color: var(--ink-600);
  font: 400 14.5px var(--font-body); text-align: left; cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.nav-item:hover { background: var(--surface-sunken); color: var(--text-strong); }
.nav-item:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.nav-item[aria-selected="true"] { background: var(--cobalt-100); color: var(--cobalt-700); font-weight: 500; }
.nav-item .soon {
  margin-left: auto; font-family: var(--font-label); font-size: 9.5px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--text-faint);
}

.sidebar-foot { margin-top: auto; }
.env-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 12px; border-radius: var(--radius-md);
  background: var(--surface-page); border: 1px solid var(--border-subtle);
  font-size: 12.5px; color: var(--text-muted);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-300); flex: none; }
.dot.ok { background: var(--success-600); box-shadow: 0 0 0 3px var(--success-100); }
.dot.bad { background: var(--danger-500); box-shadow: 0 0 0 3px var(--danger-100); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 68px; flex: none;
  display: flex; align-items: center; gap: 16px;
  padding: 0 32px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 21px; }
.topbar .crumb { color: var(--text-faint); font-size: 13px; }

.account { margin-left: auto; position: relative; }
.account-trigger {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 10px 5px 5px; border: 1px solid var(--border-default); border-radius: var(--radius-full);
  background: var(--paper); cursor: pointer; font: 500 13.5px var(--font-body); color: var(--text-strong);
  transition: background var(--dur-fast) var(--ease-out);
}
.account-trigger:hover { background: var(--surface-sunken); }
.account-trigger:focus-visible { outline: none; box-shadow: var(--ring-focus); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--cobalt-100); color: var(--cobalt-700);
  font: 500 12px var(--font-body); letter-spacing: 0.02em;
}
.avatar-lg { width: 36px; height: 36px; font-size: 13px; }

.menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px;
  padding: 6px; border-radius: var(--radius-lg);
  background: var(--paper); border: 1px solid var(--border-subtle); box-shadow: var(--shadow-lg);
  animation: rise var(--dur-base) var(--ease-out) both;
}
.menu-head { padding: 10px 12px 12px; border-bottom: 1px solid var(--border-subtle); margin-bottom: 6px; }
.menu-head strong { display: block; color: var(--text-strong); font-weight: 500; }
.menu-head span { font-size: 13px; color: var(--text-muted); }
.menu button {
  width: 100%; display: flex; align-items: center; gap: 10px;
  height: 38px; padding: 0 12px; border: 0; border-radius: var(--radius-md);
  background: transparent; color: var(--text-body); font: 400 14px var(--font-body); cursor: pointer; text-align: left;
}
.menu button:hover { background: var(--surface-sunken); color: var(--text-strong); }

.content { padding: 32px; max-width: 1240px; width: 100%; }
.tab-panel { animation: rise var(--dur-slow) var(--ease-out) both; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-head h2 { font-size: 30px; line-height: 1.15; margin-top: 8px; }
.page-head p { color: var(--text-muted); margin-top: 6px; max-width: 620px; }

/* ---------- Cards, stats --------------------------------------------- */
.card {
  background: var(--surface-card); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.card-pad { padding: 24px; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border-subtle); }
.card-head h3 { font-size: 17px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { padding: 20px 22px; }
.stat .value { font-family: var(--font-title); font-size: 32px; line-height: 1.1; color: var(--text-strong); margin-top: 10px; }
.stat .value.placeholder { color: var(--ink-300); }
.stat .sub { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Empty / placeholder states ------------------------------- */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 64px 24px;
}
.empty .orb {
  width: 64px; height: 64px; border-radius: 50%; margin-bottom: 20px;
  display: grid; place-items: center; color: var(--cobalt-600);
  background: radial-gradient(circle at 32% 28%, #FFFFFF 0%, var(--cobalt-100) 45%, var(--cobalt-200) 100%);
  box-shadow: inset 0 -6px 14px rgba(22, 64, 214, 0.14), var(--shadow-sm);
}
.empty .orb .icon { width: 26px; height: 26px; }
.empty h3 { font-size: 20px; }
.empty p { color: var(--text-muted); max-width: 440px; margin-top: 8px; }

.list-placeholder { display: flex; flex-direction: column; }
.list-placeholder .row { display: flex; align-items: center; gap: 14px; padding: 16px 24px; border-bottom: 1px solid var(--border-subtle); }
.list-placeholder .row:last-child { border-bottom: 0; }
.bar { height: 10px; border-radius: var(--radius-full); background: var(--surface-sunken); }

/* ---------- Table ---------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; padding: 12px 24px;
  font-family: var(--font-label); font-weight: 400; font-size: 10.5px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-muted);
  background: var(--surface-page); border-bottom: 1px solid var(--border-subtle);
}
td { padding: 14px 24px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background var(--dur-fast) var(--ease-out); }
tbody tr:hover { background: var(--cobalt-50); }
.person { display: flex; align-items: center; gap: 12px; }
.person strong { display: block; font-weight: 500; color: var(--text-strong); }
.person span { font-size: 13px; color: var(--text-muted); }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; }
td.actions { text-align: right; white-space: nowrap; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 24px; padding: 0 10px; border-radius: var(--radius-full);
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.badge-success { background: var(--success-100); color: var(--success-600); }
.badge-neutral { background: var(--surface-sunken); color: var(--ink-600); }
.badge-warning { background: var(--warning-100); color: var(--warning-600); }
.badge-brand { background: var(--cobalt-100); color: var(--cobalt-700); }

/* ---------- Dialog --------------------------------------------------- */
dialog {
  width: min(480px, calc(100vw - 32px)); padding: 0;
  border: 0; border-radius: var(--radius-xl);
  background: var(--paper); color: var(--text-body);
  box-shadow: var(--shadow-xl);
}
dialog[open] { animation: rise var(--dur-slow) var(--ease-out) both; }
dialog::backdrop { background: rgba(14, 17, 24, 0.32); backdrop-filter: blur(3px); }
.dialog-body { padding: 28px 28px 8px; }
.dialog-body h2 { font-size: 22px; margin: 8px 0 8px; }
.dialog-body > p { color: var(--text-muted); margin-bottom: 22px; }
.dialog-body .alert { margin-bottom: 16px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 20px 28px 24px; }

.secret {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px 14px 18px; border-radius: var(--radius-md);
  background: var(--surface-page); border: 1px dashed var(--border-strong);
}
.secret code { flex: 1; font: 500 18px/1.2 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: 0.04em; color: var(--text-strong); word-break: break-all; }

/* ---------- Toast ---------------------------------------------------- */
.toasts { position: fixed; right: 24px; bottom: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast {
  display: flex; align-items: center; gap: 10px;
  min-width: 280px; max-width: 420px; padding: 14px 16px;
  border-radius: var(--radius-lg); background: var(--ink-900); color: var(--paper);
  box-shadow: var(--shadow-lg); font-size: 14px;
  animation: rise var(--dur-base) var(--ease-out) both;
}
.toast.is-error { background: var(--danger-600); }
.toast.is-leaving { animation: fade-out var(--dur-base) var(--ease-out) both; }

/* ---------- Motion --------------------------------------------------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade-out { to { opacity: 0; transform: translateY(6px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
}

@media (max-width: 760px) {
  .sidebar { display: none; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .stats { grid-template-columns: 1fr; }
}
