:root {
  --ink: #172033;
  --muted: #667085;
  --faint: #98a2b3;
  --line: #e3e8ef;
  --panel: #ffffff;
  --canvas: #f4f7fa;
  --nav: #101b31;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-soft: #eff6ff;
  --green: #18794e;
  --green-soft: #eaf7ef;
  --amber: #a15c07;
  --amber-soft: #fff6df;
  --red: #b42318;
  --red-soft: #fff0f0;
  --shadow: 0 18px 48px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
button, a, select { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.brand { display: inline-flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand span:last-child { display: grid; line-height: 1.2; }
.brand strong { font-size: 16px; letter-spacing: -.01em; }
.brand small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.brand-mark {
  width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px;
  color: white; background: linear-gradient(145deg, #3978f6, #194ab8); font-weight: 800;
  box-shadow: 0 8px 20px rgba(37, 99, 235, .24);
}

.auth-shell {
  min-height: 100vh; display: grid; place-items: center; padding: 28px;
  background:
    radial-gradient(circle at 20% 5%, rgba(37, 99, 235, .13), transparent 33rem),
    radial-gradient(circle at 90% 90%, rgba(24, 121, 78, .08), transparent 28rem),
    var(--canvas);
}
.auth-card { width: min(410px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 22px; background: rgba(255,255,255,.95); box-shadow: var(--shadow); }
.auth-copy { margin: 34px 0 22px; }
.eyebrow { margin: 0 0 7px; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .09em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: 30px; line-height: 1.16; letter-spacing: -.035em; }
h2 { margin-bottom: 5px; font-size: 20px; letter-spacing: -.02em; }
h3 { margin-bottom: 5px; font-size: 15px; }
.auth-copy p:last-child, .dialog-card > p { color: var(--muted); }
label { display: grid; gap: 6px; margin: 13px 0; color: #475467; font-size: 12px; font-weight: 700; }
input, select {
  width: 100%; height: 42px; padding: 0 12px; color: var(--ink); background: white;
  border: 1px solid #cbd5e1; border-radius: 10px; outline: none;
}
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
button {
  min-height: 38px; padding: 0 14px; color: var(--ink); background: white;
  border: 1px solid #cbd5e1; border-radius: 10px; font-weight: 650;
}
button:hover { border-color: #94a3b8; background: #f8fafc; }
button:disabled { cursor: not-allowed; opacity: .48; }
button.primary { color: white; border-color: var(--blue); background: var(--blue); }
button.primary:hover { border-color: var(--blue-dark); background: var(--blue-dark); }
button.danger { color: var(--red); border-color: #fecaca; }
button.wide { width: 100%; margin-top: 8px; }
.text-button { min-height: 30px; padding: 0; color: var(--blue); border: 0; background: transparent; }
.text-button:hover { color: var(--blue-dark); background: transparent; }
.auth-card > .text-button { width: 100%; margin-top: 5px; }
.auth-foot { margin: 24px 0 0; padding-top: 18px; color: var(--faint); border-top: 1px solid var(--line); font-size: 11.5px; text-align: center; }
.form-message { min-height: 20px; margin: 9px 0 0; color: var(--red); font-size: 12px; }
.form-message.success { color: var(--green); }
.mfa-account { margin: -4px 0 8px; color: var(--muted); font-size: 12px; }
.mfa-code { font-size: 20px; font-weight: 700; letter-spacing: .28em; text-align: center; }
#mfa-form .text-button { width: 100%; margin-top: 8px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 26px 18px 20px; color: white; background: var(--nav); }
.sidebar-brand { margin: 0 9px 32px; }
.sidebar-brand small { color: #9aa9c2; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar nav a { padding: 11px 13px; color: #b8c3d4; border-radius: 10px; text-decoration: none; font-weight: 650; }
.sidebar nav a:hover { color: white; background: rgba(255,255,255,.07); }
.sidebar nav a.active { color: white; background: rgba(59,130,246,.24); box-shadow: inset 3px 0 #60a5fa; }
.sidebar-account { margin-top: auto; padding: 17px 10px 0; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-account span { display: block; color: #b8c3d4; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; }
.sidebar-account .text-button { margin-top: 6px; color: #d8e0ec; }
.content-shell { min-width: 0; }
.page { width: min(1120px, 100%); margin: 0 auto; padding: 46px 38px 70px; outline: none; }
.mobile-header { display: none; }
.loading { position: fixed; inset: 0 0 0 244px; z-index: 20; display: grid; place-items: center; align-content: center; gap: 13px; color: var(--muted); background: rgba(244,247,250,.82); backdrop-filter: blur(4px); }
.loading span { width: 27px; height: 27px; border: 3px solid #cbd5e1; border-top-color: var(--blue); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.page-head { display: flex; align-items: flex-end; gap: 20px; margin-bottom: 24px; }
.page-head > div:first-child { flex: 1; }
.page-head p { margin-bottom: 0; color: var(--muted); }
.page-head-actions { display: flex; gap: 8px; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: grid; gap: 14px; }
.section { margin-top: 28px; }
.section-title { display: flex; align-items: center; gap: 12px; margin: 0 2px 9px; }
.section-title h2 { margin: 0; font-size: 15px; }
.section-title span { margin-left: auto; color: var(--faint); font-size: 12px; }
.card { padding: 19px 20px; border: 1px solid var(--line); border-radius: 15px; background: var(--panel); box-shadow: 0 7px 22px rgba(15,23,42,.045); }
.card-head { display: flex; align-items: flex-start; gap: 12px; }
.card-head > div:first-child { flex: 1; min-width: 0; }
.card p:last-child { margin-bottom: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.summary-value { margin: 10px 0 3px; font-size: 24px; font-weight: 760; letter-spacing: -.025em; }
.kicker { color: var(--faint); font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 750; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.active { color: var(--green); background: var(--green-soft); }
.pill.pending, .pill.warning { color: var(--amber); background: var(--amber-soft); }
.pill.inactive { color: var(--muted); background: #eef2f6; }
.pill.danger { color: var(--red); background: var(--red-soft); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(125px,1fr)); gap: 10px; margin-top: 16px; }
.fact { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fafbfd; }
.fact span { display: block; color: var(--faint); font-size: 10.5px; font-weight: 750; text-transform: uppercase; }
.fact strong { display: block; margin-top: 4px; font-size: 13px; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.notice { padding: 13px 15px; border: 1px solid #bfdbfe; border-radius: 12px; color: #1e40af; background: var(--blue-soft); }
.notice.warning { color: #854d0e; border-color: #fde68a; background: var(--amber-soft); }
.empty { padding: 28px; color: var(--muted); border: 1px dashed #cbd5e1; border-radius: 14px; text-align: center; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 14px; background: white; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); background: #fafbfd; font-size: 11px; text-transform: uppercase; letter-spacing: .035em; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.actions-cell { text-align: right; white-space: nowrap; }
td.actions-cell button { min-height: 30px; padding: 0 10px; font-size: 11.5px; }

dialog { width: min(520px, calc(100% - 30px)); padding: 0; border: 0; border-radius: 18px; box-shadow: 0 30px 90px rgba(15,23,42,.24); }
dialog::backdrop { background: rgba(15,23,42,.45); backdrop-filter: blur(4px); }
.dialog-card { padding: 23px; }
.dialog-head { display: flex; gap: 15px; align-items: flex-start; }
.dialog-head > div { flex: 1; }
.icon-button { min-width: 34px; min-height: 34px; padding: 0; border-radius: 50%; font-size: 20px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
#toast { position: fixed; z-index: 100; left: 50%; bottom: 25px; transform: translateX(-50%); max-width: min(520px,90vw); padding: 10px 17px; color: white; background: #172033; border-radius: 999px; box-shadow: var(--shadow); }

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .mobile-header { position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
  .mobile-header .brand-mark { width: 32px; height: 32px; }
  .mobile-header select { width: 135px; height: 36px; }
  .page { padding: 30px 18px 54px; }
  .loading { inset: 0; }
  .grid.two, .grid.three { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .page-head { align-items: flex-start; flex-direction: column; }
  .page-head-actions { width: 100%; }
  .page-head-actions button { flex: 1; }
  .two-col { grid-template-columns: 1fr; gap: 0; }
  .card { padding: 16px; }
}
