/* DeviceConsole Portal - design tokens, layouts and components. No inline styles anywhere in the
   templates: the Content-Security-Policy (app/security.py) only allows this stylesheet. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --surface-hover: #f3f4f6;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff4ff;
  --accent-text: #1d4ed8;
  --on-accent: #ffffff;
  --success: #15803d;
  --success-soft: #ecfdf3;
  --success-border: #bbf7d0;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --warning-border: #fde68a;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;
  --info: #1d4ed8;
  --info-soft: #eff6ff;
  --info-border: #bfdbfe;
  --neutral-soft: #f3f4f6;
  --code-bg: #f3f4f6;
  --focus: 0 0 0 3px rgba(37, 99, 235, 0.28);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, 0.18);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f17;
    --surface: #121826;
    --surface-2: #161d2d;
    --surface-hover: #1b2335;
    --border: #243049;
    --border-strong: #33415e;
    --text: #e5e9f0;
    --text-2: #c3cad6;
    --muted: #8b95a7;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-soft: rgba(59, 130, 246, 0.14);
    --accent-text: #93c5fd;
    --success: #4ade80;
    --success-soft: rgba(34, 197, 94, 0.12);
    --success-border: rgba(74, 222, 128, 0.3);
    --warning: #fbbf24;
    --warning-soft: rgba(245, 158, 11, 0.12);
    --warning-border: rgba(251, 191, 36, 0.3);
    --danger: #f87171;
    --danger-soft: rgba(239, 68, 68, 0.12);
    --danger-border: rgba(248, 113, 113, 0.32);
    --info: #93c5fd;
    --info-soft: rgba(59, 130, 246, 0.12);
    --info-border: rgba(147, 197, 253, 0.3);
    --neutral-soft: #1f2839;
    --code-bg: #0e1420;
    --focus: 0 0 0 3px rgba(96, 165, 250, 0.35);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0b0f17;
  --surface: #121826;
  --surface-2: #161d2d;
  --surface-hover: #1b2335;
  --border: #243049;
  --border-strong: #33415e;
  --text: #e5e9f0;
  --text-2: #c3cad6;
  --muted: #8b95a7;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --accent-text: #93c5fd;
  --success: #4ade80;
  --success-soft: rgba(34, 197, 94, 0.12);
  --success-border: rgba(74, 222, 128, 0.3);
  --warning: #fbbf24;
  --warning-soft: rgba(245, 158, 11, 0.12);
  --warning-border: rgba(251, 191, 36, 0.3);
  --danger: #f87171;
  --danger-soft: rgba(239, 68, 68, 0.12);
  --danger-border: rgba(248, 113, 113, 0.32);
  --info: #93c5fd;
  --info-soft: rgba(59, 130, 246, 0.12);
  --info-border: rgba(147, 197, 253, 0.3);
  --neutral-soft: #1f2839;
  --code-bg: #0e1420;
  --focus: 0 0 0 3px rgba(96, 165, 250, 0.35);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

/* ------------------------------------------------------------------ base */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; color: var(--text); letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; font-weight: 650; }
h2 { font-size: 1.05rem; font-weight: 600; }
h3 { font-size: 0.95rem; font-weight: 600; }
p { margin: 0 0 0.75rem; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

code, .mono { font-family: var(--mono); font-size: 0.86em; }
code { background: var(--code-bg); padding: 0.1rem 0.35rem; border-radius: 4px; word-break: break-all; }

hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }

.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.break { word-break: break-all; }
.stack > * + * { margin-top: 1rem; }
.stack-lg > * + * { margin-top: 1.5rem; }
.row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.hidden { display: none !important; }
.mt-lg { margin-top: 1.5rem; }
.mb-lg { margin-bottom: 1.5rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }

