:root {
  color-scheme: light;
  --navy-950: #071a38;
  --navy-900: #0b2348;
  --navy-800: #142f5b;
  --navy-700: #214371;
  --coral-500: #f26b5b;
  --coral-100: #fff0ed;
  --mint-600: #129a7d;
  --mint-500: #38c6a3;
  --mint-100: #e8f9f4;
  --amber-500: #ffb230;
  --amber-100: #fff6df;
  --red-600: #c84444;
  --red-100: #fff0f0;
  --ink-900: #14213d;
  --ink-700: #3e4b63;
  --ink-500: #6b7588;
  --line: #e1e6ed;
  --canvas: #f5f6f4;
  --surface: #ffffff;
  --shadow: 0 16px 48px rgba(16, 34, 61, .1);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink-900);
  font-family: Manrope, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgba(56, 198, 163, .32);
  outline-offset: 2px;
}

.boot-screen, .login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
}
.boot-screen { align-content: center; gap: 14px; color: var(--ink-500); }
.boot-error { padding: 28px; text-align: center; }
.boot-error-copy { max-width: 520px; }
.boot-error-copy h1 { margin: 8px 0 10px; color: var(--ink-900); font-size: 28px; }
.boot-error-copy p { margin: 0; line-height: 1.65; }
.boot-help { max-width: 480px; margin: 0; font-size: 12px; }
.brand-mark {
  width: 52px; height: 52px; border-radius: 16px;
  display: grid; place-items: center;
  background: var(--navy-950); color: white; font-weight: 800;
  letter-spacing: -.04em;
}

