/* Enterprise Admin Console Visual System
   Deep Slate sidebar (#0F172A) · Crisp Slate-Snow workspace (#F8FAFC) · Electric Indigo (#4F46E5) accent
   Zero external fonts or assets (strict CSP compatible). */

:root {
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, Menlo, monospace;

  --bg: #f4f6fa;
  --bg-subtle: #f8fafc;
  --card: #ffffff;
  --card-hover: #fbfcfe;

  --side-bg: #0f172a;
  --side-bg-2: #162036;
  --side-border: rgba(148, 163, 184, 0.14);
  --side-ink: #f1f5f9;
  --side-muted: #94a3b8;
  --side-faint: #64748b;
  --side-active-bg: rgba(99, 102, 241, 0.18);
  --side-active-ink: #ffffff;

  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;

  --line: #e2e8f0;
  --line-soft: #eef2f6;
  --line-strong: #cbd5e1;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-border: #c7d2fe;

  --ok: #059669;
  --ok-soft: #ecfdf5;
  --ok-border: #a7f3d0;

  --info: #2563eb;
  --info-soft: #eff6ff;
  --info-border: #bfdbfe;

  --warn: #d97706;
  --warn-soft: #fffbeb;
  --warn-border: #fde68a;

  --danger: #e11d48;
  --danger-hover: #be123c;
  --danger-soft: #fff1f2;
  --danger-border: #fecdd3;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05), 0 4px 12px -4px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 12px 32px -8px rgba(15, 23, 42, 0.14), 0 4px 12px -4px rgba(15, 23, 42, 0.06);
  --shadow-dialog: 0 24px 64px -12px rgba(15, 23, 42, 0.34), 0 8px 24px -8px rgba(15, 23, 42, 0.16);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  font: 14px/1.55 var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

/* Subtle ambient background on login screen */
body:not(.signed-in) {
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(79, 70, 229, 0.12), transparent 65%),
    radial-gradient(circle at 85% 90%, rgba(14, 165, 233, 0.07), transparent 50%),
    var(--bg);
}

svg {
  display: block;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

h1, h2, h3, p { margin: 0; }
h1 {
  font-size: clamp(22px, 2.4vw, 26px);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.025em;
  color: var(--ink);
}
h2 {
  font-size: 16px;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -0.015em;
  color: var(--ink);
  overflow-wrap: anywhere;
}
h3 {
  font-size: 14.5px;
  font-weight: 650;
  color: var(--ink);
}

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

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

/* ---------- Buttons ---------- */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: background 0.14s var(--ease), border-color 0.14s var(--ease), color 0.14s var(--ease), box-shadow 0.14s var(--ease), transform 0.1s;
}
button:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: var(--line-strong);
  color: var(--ink);
}
button:active:not(:disabled) { transform: translateY(0.5px); }
button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  box-shadow: none;
}

button.primary {
  background: linear-gradient(180deg, #5850ec 0%, var(--accent) 100%);
  border-color: var(--accent);
  color: #ffffff;
  box-shadow: 0 1px 2px 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) 0%, var(--accent-hover) 100%);
  border-color: var(--accent-hover);
  color: #ffffff;
  box-shadow: 0 4px 12px -2px rgba(79, 70, 229, 0.36);
}

button.secondary {
  background: var(--card);
  border-color: var(--line-strong);
  color: var(--ink);
}
button.secondary:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

button.quiet {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-2);
  box-shadow: none;
}
button.quiet:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: var(--line-strong);
  color: var(--ink);
}

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