/* ------------------------------------------------------------------ top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  height: 60px;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.brand { display: flex; align-items: center; gap: 0.6rem; color: var(--text); font-weight: 650; letter-spacing: -0.01em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.brand-sub { color: var(--muted); font-weight: 500; }

.nav { display: flex; align-items: center; gap: 0.25rem; }
.nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 500;
  font-size: 0.92rem;
  white-space: nowrap;
}
.nav a:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent-text); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }

.user-chip { display: flex; align-items: center; gap: 0.55rem; padding: 0.25rem 0.35rem 0.25rem 0.25rem; border-radius: 999px; color: var(--text-2); font-size: 0.88rem; }
.avatar {
  width: 30px; height: 30px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-text);
  font-weight: 650; font-size: 0.8rem; text-transform: uppercase;
}
.avatar-lg { width: 44px; height: 44px; font-size: 1rem; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }

.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

.nav-toggle { display: none; }

@media (max-width: 1180px) {
  .user-chip .user-email { display: none; }
}

@media (max-width: 860px) {
  .topbar-inner { gap: 0.75rem; padding: 0 1rem; }
  .nav-toggle { display: inline-flex; }
  .nav {
    display: none;
    position: absolute; top: 60px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0.15rem;
    padding: 0.6rem 1rem 1rem;
    background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-lg);
  }
  .nav.is-open { display: flex; }
  .nav a { padding: 0.65rem 0.75rem; }
  .user-chip .user-email { display: none; }
  .brand-sub { display: none; }
}

/* ------------------------------------------------------------------ page shells */

.page { width: 100%; max-width: 1240px; margin: 0 auto; padding: 2rem 1.25rem 4rem; flex: 1 0 auto; }
.page-narrow { max-width: 880px; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.page-header .subtitle { color: var(--muted); margin-top: 0.35rem; }
.page-header .actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.page-title-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }

.breadcrumb { display: flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.6rem; }
.breadcrumb a { color: var(--muted); display: inline-flex; align-items: center; gap: 0.3rem; }
.breadcrumb a:hover { color: var(--text); }

.admin-shell { width: 100%; max-width: 1320px; margin: 0 auto; flex: 1 0 auto; display: grid; grid-template-columns: 236px minmax(0, 1fr); gap: 0; min-height: calc(100vh - 60px); }
.sidebar { border-right: 1px solid var(--border); padding: 1.5rem 0.85rem; position: sticky; top: 60px; align-self: start; height: calc(100vh - 60px); overflow-y: auto; }
.sidebar-label { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 0 0.7rem; margin: 1.1rem 0 0.4rem; }
.sidebar-label:first-child { margin-top: 0; }
.sidebar a {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.5rem 0.7rem; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 0.92rem; font-weight: 500;
}
.sidebar a:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.sidebar a.active { background: var(--accent-soft); color: var(--accent-text); }
.sidebar .count { margin-left: auto; background: var(--accent); color: var(--on-accent); font-size: 0.72rem; font-weight: 650; border-radius: 999px; padding: 0.05rem 0.5rem; }
.admin-main { padding: 2rem 2rem 4rem; min-width: 0; }
/* Next to the sidebar, two columns only have room on a wide screen. */
@media (max-width: 1280px) {
  .admin-main .grid-2 { grid-template-columns: 1fr; }
  .admin-main .grid-main { grid-template-columns: 1fr; }
}

@media (max-width: 960px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border);
    display: flex; gap: 0.25rem; overflow-x: auto; padding: 0.6rem 1rem; scrollbar-width: none;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar-label { display: none; }
  .sidebar a { white-space: nowrap; }
  .admin-main { padding: 1.5rem 1rem 3rem; }
}

/* ------------------------------------------------------------------ cards */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-header .card-sub { color: var(--muted); font-size: 0.85rem; margin-top: 0.15rem; }
.card-body { padding: 1.25rem; }
.card-body-flush { padding: 0; }
.card-footer { padding: 0.9rem 1.25rem; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.card-danger { border-color: var(--danger-border); }
.card-danger .card-header { border-bottom-color: var(--danger-border); }
.card-accent { border-color: var(--info-border); background: linear-gradient(180deg, var(--accent-soft), var(--surface) 70%); }

.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
@media (max-width: 1080px) { .grid-main { grid-template-columns: 1fr; } }
@media (max-width: 860px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.1rem 1.2rem; box-shadow: var(--shadow-sm); display: block; color: inherit; }
a.stat:hover { border-color: var(--border-strong); text-decoration: none; box-shadow: var(--shadow); }
.stat-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 0.85rem; font-weight: 500; }
.stat-icon { width: 34px; height: 34px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent-text); }
.stat-icon.warning { background: var(--warning-soft); color: var(--warning); }
.stat-icon.success { background: var(--success-soft); color: var(--success); }
.stat-icon.danger { background: var(--danger-soft); color: var(--danger); }
.stat-value { font-size: 1.75rem; font-weight: 650; letter-spacing: -0.02em; margin-top: 0.4rem; color: var(--text); }
.stat-foot { font-size: 0.82rem; color: var(--muted); margin-top: 0.15rem; }