.login-shell {
  grid-template-columns: minmax(320px, 46%) minmax(420px, 54%);
  background: var(--surface);
}
.login-story {
  min-height: 100vh;
  padding: clamp(36px, 7vw, 96px);
  background: var(--navy-950);
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.login-brand { display: flex; align-items: center; gap: 14px; font-size: 24px; font-weight: 800; }
.login-brand .brand-mark { background: rgba(255,255,255,.12); }
.login-copy { max-width: 600px; }
.eyebrow { color: var(--mint-500); font-weight: 800; letter-spacing: .1em; text-transform: uppercase; font-size: 12px; }
.login-copy h1 { margin: 14px 0 18px; font-size: clamp(38px, 5vw, 68px); line-height: 1.02; letter-spacing: -.05em; }
.login-copy p { color: #c8d3e5; font-size: 17px; line-height: 1.75; }
.security-note { display: flex; gap: 12px; color: #aebbd0; max-width: 520px; line-height: 1.6; }
.security-dot { flex: 0 0 auto; width: 12px; height: 12px; border-radius: 50%; background: var(--mint-500); margin-top: 5px; box-shadow: 0 0 0 6px rgba(56,198,163,.13); }
.login-panel { display: grid; place-items: center; padding: 36px; }
.login-card { width: min(440px, 100%); }
.login-card h2 { font-size: 30px; margin: 0 0 8px; letter-spacing: -.035em; }
.muted { color: var(--ink-500); }
.field { display: grid; gap: 8px; margin-top: 20px; }
.field label { font-weight: 700; }
.input, .select {
  width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 0 14px; color: var(--ink-900); background: white;
}
.button {
  min-height: 46px; border: 0; border-radius: var(--radius-sm); padding: 0 18px;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  font-weight: 800; transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.button:hover { transform: translateY(-1px); }
.button-primary { color: white; background: var(--navy-950); box-shadow: 0 8px 20px rgba(7,26,56,.2); }
.button-secondary { color: var(--ink-900); background: white; border: 1px solid var(--line); }
.button-danger { color: var(--red-600); background: var(--red-100); }
.button-block { width: 100%; margin-top: 24px; }
.button:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.login-error { min-height: 22px; margin: 12px 0 0; color: var(--red-600); }

.shell { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 24px 16px;
  background: var(--navy-950); color: white; display: flex; flex-direction: column;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 26px; font-size: 21px; font-weight: 800; }
.sidebar-brand .brand-mark { background: rgba(255,255,255,.12); width: 40px; height: 40px; border-radius: 12px; }
.nav { display: grid; gap: 7px; }
.nav-button {
  min-height: 48px; border: 0; border-radius: 12px; padding: 0 14px;
  background: transparent; color: #d5dfed; text-align: left; font-weight: 700;
  display: flex; align-items: center; gap: 12px;
}
.nav-button:hover, .nav-button.active { color: white; background: rgba(255,255,255,.1); }
.nav-icon { width: 22px; text-align: center; font-size: 17px; }
.operator-card { margin-top: auto; border-top: 1px solid rgba(255,255,255,.13); padding: 18px 8px 0; }
.operator-name { font-weight: 800; }
.operator-role { color: #aebbd0; font-size: 12px; margin-top: 3px; }

.workspace { min-width: 0; }
.topbar {
  min-height: 76px; padding: 14px clamp(20px, 3vw, 42px); background: rgba(255,255,255,.92);
  border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 18px;
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(14px);
}
.mobile-menu { display: none; }
.search { position: relative; width: min(480px, 50vw); }
.search input { padding-left: 42px; }
.search::before { content: '⌕'; position: absolute; left: 15px; top: 11px; color: var(--ink-500); font-size: 22px; }
.topbar-spacer { flex: 1; }
.connection-pill { display: flex; align-items: center; gap: 8px; color: var(--mint-600); font-weight: 800; font-size: 12px; }
.connection-pill::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--mint-500); }

.content { padding: 32px clamp(20px, 3vw, 42px) 60px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 26px; }
.page-heading h1 { margin: 0; font-size: 30px; letter-spacing: -.04em; }
.page-heading p { margin: 7px 0 0; color: var(--ink-500); }
.heading-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.summary-card { background: white; border: 1px solid var(--line); border-radius: var(--radius-md); padding: 20px; box-shadow: 0 8px 28px rgba(16,34,61,.045); }
.summary-label { color: var(--ink-500); font-weight: 700; }
.summary-value { font-size: 28px; font-weight: 800; margin-top: 12px; letter-spacing: -.04em; }
.summary-detail { color: var(--ink-500); font-size: 12px; margin-top: 8px; }

.panel { background: white; border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: 0 8px 28px rgba(16,34,61,.045); overflow: hidden; }
.panel-header { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px; }
.panel-header h2 { margin: 0; font-size: 18px; }
.panel-header .muted { margin-left: auto; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 860px; }
.data-table th { padding: 14px 18px; color: var(--ink-500); text-align: left; font-size: 12px; font-weight: 800; background: #fafbfa; }
.data-table td { padding: 15px 18px; border-top: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr { transition: background .15s ease; }
.data-table tbody tr:hover, .data-table tbody tr.selected { background: #f5f9ff; }
.account-cell { display: flex; align-items: center; gap: 12px; }
.account-avatar { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--navy-950); color: white; font-weight: 800; }
.account-name { font-weight: 800; }
.account-sub { color: var(--ink-500); font-size: 12px; margin-top: 3px; }
.status { display: inline-flex; align-items: center; min-height: 28px; border-radius: 999px; padding: 0 10px; font-size: 12px; font-weight: 800; }
.status-active { color: var(--mint-600); background: var(--mint-100); }
.status-suspended, .status-expired { color: #9a6300; background: var(--amber-100); }
.status-revoked { color: var(--red-600); background: var(--red-100); }
.empty-state { padding: 56px 24px; text-align: center; color: var(--ink-500); }

.drawer-backdrop { position: fixed; inset: 0; background: rgba(7,26,56,.26); z-index: 39; }
.drawer {
  position: fixed; z-index: 40; top: 0; right: 0; height: 100vh; width: min(480px, 100vw);
  background: white; box-shadow: -22px 0 60px rgba(7,26,56,.18); overflow-y: auto;
}
.drawer-header { padding: 24px; display: flex; gap: 14px; border-bottom: 1px solid var(--line); }
.drawer-header h2 { margin: 0; }
.icon-button { margin-left: auto; border: 0; background: transparent; width: 44px; height: 44px; border-radius: 12px; font-size: 21px; }
.icon-button:hover { background: var(--canvas); }
.drawer-section { padding: 22px 24px; border-bottom: 1px solid var(--line); }
.drawer-section h3 { margin: 0 0 14px; font-size: 15px; }
.key-values { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.key-value { padding: 13px; border-radius: 12px; background: var(--canvas); }
.key-value span { display: block; color: var(--ink-500); font-size: 11px; }
.key-value strong { display: block; margin-top: 6px; }
.switch-row { min-height: 50px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch-copy strong { display: block; }
.switch-copy small { color: var(--ink-500); }
.switch { position: relative; width: 46px; height: 26px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: #ccd3dc; transition: .18s; }
.switch span::after { content: ''; position: absolute; width: 20px; height: 20px; top: 3px; left: 3px; border-radius: 50%; background: white; transition: .18s; box-shadow: 0 2px 6px rgba(0,0,0,.18); }
.switch input:checked + span { background: var(--mint-500); }
.switch input:checked + span::after { transform: translateX(20px); }
.device-row { padding: 12px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.device-row:first-of-type { border-top: 0; }
.device-meta { color: var(--ink-500); font-size: 12px; margin-top: 4px; }
.drawer-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(7,26,56,.36); display: grid; place-items: center; padding: 20px; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: white; border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.modal-header { display: flex; align-items: center; gap: 12px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 20px; }
.modal-body { padding: 22px 24px; }
.modal-footer { padding: 18px 24px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .field-full { grid-column: 1 / -1; }
.token-box { margin-top: 16px; padding: 16px; border: 1px dashed var(--mint-600); background: var(--mint-100); border-radius: 12px; word-break: break-all; }
.token-box code { display: block; margin-top: 8px; font-size: 14px; }
.warning-box { padding: 14px; border-radius: 12px; background: var(--amber-100); color: #714b00; line-height: 1.55; }
.toast-region { position: fixed; right: 24px; bottom: 24px; z-index: 80; display: grid; gap: 10px; }
.toast { max-width: 390px; padding: 14px 16px; border-radius: 12px; color: white; background: var(--navy-950); box-shadow: var(--shadow); }
.toast.error { background: var(--red-600); }

@media (max-width: 1040px) {
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .shell { grid-template-columns: 210px minmax(0,1fr); }
}
@media (max-width: 760px) {
  .login-shell { display: block; }
  .login-story { min-height: auto; padding: 28px 24px; }
  .login-copy h1 { font-size: 38px; }
  .login-copy p, .security-note { display: none; }
  .login-panel { padding: 40px 22px; }
  .shell { display: block; }
  .sidebar { position: fixed; left: 0; z-index: 45; width: 260px; transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: none; }
  .mobile-menu { display: inline-grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 12px; background: white; }
  .search { width: auto; flex: 1; }
  .connection-pill { display: none; }
  .content { padding-top: 22px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .field-full { grid-column: auto; }
}
@media (max-width: 480px) {
  .summary-grid { grid-template-columns: 1fr; }
  .topbar { padding: 12px 14px; }
  .search input { padding-left: 14px; }
  .search::before { display: none; }
  .key-values { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
