:root {
  color-scheme: dark;
  --canvas: #141819;
  --sidebar: #111516;
  --surface: #1a2021;
  --raised: #202829;
  --line: #344142;
  --text: #eaf1ef;
  --muted: #a5b5b3;
  --accent: #75e1c9;
  --accent-bg: #1b3833;
  --warning: #ffb6a7;
  --mono: ui-monospace, "Cascadia Mono", "Liberation Mono", monospace;
  font: 15px/1.55 system-ui, sans-serif;
  background: var(--canvas);
  color: var(--text);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select { font: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(2rem, 4vw, 2.75rem); line-height: 1.1; letter-spacing: -.055em; }
h2 { font-size: 1.25rem; letter-spacing: -.025em; }
p + p { margin-top: .75rem; }
small, .muted { color: var(--muted); }
code, .mono, .pill, .topbar, .brand span, .table th, .field > span:first-child { font-family: var(--mono); }
code { overflow-wrap: anywhere; }
.skip { position: absolute; left: 1rem; top: -5rem; z-index: 5; padding: .75rem; background: var(--surface); }
.skip:focus { top: 1rem; }

.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--line); padding: 24px 16px; display: flex; flex-direction: column; gap: 32px; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 6px; }
.brand strong { display: block; font-size: 1.05rem; }
.brand span { display: block; color: var(--muted); font-size: .71rem; text-transform: uppercase; letter-spacing: .15em; }
nav { display: grid; gap: 4px; }
nav a { min-height: 44px; display: flex; align-items: center; gap: 11px; padding: 0 12px; border: 1px solid transparent; border-radius: 7px; text-decoration: none; color: var(--muted); }
nav a span { width: 18px; text-align: center; font-size: 1.15rem; }
nav a:hover, button:hover, .button:hover { background: var(--raised); color: var(--text); }
nav a[aria-current] { color: var(--accent); background: var(--accent-bg); border-color: #31544d; }
.identity { margin-top: auto; display: grid; padding: 16px 6px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.identity span { color: var(--muted); font-size: .82rem; }
.identity button { justify-self: start; margin-top: 10px; }
.topbar { min-height: 63px; padding: 8px clamp(18px, 4vw, 52px); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: .75rem; }
.workspace { max-width: 1510px; margin-inline: auto; padding: 34px clamp(18px, 4vw, 52px) 56px; }
.heading { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 26px; }
.heading p { color: var(--muted); margin-top: 9px; }
.notice { padding: 12px 16px; border: 1px solid #31544d; border-radius: 8px; background: var(--accent-bg); margin-bottom: 20px; overflow-wrap: anywhere; }
.notice.error { color: var(--warning); border-color: #75463e; background: #352522; }
.panel { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); margin-top: 18px; }
.panel-head, .empty, .panel-body { padding: 17px 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.empty { color: var(--muted); }
.table-wrap { overflow-x: auto; }
.table-wrap:focus-visible { outline-offset: -3px; }
.table { width: 100%; border-collapse: collapse; text-align: left; }
.table th, .table td { padding: 12px 18px; border-top: 1px solid var(--line); vertical-align: middle; }
.table th { color: var(--muted); font-size: .74rem; font-weight: 600; background: var(--sidebar); }
.table td { font-size: .91rem; }
.table td:last-child { white-space: normal; }
.table .numeric { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table td strong, .table td small { display: block; }
.table small { margin-top: 2px; }
.pill { display: inline-block; width: fit-content; border: 1px solid var(--line); border-radius: 99px; padding: 3px 9px; font-size: .72rem; color: var(--muted); white-space: nowrap; }
.pill.active { color: var(--accent); border-color: #31544d; background: var(--accent-bg); }
.balance { margin-block: 4px 8px; font-size: clamp(1.3rem, 4vw, 2.1rem); letter-spacing: -.04em; }
.origin-list { padding-left: 1.25rem; margin-bottom: 0; }
.search { width: min(100%, 330px); }
.search input { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
button, .button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 13px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--text); text-decoration: none; cursor: pointer; }
.primary { background: var(--accent); color: #102420; border-color: var(--accent); font-weight: 700; }
.primary:hover { background: #a6f2e1; color: #102420; }
.quiet { background: transparent; }
.danger { color: var(--warning); }
button:disabled { opacity: .55; cursor: wait; }
input:not([type="checkbox"]), select { min-height: 44px; width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 7px; background: var(--canvas); color: var(--text); padding: 8px 11px; }
input::placeholder { color: var(--muted); }
input[type="checkbox"] { accent-color: var(--accent); }

dialog { width: min(720px, calc(100% - 28px)); max-height: calc(100% - 28px); padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); }
dialog::backdrop { background: #080c0dd6; }
#editor-form { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
.dialog-header, .dialog-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; }
.dialog-header { border-bottom: 1px solid var(--line); }
.dialog-footer { border-top: 1px solid var(--line); flex-wrap: wrap; }
.dialog-footer .actions { margin-left: auto; }
#dialog-status { color: var(--muted); overflow-wrap: anywhere; }
#dialog-status.error { color: var(--warning); }
#dialog-close { min-width: 44px; font-size: 1.4rem; }
.dialog-fields { padding: 18px 20px; overflow: auto; display: grid; gap: 14px; }
.field { display: grid; gap: 5px; align-content: start; }
.field > span:first-child { color: var(--muted); font-size: .79rem; }
.field:has(input[type="checkbox"]) { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.fields-grid { display: grid; grid-template-columns: repeat(2,minmax(0, 1fr)); gap: 12px; }
fieldset { min-inline-size: 0; border: 1px solid var(--line); border-radius: 8px; margin: 0; padding: 12px; }
legend { padding: 0 6px; font-weight: 600; }
.route-list, .route-fields { display: grid; gap: 12px; }
.formats { display: flex; flex-wrap: wrap; gap: 0 14px; }
.formats .field { min-height: 44px; }
.route-list + p { margin-top: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#silent-sso { display: none; }

@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0,1fr); }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 16px; gap: 12px; }
  nav { display: flex; flex-wrap: wrap; }
  nav a { padding-inline: 8px; gap: 6px; }
  .identity { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-top: 0; padding-top: 6px; }
  .identity button { margin: 0 0 0 auto; }
  .workspace { padding-top: 22px; }
  .table th, .table td { padding-inline: 12px; }
}
@media (max-width: 440px) {
  .heading { align-items: start; flex-direction: column; }
  .fields-grid { grid-template-columns: minmax(0,1fr); }
  .dialog-header, .dialog-footer, .dialog-fields { padding-inline: 14px; }
}
