
:root {
  color-scheme: light;
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --surface-3: #fafafa;
  --text: #18181b;
  --muted: #71717a;
  --border: #e4e4e7;
  --accent: #18181b;
  --accent-hover: #3f3f46;
  --accent-soft: #f4f4f5;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warning: #a16207;
  --warning-soft: #fefce8;
  --ok-bg: #f0fdf4;
  --ok: #166534;
  --err-bg: #fef2f2;
  --err: #b91c1c;
  --info-bg: #eff6ff;
  --info: #1d4ed8;
  --shadow-sm: 0 1px 2px 0 rgb(24 24 27 / 0.04);
  --shadow: 0 8px 24px rgb(24 24 27 / 0.08);
  --shadow-lg: 0 24px 48px -12px rgb(24 24 27 / 0.22);
  --radius: 8px;
  --radius-sm: 6px;
  --transition: 150ms ease;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #09090b;
  --surface: #18181b;
  --surface-2: #27272a;
  --surface-3: #111113;
  --text: #fafafa;
  --muted: #a1a1aa;
  --border: #27272a;
  --accent: #fafafa;
  --accent-hover: #e4e4e7;
  --accent-soft: #27272a;
  --danger: #f87171;
  --danger-soft: #3f1212;
  --warning: #facc15;
  --warning-soft: #332b08;
  --ok-bg: #052e16;
  --ok: #86efac;
  --err-bg: #3f1212;
  --err: #f87171;
  --info-bg: #172554;
  --info: #93c5fd;
  --shadow: 0 16px 36px rgb(0 0 0 / 0.35);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
body::before { background: linear-gradient(to bottom, color-mix(in srgb, var(--surface) 65%, transparent), transparent); content: ""; height: 220px; inset: 0 0 auto; pointer-events: none; position: fixed; z-index: -1; }
a { color: inherit; }
button, input, textarea { font: inherit; }
header { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--surface) 88%, transparent); border-bottom: 1px solid var(--border); backdrop-filter: blur(16px); }
.topbar { align-items: center; display: flex; gap: 20px; min-height: 64px; padding: 0 28px; max-width: 1440px; margin: 0 auto; }
.brand { align-items: center; color: var(--text); display: inline-flex; font-size: 15px; font-weight: 700; gap: 10px; text-decoration: none; white-space: nowrap; }
.brand-mark { align-items: center; background: var(--text); border-radius: var(--radius-sm); color: var(--surface); display: inline-flex; height: 28px; justify-content: center; width: 28px; }
main { max-width: 1220px; margin: 0 auto; padding: 34px 28px 56px; }
.auth-shell main { max-width: 640px; padding-top: 72px; }
nav { align-items: center; display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
nav::-webkit-scrollbar { display: none; }
nav a { border-radius: var(--radius-sm); color: var(--muted); flex: 0 0 auto; padding: 8px 10px; text-decoration: none; font-size: 13px; font-weight: 500; transition: background var(--transition), color var(--transition); }
nav a:hover { background: var(--surface-2); color: var(--text); }
nav a.active { background: var(--accent-soft); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
.account { align-items: center; display: flex; gap: 10px; margin-left: auto; }
.icon-button { align-items: center; background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm); color: var(--muted); cursor: pointer; display: inline-flex; flex: 0 0 auto; height: 34px; justify-content: center; padding: 0; width: 34px; transition: background var(--transition), border-color var(--transition), color var(--transition); }
.icon-button:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.icon-button.copied { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 25%, transparent); color: var(--ok); }
.icon-button.danger { color: var(--danger); }
.icon-button.danger:hover { background: var(--danger-soft); }
.icon-button svg { fill: currentColor; height: 17px; width: 17px; }