/* ------------------------------------------------------------------ buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  min-height: 38px; padding: 0.5rem 0.95rem;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 0.9rem; font-weight: 550; line-height: 1.2;
  cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-sm);
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.btn:hover { background: var(--surface-hover); text-decoration: none; }
.btn:disabled, .btn.is-loading { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--surface); border-color: var(--danger-border); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-danger-solid { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn-danger-solid:hover { background: #b91c1c; border-color: #b91c1c; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn-sm { min-height: 32px; padding: 0.35rem 0.7rem; font-size: 0.84rem; }
.btn-lg { min-height: 46px; padding: 0.7rem 1.25rem; font-size: 0.98rem; }
.btn-block { width: 100%; }

/* ------------------------------------------------------------------ forms */

.form-grid { display: grid; gap: 1.1rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; }
.label { font-size: 0.87rem; font-weight: 600; color: var(--text-2); }
.hint { font-size: 0.82rem; color: var(--muted); }
.input, .select, .textarea {
  width: 100%;
  min-height: 40px;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: 0.93rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.input::placeholder, .textarea::placeholder { color: var(--muted); opacity: 0.8; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.input.mono { font-family: var(--mono); font-size: 0.86rem; letter-spacing: 0.01em; }
.textarea { min-height: 96px; resize: vertical; }
.select { appearance: none; padding-right: 2.2rem; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.input-sm, .select-sm { min-height: 34px; padding: 0.35rem 0.6rem; font-size: 0.86rem; }
.select-sm { padding-right: 2rem; }
.input-days { width: 6.5rem; }
.checkbox { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; color: var(--text-2); cursor: pointer; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--accent); }

.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon .input { padding-left: 2.3rem; }

.inline-form { display: flex; align-items: flex-end; gap: 0.5rem; flex-wrap: wrap; }
.inline-form .field { flex: 0 0 auto; }
.inline-form .field.grow { flex: 1 1 200px; }

.filters { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filters .input-icon { flex: 1 1 260px; max-width: 420px; }
.filters .select { width: auto; min-width: 170px; }

.segmented { display: inline-flex; padding: 3px; background: var(--neutral-soft); border-radius: 9px; gap: 2px; flex-wrap: wrap; }
.segmented a { padding: 0.35rem 0.75rem; border-radius: 7px; font-size: 0.85rem; font-weight: 550; color: var(--text-2); }
.segmented a:hover { color: var(--text); text-decoration: none; }
.segmented a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.file-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 2rem 1rem; text-align: center;
  border: 2px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2);
  cursor: pointer; transition: border-color 0.12s ease, background-color 0.12s ease;
}
.file-drop:hover, .file-drop.is-dragover { border-color: var(--accent); background: var(--accent-soft); }
.file-drop input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-drop .file-name { font-weight: 600; color: var(--text); }

.progress { height: 8px; border-radius: 999px; background: var(--neutral-soft); overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.2s ease; }

/* ------------------------------------------------------------------ alerts & badges */

.alerts { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 1.25rem; }
.alert { display: flex; align-items: flex-start; gap: 0.65rem; padding: 0.8rem 1rem; border-radius: var(--radius); border: 1px solid; font-size: 0.92rem; }
.alert .icon { margin-top: 1px; }
.alert-body { flex: 1 1 auto; min-width: 0; }
.alert-title { font-weight: 600; margin-bottom: 0.15rem; }
.alert-success { background: var(--success-soft); border-color: var(--success-border); color: var(--success); }
.alert-error { background: var(--danger-soft); border-color: var(--danger-border); color: var(--danger); }
.alert-warning { background: var(--warning-soft); border-color: var(--warning-border); color: var(--warning); }
.alert-info { background: var(--info-soft); border-color: var(--info-border); color: var(--info); }
.alert .alert-body p, .alert .alert-body { color: var(--text-2); }
.alert-success .alert-body, .alert-error .alert-body, .alert-info .alert-body, .alert-warning .alert-body { color: inherit; }
.alert a { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.alert-dismiss { margin-left: auto; background: none; border: 0; color: inherit; opacity: 0.6; cursor: pointer; padding: 0; }
.alert-dismiss:hover { opacity: 1; }

.badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.15rem 0.55rem; border-radius: 999px;
  font-size: 0.76rem; font-weight: 600; line-height: 1.5; white-space: nowrap;
  border: 1px solid transparent;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.badge.no-dot::before { display: none; }
.badge-success { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-border); }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-border); }
.badge-info { background: var(--info-soft); color: var(--info); border-color: var(--info-border); }
.badge-neutral { background: var(--neutral-soft); color: var(--muted); border-color: var(--border); }
.badge-accent { background: var(--accent); color: var(--on-accent); }
.badge-accent::before { display: none; }

