:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0e1116;
  color: #eef2f6;
  --panel: #171c23;
  --panel-2: #11161d;
  --line: #2d3744;
  --muted: #a8b3c2;
  --accent: #37a6ff;
  --ok: #49d17c;
  --warn: #ffbe55;
  --bad: #ff6b6b;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; background: #0e1116; }
button, input, select, textarea { font: inherit; }
button {
  min-height: 36px; border: 1px solid #465668; border-radius: 6px; padding: 0 14px;
  color: #eef2f6; background: #1d2631; cursor: pointer;
}
button:hover { border-color: var(--accent); }
button:disabled { cursor: not-allowed; opacity: .45; }
button.danger { border-color: #82404a; color: #ffb7be; }
input, select, textarea {
  width: 100%; min-height: 38px; border: 1px solid #465668; border-radius: 6px; padding: 8px 10px;
  color: #eef2f6; background: #0d1218;
}
textarea { resize: vertical; line-height: 1.4; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 20px 28px; border-bottom: 1px solid var(--line); background: #111720;
}
.eyebrow { margin: 0 0 4px; color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: 0; text-transform: uppercase; }
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 24px; }
h2 { font-size: 17px; }
.session-actions { display: flex; align-items: center; gap: 10px; }
.environment { padding: 5px 8px; border: 1px solid var(--line); border-radius: 4px; color: var(--accent); text-transform: uppercase; font-size: 12px; font-weight: 700; }
.session-name { color: var(--muted); font-size: 13px; }
main { display: grid; gap: 18px; padding: 22px 28px 36px; }
.session-notice {
  padding: 14px 16px;
  border: 1px solid #8f6b2d;
  border-left: 4px solid var(--warn);
  border-radius: 6px;
  color: #eef2f6;
  background: #261f14;
  font-weight: 650;
}
.view-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); }
.view-tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent; }
.view-tabs button.active { border-bottom-color: var(--accent); color: var(--accent); }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric { display: grid; gap: 8px; padding: 16px; border: 1px solid var(--line); background: var(--panel); }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { font-size: 26px; line-height: 1; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-items: start; }
.workspace > * { min-width: 0; }
.inline-filter { display: flex; align-items: center; grid-auto-flow: column; gap: 8px; }
.inline-filter select { min-width: 150px; }
.muted-action, .empty-state { color: var(--muted); }
.empty-state { padding: 18px; text-align: center; }
.operations-view { display: grid; gap: 18px; }
.operations-toolbar { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; padding: 14px; border: 1px solid var(--line); background: var(--panel); }
.operations-toolbar label { min-width: 170px; }
.form-section, .records-section { border: 1px solid var(--line); background: var(--panel); }
.section-head { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; padding: 16px; }
.form-grid > * { min-width: 0; }
.form-grid p { margin: 4px 0; line-height: 1.5; }
label { display: grid; align-content: start; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 650; }
.wide { grid-column: 1 / -1; }
.toggle { display: flex; align-items: center; gap: 9px; min-height: 36px; }
.toggle input { width: 18px; min-height: 18px; }
.contact-preview { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; }
.form-actions { display: flex; justify-content: flex-end; padding-top: 3px; }
.table-wrap { overflow-x: auto; }
.table-wrap:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 12px; border-bottom: 1px solid #25303c; text-align: left; vertical-align: top; overflow-wrap: anywhere; }
th { color: var(--muted); background: #151b23; }
.actions { min-width: 170px; }
.actions button { min-height: 30px; margin: 0 6px 6px 0; padding: 0 9px; font-size: 12px; }
.member-records-table, .removal-records-table { min-width: 960px; }
.membership-requests-table { min-width: 760px; }
.member-records-table th, .membership-requests-table th, .removal-records-table th { white-space: nowrap; overflow-wrap: normal; }
.member-records-table td, .membership-requests-table td, .removal-records-table td { overflow-wrap: break-word; }
.member-records-table td:nth-child(2), .membership-requests-table td:nth-child(2) { min-width: 180px; max-width: 360px; overflow-wrap: anywhere; }
.member-records-table td:nth-child(3), .member-records-table td:nth-child(4), .member-records-table td:nth-child(5),
.membership-requests-table td:nth-child(3), .membership-requests-table td:nth-child(4),
.removal-records-table td:nth-child(4), .removal-records-table td:nth-child(5), .removal-records-table td:last-child { white-space: nowrap; overflow-wrap: normal; }
.membership-requests > summary { min-height: 58px; padding: 17px 14px; background: var(--panel-2); cursor: pointer; font-size: 17px; font-weight: 700; }
.membership-requests[open] > summary { border-bottom: 1px solid var(--line); }
.membership-requests > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.requests-content { padding: 0 16px; }
.requests-content p { line-height: 1.5; }
.requests-content > p:first-child { color: var(--muted); }
.pill { display: inline-flex; align-items: center; min-height: 24px; padding: 0 8px; border-radius: 4px; color: #081018; background: var(--muted); font-size: 11px; font-weight: 750; text-transform: capitalize; white-space: nowrap; }
.pill.ok { background: var(--ok); }
.pill.warn { background: var(--warn); }
.pill.bad { background: var(--bad); }
pre { min-height: 160px; max-height: 420px; margin: 0; padding: 15px; overflow: auto; color: #c6d1dd; background: #0c1117; font-size: 12px; }
dialog { width: min(680px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 8px; color: #eef2f6; background: var(--panel); }
dialog::backdrop { background: rgb(0 0 0 / 70%); }
dialog label { padding: 16px; }
.dialog-guidance { margin: 0; padding: 16px 16px 0; color: var(--muted); line-height: 1.5; }
.dialog-actions { display: flex; justify-content: end; padding: 0 16px 16px; }
#toast { position: fixed; right: 22px; bottom: 22px; max-width: min(440px, calc(100vw - 44px)); padding: 11px 14px; border: 1px solid #4a6075; border-radius: 6px; background: #182430; opacity: 0; transform: translateY(8px); pointer-events: none; transition: 140ms ease; }
#toast.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 960px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 620px) {
  .topbar { display: grid; align-items: start; padding: 16px; }
  .session-actions { width: 100%; flex-wrap: wrap; justify-content: start; }
  .session-name { display: none; }
  main { padding: 16px; }
  .summary-grid, .form-grid { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  .section-head { align-items: start; justify-content: flex-start; flex-wrap: wrap; }
  .section-head h2 { flex: 1 1 140px; }
  .section-head button { flex: 0 1 auto; max-width: 100%; }
  .contact-preview { align-items: stretch; flex-direction: column; }
  .form-actions, #createOnboarding { width: 100%; }
}

#serviceNumberForm { padding: 20px; }
#serviceNumberForm .dialog-guidance, #serviceNumberForm label { padding: 0; }
#serviceNumberForm .dialog-actions { padding: 0; gap: 8px; flex-wrap: wrap; }
#serviceNumberStatus { line-height: 1.5; }