.avatar-menu { position: relative; }
.avatar-menu summary { cursor: pointer; list-style: none; outline: none; }
.avatar-menu summary::-webkit-details-marker { display: none; }
.avatar { align-items: center; background: var(--text); border-radius: 999px; color: var(--surface); display: inline-flex; font-size: 12px; font-weight: 700; height: 34px; justify-content: center; width: 34px; }
.menu { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); display: grid; gap: 4px; min-width: 240px; padding: 10px; position: absolute; right: 0; top: 44px; z-index: 100; animation: menu-slide 0.16s ease-out; }
@keyframes menu-slide { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.menu strong { font-size: 14px; padding: 0 8px; }
.menu span { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; padding: 0 8px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu a { border-radius: var(--radius-sm); color: var(--text); padding: 9px 8px; text-decoration: none; font-weight: 500; transition: background var(--transition); }
.menu a:hover { background: var(--surface-2); }
.menu a[href="/logout"] { color: var(--danger); margin-top: 4px; border-top: 1px solid var(--border); border-radius: 0; padding-top: 12px; }
.menu a[href="/logout"]:hover { background: var(--danger-soft); }

.page-heading { align-items: flex-start; display: flex; gap: 16px; justify-content: space-between; margin-bottom: 22px; }
.page-heading h1 { font-size: 30px; font-weight: 700; line-height: 1.15; margin: 2px 0 8px; }
.page-heading p { color: var(--muted); margin: 0; max-width: 760px; }
.breadcrumb { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0.06em; margin: 0; text-transform: uppercase; }
h2 { font-size: 24px; font-weight: 700; margin: 0 0 18px; }
h3 { font-size: 17px; font-weight: 650; margin: 0 0 14px; }

.button { align-items: center; background: var(--accent); border: 1px solid var(--accent); border-radius: var(--radius-sm); color: var(--surface); cursor: pointer; display: inline-flex; gap: 8px; justify-content: center; min-height: 36px; padding: 8px 13px; text-decoration: none; font-weight: 600; font-size: 13px; transition: background var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition); white-space: nowrap; }
.button svg { height: 14px; width: 14px; }
.button:hover { background: var(--accent-hover); border-color: var(--accent-hover); box-shadow: var(--shadow-sm); }
.button:active { box-shadow: none; }
.button.secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.button.secondary:hover { background: var(--surface-2); border-color: color-mix(in srgb, var(--border) 70%, var(--muted)); }
.button.danger { background: var(--danger); color: white; }
.button.danger:hover { opacity: 0.9; }
.button.muted { cursor: not-allowed; opacity: 0.55; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin-bottom: 20px; box-shadow: var(--shadow-sm); }
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; background: var(--surface); box-shadow: var(--shadow-sm); }
.table-wrap.flat { box-shadow: none; margin-top: 12px; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { border-bottom: 1px solid var(--border); padding: 13px 15px; text-align: left; vertical-align: middle; }
th { background: var(--surface-3); color: var(--muted); font-size: 12px; font-weight: 600; height: 42px; text-transform: none; }
tr:hover td { background: color-mix(in srgb, var(--surface-2) 30%, transparent); }
tr:last-child td { border-bottom: 0; }
.table-empty { color: var(--muted); padding: 34px 16px; text-align: center; }
.empty-state { align-items: center; display: flex; flex-direction: column; gap: 8px; justify-content: center; min-height: 120px; }
.empty-state strong { color: var(--text); font-size: 15px; }
.empty-state span { max-width: 420px; }
.cell-stack { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cell-stack .muted { overflow-wrap: anywhere; }
.ip-location { align-items: center; color: var(--muted); display: inline-flex; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
.ip-location .fi { border-radius: 2px; box-shadow: 0 0 0 1px color-mix(in srgb, var(--border) 70%, transparent); flex: 0 0 auto; font-size: 14px; line-height: 1; }
.ip-location-muted { color: color-mix(in srgb, var(--muted) 78%, var(--text)); }
.cidr-list { display: flex; flex-direction: column; gap: 5px; max-width: 220px; }
.nowrap { white-space: nowrap; }
.truncate { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mono-small { font-size: 12px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.compact-text { font-size: 12px; line-height: 1.4; }
.compact-text .button { align-self: flex-start; font-size: 12px; min-height: 28px; padding: 4px 8px; }
.detail-list { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
.detail-list div { border-bottom: 1px solid var(--border); display: grid; gap: 4px; padding-bottom: 12px; }
.detail-list dt { color: var(--muted); font-size: 12px; font-weight: 600; }
.detail-list dd { margin: 0; min-width: 0; }
.inline-form { align-items: flex-end; display: flex; gap: 12px; }
.inline-form .field { margin-bottom: 0; }
.inline-form .grow { flex: 1; }

label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; }
.field { margin-bottom: 18px; }
.field-help { color: var(--muted); font-size: 12px; margin: 7px 0 0; }
input, textarea { background: var(--surface); color: var(--text); padding: 9px 11px; min-width: 260px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-family: inherit; font-size: 14px; transition: border-color var(--transition), box-shadow var(--transition); }
input:focus, textarea:focus { outline: none; border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent); }
input.invalid, textarea.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 14%, transparent); }
textarea { display: block; margin: 0 0 16px; max-width: 100%; width: 100%; resize: vertical; }

code { background: var(--surface-2); padding: 3px 5px; border-radius: 5px; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 0.9em; color: var(--text); border: 1px solid var(--border); }
.flash { border-radius: var(--radius); padding: 13px 14px; margin-bottom: 18px; font-weight: 500; display: flex; align-items: center; gap: 10px; animation: flash-slide 0.2s ease-out; }
.flash-dot { border-radius: 999px; flex: 0 0 auto; height: 8px; width: 8px; }
.flash.ok .flash-dot { background: var(--ok); }
.flash.err .flash-dot { background: var(--err); }
@keyframes flash-slide { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid color-mix(in srgb, var(--ok) 20%, transparent); }
.err { background: var(--err-bg); color: var(--err); border: 1px solid color-mix(in srgb, var(--err) 20%, transparent); }
.warning { background: var(--warning-soft); color: var(--warning); border: 1px solid color-mix(in srgb, var(--warning) 22%, transparent); }
.info { background: var(--info-bg); color: var(--info); border: 1px solid color-mix(in srgb, var(--info) 20%, transparent); }

.muted { color: var(--muted); font-size: 13px; }
form.inline { display: inline; }
.actions { align-items: center; display: flex; gap: 6px; justify-content: flex-end; }
.status { align-items: center; border-radius: 999px; border: 1px solid transparent; display: inline-flex; font-size: 12px; font-weight: 600; line-height: 1; min-height: 24px; padding: 0 9px; text-transform: capitalize; white-space: nowrap; }
.status.active { background: var(--ok-bg); color: var(--ok); }
.status.inactive { background: var(--surface-2); border-color: var(--border); color: var(--muted); }
.status.revoked { background: var(--danger-soft); color: var(--danger); }

.pagination { align-items: center; display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.pagination .muted:first-child { margin-right: auto; }
.page-actions { display: flex; gap: 10px; justify-content: flex-end; margin: 0 0 18px; min-height: 38px; position: relative; z-index: 1; }
.metrics { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 20px; }
.metric { display: flex; flex-direction: column; gap: 8px; }
.metric span { font-weight: 600; font-size: 13px; }
.metric strong { color: var(--text); display: block; font-size: 30px; font-weight: 700; letter-spacing: 0; line-height: 1; }
.metric-code { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 18px !important; }

.chart-box { height: 340px; position: relative; margin-top: 14px; }
canvas { height: 100%; width: 100%; }

.modal-backdrop { align-items: center; background: color-mix(in srgb, var(--bg) 60%, transparent); backdrop-filter: blur(4px); display: none; inset: 0; justify-content: center; padding: 24px; position: fixed; z-index: 1000; animation: fade-in 0.2s ease-out; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); max-width: 500px; padding: 24px; width: 100%; animation: modal-up 0.18s ease-out; }
@keyframes modal-up { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal h3 { margin-bottom: 8px; }
.modal p { color: var(--muted); line-height: 1.6; margin: 0 0 20px; font-size: 14px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }
.key-result { align-items: stretch; background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius); display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr) auto; padding: 10px; }
.secret-value { align-items: center; display: flex; min-height: 38px; overflow-wrap: anywhere; white-space: normal; }

@media (max-width: 840px) {
  .topbar { align-items: flex-start; flex-wrap: wrap; gap: 10px 12px; padding: 12px 16px; }
  .brand { margin-right: auto; }
  .account { margin-left: 0; }
  nav { flex-basis: 100%; order: 3; padding-bottom: 2px; }
  main { padding: 26px 16px 40px; }
  .page-heading { display: block; margin-bottom: 18px; }
  .page-heading h1 { font-size: 24px; }
  .page-actions { justify-content: flex-start; margin: 0 0 16px; min-height: 0; }
  .metrics { grid-template-columns: 1fr; }
  input, textarea { min-width: 0; width: 100%; }
  .modal { padding: 20px; }
  .detail-list { grid-template-columns: 1fr; }
  .inline-form { align-items: stretch; flex-direction: column; }
  .key-result { grid-template-columns: 1fr; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .button { width: 100%; }
  .pagination { justify-content: flex-start; }
  .pagination .muted:first-child { flex-basis: 100%; margin-right: 0; }
  th, td { padding: 11px 12px; }
}
@media (max-width: 680px) {
  .table-wrap { border: 0; box-shadow: none; overflow: visible; }
  .table-wrap table, .table-wrap thead, .table-wrap tbody, .table-wrap tr, .table-wrap th, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 12px; padding: 8px 0; }
  .table-wrap td { align-items: flex-start; border-bottom: 0; display: grid; gap: 10px; grid-template-columns: 120px minmax(0, 1fr); padding: 8px 12px; text-align: left; }
  .table-wrap td::before { color: var(--muted); content: attr(data-label); font-size: 12px; font-weight: 600; }
  .table-wrap td.actions { justify-content: stretch; }
  .table-wrap td.actions::before { padding-top: 7px; }
  .table-wrap td.table-empty { display: block; padding: 0; }
  .table-wrap td.table-empty::before { content: ""; display: none; }
  .truncate { max-width: none; white-space: normal; }
}
