:root {
  font: 16px/1.55 "Segoe UI", system-ui, sans-serif;
  color: #172641;
  background: #f5f7fb;
  --panel: #fff;
  --navy: #0d2445;
  --blue: #2057bb;
  --blue-dark: #133f91;
  --muted: #52647e;
  --border: #dee6f0;
  --focus: #2057bb;
  --failure: #a0303c;
  --success: #15614a;
  --round: 18px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
::selection { background: #dbeaff; color: #17395e; }
a { color: var(--blue-dark); text-decoration-thickness: .08em; text-underline-offset: .19em; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .64; }
:where(a, button, input, select, textarea, summary):focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.skip-link { position: fixed; z-index: 3; top: .65rem; left: .65rem; padding: .75rem; background: var(--panel); transform: translateY(-180%); }
.skip-link:focus { transform: none; }

.header { background: var(--panel); border-bottom: 1px solid var(--border); }
.header-inner { max-width: 1300px; min-height: 75px; margin: auto; padding: .5rem 1.75rem; display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
.header-actions { display: flex; gap: .45rem; align-items: center; }
.brand { display: flex; gap: .5rem; align-items: center; font-size: .95rem; line-height: 1.3; color: inherit; text-decoration: none; }
.brand-logo { object-fit: contain; flex: none; }
.brand small { color: var(--muted); display: block; margin-top: .14rem; font-size: .78rem; }
.button { min-height: 42px; display: inline-flex; gap: .35rem; justify-content: center; align-items: center; border: 1px solid transparent; border-radius: 10px; padding: .55rem .95rem; font-weight: 700; font-size: .91rem; line-height: 1.25; text-align: center; text-decoration: none; }
.button.primary { background: var(--blue); color: #fff; box-shadow: 0 2px 4px #17376d22; }
.button.primary:hover { background: var(--blue-dark); }
.button.secondary { background: #fff; color: var(--blue-dark); border-color: var(--border); }
.button.secondary:hover, .button.quiet:hover { background: #edf4fc; }
.button.quiet { color: var(--blue-dark); background: transparent; }
.button.danger { color: var(--failure); background: #fff; border-color: #f0c6c6; }
.button.danger:hover { background: #fff3f3; }

h1, h2, h3, p { margin: 0; }
h1, h2, h3 { color: var(--navy); line-height: 1.2; }
h1 { font-size: clamp(1.8rem, 3.5vw, 2.65rem); letter-spacing: -.045em; }
h2 { font-size: 1.25rem; letter-spacing: -.025em; }
h3 { font-size: 1rem; }
p.muted, .muted, small.help { color: var(--muted); }
p.muted { margin-top: .4rem; }
.loading { margin: 5rem auto; padding: 0 1.25rem; text-align: center; color: var(--muted); }
.box { padding: 1.42rem; border: 1px solid var(--border); border-radius: var(--round); background: var(--panel); min-width: 0; }
.box + .box { margin-top: 1rem; }
.box-header { display: flex; gap: .8rem; justify-content: space-between; align-items: start; margin-bottom: 1.15rem; }
.box-header p { margin-top: .35rem; }
.stack { display: grid; gap: 1rem; }
.stack-tight { display: grid; gap: .65rem; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; }
.row-between { justify-content: space-between; }
.actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; overflow-wrap: normal; }
.input-row { display: flex; align-items: end; gap: .65rem; }
.input-row label { flex: 1; margin: 0; }
.input-row .button { min-height: 44px; }
.badge { display: inline-flex; align-items: center; padding: .24rem .6rem; font-size: .78rem; line-height: 1.25; border-radius: 2rem; font-weight: 700; color: #244a79; background: #e9f1fd; white-space: nowrap; }
.badge.live { color: #784a06; background: #fff1d1; }
.badge.success { color: var(--success); background: #e4f4ed; }
.badge.error { color: var(--failure); background: #faeaea; }
.badge.pending { color: #704d06; background: #fff0cb; }
.notice { padding: .76rem .9rem; border: 1px solid #bad3f8; border-radius: 10px; background: #eaf4ff; overflow-wrap: anywhere; }
.notice.error { border-color: #efc5c5; background: #fff2f2; color: var(--failure); }
.notice.success { color: var(--success); background: #eefaf5; border-color: #b6e2cd; }
.notice > * + * { margin-top: .4rem; }

.auth-layout { max-width: 1120px; padding: clamp(2rem, 7vw, 6rem) 1.75rem; margin: auto; display: grid; grid-template-columns: minmax(0, 1.22fr) minmax(340px, 1fr); align-items: stretch; gap: 1.35rem; }
.auth-heading { display: flex; flex-direction: column; justify-content: space-between; gap: clamp(1.85rem, 7vw, 4.25rem); min-width: 0; padding: clamp(1.9rem, 5vw, 3.25rem); border-radius: 24px; color: #fff; background: radial-gradient(ellipse at 100% 2%, #214f91 0, transparent 60%), linear-gradient(150deg,#0b2040,#132f55); }
.auth-hero-copy::before { content: ""; display: block; width: 2.65rem; height: 3px; margin-bottom: 1.25rem; border-radius: 3px; background: #f3bf53; }
.auth-heading h1 { max-width: 13ch; font-size: clamp(2.45rem, 5vw, 4.15rem); color: white; }
.auth-heading p { max-width: 32ch; font-size: 1.045rem; margin-top: .85rem; color: #d4e2f7; }
.auth-modes { display: grid; gap: .7rem; grid-template-columns: 1fr 1fr; margin: 0; }
.auth-modes > div { padding: .85rem .9rem; border: 1px solid #c0d7ff35; border-radius: 12px; background: #adcaff11; }
.auth-modes dt { color: #ffd982; font-size: .76rem; letter-spacing: .09em; font-weight: 800; }
.auth-modes dd { margin: .25rem 0 0; color: #e6efff; font-size: .88rem; }
.auth-card { padding: clamp(1.2rem, 3.5vw, 2.25rem); border-radius: 24px; box-shadow: 0 16px 40px #182e5010; }
.auth-card h2 { font-size: clamp(1.5rem, 3.2vw, 2rem); }
.auth-card .form-actions .button { width: 100%; min-height: 47px; }
.auth-card > .notice { margin-bottom: .85rem; }
.auth-actions { display: grid; margin-top: .55rem; }
.auth-actions > .quiet { justify-self: start; padding-left: 0; }
.auth-actions.compact { display: flex; flex-wrap: wrap; gap: .2rem 1rem; }
.auth-register { border-top: 1px solid var(--border); display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: .45rem .5rem; margin-top: .65rem; padding-top: .9rem; font-size: .9rem; color: var(--muted); }
.auth-progress { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .38rem; padding: 0; margin: 0 0 1.3rem; }
.auth-progress li { display: flex; gap: .35rem; align-items: center; color: var(--muted); font-size: .78rem; font-weight: 700; padding: .4rem 0; }
.auth-progress span { display: grid; place-items: center; flex: none; width: 1.45rem; height: 1.45rem; border-radius: 50%; border: 1px solid var(--border); background: #f1f5fb; }
.auth-progress [aria-current], .auth-progress .completed { color: var(--blue-dark); }
.auth-progress [aria-current] span { background: var(--blue); color: white; border-color: var(--blue); }
.auth-progress .completed span { color: var(--success); background: #e5f3ed; }

.app-layout { max-width: 1300px; margin: auto; padding: 1.75rem; display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 1.6rem; }
.sidebar { position: sticky; align-self: start; top: 1.1rem; display: grid; gap: .8rem; padding: .75rem; }
.nav-profile { display: flex; align-items: start; flex-direction: column; gap: .45rem; min-width: 0; border-bottom: 1px solid var(--border); padding: .4rem .45rem .85rem; }
.nav-profile strong { max-width: 100%; overflow-wrap: anywhere; }
.nav-label { padding: .3rem .6rem; color: var(--muted); font-size: .74rem; font-weight: 780; }
.nav-group { display: grid; gap: .12rem; }
.sidebar a { display: block; position: relative; min-height: 42px; border-radius: 9px; padding: .58rem .65rem; color: #394d6b; font-weight: 650; font-size: .92rem; text-decoration: none; }
.sidebar a:hover { color: var(--blue-dark); background: #f1f6fe; }
.sidebar a[aria-current="page"] { background: #e8f0ff; color: var(--blue-dark); }
.sidebar a[aria-current="page"]::after { content: ""; position: absolute; right: .75rem; top: 50%; width: .38rem; height: .38rem; border-radius: 50%; background: var(--blue); transform: translateY(-50%); }
.workspace { min-width: 0; }
.page-intro { margin-bottom: 1.25rem; display: flex; justify-content: space-between; align-items: start; gap: .8rem; }
.page-intro p { margin-top: .35rem; max-width: 68ch; }
.page-notice { margin: 0 0 .85rem; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .85rem; margin-bottom: 1rem; }
.metric { padding: 1.1rem 1.2rem; }
.metric.box + .metric.box { margin-top: 0; }
.metric dt { color: var(--muted); font-weight: 650; font-size: .84rem; }
.metric dd { margin: .4rem 0 0; font-size: clamp(1.25rem, 2.4vw, 1.85rem); font-weight: 760; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.metric dl { margin: 0; }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.overview-grid > .box { margin-top: 0; }
.setup-list { list-style: none; padding: 0; margin: 0; }
.setup-list li { display: grid; grid-template-columns: 2rem minmax(0, 1fr) auto; align-items: start; gap: .65rem; padding: .75rem 0; }
.setup-list li + li { border-top: 1px solid var(--border); }
.setup-list li a { font-weight: 700; text-decoration: none; }
.setup-list li a:hover { text-decoration: underline; }
.setup-list p { margin-top: .18rem; font-size: .86rem; }
.setup-index { display: grid; place-items: center; width: 1.9rem; height: 1.9rem; border-radius: 9px; color: var(--blue-dark); background: #eaf1fd; font-size: .84rem; font-weight: 760; }
.setup-list .done .setup-index { color: var(--success); background: #e4f4ed; }
.live-panel .form { margin-top: .35rem; }
.live-panel a { justify-self: start; }
.info-list { display: grid; gap: .5rem; margin: 0; }
.info-list > div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: .6rem; align-items: baseline; }
.info-list dt { color: var(--muted); font-size: .9rem; }
.info-list dd { margin: 0; overflow-wrap: anywhere; }

.table-wrap { max-width: 100%; overflow: auto; border: 1px solid var(--border); border-radius: 11px; }
table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: .89rem; }
.mobile-cell-label { display: none; }
th, td { text-align: left; vertical-align: top; padding: .73rem .8rem; border-bottom: 1px solid #e5edf5; overflow-wrap: anywhere; }
th { background: #eef3fb; color: #344965; font-size: .83rem; }
tr:last-child td { border-bottom: 0; }
td:nth-child(1) { font-variant-numeric: tabular-nums; }
td .actions { margin: 0; }
td .button { min-height: 36px; padding: .3rem .5rem; font-size: .81rem; }
td code { font-size: .87em; white-space: normal; }
.empty { padding: 1rem; border: 1px dashed var(--border); background: #f8faff; border-radius: 10px; color: var(--muted); }

form { margin: 0; }
.form { display: grid; gap: .9rem; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
label, legend { font-size: .92rem; font-weight: 700; }
label { display: grid; gap: .32rem; color: #263c59; }
small.help { display: block; font-weight: 400; }
input:not([type="checkbox"]), select, textarea { padding: .6rem .72rem; width: 100%; min-height: 46px; border: 1px solid #bfcddd; color: inherit; background: #fcfdff; border-radius: 9px; }
input[type="checkbox"] { accent-color: var(--blue); width: 1rem; height: 1rem; margin: 0; }
label.check { display: flex; align-items: center; gap: .45rem; font-weight: 500; }
fieldset { min-width: 0; border: 1px solid var(--border); border-radius: 10px; padding: .7rem .85rem; margin: 0; }
fieldset label + label { margin-top: .4rem; }
details { min-width: 0; }
summary { cursor: pointer; color: var(--blue-dark); font-weight: 700; }
details[open] > summary { margin-bottom: .85rem; }
code { font: .91em/1.5 "Cascadia Mono", Consolas, monospace; overflow-wrap: anywhere; }
.secret-list > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .4rem; align-items: end; }
.secret-list label { min-width: 0; }
.secret-list input { font-family: "Cascadia Mono", Consolas, monospace; }
dialog { width: min(520px, calc(100% - 2rem)); max-height: calc(100% - 2rem); overflow: auto; border: 1px solid var(--border); border-radius: var(--round); padding: 1.45rem; color: inherit; }
dialog::backdrop { background: #102b5099; }
dialog h2 { margin-bottom: .55rem; }
dialog .form-actions { margin-top: .85rem; }

@media (max-width: 960px) {
  .overview-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .app-layout { grid-template-columns: minmax(0, 1fr); gap: 1rem; padding: 1rem 1.1rem; }
  .sidebar { position: static; gap: .25rem; grid-template-columns: repeat(3, minmax(0,1fr)); padding: .45rem; }
  .nav-profile { display: none; }
  .nav-group { display: contents; }
  .nav-label { display: none; }
  .sidebar a { display: grid; place-items: center; padding: .45rem .25rem; text-align: center; }
  .sidebar a[aria-current="page"]::after { display: none; }
  .auth-layout { padding-block: 2rem; }
}
@media (max-width: 660px) {
  .header-inner { padding-inline: .65rem; min-height: 63px; }
  .brand-logo { width: 43px; height: 43px; }
  .brand { gap: .14rem; font-size: .84rem; }
  .brand small { font-size: .72rem; }
  .header-actions { gap: .18rem; }
  .header-actions .button { font-size: .77rem; padding: .4rem .5rem; }
  .auth-layout { grid-template-columns: 1fr; padding: 1rem; gap: .75rem; }
  .auth-heading { padding: 1.15rem 1.15rem; gap: .9rem; border-radius: 17px; }
  .auth-hero-copy::before { width: 1.75rem; margin-bottom: .65rem; }
  .auth-heading h1 { font-size: clamp(1.8rem, 8vw, 2.3rem); max-width: none; }
  .auth-heading p { font-size: .9rem; margin-top: .35rem; }
  .auth-modes { gap: .45rem; }
  .auth-modes > div { padding: .46rem .5rem; }
  .auth-modes dd { font-size: .74rem; }
  .box:not(.sidebar) { padding: .95rem; border-radius: 14px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .55rem; }
  .metric:last-child { grid-column: span 2; }
  .box-header { flex-wrap: wrap; }
  .page-intro { flex-wrap: wrap; }
  .page-intro h1 { font-size: 1.85rem; }
  .table-wrap { border-radius: 10px; }
  table { min-width: 0; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  tbody, tr { display: block; }
  tr { padding: .55rem .64rem; }
  tr + tr { border-top: 1px solid var(--border); }
  td { display: grid; grid-template-columns: minmax(5.4rem, .68fr) minmax(0, 1fr); align-items: start; gap: .5rem; padding: .28rem .15rem; border: 0; }
  .mobile-cell-label { display: inline; color: var(--muted); font-size: .79rem; font-weight: 650; }
  .input-row { align-items: stretch; flex-direction: column; }
}
.history-modes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
.history-mode { display: grid; gap: .12rem; padding: .65rem .85rem; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--navy); text-align: left; }
.history-mode:hover { border-color: #95b0d8; }
.history-mode[aria-pressed="true"] { border-color: var(--blue); background: #edf4ff; box-shadow: inset 0 0 0 1px var(--blue); }
.history-mode small { color: var(--muted); font-size: .83rem; }
.history-toolbar { display: flex; align-items: end; flex-wrap: wrap; gap: .5rem; }
.history-search { display: flex; flex-wrap: wrap; align-items: end; gap: .5rem; flex: 1 1 19rem; }
.history-search label { min-width: 0; flex: 1 1 13rem; }
.history-toolbar .button { min-height: 46px; }
.history-help { margin-top: -.5rem; font-size: .86rem; }
.history-empty { display: grid; gap: .4rem; justify-items: start; }
.history-empty strong { color: var(--navy); }
.history-empty p { max-width: 64ch; }
.history-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .25rem; }
@media (max-width: 420px) {
  .history-toolbar .button { min-height: 42px; }
  .history-search label { flex-basis: 100%; }
}
