:root {
  color-scheme: dark;
  --night: #07111f;
  --deep: #11152f;
  --panel: rgba(13, 26, 48, .88);
  --panel-strong: #10243c;
  --line: #2c3c50;
  --text: #f8f8ff;
  --muted: #95a9bd;
  --cyan: #67b7ff;
  --pink: #67b7ff;
  --sun: #ffb347;
  --mint: #62f7c1;
  --red: #ff718a;
}
* { box-sizing: border-box; }
nav.app-navbar { align-items: center; justify-content: flex-start; gap: 20px; padding: 14px 28px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; background: #111e2e; }
.app-brand { font-size: 22px; font-weight: 850; white-space: nowrap; }
.app-brand small { display: block; color: var(--muted); font-size: 10px; font-weight: 500; text-transform: uppercase; }
.nav-section, .nav-account { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.nav-section { border-left: 1px solid var(--line); padding-left: 16px; }
.nav-site { color: var(--muted); font-size: 12px; font-weight: 700; padding-right: 8px; }
.nav-account { margin-left: auto; }
nav.app-navbar a { border-radius: 5px; font-size: 13px; }
nav.app-navbar a.active { background: #245683; box-shadow: none; }
nav.app-navbar a:hover { background: #263a50; color: white; }
nav.app-navbar a:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
@media (max-width: 850px) {
  nav.app-navbar { gap: 12px; padding: 12px 16px; }
  .nav-section { flex-basis: 100%; border-left: 0; padding-left: 0; }
  .nav-account { margin-left: 0; }
}
body {
  margin: 0;
  min-height: 100vh;
  background: #0c1420;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
}
body::before {
  display: none;
  content: "";
  position: fixed;
  z-index: -1;
  width: 290px;
  height: 290px;
  right: 8vw;
  top: -150px;
  border-radius: 50%;
  background: linear-gradient(#ffce63, #ff4f9a 55%, #7c3cff);
  filter: blur(.2px);
  opacity: .8;
  box-shadow: 0 0 80px rgba(255,79,184,.3);
}
.shell { max-width: none; margin: 0; padding: 42px 28px 70px; }
header { display: flex; align-items: end; justify-content: space-between; gap: 26px; margin-bottom: 30px; }
.eyebrow { color: var(--cyan); font-size: 11px; font-weight: 900; letter-spacing: .12em; margin: 0 0 9px; }
h1 { font-size: 44px; line-height: 1; margin: 0 0 10px; letter-spacing: -.045em; }
h2 { margin: 0 0 9px; font-size: 25px; }
.muted { color: var(--muted); margin: 0; }
.header-actions { display: grid; justify-items: end; gap: 12px; }
nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; padding: 4px; border: 1px solid var(--line); border-radius: 20px; background: rgba(5,13,28,.55); }
nav a { padding: 8px 11px; border-radius: 999px; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 750; }
nav a.active { background: linear-gradient(100deg, rgba(77,232,255,.2), rgba(255,79,184,.2)); color: white; box-shadow: inset 0 0 0 1px rgba(77,232,255,.18); }
nav form { display: flex; margin: 0; }
nav .logout-button { padding: 8px 11px; border-radius: 999px; background: transparent; box-shadow: none; color: var(--red); font-size: 12px; font-weight: 750; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 28px; }
.login-card { width: min(440px, 100%); padding: 34px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 24px 70px rgba(0,0,0,.3); backdrop-filter: blur(14px); }
.login-card .muted { margin-bottom: 24px; }
.login-form { display: grid; gap: 16px; }
.login-form label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 750; }
.login-form input { width: 100%; }
.controls { display: flex; align-items: center; gap: 10px; }
.controls label { color: var(--muted); font-size: 13px; }
.controls select, .controls button, input, textarea, .transaction-form select { border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; font: inherit; }
.controls select, input, textarea, .transaction-form select { background: rgba(6,18,35,.9); color: var(--text); }
button { border: 0; border-radius: 6px; padding: 11px 15px; font: inherit; background: #2874b2; color: white; font-weight: 700; cursor: pointer; box-shadow: none; }
button.secondary { background: transparent; color: var(--pink); border: 1px solid rgba(255,79,184,.35); box-shadow: none; }
button.compact { padding: 6px 10px; font-size: 11px; }
.summary { display: grid; grid-template-columns: 1.25fr .7fr 1fr; gap: 14px; margin-bottom: 16px; }
.summary article, .table-card, .hierarchy-card, .alert, .formula-guide, .rule-card, .notice { background: var(--panel); border: 1px solid var(--line); border-radius: 17px; box-shadow: 0 18px 45px rgba(0,0,0,.18); backdrop-filter: blur(14px); }
.summary article { padding: 20px 22px; position: relative; overflow: hidden; }
.adjustment-log { margin-bottom: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 17px; overflow: hidden; box-shadow: 0 18px 45px rgba(0,0,0,.18); }
.adjustment-log > summary { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 20px; cursor: pointer; list-style: none; }
.adjustment-log > summary::-webkit-details-marker { display: none; }
.adjustment-log > summary small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.adjustment-log[open] > summary { border-bottom: 1px solid var(--line); background: linear-gradient(90deg, rgba(77,232,255,.05), rgba(255,79,184,.05)); }
.adjustment-count { flex: 0 0 auto; padding: 4px 11px; border-radius: 999px; background: rgba(77,232,255,.12); border: 1px solid rgba(77,232,255,.28); color: var(--cyan); font-size: 12px; font-weight: 900; }
.adjustment-log th { position: static; }
.adjustment-when { color: var(--muted); font-variant-numeric: tabular-nums; }
.adjustment-when small { display: block; font-size: 10px; }
.refresh-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.refresh-card form { flex: 0 0 auto; }
.summary article:first-child::after { content: ""; position: absolute; inset: auto 0 0; height: 2px; background: linear-gradient(90deg, var(--cyan), var(--pink)); }
.summary span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.summary strong { font-size: 27px; }
.summary strong.small { font-size: 16px; }
.hierarchy-intro { display: grid; grid-template-columns: .55fr 1.45fr; gap: 14px; margin-bottom: 16px; }
.hierarchy-intro > div { padding: 18px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 15px; }
.hierarchy-intro span, .hierarchy-name small, .hierarchy-net small { display: block; color: var(--muted); font-size: 11px; }
.hierarchy-intro strong { display: block; margin-top: 6px; font-size: 18px; }
.hierarchy-card { overflow: hidden; }
.hierarchy-card-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; padding: 22px; border-bottom: 1px solid var(--line); }
.hierarchy-card-heading h2 { margin-bottom: 0; }
.hierarchy-tree { width: 100%; max-width: none; padding: 15px 22px 24px; }
.hierarchy-node summary { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; align-items: center; gap: 11px; min-height: 48px; cursor: pointer; list-style: none; padding: 6px 10px; border-radius: 9px; }
.hierarchy-node summary::-webkit-details-marker { display: none; }
.hierarchy-node summary:hover { background: rgba(77,232,255,.05); }
.hierarchy-toggle { width: 7px; height: 7px; border-right: 1px solid var(--cyan); border-bottom: 1px solid var(--cyan); transform: rotate(-45deg); transition: transform .15s ease; }
.hierarchy-node[open] > summary .hierarchy-toggle { transform: rotate(45deg) translate(-1px, -1px); }
.hierarchy-name strong { letter-spacing: .025em; }
.hierarchy-name small { margin-top: 3px; }
.hierarchy-name i { color: var(--sun); margin-left: 5px; }
.hierarchy-net { text-align: right; font-variant-numeric: tabular-nums; }
.hierarchy-net strong { display: block; margin-top: 2px; font-size: 16px; }
.hierarchy-children { margin-left: 13px; padding-left: 20px; border-left: 1px solid rgba(77,232,255,.2); }
.hierarchy-leaf { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; min-height: 45px; padding: 5px 10px 5px 29px; color: #c8d9e4; font-size: 13px; font-variant-numeric: tabular-nums; position: relative; }
.hierarchy-leaf::before { content: ""; position: absolute; left: 0; width: 18px; border-top: 1px solid rgba(77,232,255,.2); }
.hierarchy-leaf.own-account { color: var(--muted); }
.hierarchy-agent > summary { margin-left: -1px; }
.hierarchy-customers { padding-bottom: 5px; }
.hierarchy-customer { min-height: 42px; }
.hierarchy-customer .hierarchy-name strong { color: #d9e9f2; font-weight: 750; }
.hierarchy-customer .hierarchy-name small { font-size: 10px; }
.table-card { overflow: hidden; }
.table-wrap { overflow: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 15px 16px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; font-size: 13px; }
th { color: #8dc7d2; font-size: 10px; text-transform: uppercase; letter-spacing: .09em; background: rgba(5,16,31,.92); position: sticky; top: 0; }
th:first-child, td:first-child, th:nth-child(4), td:nth-child(4), th:last-child, td:last-child { text-align: left; }
/* The figures table gained an Adjustments column at 4, pushing Rule to 5. */
.figures-table th:nth-child(4), .figures-table td:nth-child(4) { text-align: right; }
.figures-table th:nth-child(5), .figures-table td:nth-child(5) { text-align: left; }
/* Larger monetary values on AcesHigh only; keep names and rule labels compact. */
.aceshigh-figures-table td:not(:first-child):not(:nth-child(5)) {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
}
.aceshigh-figures-table td:nth-child(12),
.aceshigh-figures-table td:nth-child(13) {
  font-size: 18px;
  font-weight: 700;
}
.adjustment-cell .muted { color: rgba(149,169,189,.45); }
.agent { font-weight: 900; letter-spacing: .03em; color: white; }
.agent i { color: var(--sun); margin-left: 6px; }
.agent-toggle { display: inline-flex; align-items: center; margin-right: 9px; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; color: white; font: inherit; font-weight: 900; letter-spacing: .03em; }
.agent-toggle span { color: var(--cyan); font-size: 18px; line-height: 1; width: 10px; }
.agent-transaction-link { color: inherit; font-weight: 900; text-decoration: none; }
.agent-transaction-link:hover { color: var(--cyan); text-decoration: underline; text-underline-offset: 3px; }
.share-agent { margin-left: 7px; padding: 3px 6px; border: 1px solid rgba(77,232,255,.35); border-radius: 6px; background: rgba(77,232,255,.08); color: var(--cyan); font-size: 10px; font-weight: 800; letter-spacing: 0; vertical-align: middle; cursor: pointer; }
.share-agent:hover { background: rgba(77,232,255,.18); }
.agent-master-row { background: rgba(77,232,255,.045); }
.agent-child-row { background: rgba(5,16,31,.35); }
.agent-child-name { display: inline-block; padding-left: 25px; color: #c8dce7; }
.rule { background: #1b2b3d; border: 1px solid var(--line); border-radius: 4px; padding: 5px 9px; color: #caeaf0; }
.latest-xfer { display: block; margin-top: 4px; font-size: 11px; color: var(--muted); }
.mine { color: var(--mint); font-weight: 900; text-shadow: 0 0 14px rgba(98,247,193,.25); }
.positive { color: var(--mint); }
.negative { color: var(--red); }
footer { padding: 14px 16px; color: var(--muted); font-size: 12px; }
.alert, .notice { padding: 16px 18px; color: var(--red); margin-bottom: 16px; display: flex; gap: 10px; }
.notice.success { color: var(--mint); }
.agent-portal-shell { max-width: none; }
.agent-locked, .agent-rule { padding: 34px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 24px 70px rgba(0,0,0,.25); }
.agent-locked { text-align: center; }
.agent-figure-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.agent-figure-grid article { min-height: 132px; padding: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: 17px; display: grid; align-content: space-between; }
.agent-figure-grid span, .agent-rule span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.agent-figure-grid strong { display: block; margin-top: 20px; font-size: 25px; }
.agent-final-balance { background: linear-gradient(130deg, rgba(77,232,255,.12), rgba(255,79,184,.11)) !important; }
.agent-rule { margin-top: 14px; padding: 22px; }
.agent-rule strong { display: block; margin-top: 8px; }
.admin-shell { max-width: none; }
.back-link { display: inline-flex; align-items: center; gap: 7px; margin-bottom: 14px; padding: 7px 13px; border: 1px solid var(--line); border-radius: 999px; background: rgba(5,13,28,.55); color: var(--muted); font-size: 12px; font-weight: 750; text-decoration: none; }
.back-link:hover { border-color: rgba(77,232,255,.42); color: var(--text); }
.back-link span { color: var(--cyan); font-size: 14px; line-height: 1; }
.admin-section, .credential-reveal { margin-bottom: 16px; padding: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: 17px; box-shadow: 0 18px 45px rgba(0,0,0,.18); }
.admin-section-heading, .credential-reveal { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.admin-section-heading { margin-bottom: 18px; }
.admin-section-heading.compact-heading { align-items: end; gap: 12px; }
.admin-section-heading.compact-heading .muted { max-width: 260px; text-align: right; font-size: 12px; }
.admin-section-heading h2, .credential-reveal h2 { margin-bottom: 0; }
.credential-reveal { border-color: rgba(98,247,193,.42); background: linear-gradient(110deg, rgba(77,232,255,.10), rgba(98,247,193,.09)); }
.credential-values { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.credential-values span { display: grid; gap: 4px; }
.credential-values small { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.credential-values code { padding: 9px 11px; border-radius: 8px; background: rgba(4,15,28,.8); color: var(--mint); font-size: 15px; }
.account-actions { display: flex; justify-content: flex-end; gap: 7px; }
.account-actions form { margin: 0; }
.admin-empty-state { padding: 24px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted); text-align: center; }
.access-console { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) minmax(0, 1fr) auto; align-items: end; gap: 14px 16px; padding: 18px; border: 1px solid var(--line); border-radius: 14px; background: rgba(5,16,31,.42); }
.console-step { display: grid; gap: 8px; min-width: 0; }
.console-step label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 800; }
.console-step label b { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: linear-gradient(110deg, var(--cyan), #6fffd2); color: #071727; font-size: 11px; font-weight: 900; }
.console-step label small { color: rgba(149,169,189,.75); font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .08em; }
.console-step select, .console-step input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; background: rgba(6,18,35,.9); color: var(--text); font: inherit; font-size: 13px; }
.console-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.console-status { grid-column: 1 / -1; min-height: 16px; margin: 0; padding-top: 13px; border-top: 1px solid rgba(90,228,255,.12); color: var(--muted); font-size: 12px; }
.admin-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.admin-stats article { padding: 16px 18px; border: 1px solid var(--line); border-radius: 15px; background: rgba(5,16,31,.36); }
.admin-stats span { display: block; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.admin-stats strong { display: block; margin: 9px 0 7px; font-size: 26px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.admin-stats strong i { margin-left: 6px; color: var(--muted); font-size: 13px; font-style: normal; font-weight: 750; }
.admin-stats small { font-size: 11px; }
.inline-actions { display: flex; gap: 7px; margin: 0; }
.access-state { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 800; }
.access-state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px currentColor; }
.access-state.is-allowed { color: var(--mint); }
.access-state.is-locked, .access-state.is-disabled { color: var(--red); }
.access-state.is-unconfigured { color: var(--muted); }
.agent-control-center { padding-bottom: 8px; }
.directory-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 20px 0 12px; }
.directory-bar input { width: 220px; padding: 8px 11px; border-radius: 10px; font-size: 12px; }
.bulk-actions { display: flex; gap: 7px; }
.filter-empty { margin-top: 12px; }
.access-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(212px, 1fr)); gap: 10px; }
.access-tile { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(5,16,31,.36); }
.access-tile.is-on { border-color: rgba(98,247,193,.34); background: rgba(98,247,193,.06); }
.access-tile strong { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 900; letter-spacing: .03em; color: white; }
.access-tile form { flex: 0 0 auto; }
.login-section .admin-section-heading .muted { max-width: 420px; }
.login-section .admin-section-heading code { color: var(--cyan); font-size: 11px; }
.login-console { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
.login-console + .table-wrap { margin-top: 18px; border: 1px solid var(--line); border-radius: 12px; }
.login-section .admin-empty-state { margin-top: 18px; }
.login-portal { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; padding: 13px 16px; border: 1px solid rgba(77,232,255,.3); border-radius: 12px; background: rgba(77,232,255,.06); }
.login-portal small { display: block; margin-bottom: 5px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.login-portal code { color: var(--cyan); font-size: 14px; font-weight: 750; overflow-wrap: anywhere; }
.agent-control-center .table-wrap { border: 1px solid var(--line); border-radius: 12px; }
.agent-control-table { min-width: 850px; }
.agent-control-table th { position: static; }
.agent-control-table th, .agent-control-table td { padding: 12px 14px; text-align: left; }
.agent-control-table th span, .agent-control-table th small { display: block; }
.agent-control-table th small { margin-top: 4px; color: var(--muted); font-size: 10px; letter-spacing: 0; }
.agent-control-table tr:last-child td { border-bottom: 0; }
.agent-week-access form { display: inline-block; margin: 0 0 0 10px; }
.login-username { display: block; margin-bottom: 6px; color: #dcecf4; }
.agent-control-table .account-actions { min-width: 315px; }
.agent-control-table .account-actions form { display: inline-block; margin: 0 7px 0 0; }
.danger { color: var(--red) !important; border-color: rgba(255,113,138,.4) !important; }
.formula-guide { display: grid; grid-template-columns: 1fr 1.6fr; gap: 20px; padding: 24px; margin-bottom: 18px; }
.formula-guide p { color: var(--muted); line-height: 1.55; }
.formula-guide code, .chips code { color: var(--cyan); background: rgba(77,232,255,.08); border: 1px solid rgba(77,232,255,.14); border-radius: 7px; padding: 4px 7px; }
.chips { display: flex; align-content: start; flex-wrap: wrap; gap: 7px; }
.formula-help { grid-column: 1 / -1; margin: 0; }
.transaction-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, .7fr); gap: 16px; margin-bottom: 16px; }
.transaction-form, .transaction-help { background: var(--panel); border: 1px solid var(--line); border-radius: 17px; padding: 22px; }
.transaction-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.transaction-form select, .transaction-form input { width: 100%; }
.form-balance-preview { min-height: 39px; margin: -7px 0 8px; padding: 7px 9px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid rgba(77,232,255,.22); border-radius: 10px; background: rgba(77,232,255,.06); }
.form-balance-preview span { min-width: 0; }
.form-balance-preview small { display: block; color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; }
.form-balance-preview strong { display: block; margin-top: 2px; font-size: 17px; overflow-wrap: anywhere; }
.form-balance-preview button { flex: 0 0 auto; }
.form-balance-actions { display: flex; align-items: center; gap: 7px; }
.settlement-preview > span { flex: 1 1 150px; }
.transaction-help p { color: var(--muted); line-height: 1.5; }
.transaction-help strong { color: var(--text); }
.transaction-history .voided { opacity: .48; text-decoration: line-through; }
.ledger-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 28px 0 14px; }
.ledger-heading h2 { margin-bottom: 0; }
.board-filter { display: flex; align-items: center; gap: 12px; }
.board-filter input { width: 320px; max-width: 46vw; }
.board-filter span { font-size: 12px; white-space: nowrap; }
.board th { font-size: 10px; }
.board td { font-size: 12px; vertical-align: top; padding: 12px 12px; }
.board .crypto-details { min-width: 0; max-width: 230px; white-space: normal; }
.board .crypto-details code { font-size: 11px; }
.board .worker-note { max-width: 190px; white-space: normal; text-align: left; }
.board td.agent { font-weight: 900; letter-spacing: .03em; color: white; }
.board .txn-id { display: block; margin-top: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; font-weight: 400; letter-spacing: 0; color: var(--muted); }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 14px 16px; border-top: 1px solid var(--line); }
.pager:empty { display: none; }
.pager span { font-size: 12px; }
.board .voided { opacity: .48; text-decoration: line-through; }
.agent-ledger-list { display: grid; gap: 12px; }
.agent-ledger { background: var(--panel); border: 1px solid var(--line); border-radius: 17px; overflow: hidden; box-shadow: 0 18px 45px rgba(0,0,0,.18); }
.agent-ledger > summary { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 17px 20px; cursor: pointer; list-style: none; }
.agent-ledger > summary::-webkit-details-marker { display: none; }
.agent-ledger > summary b { font-size: 17px; letter-spacing: .03em; }
.agent-ledger > summary small { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; }
.agent-ledger[open] > summary { border-bottom: 1px solid var(--line); background: linear-gradient(90deg, rgba(77,232,255,.05), rgba(255,79,184,.05)); }
.ledger-current { text-align: right; }
.ledger-current strong { display: block; margin-top: 3px; font-size: 18px; }
.ledger-content { padding: 18px 20px 22px; }
.ledger-content h3 { margin: 4px 0 10px; font-size: 14px; color: #cbe8ee; }
.ledger-content .table-wrap + h3 { margin-top: 24px; }
.ledger-content .table-wrap { border: 1px solid var(--line); border-radius: 12px; }
.ledger-content th { position: static; }
.ledger-content .voided { opacity: .48; text-decoration: line-through; }
/* Never make this a flex container: a <td> that is not display:table-cell
   drops out of its row and the buttons drift away from their transaction. */
.transaction-actions { white-space: nowrap; }
.transaction-actions form { display: inline-block; margin: 0; vertical-align: middle; }
.transaction-actions form + form { margin-left: 7px; }
.transaction-actions .danger { border-color: rgba(255, 92, 122, .5); color: var(--negative); }
.crypto-details { min-width: 240px; }
.crypto-details strong, .crypto-details span { display: block; margin-bottom: 4px; }
.crypto-details span { color: var(--muted); font-size: 12px; }
.crypto-details code { color: var(--cyan); overflow-wrap: anywhere; word-break: break-all; }
.rule-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.rule-card { overflow: hidden; }
.rule-card summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; }
.rule-card summary::-webkit-details-marker { display: none; }
.rule-card summary b { display: block; font-size: 17px; }
.rule-card summary small { display: block; color: var(--muted); margin-top: 4px; }
.share-preview { color: var(--pink); font-family: ui-monospace, monospace; font-weight: 800; }
.rule-card[open] summary { border-bottom: 1px solid var(--line); background: linear-gradient(90deg, rgba(77,232,255,.06), rgba(255,79,184,.06)); }
.rule-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 20px; }
.field label { display: block; color: var(--muted); font-size: 12px; font-weight: 750; margin-bottom: 7px; }
.field input, .field textarea { width: 100%; }
.field textarea { min-height: 88px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.45; color: #baf5ff; }
.span-2 { grid-column: 1 / -1; }
.toggle { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.toggle input { accent-color: var(--pink); width: 17px; height: 17px; }
.form-actions { display: flex; justify-content: space-between; gap: 10px; padding-top: 5px; }
@media (max-width: 980px) {
  .rule-grid { grid-template-columns: 1fr; }
  .formula-guide { grid-template-columns: 1fr; }
  .formula-help { grid-column: auto; }
  .access-console, .login-console { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .console-actions { grid-column: 1 / -1; }
  .admin-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .shell { padding: 28px 14px; }
  header { align-items: stretch; flex-direction: column; }
  h1 { font-size: 36px; }
  .header-actions { justify-items: stretch; }
  nav { align-self: start; }
  .controls { display: grid; grid-template-columns: auto 1fr; }
  .controls button { grid-column: 1 / -1; }
  .summary { grid-template-columns: 1fr; }
  .agent-figure-grid { grid-template-columns: 1fr; }
  .admin-section-heading, .credential-reveal { align-items: stretch; flex-direction: column; }
  .admin-section-heading.compact-heading .muted { max-width: none; text-align: left; }
  .access-console, .login-console { grid-template-columns: 1fr; }
  .admin-stats { grid-template-columns: 1fr; }
  .directory-bar { align-items: stretch; flex-direction: column; }
  .directory-bar input { width: 100%; }
  .hierarchy-intro { grid-template-columns: 1fr; }
  .hierarchy-card-heading { align-items: start; flex-direction: column; }
  .hierarchy-tree { padding-left: 10px; padding-right: 10px; }
  .hierarchy-children { margin-left: 5px; padding-left: 9px; }
  .hierarchy-net small { display: none; }
  .rule-form { grid-template-columns: 1fr; }
  .transaction-layout, .transaction-form { grid-template-columns: 1fr; }
  .ledger-heading { align-items: start; flex-direction: column; }
  .span-2 { grid-column: auto; }
}

/* Responsive spacing and controls, retaining the existing dark palette. */
.admin-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.admin-tabs button { min-height: 48px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); }
.admin-tabs button[aria-selected="true"] { background: #245683; color: white; }
.admin-section[hidden], .access-tile[hidden] { display: none; }
.access-overview { color: var(--muted); padding: 12px 0; }
.access-console-section .access-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.access-console-section .access-tile { border-radius: 10px; padding: 18px; background: #0c1929; border: 1px solid var(--line); min-width: 0; gap: 12px; flex-wrap: wrap; }
.access-console-section .access-tile.is-on { border-left: 3px solid var(--mint); }
.access-console-section .access-tile.is-off { border-left: 3px solid var(--sun); }
.access-toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 16px; padding: 16px; border: 1px solid var(--line); border-radius: 10px; }
.access-toolbar .controls.week-filter { flex: 1 1 350px; width: auto; padding: 0; border: 0; background: transparent; }
.access-toolbar .directory-bar { flex: 1 1 500px; margin: 0; gap: 12px; flex-wrap: wrap; }
.access-toolbar .directory-bar input { flex: 1 1 180px; width: auto; min-width: 0; min-height: 44px; }
.access-toolbar .bulk-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.access-toolbar .bulk-actions button { min-height: 44px; }
@media (max-width: 1100px) { .access-console-section .access-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.access-console-section .access-tile strong { font-size: 16px; }
.access-console-section .access-tile button { min-height: 44px; min-width: 160px; }
.admin-shell .console-step select { min-height: 44px; font-size: 16px; }
@media (max-width: 600px) {
  .admin-tabs button { flex: 1; }
  .access-console-section .access-grid { grid-template-columns: minmax(0, 1fr); }
  .access-console-section .access-tile { padding: 16px; gap: 10px; }
  .access-toolbar .directory-bar { align-items: stretch; }
  .access-toolbar .directory-bar input { flex-basis: auto; width: 100%; }
  .access-console-section .access-tile button { min-width: 0; font-size: 13px; }
  .bulk-actions { display: flex; flex-wrap: wrap; gap: 8px; }
}
.inline-player { background: #0d1927; }
.inline-player .tree-player-name { padding-left: calc(var(--tree-depth, 1) * 18px); font-size: 13px; font-weight: 600; }
.figures-table .inline-player td { padding-top: 10px; padding-bottom: 10px; font-size: 14px; }
.inline-player small { padding-left: calc(var(--tree-depth, 1) * 18px); }
.inline-player .latest-xfer { max-width: 180px; white-space: normal; overflow-wrap: anywhere; }
.view-players { display: block; margin-top: 6px; padding: 5px 8px; font-size: 11px; }
.players-dialog { width: min(1200px, calc(100vw - 40px)); max-height: 90vh; padding: 24px; border: 1px solid var(--line); border-radius: 12px; background: #111e2e; color: var(--text); }
.players-dialog::backdrop { background: rgba(0, 0, 0, .7); }
.players-dialog header { align-items: center; margin-bottom: 20px; }
.players-dialog .player-search { width: 100%; margin: 8px 0 12px; }
.players-dialog .player-details { max-width: none; padding: 0; border: 0; margin-top: 24px; }
.players-dialog .player-table td { font-size: 15px; }
.players-dialog .player-table th, .players-dialog .player-table td { text-align: right; }
.players-dialog .player-table th:first-child, .players-dialog .player-table td:first-child { text-align: left; }
@media (max-width: 600px) {
  .players-dialog { width: 100%; height: 100dvh; max-height: 100dvh; max-width: 100%; margin: 0; padding: 16px; border-radius: 0; }
  .players-dialog header { flex-direction: row; align-items: start; }
  .players-dialog h2 { font-size: 21px; }
}
.figures-table .player-detail-row > td:first-child { position: static; white-space: normal; max-width: none; padding: 16px; }
.player-details { border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin: 8px 0; max-width: 1100px; }
.player-details summary { cursor: pointer; font-size: 15px; font-weight: 700; padding: 6px 0; }
.player-details p { margin: 12px 0; font-size: 13px; }
.player-discrepancy { color: var(--sun); }
.figures-table .player-table td { font-size: 14px; font-weight: 500; position: static; text-align: right; }
.figures-table .player-table th { position: static; text-align: right; }
.figures-table .player-table td:first-child, .figures-table .player-table th:first-child { text-align: left; }
.shell { width: 100%; min-width: 0; padding: clamp(16px, 2vw, 28px) clamp(12px, 1.25vw, 24px) 40px; }
.shell > header { align-items: center; flex-wrap: wrap; gap: 20px; margin-bottom: 24px; }
.shell > header > *, .header-actions, .summary > *, .table-card { min-width: 0; }
h1 { font-size: clamp(28px, 3vw, 40px); line-height: 1.15; }
.muted { line-height: 1.5; }
.header-actions { max-width: 100%; }
.controls.week-filter { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; width: min(100%, 540px); padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.week-filter label { grid-column: 1 / -1; font-size: 12px; font-weight: 700; letter-spacing: .03em; }
.controls.week-filter select { width: 100%; min-width: 0; min-height: 44px; font-size: 14px; border-radius: 6px; padding: 10px 32px 10px 12px; }
.controls.week-filter button { grid-column: auto; min-height: 44px; white-space: nowrap; border-radius: 6px; }
select:focus-visible, input:focus-visible, button:focus-visible, .table-wrap:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.summary { gap: 16px; margin-bottom: 20px; }
.summary article { padding: 20px; }
.summary strong { overflow-wrap: anywhere; }
.table-wrap { max-width: 100%; overscroll-behavior-x: contain; }
.figures-table td { padding: 16px 18px; }
.figures-scroll { max-height: 75vh; max-height: 75dvh; scroll-padding-top: 48px; }
.figures-table { border-collapse: separate; border-spacing: 0; }
.figures-table th { padding: 14px 18px; z-index: 2; background: #05101f; box-shadow: 0 1px 0 var(--line); }
.figures-table td:first-child { position: sticky; left: 0; background: #111e2e; z-index: 1; }
.figures-table th:first-child { position: sticky; left: 0; z-index: 3; }
.figures-table th:first-child, .figures-table td:first-child { min-width: 140px; box-shadow: 1px 0 0 var(--line); }
nav.app-navbar a, nav.app-navbar .logout-button { min-height: 44px; display: inline-flex; align-items: center; }
@media (max-width: 1100px) {
  .shell > header { align-items: stretch; }
  .header-actions { width: 100%; justify-items: stretch; }
  .controls.week-filter { width: 100%; }
}
@media (max-width: 760px) {
  .shell > header { gap: 16px; margin-bottom: 20px; }
  .summary article { padding: 18px; }
  .figures-table td, .figures-table th { padding: 14px 12px; }
  .figures-table td:first-child { max-width: 155px; white-space: normal; overflow-wrap: anywhere; }
  .nav-section { gap: 4px; }
  .nav-site { flex-basis: 100%; padding: 4px 0; }
  .adjustment-log summary { padding: 16px; gap: 12px; }
  input, textarea, select { max-width: 100%; }
}
@media (max-width: 480px) {
  .controls.week-filter { grid-template-columns: minmax(0, 1fr); padding: 12px; }
  .controls.week-filter button { width: 100%; }
  .controls.week-filter select { font-size: 16px; }
  .agent-figure-grid article { padding: 20px; }
}
