/* SPDX-License-Identifier: AGPL-3.0-only */
:root {
  color-scheme: light dark;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Monaco, Consolas, "Liberation Mono", monospace;

  --bg-canvas: #f3f5f9;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-muted: #f1f5f9;
  --bg-hover: rgba(15, 23, 42, 0.04);
  --bg-topbar: rgba(243, 245, 249, 0.82);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --border-subtle: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.14);

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: rgba(79, 70, 229, 0.1);
  --accent-ring: rgba(79, 70, 229, 0.24);

  --success: #059669;
  --success-soft: rgba(5, 150, 105, 0.11);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.12);
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: rgba(220, 38, 38, 0.1);

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px -6px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 24px 48px -12px rgba(15, 23, 42, 0.18), 0 4px 16px rgba(15, 23, 42, 0.08);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --sidebar-width: 256px;
  --transition: 160ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-canvas: #0b0f17;
    --bg-surface: #111827;
    --bg-surface-elevated: #161f30;
    --bg-subtle: #0f1624;
    --bg-muted: #1e293b;
    --bg-hover: rgba(255, 255, 255, 0.05);
    --bg-topbar: rgba(11, 15, 23, 0.8);

    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;

    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);

    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-soft: rgba(99, 102, 241, 0.16);
    --accent-ring: rgba(99, 102, 241, 0.35);

    --success: #34d399;
    --success-soft: rgba(52, 211, 153, 0.14);
    --warning: #fbbf24;
    --warning-soft: rgba(251, 191, 36, 0.15);
    --danger: #f87171;
    --danger-hover: #ef4444;
    --danger-soft: rgba(248, 113, 113, 0.15);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 28px -6px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 24px 56px -12px rgba(0, 0, 0, 0.65);
  }
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background:
    radial-gradient(960px 420px at 70% -120px, var(--accent-soft), transparent 70%),
    var(--bg-canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }
[hidden] { display: none !important; }

.mono {
  font-family: var(--font-mono);
  font-size: 0.875em;
}
.muted { color: var(--text-muted); }

/* App Shell */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100dvh;
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 20px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 16px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  object-fit: cover;
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--border-subtle), var(--shadow-xs);
  flex-shrink: 0;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.brand-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 500;
  text-align: left;
  transition: background var(--transition), color var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(79, 70, 229, 0.14);
  font-weight: 600;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
}

.gateway-card {
  padding: 13px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gateway-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.gateway-address {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-subtle);
}

.address-label {
  font-size: 11px;
  color: var(--text-muted);
}

.gateway-address code {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Workspace & Topbar */
.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  height: 58px;
  background: var(--bg-topbar);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-subtle);
}

.topbar-inner {
  max-width: 1220px;
  margin: 0 auto;
  height: 100%;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.breadcrumb-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.breadcrumb-root { color: var(--text-muted); }
.breadcrumb-sep { color: var(--border-strong); }
.breadcrumb-current {
  font-weight: 600;
  color: var(--text-primary);
}

.local-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-xs);
}

.main-container {
  width: 100%;
  max-width: 1220px;
  margin: 0 auto;
  padding: 28px 28px 56px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Page Heading */
.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.heading-copy h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.heading-copy p {
  margin: 5px 0 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.heading-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition), transform 100ms ease, color var(--transition);
}

.button:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.button:active:not(:disabled) {
  transform: translateY(1px);
}

.button:focus-visible,
.tab:focus-visible,
.nav-item:focus-visible,
.name-button:focus-visible,
.switch:focus-visible,
.text-input:focus-visible,
select:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.button.primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-hover));
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.button.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--accent-hover), var(--accent-hover));
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.36);
}

.button.danger {
  background: var(--danger-soft);
  border-color: rgba(220, 38, 38, 0.24);
  color: var(--danger);
  box-shadow: none;
}

.button.danger:hover:not(:disabled) {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

.button.quiet {
  height: 32px;
  padding: 0 10px;
  border-color: transparent;
  background: transparent;
  color: var(--text-secondary);
  box-shadow: none;
}

.button.quiet:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
  box-shadow: none;
}

.button.icon-button {
  width: 32px;
  height: 32px;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: var(--text-secondary);
  box-shadow: none;
}