button.btn-sm {
  height: 31px;
  padding: 0 10px;
  font-size: 12.5px;
}
button.btn-sm svg { width: 14px; height: 14px; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Inputs ---------- */
input, select, textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--ink);
  font-size: 13.5px;
  transition: border-color 0.14s var(--ease), box-shadow 0.14s var(--ease);
}
input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover:not(:disabled) {
  border-color: #94a3b8;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { resize: vertical; line-height: 1.55; }

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
label small {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}

/* ---------- Shell & Dark Enterprise Sidebar ---------- */
.shell { min-height: 100vh; }
.signed-in .shell {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  align-items: start;
}
.content-column {
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.frame {
  width: min(1280px, calc(100% - 48px));
  margin-inline: auto;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  background: linear-gradient(180deg, #0f172a 0%, #0b1120 100%);
  border-right: 1px solid rgba(15, 23, 42, 0.9);
  color: var(--side-ink);
  display: flex;
  flex-direction: column;
  padding: 16px 12px 14px;
  min-width: 0;
  z-index: 20;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 700;
}
.mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  flex-shrink: 0;
}
.mark svg { width: 18px; height: 18px; stroke-width: 2; }
.brand-copy {
  display: grid;
  gap: 1px;
  min-width: 0;
}
.brand-copy strong {
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.2;
}
.brand-copy small {
  display: block;
  font-size: 11px;
  font-weight: 450;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.sidebar .wordmark {
  padding: 4px 6px 18px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--side-border);
}
.sidebar .brand-copy strong { color: #f8fafc; }
.sidebar .brand-copy small { color: var(--side-faint); }

.nav-group {
  color: var(--side-faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 10px 8px;
}

.sidebar nav {
  display: grid;
  gap: 3px;
}
.sidebar nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 9px;
  color: var(--side-muted);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.sidebar nav a:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #f8fafc;
  text-decoration: none;
}
.sidebar nav a[aria-current="page"] {
  background: var(--side-active-bg);
  color: var(--side-active-ink);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(129, 140, 248, 0.25);
}
.sidebar nav a[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: #818cf8;
}
.sidebar nav a[aria-current="page"] svg { color: #a5b4fc; }
.sidebar svg { width: 17px; height: 17px; }

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--side-border);
}
.sidebar-external {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 9px;
  color: var(--side-muted);
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.14s, color 0.14s;
}
.sidebar-external:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #f8fafc;
  text-decoration: none;
}
.external-lead {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.external-lead svg { width: 15px; height: 15px; opacity: 0.8; }
.external-arrow { opacity: 0.65; font-size: 12px; }

/* ---------- Sticky Frosted Top Header ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 15;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
body:not(.signed-in) .top {
  background: rgba(255, 255, 255, 0.72);
}
.top-inner {
  min-height: 58px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}
.crumb-sep { color: var(--faint); }
.breadcrumb strong {
  color: var(--ink);
  font-weight: 600;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.logout-btn {
  height: 33px;
  padding: 0 11px;
  font-size: 12.5px;
  color: var(--muted);
  border-color: var(--line);
}
.logout-btn svg { width: 14px; height: 14px; }
.logout-btn:hover:not(:disabled) {
  color: var(--danger);
  border-color: var(--danger-border);
  background: var(--danger-soft);
}

/* ---------- Main Canvas & Page Header ---------- */
main {
  flex: 1;
  padding-block: 28px 32px;
}
.page-lead {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 22px;
}
.page-lead-copy p {
  margin-top: 4px;
  font-size: 13.5px;
}

.eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.muted {
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* ---------- Surface Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

/* ---------- Login Portal ---------- */
.login {
  max-width: 430px;
  margin: 7vh auto 4vh;
  padding: 36px 34px 28px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}
.login-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  display: grid;
  place-items: center;
  margin-bottom: 18px;
}
.login-badge svg { width: 21px; height: 21px; }
.login h1 { font-size: 22px; }
.login > p.muted {
  margin: 7px 0 22px;
  font-size: 13.5px;
  line-height: 1.55;
}
.login .submit-btn {
  height: 42px;
  font-size: 14px;
  font-weight: 600;
  margin-top: 2px;
}
.login-footnote {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  text-align: center;
  font-size: 12px;
  color: var(--faint);
}

form { display: grid; gap: 15px; }

/* ---------- Overview KPI Metrics ---------- */
.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.metric {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.16s, box-shadow 0.16s;
}
.metric:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}
.metric-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.metric-top > span:first-child {
  font-size: 13px;
  font-weight: 550;
  color: var(--muted);
}
.metric-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.metric-users .metric-icon { background: var(--accent-soft); color: var(--accent); }
.metric-keys .metric-icon { background: var(--ok-soft); color: var(--ok); }
.metric-attention .metric-icon { background: var(--danger-soft); color: var(--danger); }

.metric strong {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.03em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.metric small {
  font-size: 12px;
  color: var(--faint);
}

/* ---------- Overview Split Panels & Quick Actions ---------- */
.overview-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 18px;
  align-items: start;
}

.quick {
  display: grid;
  gap: 10px;
}
.quick-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg-subtle);
  text-decoration: none;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.quick-item:hover {
  background: var(--card);
  border-color: var(--accent-border);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
}
.quick-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.quick-icon svg { width: 19px; height: 19px; }
.quick-indigo { background: var(--accent-soft); color: var(--accent); }
.quick-emerald { background: var(--ok-soft); color: var(--ok); }
.quick-copy {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}
.quick-copy strong {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.quick-copy span {
  font-size: 12.5px;
  color: var(--muted);
}
.quick-arrow {
  color: var(--faint);
  font-size: 15px;
  transition: transform 0.16s var(--ease), color 0.16s;
}
.quick-item:hover .quick-arrow {
  transform: translateX(3px);
  color: var(--accent);
}

/* ---------- Users / Usage Master-Detail Workspace ---------- */
.workspace {
  display: grid;
  grid-template-columns: minmax(276px, 340px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.directory, .detail { padding: 20px; }

.directory-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.directory-head p {
  margin-top: 2px;
  font-size: 12.5px;
}

.search-box {
  position: relative;
  margin-bottom: 12px;
}
.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--faint);
  pointer-events: none;
}
.search-box input {
  padding-left: 34px;
  background: var(--bg-subtle);
  border-color: var(--line);
}
.search-box input:focus {
  background: var(--card);
  border-color: var(--accent);
}

.accounts {
  display: grid;
  gap: 6px;
}

.account {
  width: 100%;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--card);
  text-align: left;
  font-weight: 400;
  box-shadow: none;
  transition: background 0.14s, border-color 0.14s, box-shadow 0.14s;
}
.account:hover {
  background: var(--bg-subtle);
  border-color: var(--line);
}
.account[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  box-shadow: inset 3px 0 0 var(--accent);
}
.account-info {
  display: grid;
  min-width: 0;
  gap: 2px;
}
.account-info > * {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-info strong {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}
.account-info .muted {
  font-size: 12px;
  color: var(--muted);
}

.attention-link {
  text-decoration: none;
  color: var(--ink);
  border-color: var(--line);
}
.attention-link:hover {
  background: var(--danger-soft);
  border-color: var(--danger-border);
  text-decoration: none;
}
.attention-link strong {
  font-size: 13.5px;
  font-weight: 600;
}

/* ---------- Semantic Status Pills ---------- */
.pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-subtle);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}
.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--faint);
}
.pill.ok {
  background: var(--ok-soft);
  border-color: var(--ok-border);
  color: #047857;
}
.pill.ok::before { background: var(--ok); }
.pill.pending {
  background: var(--info-soft);
  border-color: var(--info-border);
  color: #1d4ed8;
}
.pill.pending::before { background: var(--info); }
.pill.warn {
  background: var(--danger-soft);
  border-color: var(--danger-border);
  color: var(--danger-hover);
}
.pill.warn::before { background: var(--danger); }

