:root {
    --bg: #0b1220;
    --panel: #111a2e;
    --card: rgba(255,255,255,0.06);
    --text: rgba(255,255,255,0.92);
    --muted: rgba(255,255,255,0.68);
    --border: rgba(255,255,255,0.12);
    --accent: #6ee7ff;
    --accent2: #a78bfa;
  }

  body {
    margin: 0;
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji","Segoe UI Emoji";
    background: radial-gradient(1000px 600px at 20% -10%, rgba(110,231,255,0.18), transparent 60%),
                radial-gradient(1000px 600px at 80% 0%, rgba(167,139,250,0.18), transparent 60%),
                var(--bg);
    color: var(--text);
  }

  .wrap {
    max-width: 980px;
    margin: 36px auto;
    padding: 0 18px 40px;
  }

  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
  }

  .brand {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .brand h1 {
    font-size: 24px;
    margin: 0;
    letter-spacing: 0.2px;
  }

  .brand p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
  }

  .back {
    color: var(--muted);
    text-decoration: none;
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(255,255,255,0.04);
  }

  .back:hover {
    border-color: rgba(255,255,255,0.22);
    color: var(--text);
  }

  .panel {
    background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
  }

  .grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 14px;
  }

  .card {
    grid-column: span 6;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
  }

  .card.full {
    grid-column: span 12;
  }

  .card h2 {
    margin: 0 0 8px;
    font-size: 15px;
    letter-spacing: 0.2px;
  }

  .card p {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
  }

  .card ul,
  
  .card ol {
    margin: 0 0 12px;
    padding-left: 18px;
    color: var(--muted);  
    font-size: 13px;
    line-height: 1.45;
  }

  .card li {
    margin: 6px 0;
  }

  .card ul {
    padding-left: 16px;
  }

  .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }

  .actions.compact {
    gap: 8px;
    margin-top: 12px;
  }

  .actions.cell {
    justify-content: flex-start;
  }

  .actions.inline {
    flex-wrap: nowrap;
  }

  .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.05);
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    white-space: nowrap;
    cursor: pointer;
  }

  .btn:hover {
    border-color: rgba(255,255,255,0.22);
    background: rgba(255,255,255,0.07);
  }

  .btn.primary {
    border-color: rgba(110,231,255,0.35);
    background: rgba(110,231,255,0.10);
  }

  .btn.danger {
    border-color: rgba(248,113,113,0.35);
    background: rgba(248,113,113,0.10);
  }

  code {
    background: rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.12);
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 12px;
  }

  .pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 12px;
    color: var(--muted);
    background: rgba(255,255,255,0.04);
  }

  .hint {
    color: var(--muted);
    font-size: 12px;
    margin-top: 10px;
  }

  .table-wrap {
    overflow-x: auto;
  }

  .table {
    width: 100%;
    table-layout: fixed; /* key: predictable column sizing */
    border-collapse: collapse;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
  }

  .table th, .table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    vertical-align: top;
    word-wrap: break-word;
  }

  .table th {
    background: rgba(255,255,255,0.06);
    color: var(--muted);
    font-weight: 600;
  }

  th.col-client { width: 28%; }
  th.col-realm  { width: 28%; }
  th.col-expiry { width: 14%; }
  th.col-status { width: 10%; }
  th.col-actions{ width: 20%; }

  [hidden] {
    display: none !important;
  }

  /* ---- Forms ---- */
  .field {
    display: grid;
    gap: 6px;
    margin-bottom: 12px;
    position: relative;
  }

  .field label {
    font-size: 13px;
    color: var(--muted);
  }

  .input, select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.04);
    color: var(--text);
    outline: none;
    font-size: 13px;
  }

  .input:focus, select:focus {
    border-color: rgba(110,231,255,0.35);
  }

  /* Section heading inside a form/card (e.g. "Reporting period"). */
  .section-title {
    margin: 18px 0 10px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    color: var(--accent);
  }

  /* Two date inputs side-by-side; collapses to one column on small screens. */
  .field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }

  .field-row .field {
    margin-bottom: 0;
  }

  /* Segmented period-type toggle (Date range / As of date). */
  .toggle-group {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: rgba(255,255,255,0.04);
  }

  .toggle {
    margin: 0;
    cursor: pointer;
  }

  .toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
  }

  .toggle span {
    display: inline-flex;
    align-items: center;
    padding: 9px 16px;
    font-size: 13px;
    color: var(--muted);
    user-select: none;
  }

  .toggle + .toggle span {
    border-left: 1px solid var(--border);
  }

  .toggle input:checked + span {
    background: rgba(110,231,255,0.12);
    color: var(--text);
  }

  .toggle input:focus-visible + span {
    outline: 2px solid rgba(110,231,255,0.5);
    outline-offset: -2px;
  }

  .mode-group {
    margin-top: 4px;
  }

  .period-mode {
    position: relative;
    margin-bottom: 16px;
  }

  .period-picker-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .period-tile {
    display: grid;
    gap: 8px;
    min-width: 0;
  }

  .period-kicker {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.2px;
  }

  .period-trigger {
    display: flex;
    width: 100%;
    min-height: 46px;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255,255,255,0.05);
    color: var(--text);
    text-align: left;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
  }

  .period-trigger:hover {
    border-color: rgba(110,231,255,0.28);
    background: rgba(255,255,255,0.07);
  }

  .period-trigger.readonly {
    cursor: default;
    color: rgba(255,255,255,0.78);
    background: rgba(255,255,255,0.035);
  }

  .period-trigger-icon {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 13px;
  }

  .date-popover {
    position: absolute;
    z-index: 20;
    top: calc(100% + 8px);
    left: 0;
    width: min(560px, 100%);
  }

  .date-popover-panel {
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 14px;
    background: rgba(17,26,46,0.98);
    box-shadow: 0 20px 44px rgba(0,0,0,0.38);
    padding: 14px;
  }

  .date-popover-panel.single {
    width: min(340px, 100%);
  }

  .date-popover-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
  }

  .date-popover-head h4 {
    margin: 0;
    font-size: 14px;
    letter-spacing: 0.1px;
  }

  .calendar-shell {
    display: grid;
    gap: 10px;
  }

  .calendar-toolbar {
    display: grid;
    grid-template-columns: 30px 1fr 30px;
    align-items: center;
    gap: 10px;
  }

  .calendar-month {
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
  }

  .calendar-weekdays,
  .calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
  }

  .calendar-weekdays span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-align: center;
  }

  .calendar-day {
    display: inline-flex;
    min-width: 0;
    height: 34px;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    user-select: none;
    touch-action: none;
  }

  .calendar-day:hover {
    border-color: rgba(110,231,255,0.26);
    background: rgba(255,255,255,0.06);
  }

  .calendar-day.empty {
    pointer-events: none;
  }

  .calendar-day.today {
    border-color: rgba(255,255,255,0.28);
  }

  .calendar-day.in-range {
    border-color: rgba(110,231,255,0.18);
    background: rgba(110,231,255,0.12);
  }

  .calendar-day.range-start,
  .calendar-day.range-end {
    border-color: rgba(110,231,255,0.52);
    background: rgba(110,231,255,0.24);
    color: #ffffff;
    font-weight: 700;
  }

  .calendar-selection {
    min-height: 18px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
  }

  .icon-btn {
    display: inline-flex;
    width: 30px;
    height: 30px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255,255,255,0.05);
    color: var(--text);
    cursor: pointer;
    font: inherit;
    line-height: 1;
  }

  .icon-btn:hover {
    border-color: rgba(255,255,255,0.24);
    background: rgba(255,255,255,0.08);
  }

  @media (max-width: 860px) {
    .card { grid-column: span 12; }
    .field-row { grid-template-columns: 1fr; }
    .period-picker-grid { grid-template-columns: 1fr; }
    .date-popover { position: static; width: 100%; margin-top: 10px; }
    .date-popover-panel.single { width: auto; }
  }

  /* ---- Status pills -------------------------------------------------- */
  /* status.html has referenced these three since it was written, but they
     were never defined — every pill rendered neutral grey, which is why the
     connection page could not be read at a glance. Defining them here fixes
     that page too. Colours are borrowed from .btn.primary / .btn.danger so
     the palette stays to the two accents already in use. */

  .pill-ok {
    border-color: rgba(110,231,255,0.35);
    background: rgba(110,231,255,0.10);
    color: var(--text);
  }

  .pill-expiring {
    border-color: rgba(251,191,36,0.40);
    background: rgba(251,191,36,0.12);
    color: #fde68a;
  }

  .pill-expired {
    border-color: rgba(248,113,113,0.40);
    background: rgba(248,113,113,0.12);
    color: #fca5a5;
  }

  /* ---- Review page --------------------------------------------------- */

  /* Summary chip strip. Wraps rather than scrolls: a chip pushed off-screen
     is a count nobody reads. */
  .chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 4px;
  }

  /* Money and other figures. tabular-nums keeps digits in a fixed grid so a
     column of balances lines up on the decimal even in a proportional font —
     without it, scanning for the odd one out is guesswork. */
  .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  /* Negative amounts. The parentheses in money() carry the meaning; colour is
     redundant reinforcement, so this stays readable in greyscale / for
     red-green colour blindness. */
  .neg {
    color: #fca5a5;
  }

  /* Second line inside a cell: drive path, source type. */
  .sub {
    color: var(--muted);
    font-size: 12px;
    margin-top: 2px;
    word-break: break-word;
  }

  .muted {
    color: var(--muted);
  }

  /* ISO dates are a fixed 10 characters. Left to wrap they break after the
     month and read as two different values stacked. */
  .nowrap {
    white-space: nowrap;
  }

  /* Column widths, scoped per table: .table is table-layout:fixed, so the
     first row's widths win, and both review tables use .col-file / .col-period
     for differently sized content.

     The page is 980px wide (.wrap), which is the real constraint here — it is
     why both tables were cut down to seven and six columns. Anything narrower
     than about 9% renders as a column of wrapped fragments. */
  .table.recon th.col-account { width: 20%; }
  .table.recon th.col-period  { width: 11%; }
  .table.recon th.col-money   { width: 12%; }
  .table.recon th.col-state   { width: 12%; }
  .table.recon th.col-why     { width: 21%; }

  .table.docs th.col-file   { width: 23%; }
  .table.docs th.col-inst   { width: 14%; }
  .table.docs th.col-period { width: 11%; }
  .table.docs th.col-money  { width: 14%; }
  .table.docs th.col-state  { width: 13%; }
  .table.docs th.col-why    { width: 25%; }