.button.icon-button:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
  box-shadow: none;
}

.button.icon-button.is-active-star {
  color: var(--warning);
  opacity: 1;
}

.button.icon-button.is-active-star svg {
  fill: currentColor;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.button.spinner svg,
.button.is-busy svg {
  animation: spin 0.9s linear infinite;
}

/* Banners */
.info-banner {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  border: 1px solid rgba(79, 70, 229, 0.2);
  color: var(--text-primary);
  font-size: 13.5px;
}

.info-banner svg {
  color: var(--accent);
  flex-shrink: 0;
}

.info-banner .button {
  margin-left: auto;
}

.verification-banner > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.info-banner.warning {
  background: var(--warning-soft);
  border-color: rgba(217, 119, 6, 0.24);
}
.info-banner.warning svg { color: var(--warning); }

.info-banner.error {
  background: var(--danger-soft);
  border-color: rgba(220, 38, 38, 0.24);
}
.info-banner.error svg { color: var(--danger); }

/* Metrics Bento Grid */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric {
  position: relative;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.metric:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.metric-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.metric-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-muted);
  color: var(--text-secondary);
}

.metric-icon.indigo { background: var(--accent-soft); color: var(--accent); }
.metric-icon.emerald { background: var(--success-soft); color: var(--success); }
.metric-icon.amber { background: var(--warning-soft); color: var(--warning); }
.metric-icon.slate { background: var(--bg-muted); color: var(--text-muted); }
.metric-icon.danger { background: var(--danger-soft); color: var(--danger); }
.metric-danger .metric-value { color: var(--danger); }

.metric-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-value.accent { color: var(--success); }
.metric-value.account-metric {
  font-size: 20px;
  line-height: 1.4;
  padding-top: 2px;
}

.metric-note {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Panels & Toolbars */
.pool-panel,
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.pool-toolbar,
.model-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.pool-toolbar {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
}

.tabs {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: var(--bg-muted);
  border: 1px solid var(--border-subtle);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 12px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}

.tab:hover { color: var(--text-primary); }

.tab.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

.tab-count {
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--bg-muted);
  color: var(--text-muted);
}

.tab.active .tab-count {
  background: var(--accent-soft);
  color: var(--accent);
}

.search-field {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: 240px;
  flex: 0 1 300px;
}

.search-field svg {
  position: absolute;
  left: 11px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-field input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 34px;
  border-radius: 9px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  font-size: 13.5px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-field input::placeholder { color: var(--text-muted); }

.search-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

/* Tables */
.table-scroll {
  width: 100%;
  overflow-x: auto;
}

.accounts-table,
.model-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.accounts-table th,
.model-table th {
  padding: 11px 18px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.accounts-table td,
.model-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

.accounts-table tbody tr,
.model-table tbody tr {
  transition: background var(--transition);
}

.accounts-table tbody tr:hover,
.model-table tbody tr:hover {
  background: var(--bg-hover);
}

.accounts-table tbody tr.is-default {
  background: rgba(79, 70, 229, 0.025);
}

.accounts-table tbody tr.is-default:hover {
  background: rgba(79, 70, 229, 0.05);
}

.accounts-table tbody tr:last-child td,
.model-table tbody tr:last-child td {
  border-bottom: none;
}

.accounts-table th:last-child,
.accounts-table td:last-child,
.model-table th:last-child,
.model-table td:last-child {
  text-align: right;
  width: 1%;
  white-space: nowrap;
}

/* Account Identity & Deterministic Avatars */
.account-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 200px;
}

.account-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: #ffffff;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), var(--shadow-xs);
  flex-shrink: 0;
}