.empty {
  padding: 20px 14px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: var(--bg-subtle);
  font-size: 13px;
}

/* ---------- Detail Pane ---------- */
.detail { min-height: 300px; }

.detail-empty {
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  padding: 24px;
}
.empty-illustration {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  color: var(--faint);
  display: grid;
  place-items: center;
  margin-bottom: 4px;
}
.empty-illustration svg { width: 22px; height: 22px; }

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line-soft);
}
.detail-identity {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 0;
}
.user-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-size: 17px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.detail-identity-copy { min-width: 0; }
.detail-identity-copy h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.detail-identity-copy .muted {
  margin-top: 4px;
  font-size: 13px;
  white-space: pre-wrap;
}

.actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

/* ---------- Credential Box (API Key Card) ---------- */
.credential {
  margin-top: 18px;
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.credential-info {
  display: grid;
  gap: 4px;
}
.credential-info span {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.credential-info strong {
  font-family: var(--font-mono);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

.related {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--ink-2);
}
.related a {
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

/* ---------- Usage, Progress & Bar Chart ---------- */
.usage-key {
  margin-top: 14px;
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 550;
  color: var(--ink-2);
}

.usage { margin-top: 18px; }
.usage-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.usage-head > span { font-size: 12px; }

.quota-warning {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger-hover);
  font-size: 13px;
  font-weight: 550;
  margin-bottom: 12px;
}

.quota-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}
.quota-line strong {
  font-size: 14px;
  font-weight: 650;
  color: var(--ink);
}
.quota-line span {
  font-size: 13px;
  font-weight: 600;
  color: var(--ok);
}

progress {
  width: 100%;
  height: 10px;
  margin: 10px 0 4px;
  appearance: none;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  background: #e2e8f0;
}
progress::-webkit-progress-bar {
  background: #e2e8f0;
  border-radius: 999px;
}
progress::-webkit-progress-value {
  background: linear-gradient(90deg, #4f46e5, #6366f1);
  border-radius: 999px;
  transition: width 0.3s var(--ease);
}
progress::-moz-progress-bar {
  background: linear-gradient(90deg, #4f46e5, #6366f1);
  border-radius: 999px;
}
progress.near::-webkit-progress-value {
  background: linear-gradient(90deg, #f59e0b, #e11d48);
}
progress.near::-moz-progress-bar {
  background: linear-gradient(90deg, #f59e0b, #e11d48);
}

.usage-stats {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.usage-stat {
  display: grid;
  align-content: start;
  gap: 5px;
  padding: 12px 14px;
  background: var(--bg-subtle);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  overflow-wrap: anywhere;
}
.usage-stat span {
  font-size: 11.5px;
  font-weight: 550;
  color: var(--muted);
}
.usage-stat strong {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.chart {
  margin-top: 16px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}
.chart p {
  margin-top: 3px;
  font-size: 12px;
}
.plot {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  margin-top: 16px;
}
.axis {
  color: var(--faint);
  font-size: 11px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding-bottom: 2px;
}
.bars {
  display: flex;
  gap: clamp(3px, 0.55vw, 8px);
  align-items: flex-end;
  height: 132px;
  padding: 0 4px;
  border-bottom: 1px solid var(--line-strong);
  background: repeating-linear-gradient(
    to top,
    transparent,
    transparent calc(25% - 1px),
    var(--line-soft) 25%
  );
}
.bar {
  flex: 1;
  max-width: 28px;
  height: var(--height);
  background: linear-gradient(180deg, #6366f1 0%, #4f46e5 100%);
  border-radius: 5px 5px 0 0;
  min-width: 0;
  cursor: pointer;
  transition: opacity 0.14s, transform 0.14s, background 0.14s;
}
.bar:hover, .bar:focus-visible {
  background: linear-gradient(180deg, #4f46e5 0%, #3730a3 100%);
  transform: scaleY(1.03);
  transform-origin: bottom;
}
.days {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-top: 8px;
  padding-left: 52px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--faint);
}

/* ---------- Collapsible Key History ---------- */
details {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg-subtle);
  padding: 12px 14px;
}
summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
summary::-webkit-details-marker { display: none; }
summary::after {
  content: "▾";
  color: var(--muted);
  font-size: 12px;
  transition: transform 0.18s var(--ease);
}
details[open] summary::after { transform: rotate(180deg); }
summary:hover { color: var(--accent); }

#history { margin-top: 10px; }
.history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  font-size: 12.5px;
  border-top: 1px solid var(--line);
}
.history-row strong {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}
.history-row span {
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- Feedback Alert Banners ---------- */
.feedback {
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.feedback:not(:empty) {
  margin-block: 10px;
  padding: 10px 13px;
  border-radius: 9px;
  background: var(--ok-soft);
  border: 1px solid var(--ok-border);
  color: #065f46;
  font-weight: 500;
}
.feedback.error:not(:empty) {
  background: var(--danger-soft);
  border-color: var(--danger-border);
  color: var(--danger-hover);
}
.startup-status:not(:empty) {
  max-width: 360px;
  margin: 18vh auto;
  text-align: center;
  background: var(--card);
  border-color: var(--line);
  color: var(--muted);
  box-shadow: var(--shadow-sm);
}

footer {
  padding-block: 22px 4px;
  color: var(--faint);
  font-size: 12px;
  text-align: right;
}

/* ---------- Polished Dialog Modals ---------- */
dialog {
  width: min(500px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow-dialog);
  overflow: hidden;
}
dialog[open] { animation: modal-in 0.18s var(--ease); }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(6px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
dialog::backdrop {
  background: rgba(15, 23, 42, 0.56);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
dialog form, dialog .secret-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.dialog-head {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.dialog-head h2 {
  font-size: 17px;
  font-weight: 700;
}
.dialog-head p {
  margin-top: 5px;
  font-size: 13px;
}
.dialog-body {
  padding: 20px 24px;
  display: grid;
  gap: 15px;
  overflow-y: auto;
}
.dialog-actions {
  padding: 14px 24px;
  border-top: 1px solid var(--line-soft);
  background: var(--bg-subtle);
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.key-field { display: grid; gap: 6px; }
.key-input-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.key-input-row input {
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 13px;
}
.key-input-row button { flex: none; height: 38px; }

#secret-output {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--ink);
  font-weight: 600;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- Responsive Breakpoints ---------- */
@media (max-width: 1024px) {
  .signed-in .shell { grid-template-columns: 212px minmax(0, 1fr); }
  .workspace { grid-template-columns: minmax(240px, 290px) minmax(0, 1fr); }
  .usage-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 840px) {
  .workspace, .overview-grid { grid-template-columns: 1fr; }
  .accounts { max-height: 300px; overflow: auto; }
  .frame { width: calc(100% - 32px); }
}

@media (max-width: 640px) {
  .signed-in .shell { grid-template-columns: 72px minmax(0, 1fr); }
  .sidebar { padding: 12px 8px; }
  .sidebar .wordmark { justify-content: center; padding: 2px 0 14px; }
  .sidebar .brand-copy, .sidebar .nav-group, .external-arrow { display: none; }
  .sidebar nav a {
    flex-direction: column;
    gap: 4px;
    padding: 9px 4px;
    font-size: 11px;
  }
  .sidebar nav a[aria-current="page"]::before { left: -8px; }
  .sidebar-external { justify-content: center; padding: 9px 4px; }
  .external-lead span { display: none; }
  .top-inner { min-height: 52px; }
  .metrics { grid-template-columns: 1fr; gap: 10px; }
}

@media (max-width: 480px) {
  main { padding-top: 18px; }
  .frame { width: calc(100% - 20px); }
  .page-lead, .detail-header, .credential, .related {
    align-items: flex-start;
    flex-direction: column;
  }
  .actions { justify-content: flex-start; }
  .directory, .detail { padding: 14px; }
  .login { padding: 24px 20px; margin-top: 4vh; }
  .days { padding-left: 0; }
}