.pill { display: inline-flex; align-items: center; padding: 0.1rem 0.5rem; border-radius: 6px; background: var(--neutral-soft); color: var(--text-2); font-family: var(--mono); font-size: 0.78rem; }

/* ------------------------------------------------------------------ tables */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th {
  text-align: left; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); padding: 0.7rem 1rem; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 0.8rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .primary-cell { color: var(--text); font-weight: 550; }
.table .primary-cell a { color: var(--text); }
.table .primary-cell a:hover { color: var(--accent-text); }
.table .sub { display: block; color: var(--muted); font-size: 0.8rem; font-weight: 400; }
.table td.actions { text-align: right; white-space: nowrap; }
.table td.actions .row { flex-wrap: nowrap; justify-content: flex-end; }
.card > .table-wrap:first-child .table th:first-child { border-top-left-radius: var(--radius-lg); }
.card > .table-wrap:first-child .table th:last-child { border-top-right-radius: var(--radius-lg); }

.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 0.7rem 1rem; font-size: 0.92rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--text); min-width: 0; }
@media (max-width: 560px) { .kv { grid-template-columns: 1fr; gap: 0.15rem 0; } .kv dd { margin-bottom: 0.6rem; } }

/* ------------------------------------------------------------------ code / copy */

.code-box { position: relative; background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1rem 1rem 1.1rem; }
.code-box pre, .code-box .code-text { margin: 0; font-family: var(--mono); font-size: 0.86rem; line-height: 1.7; color: var(--text); white-space: pre-wrap; word-break: break-all; }
.code-box.has-copy { display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.75rem 0.75rem 0.75rem 1.1rem; }
.code-box.has-copy > pre, .code-box.has-copy > .code-text { flex: 1 1 auto; min-width: 0; padding-top: 0.2rem; }
.code-box .copy-btn { flex: none; }
.code-box-lg .code-text { font-size: 1rem; letter-spacing: 0.02em; }
.copy-btn.is-copied { color: var(--success); border-color: var(--success-border); background: var(--success-soft); }

.key-line { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.key-line code { flex: 1 1 auto; min-width: 0; }

/* ------------------------------------------------------------------ lists / activity / empty */

.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; gap: 0.75rem; padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.activity li:last-child { border-bottom: 0; }
.activity .dot { width: 8px; height: 8px; border-radius: 999px; background: var(--border-strong); margin-top: 0.45rem; flex: none; }
.activity .dot.success { background: var(--success); }
.activity .dot.danger { background: var(--danger); }
.activity .dot.warning { background: var(--warning); }
.activity .dot.accent { background: var(--accent); }
.activity .what { color: var(--text); font-weight: 550; }
.activity .meta { color: var(--muted); font-size: 0.8rem; }
.activity .detail { color: var(--muted); font-size: 0.8rem; word-break: break-all; }

.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--border); }
.list-plain li:last-child { border-bottom: 0; }