.account-avatar.tone-0 { background: linear-gradient(135deg, #6366f1, #4338ca); }
.account-avatar.tone-1 { background: linear-gradient(135deg, #0ea5e9, #0284c7); }
.account-avatar.tone-2 { background: linear-gradient(135deg, #10b981, #059669); }
.account-avatar.tone-3 { background: linear-gradient(135deg, #f59e0b, #d97706); }
.account-avatar.tone-4 { background: linear-gradient(135deg, #ec4899, #db2777); }
.account-avatar.tone-5 { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }

.identity-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.account-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.name-button {
  padding: 0;
  border: none;
  background: transparent;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  text-align: left;
  border-radius: 4px;
  transition: color var(--transition);
}

.name-button:hover {
  color: var(--accent);
}

.default-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--warning);
  background: var(--warning-soft);
  border: 1px solid rgba(217, 119, 6, 0.2);
}

.default-tag svg {
  fill: currentColor;
}

.uid-chip {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 240px;
}

/* Status Pills & Dots */
.status-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-muted);
  color: var(--text-secondary);
}

.status-pill.success { background: var(--success-soft); color: var(--success); }
.status-pill.warning { background: var(--warning-soft); color: var(--warning); }
.status-pill.danger { background: var(--danger-soft); color: var(--danger); }
.status-pill.neutral { background: var(--bg-muted); color: var(--text-muted); }
.status-pill.accent { background: var(--accent-soft); color: var(--accent); }

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
  flex-shrink: 0;
}

.status-dot.success {
  color: var(--success);
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
}

.status-dot.neutral {
  color: var(--text-muted);
  background: var(--text-muted);
}

.session-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.session-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
}

.session-state.success { color: var(--success); }
.session-state.warning { color: var(--warning); }
.session-state.danger { color: var(--danger); }
.session-state.neutral { color: var(--text-muted); }

/* Quota & Native Progress Styling (CSP-Safe) */
.quota-compact { min-width: 170px; max-width: 240px; }
.quota-list { display: flex; flex-direction: column; gap: 12px; }
.quota-item { display: flex; flex-direction: column; gap: 5px; }

.quota-caption {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.quota-caption strong {
  color: var(--text-primary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.quota-unavailable {
  font-size: 12.5px;
  color: var(--text-muted);
}

progress.quota-progress {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border: none;
  border-radius: 999px;
  background: var(--bg-muted);
  overflow: hidden;
}

progress.quota-progress::-webkit-progress-bar {
  background: var(--bg-muted);
  border-radius: 999px;
}

progress.quota-progress::-webkit-progress-value {
  background: linear-gradient(90deg, var(--accent), #3b82f6);
  border-radius: 999px;
  transition: width 240ms ease;
}

progress.quota-progress.warning::-webkit-progress-value {
  background: linear-gradient(90deg, var(--warning), var(--danger));
}

progress.quota-progress::-moz-progress-bar {
  background: linear-gradient(90deg, var(--accent), #3b82f6);
  border-radius: 999px;
}

progress.quota-progress.warning::-moz-progress-bar {
  background: linear-gradient(90deg, var(--warning), var(--danger));
}

/* Date & Row Actions */
.date-cell {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.date-primary {
  font-size: 13px;
  color: var(--text-primary);
}

.date-cell .date-primary,
.date-cell small { display: block; }
.date-cell small { font-size: 12px; margin-top: 2px; }

.row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.pool-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  font-size: 12.5px;
  color: var(--text-muted);
}

.sync-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.sync-state .status-dot {
  color: var(--success);
  background: var(--success);
}

.mobile-hint {
  display: none;
  margin: 0;
  padding: 8px 18px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
}

/* Empty & Loading States */
.empty-state {
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.empty-icon {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 6px;
}

.empty-state h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.empty-state p {
  margin: 0 0 10px;
  max-width: 380px;
  color: var(--text-secondary);
  font-size: 13.5px;
}

.initial-loading {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
}

.boot-error { margin-top: 12px; }

/* Dialogs & Slide-Over Drawer */
dialog {
  padding: 0;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes drawerIn {
  from { opacity: 0; transform: translateX(28px); }
  to { opacity: 1; transform: translateX(0); }
}

dialog.modal {
  width: min(460px, calc(100vw - 28px));
  border-radius: var(--radius-lg);
  margin: auto;
  animation: modalIn 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

dialog.drawer {
  margin: 0 0 0 auto;
  width: min(440px, 100vw);
  height: 100dvh;
  max-height: 100dvh;
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  border-right: none;
  display: flex;
  flex-direction: column;
  animation: drawerIn 210ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-description,
.delete-description {
  margin: 0;
  color: var(--text-secondary);
  font-size: 13.5px;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

/* Drawer Content */
.drawer-content {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.drawer-identity {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
}

.drawer-identity .account-avatar {
  width: 44px;
  height: 44px;
  font-size: 17px;
  border-radius: 12px;
}

.drawer-identity > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.drawer-identity strong {
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.drawer-form .field-label {
  grid-column: 1 / -1;
}

.toggle-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
}

.toggle-line > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toggle-line strong { font-size: 13.5px; }
.toggle-line small { font-size: 12px; color: var(--text-muted); }

.switch {
  position: relative;
  width: 44px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background var(--transition);
  flex-shrink: 0;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: var(--shadow-xs);
  transition: transform var(--transition);
}

.switch[aria-checked="true"] {
  background: var(--accent);
}

.switch[aria-checked="true"]::after {
  transform: translateX(20px);
}

.switch:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
}

.drawer-section h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.drawer-status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.drawer-message {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  font-size: 13px;
  color: var(--text-secondary);
}

.drawer-actions {
  gap: 8px;
}

.drawer-actions .button {
  width: 100%;
  justify-content: center;
}

/* Forms & Inputs */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.field-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.field-inline {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.text-input,
select {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 13.5px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.field-inline select {
  width: auto;
  min-width: 200px;
}

.text-input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.text-input[readonly] {
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.input-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-actions .text-input {
  flex: 1;
  min-width: 0;
}

/* Login Flow States */
.login-status {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  border: 1px solid rgba(79, 70, 229, 0.2);
}

.login-status svg {
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 2px;
}

.login-status strong {
  display: block;
  font-size: 14px;
  margin-bottom: 3px;
}

.login-status p {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.login-status.login-awaiting_confirmation {
  background: var(--warning-soft);
  border-color: rgba(217, 119, 6, 0.26);
}
.login-status.login-awaiting_confirmation svg { color: var(--warning); }

.login-status.login-success {
  background: var(--success-soft);
  border-color: rgba(5, 150, 105, 0.24);
}
.login-status.login-success svg { color: var(--success); }

.login-status.error {
  background: var(--danger-soft);
  border-color: rgba(220, 38, 38, 0.24);
}
.login-status.error svg { color: var(--danger); }

.login-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
}

.login-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.step-number {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}

.login-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.login-link:hover { text-decoration: underline; }

/* Settings View */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
}

.panel-heading h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.panel-heading p {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.panel-heading svg {
  color: var(--accent);
  flex-shrink: 0;
}

.settings-body {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.settings-list {
  margin: 0;
  display: flex;
  flex-direction: column;
}

.settings-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.settings-list > div:first-child { padding-top: 0; }
.settings-list > div:last-child { padding-bottom: 0; border-bottom: none; }

.settings-list dt {
  font-size: 13px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.settings-list dd {
  margin: 0;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
  text-align: right;
  word-break: break-all;
}

.settings-footnote {
  margin: 0;
  padding-top: 12px;
  border-top: 1px dashed var(--border-subtle);
  font-size: 12.5px;
  color: var(--text-muted);
}

/* Toasts */
.toast-region {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 60;
  pointer-events: none;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.toast {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 11px 16px;
  border-radius: 12px;
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  font-weight: 500;
  animation: toastIn 180ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.toast svg {
  color: #34d399;
  flex-shrink: 0;
}

.toast.error {
  background: #450a0a;
  border-color: rgba(248, 113, 113, 0.35);
}

.toast.error svg { color: #fca5a5; }

/* Responsive */
@media (max-width: 1040px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 12px 16px;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    gap: 12px;
  }

  .brand {
    padding: 0;
    margin: 0;
    border-bottom: none;
  }

  .nav {
    flex-direction: row;
    overflow-x: auto;
  }

  .nav-item {
    width: auto;
    padding: 8px 12px;
    white-space: nowrap;
  }

  .sidebar-footer {
    display: none;
  }

  .topbar-inner,
  .main-container {
    padding-left: 16px;
    padding-right: 16px;
  }

  .mobile-hint { display: block; }

  .verification-banner {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr);
    align-items: start;
  }

  .verification-banner .button {
    grid-column: 2;
    justify-self: start;
    margin-left: 0;
  }
}

.session-input {
  display: block;
  width: 100%;
  min-height: 128px;
  resize: vertical;
  font: 14px/1.6 var(--font-mono);
  overflow-wrap: anywhere;
}
