:root {
  --canvas: #f6f7fb;
  --surface: #ffffff;
  --surface-soft: #f8f7fd;
  --ink: #17213c;
  --muted: #6f778b;
  --line: #e5e7ef;
  --brand: #6d4ed1;
  --brand-soft: #eee8ff;
  --nav: #151b2d;
  --nav-muted: #9aa5be;
  --success: #247b55;
  --success-soft: #e9f7ef;
  --warning: #a7631b;
  --warning-soft: #fff3df;
  --danger: #aa3f4e;
  --danger-soft: #fdecef;
  --shadow: 0 18px 50px rgba(25, 31, 56, .09);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--canvas); color: var(--ink); }
body { min-width: 320px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }
.eyebrow { margin: 0 0 6px; color: #7b65c7; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.error { color: var(--danger); }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 28px; background: radial-gradient(circle at 50% 10%, #efe9ff 0, #f7f8fb 34%, #f7f8fb 100%); }
.auth-card { width: min(440px, 100%); border: 1px solid var(--line); border-radius: 26px; background: rgba(255,255,255,.96); padding: 30px; box-shadow: var(--shadow); }
.back-link { display: inline-block; margin-bottom: 24px; color: #667087; text-decoration: none; font-size: 13px; font-weight: 700; }
.brand-mark { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 18px; border-radius: 15px; background: linear-gradient(145deg, #7051df, #4f36b4); color: #fff; box-shadow: 0 12px 28px rgba(96, 71, 196, .24); font-size: 23px; font-weight: 900; }
.brand-mark.small { width: 37px; height: 37px; margin: 0; border-radius: 11px; font-size: 17px; }
.auth-card h1 { margin: 0; font-size: 28px; letter-spacing: -.03em; }
.auth-copy { margin: 9px 0 22px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.auth-form { display: grid; gap: 14px; }
.auth-form label, .field { display: grid; gap: 6px; color: #4e5870; font-size: 12px; font-weight: 750; }
input, select, textarea { width: 100%; border: 1px solid #d9dce7; border-radius: 11px; background: #fff; color: var(--ink); padding: 10px 11px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: #7c61db; box-shadow: 0 0 0 3px #eee9ff; }
.auth-form button, .primary { border: 0; border-radius: 11px; background: #17213c; color: #fff; padding: 11px 14px; font-weight: 800; }
.mfa-enroll { display: grid; justify-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); padding: 14px; color: var(--muted); font-size: 12px; text-align: center; }
.mfa-enroll img { width: 180px; height: 180px; background: #fff; border-radius: 10px; }

.admin-shell { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--nav); color: #fff; padding: 18px 14px; overflow-y: auto; }
.product-brand { display: flex; align-items: center; gap: 11px; padding: 6px 7px 20px; text-decoration: none; }
.product-brand > span:last-child { display: grid; gap: 1px; }
.product-brand strong { font-size: 16px; }
.product-brand small { color: var(--nav-muted); font-size: 10px; text-transform: uppercase; letter-spacing: .07em; }
.sidebar nav { display: grid; gap: 3px; }
.sidebar nav button { width: 100%; border: 0; border-radius: 10px; background: transparent; color: #bec6d9; padding: 9px 11px; text-align: left; font-size: 12px; font-weight: 700; }
.sidebar nav button:hover, .sidebar nav button.active { background: rgba(255,255,255,.09); color: #fff; }
.sidebar nav button.active { box-shadow: inset 3px 0 0 #9c86f5; }
.sidebar-foot { margin-top: auto; display: grid; gap: 8px; padding: 14px 7px 4px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-foot a, .text-button { border: 0; background: transparent; color: var(--nav-muted); padding: 4px 0; text-decoration: none; font-size: 11px; font-weight: 700; text-align: left; }
.sidebar-foot a:hover, .text-button:hover { color: #fff; }
.viewer { display: grid; gap: 2px; margin: 8px 0 2px; min-width: 0; }
.viewer strong { overflow: hidden; text-overflow: ellipsis; font-size: 11px; }
.viewer small { color: var(--nav-muted); font-size: 10px; text-transform: capitalize; }

.content { min-width: 0; padding: 26px clamp(18px, 3vw, 42px) 48px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; max-width: 1480px; margin: 0 auto 22px; }
.topbar h1 { margin: 0; font-size: clamp(25px, 3vw, 34px); letter-spacing: -.035em; }
.topbar p:last-child { margin: 7px 0 0; max-width: 720px; color: var(--muted); font-size: 13px; }
.secondary { border: 1px solid #dcdfea; border-radius: 10px; background: #fff; color: #4b5369; padding: 9px 12px; font-size: 12px; font-weight: 800; }
.secondary:hover { border-color: #c8c0e8; background: #faf9ff; }
#page, .notice, .loading { max-width: 1480px; margin-left: auto; margin-right: auto; }
.loading, .notice { border: 1px solid var(--line); border-radius: 13px; background: #fff; padding: 12px 14px; color: var(--muted); font-size: 12px; }
.notice.error { border-color: #f0cfd5; background: #fff7f8; color: var(--danger); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.metric { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); padding: 16px; box-shadow: 0 6px 18px rgba(30,35,60,.035); }
.metric > span { display: block; color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.metric strong { display: block; margin-top: 8px; font-size: 26px; letter-spacing: -.04em; }
.metric small { display: block; margin-top: 4px; color: #8a91a1; font-size: 10px; line-height: 1.35; }

.page-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .75fr); gap: 14px; }
.panel { border: 1px solid var(--line); border-radius: 17px; background: var(--surface); padding: 16px; box-shadow: 0 7px 22px rgba(30,35,60,.035); overflow: hidden; }
.panel + .panel { margin-top: 14px; }
.page-grid > .panel + .panel { margin-top: 0; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 13px; }
.panel-heading h2 { margin: 2px 0 0; font-size: 16px; letter-spacing: -.02em; }
.panel-heading small, .panel-copy { color: var(--muted); font-size: 11px; line-height: 1.45; }
.chip, .status { display: inline-flex; align-items: center; width: fit-content; border-radius: 999px; background: #f1eff7; color: #5c6172; padding: 5px 8px; font-size: 9px; font-weight: 850; text-transform: uppercase; letter-spacing: .04em; }
.status.good, .chip.good { background: var(--success-soft); color: var(--success); }
.status.warn, .chip.warn { background: var(--warning-soft); color: var(--warning); }
.status.bad, .chip.bad { background: var(--danger-soft); color: var(--danger); }
.status.brand, .chip.brand { background: var(--brand-soft); color: var(--brand); }

.table-wrap { overflow-x: auto; border: 1px solid #ececf2; border-radius: 12px; }
table { width: 100%; border-collapse: collapse; min-width: 680px; font-size: 11px; }
th, td { padding: 10px 11px; border-bottom: 1px solid #eeeeF4; text-align: left; vertical-align: top; }
th { background: #fafafd; color: #6e7589; font-size: 9px; text-transform: uppercase; letter-spacing: .05em; }
tr:last-child td { border-bottom: 0; }
td strong { display: block; color: #29334a; font-size: 11px; }
td small { display: block; margin-top: 3px; color: #858c9c; font-size: 9px; line-height: 1.35; }
.row-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.action { border: 0; border-radius: 8px; background: var(--brand-soft); color: #5c40bd; padding: 6px 8px; font-size: 9px; font-weight: 850; }
.action.danger { background: var(--danger-soft); color: var(--danger); }
.action.success { background: var(--success-soft); color: var(--success); }
.action.warning { background: var(--warning-soft); color: var(--warning); }
.action:disabled { opacity: .5; cursor: wait; }

.filters, .form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 13px; }
.filters .wide, .form-grid .wide { grid-column: 1 / -1; }
.filters label, .form-grid label, fieldset { display: grid; gap: 5px; color: #60697e; font-size: 10px; font-weight: 750; }
fieldset { border: 1px solid var(--line); border-radius: 11px; padding: 10px; }
fieldset legend { padding: 0 5px; }
.checkbox-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 6px; }
.checkbox-grid label { display: flex; align-items: center; gap: 6px; font-size: 10px; }
.checkbox-grid input { width: auto; }

.card-list { display: grid; gap: 9px; }
.info-card { border: 1px solid #e9e8ef; border-radius: 13px; background: #fbfbfd; padding: 12px; }
.info-card header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.info-card h3 { margin: 0; font-size: 12px; }
.info-card p { margin: 6px 0 0; color: var(--muted); font-size: 10px; line-height: 1.45; }
.kv { display: grid; grid-template-columns: minmax(120px,.7fr) 1fr; gap: 7px 12px; font-size: 10px; }
.kv span { color: var(--muted); }
.kv strong { color: #30394f; word-break: break-word; }
.empty { padding: 24px 14px; border: 1px dashed #dcdfea; border-radius: 12px; color: var(--muted); font-size: 11px; text-align: center; }

.access-generator { display: grid; gap: 12px; }
.one-time-code { border: 1px solid #d8cffa; border-radius: 13px; background: #f6f2ff; padding: 13px; }
.one-time-code strong { display: block; margin: 7px 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 16px; word-break: break-all; }

.bar-list { display: grid; gap: 8px; }
.bar-row { display: grid; gap: 4px; }
.bar-row > div:first-child { display: flex; justify-content: space-between; gap: 10px; color: #596277; font-size: 10px; }
.bar { height: 7px; border-radius: 999px; background: #eeedf3; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #876de0, #6546c5); }

.system-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 9px; }
.system-card { border: 1px solid var(--line); border-radius: 13px; background: #fff; padding: 12px; }
.system-card h3 { margin: 0 0 6px; font-size: 11px; }
.system-card p { margin: 6px 0 0; color: var(--muted); font-size: 9px; line-height: 1.4; }

#action-dialog { width: min(500px, calc(100vw - 30px)); border: 0; border-radius: 18px; padding: 0; box-shadow: 0 24px 80px rgba(15,20,40,.25); }
#action-dialog::backdrop { background: rgba(16,20,34,.52); backdrop-filter: blur(2px); }
#action-form { padding: 20px; }
#action-form h2 { margin: 0; font-size: 18px; }
#dialog-copy { color: var(--muted); font-size: 11px; line-height: 1.45; }
#dialog-fields { display: grid; gap: 10px; margin: 13px 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 15px; }
.dialog-actions button { border: 0; border-radius: 9px; padding: 8px 11px; font-size: 10px; font-weight: 800; }
#dialog-confirm { background: #17213c; color: #fff; }

@media (max-width: 1080px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .page-grid { grid-template-columns: 1fr; }
  .system-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 760px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar nav { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .sidebar nav button { text-align: center; }
  .sidebar-foot { grid-template-columns: repeat(2,1fr); }
  .viewer { grid-column: 1/-1; }
  .content { padding: 18px 12px 36px; }
  .topbar { align-items: center; }
  .system-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .metric-grid, .filters, .form-grid { grid-template-columns: 1fr; }
  .filters .wide, .form-grid .wide { grid-column: auto; }
  .sidebar nav { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .checkbox-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .topbar { align-items: flex-start; }
}


.row-actions .confirm-action {
  box-shadow: 0 0 0 2px rgba(166, 46, 85, .12);
}
.notice.success {
  border: 1px solid #bee8d2;
  background: #edf9f3;
  color: #176b4b;
}