.empty { text-align: center; padding: 3rem 1.5rem; }
.empty-icon { width: 52px; height: 52px; margin: 0 auto 1rem; border-radius: 14px; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent-text); }
.empty h3 { margin-bottom: 0.35rem; font-size: 1.02rem; }
.empty p { color: var(--muted); max-width: 440px; margin: 0 auto 1.1rem; }
.empty-sm { padding: 1.75rem 1rem; }
.empty-sm p { margin-bottom: 0; }

.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: 0.9rem; }
.steps li { counter-increment: step; display: flex; gap: 0.8rem; font-size: 0.9rem; color: var(--text-2); }
.steps li::before {
  content: counter(step); flex: none; width: 24px; height: 24px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-text); font-size: 0.78rem; font-weight: 700;
}

details.disclosure { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
details.disclosure > summary { list-style: none; cursor: pointer; padding: 0.85rem 1.1rem; font-weight: 600; font-size: 0.92rem; display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::after { content: "+"; color: var(--muted); font-size: 1.15rem; font-weight: 400; }
details.disclosure[open] > summary::after { content: "\2212"; }
details.disclosure > .disclosure-body { padding: 0 1.1rem 1.1rem; }
details.inline-details > summary { cursor: pointer; color: var(--accent-text); font-size: 0.85rem; list-style: none; }
details.inline-details > summary::-webkit-details-marker { display: none; }
details.inline-details[open] > summary { margin-bottom: 0.5rem; }

.reg-grid { display: grid; grid-template-columns: 90px minmax(100px, 1fr) minmax(150px, 1.4fr) minmax(110px, 1fr) auto; gap: 1rem; align-items: center; padding: 0.8rem 1.25rem; font-size: 0.9rem; color: var(--text-2); }
.reg-grid .sub { display: block; color: var(--muted); font-size: 0.8rem; }
.reg-head { background: var(--surface-2); border-bottom: 1px solid var(--border); padding-top: 0.7rem; padding-bottom: 0.7rem; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.reg { border-bottom: 1px solid var(--border); }
.reg:last-child { border-bottom: 0; }
.reg > summary { list-style: none; cursor: pointer; }
.reg > summary::-webkit-details-marker { display: none; }
.reg > summary:hover, .reg[open] > summary { background: var(--surface-2); }
.reg-toggle { display: inline-flex; align-items: center; gap: 0.25rem; color: var(--accent-text); font-size: 0.84rem; font-weight: 550; white-space: nowrap; }
.reg-toggle .icon { transition: transform 0.15s ease; }
.reg[open] .reg-toggle .icon { transform: rotate(90deg); }
.reg-body { padding: 0.25rem 1.25rem 1.2rem; background: var(--surface-2); }
@media (max-width: 700px) {
  .reg-head { display: none; }
  .reg-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem 1rem; }
}

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.8rem 1.25rem; border-top: 1px solid var(--border); font-size: 0.86rem; color: var(--muted); flex-wrap: wrap; }
.pagination .row { gap: 0.4rem; }

/* ------------------------------------------------------------------ site cards (customer) */

.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1rem; }
.site-card { display: flex; flex-direction: column; gap: 0.9rem; padding: 1.15rem 1.2rem; color: inherit; transition: border-color 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease; }
.site-card:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow); transform: translateY(-1px); }
.site-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.site-card-title { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.site-card-title h3 { font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-glyph { width: 38px; height: 38px; border-radius: 10px; flex: none; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent-text); }
.site-card-meta { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.84rem; color: var(--muted); border-top: 1px solid var(--border); padding-top: 0.8rem; }
.site-card-meta strong { color: var(--text); font-weight: 600; }
.add-card { display: flex; align-items: center; justify-content: center; gap: 0.6rem; min-height: 150px; border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); color: var(--muted); font-weight: 600; background: transparent; }
.add-card:hover { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); text-decoration: none; }

.expiry-meter { height: 6px; border-radius: 999px; background: var(--neutral-soft); overflow: hidden; margin-top: 0.5rem; }
.expiry-meter span { display: block; height: 100%; border-radius: 999px; background: var(--success); }
.expiry-meter.warning span { background: var(--warning); }
.expiry-meter.danger span { background: var(--danger); }
.w-0 { width: 0; } .w-5 { width: 5%; } .w-10 { width: 10%; } .w-20 { width: 20%; } .w-30 { width: 30%; } .w-40 { width: 40%; }
.w-50 { width: 50%; } .w-60 { width: 60%; } .w-70 { width: 70%; } .w-80 { width: 80%; } .w-90 { width: 90%; } .w-100 { width: 100%; }

