:root {
  color-scheme: light;
  --ink: #172033;
  --ink-soft: #657086;
  --line: #e4e8ef;
  --surface: #ffffff;
  --surface-soft: #f6f8fb;
  --background: #f2f5f9;
  --navy: #111827;
  --gold: #c9942e;
  --gold-soft: #fdf4df;
  --green: #198754;
  --green-soft: #e7f6ee;
  --red: #c24141;
  --red-soft: #fff0f0;
  --blue: #356ae6;
  --shadow: 0 16px 45px rgba(17, 24, 39, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--background); font-size: 14px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 28px; letter-spacing: -.03em; }
h2 { font-size: 19px; letter-spacing: -.02em; }
h3 { font-size: 14px; }
.muted { color: var(--ink-soft); line-height: 1.5; }
.eyebrow { color: var(--gold); font-size: 10px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top right, #253452 0, var(--navy) 46%, #0b1020 100%); }
.auth-card { width: min(100%, 420px); padding: 42px; border: 1px solid rgba(255,255,255,.14); border-radius: 24px; background: rgba(255,255,255,.98); box-shadow: 0 30px 90px rgba(0,0,0,.24); }
.auth-card h1 { margin: 9px 0 7px; }
.auth-card > .muted { margin-bottom: 30px; }
.brand-mark { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; color: #fff; background: linear-gradient(135deg, #e0af50, #a66b13); font-size: 27px; font-weight: 900; }
.brand-mark.small { width: 30px; height: 30px; border-radius: 9px; font-size: 17px; }
.stack { display: grid; gap: 17px; }
.security-note { margin-top: 26px; color: var(--ink-soft); font-size: 11px; line-height: 1.5; }

label { display: grid; gap: 7px; color: #39445a; font-size: 12px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid #d8dee8; border-radius: 10px; padding: 11px 12px; color: var(--ink); background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(53,106,230,.12); }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 0 15px; border: 1px solid transparent; border-radius: 9px; font-size: 13px; font-weight: 750; transition: transform .12s, background .12s, border-color .12s; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button-primary { color: #fff; border-color: var(--navy); background: var(--navy); }
.button-primary:hover:not(:disabled) { background: #26324a; }
.button-secondary { color: #354158; border-color: #d8dee8; background: #fff; }
.button-secondary:hover:not(:disabled) { border-color: #aab5c7; background: #f8fafc; }
.button-danger { color: #fff; border-color: var(--red); background: var(--red); }
.button-ghost { color: #c6cedc; border-color: rgba(255,255,255,.15); background: transparent; }
.button-full { width: 100%; }
.button-row { display: flex; flex-wrap: wrap; gap: 9px; }

.app-shell { display: grid; min-height: 100vh; grid-template-columns: 246px 1fr; }
.sidebar { display: flex; flex-direction: column; padding: 26px 16px 18px; color: #dce4f2; background: var(--navy); }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 0 12px 35px; font-weight: 850; letter-spacing: .12em; }
.sidebar nav { display: grid; gap: 5px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 12px; color: #aeb9ce; border: 0; border-radius: 10px; background: transparent; text-align: left; font-weight: 700; }
.nav-item:hover, .nav-item.active { color: #fff; background: rgba(255,255,255,.1); }
.nav-item.active { box-shadow: inset 3px 0 var(--gold); }
.nav-icon { width: 18px; color: var(--gold); font-size: 18px; text-align: center; }
.sidebar-footer { margin-top: auto; padding: 18px 12px 0; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-admin-name { overflow: hidden; margin: 8px 0 14px; color: #fff; font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }

.content { min-width: 0; padding: 34px clamp(20px, 4vw, 58px) 70px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 32px; }
.topbar h1 { margin-top: 8px; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.admin-email { color: var(--ink-soft); font-size: 12px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card { padding: 20px 22px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: 0 8px 25px rgba(17,24,39,.035); }
.stat-card span, .stat-card small { display: block; color: var(--ink-soft); }
.stat-card span { font-weight: 700; }
.stat-card strong { display: block; margin: 8px 0 4px; font-size: 30px; letter-spacing: -.05em; }

.panel, .subpanel { border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: 0 8px 25px rgba(17,24,39,.035); }
.panel { margin-bottom: 20px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 21px 22px; }
.panel-header h2 { margin-bottom: 5px; }
.toolbar { display: flex; align-items: center; gap: 10px; padding: 0 22px 18px; }
.search-field { display: flex; align-items: center; flex: 1; gap: 8px; padding: 0 12px; border: 1px solid #d8dee8; border-radius: 10px; color: var(--ink-soft); background: #fff; }
.search-field:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(53,106,230,.12); }
.search-field input { padding-left: 0; border: 0; box-shadow: none; }
.toolbar select { width: auto; min-width: 150px; }
.table-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 14px 22px; border-bottom: 1px solid #edf0f4; white-space: nowrap; }
th { color: var(--ink-soft); background: #fbfcfd; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfd; }
.creator-cell { display: grid; gap: 3px; }
.creator-name { color: var(--ink); font-weight: 800; }
.creator-contact { color: var(--ink-soft); font-size: 12px; }
.code-text { padding: 5px 8px; border-radius: 6px; color: #79510d; background: var(--gold-soft); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; font-weight: 800; }
.empty-cell { padding: 35px 22px; color: var(--ink-soft); text-align: center; }

.badge { display: inline-flex; align-items: center; width: fit-content; padding: 5px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.badge.active { color: var(--green); background: var(--green-soft); }
.badge.inactive, .badge.suspended, .badge.disabled { color: var(--red); background: var(--red-soft); }
.badge.neutral { color: #5a6579; background: #eef1f5; }
.detail-panel { padding-bottom: 22px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 0 22px; }
.detail-grid.lower { margin-top: 16px; }
.subpanel { box-shadow: none; }
.subpanel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px; border-bottom: 1px solid var(--line); }
.definition-list { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin: 0; padding: 16px; }
.definition-list div { min-width: 0; }
.definition-list dt { color: var(--ink-soft); font-size: 11px; }
.definition-list dd { overflow: hidden; margin: 4px 0 0; font-weight: 700; text-overflow: ellipsis; }
.code-list, .compact-list { padding: 8px 16px; }
.code-row, .compact-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid #edf0f4; }
.code-row:last-child, .compact-row:last-child { border-bottom: 0; }
.code-meta, .compact-meta { display: grid; gap: 4px; min-width: 0; }
.code-actions { display: flex; align-items: center; gap: 8px; }
.text-button { padding: 4px; border: 0; color: var(--blue); background: transparent; font-size: 12px; font-weight: 750; }
.text-button.danger { color: var(--red); }
.compact-row { align-items: start; font-size: 12px; }
.compact-row strong { font-size: 12px; }
.compact-row small { color: var(--ink-soft); }
.audit-json { max-width: 100%; margin-top: 7px; color: var(--ink-soft); font-size: 10px; white-space: pre-wrap; overflow-wrap: anywhere; }

.dialog { width: min(100% - 30px, 540px); padding: 0; border: 0; border-radius: 16px; background: transparent; box-shadow: var(--shadow); }
.dialog.narrow { width: min(100% - 30px, 450px); }
.dialog::backdrop { background: rgba(10, 16, 31, .58); backdrop-filter: blur(3px); }
.dialog-card { padding: 25px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 23px; }
.dialog-header h2 { margin-top: 6px; }
.icon-button { width: 30px; height: 30px; padding: 0; border: 0; border-radius: 7px; color: var(--ink-soft); background: var(--surface-soft); font-size: 22px; line-height: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-hint { margin: 9px 0 0; color: var(--ink-soft); font-size: 11px; line-height: 1.5; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 25px; }
.form-error { margin: 0; padding: 10px 12px; border-radius: 8px; color: var(--red); background: var(--red-soft); font-size: 12px; line-height: 1.4; }
.toast { position: fixed; z-index: 10; top: 20px; right: 20px; max-width: 360px; padding: 12px 15px; border-radius: 10px; color: #fff; background: var(--navy); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(-8px); transition: opacity .2s, transform .2s; }
.toast.visible { opacity: 1; transform: translateY(0); }

[hidden] { display: none !important; }
@media (max-width: 950px) {
  .app-shell { grid-template-columns: 76px 1fr; }
  .sidebar-brand { justify-content: center; padding-inline: 0; }
  .sidebar-brand > span:not(.brand-mark), .nav-item:not(.active) { font-size: 0; }
  .nav-item { justify-content: center; }
  .nav-item .nav-icon { margin: 0; }
  .sidebar-footer { padding-inline: 0; }
  .sidebar-footer .eyebrow, .sidebar-admin-name, .sidebar-footer .button { display: none; }
}
@media (max-width: 720px) {
  .content { padding: 23px 14px 45px; }
  .topbar, .panel-header { align-items: flex-start; flex-direction: column; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .stats-grid, .detail-grid { grid-template-columns: 1fr; }
  .toolbar { align-items: stretch; flex-direction: column; padding-inline: 14px; }
  .toolbar select { width: 100%; }
  th, td { padding-inline: 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
}