.status-hero { display: flex; align-items: center; gap: 1rem; }
.status-hero .big { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }

/* ------------------------------------------------------------------ auth + landing */

.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-aside {
  position: relative; overflow: hidden;
  background: radial-gradient(1200px 500px at -10% -10%, #3b82f6 0%, transparent 55%), linear-gradient(160deg, #1e3a8a 0%, #1d4ed8 55%, #2563eb 100%);
  color: #eaf1ff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-aside::after {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 36px 36px; mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.5), transparent 80%);
  pointer-events: none;
}
.auth-aside > * { position: relative; z-index: 1; }
.auth-aside .brand { color: #fff; }
.auth-aside h2 { color: #fff; font-size: 2rem; font-weight: 700; letter-spacing: -0.025em; line-height: 1.15; max-width: 460px; }
.auth-aside p { color: #c7d7fe; max-width: 440px; font-size: 1rem; }
.auth-points { list-style: none; padding: 0; margin: 1.75rem 0 0; display: grid; gap: 0.9rem; }
.auth-points li { display: flex; gap: 0.75rem; align-items: flex-start; color: #e0e9ff; font-size: 0.95rem; }
.auth-points .icon { color: #93c5fd; margin-top: 2px; }
.auth-foot { color: #a5bdf7; font-size: 0.82rem; }

.auth-main { display: flex; align-items: center; justify-content: center; padding: 2.5rem 1.5rem; background: var(--surface); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 1.55rem; }
.auth-card .lead { color: var(--muted); margin: 0.4rem 0 1.6rem; }
.auth-alt { margin-top: 1.5rem; text-align: center; color: var(--muted); font-size: 0.9rem; }
.auth-mobile-brand { display: none; margin-bottom: 1.75rem; }
.auth-theme { position: absolute; top: 1rem; right: 1rem; }
.auth-main { position: relative; }

.stepper { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; }
.stepper span { flex: 1; height: 4px; border-radius: 999px; background: var(--neutral-soft); }
.stepper span.done { background: var(--accent); }
.step-label { font-size: 0.78rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--accent-text); margin-bottom: 0.4rem; }

@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth-mobile-brand { display: flex; }
}

.landing-hero { padding: 5rem 1.25rem 3.5rem; text-align: center; max-width: 860px; margin: 0 auto; }
.eyebrow { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.3rem 0.8rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-size: 0.82rem; font-weight: 600; margin-bottom: 1.25rem; }
.landing-hero h1 { font-size: clamp(2rem, 5vw, 3.1rem); font-weight: 750; letter-spacing: -0.035em; line-height: 1.08; }
.landing-hero p { font-size: 1.12rem; color: var(--muted); max-width: 620px; margin: 1.1rem auto 2rem; }
.landing-hero .row { justify-content: center; }
.feature-grid { max-width: 1080px; margin: 0 auto; padding: 0 1.25rem 5rem; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; }
.feature { padding: 1.5rem; }
.feature .stat-icon { margin-bottom: 1rem; }
.feature h3 { font-size: 1.02rem; margin-bottom: 0.4rem; }
.feature p { color: var(--muted); font-size: 0.92rem; }
@media (max-width: 860px) { .feature-grid { grid-template-columns: 1fr; } .landing-hero { padding-top: 3rem; } }

.site-footer { margin-top: auto; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.82rem; }
.site-footer .inner { max-width: 1240px; margin: 0 auto; padding: 1.5rem 1.25rem; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

.error-page { min-height: 70vh; display: flex; align-items: center; justify-content: center; text-align: center; padding: 2rem 1rem; }
.error-code { font-size: 4.5rem; font-weight: 800; letter-spacing: -0.04em; color: var(--accent); line-height: 1; margin-bottom: 0.75rem; }
.error-page p { color: var(--muted); max-width: 440px; margin: 0.6rem auto 1.5rem; }

@media print {
  .topbar, .sidebar, .btn, .copy-btn { display: none !important; }
  body { background: #fff; }
}
