.system-layout { min-width: 0; }
#system-menu { min-width: 0; background: var(--rail); border-right: 1px solid var(--line); }
.system-layout main { min-width: 0; padding: 26px clamp(16px, 3vw, 38px) 42px; }
#system-home { display: contents; }
#access { display: grid; align-items: center; min-height: min(68vh, 600px); }

@media (min-width: 651px) {
  body:has(#system-menu:not([hidden])) {
    display: grid;
    grid-template-columns: var(--nav-width) minmax(0, 1fr);
    grid-template-rows: var(--header-height) minmax(0, 1fr);
    min-height: 100dvh;
  }
  body:has(#system-menu:not([hidden])) .system-layout { display: contents; }
  body:has(#system-menu:not([hidden])) .top { grid-area: 1 / 2; position: sticky; top: 0; z-index: 2; }
  #system-menu {
    grid-area: 1 / 1 / -1 / 2; position: sticky; top: 0; align-self: start; height: 100dvh; overflow: auto;
  }
  #system-menu:not([hidden]) + main { grid-area: 2 / 2; }
}
@media (max-width: 650px) {
  #system-menu { border-right: 0; border-bottom: 1px solid var(--line); }
  .system-layout main { padding: 15px 12px 30px; }
}

h1, h2, h3 { color: var(--portal-ink); }
h2 { font-size: 16px; line-height: 1.35; margin: 0; }
h3 { font-size: 15px; margin: 16px 0 8px; }
p { margin: 8px 0; }
p:empty { margin: 0; }
.webhook-head h1 { overflow-wrap: anywhere; }
.webhook-head > button { flex: none; }
.actions, .pager { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pager { justify-content: flex-end; }
#system-home .avatar { width: 32px; height: 32px; font-size: 14px; }
.code-cell, code { font: 12px/1.5 ui-monospace, Menlo, monospace; color: var(--portal-quiet); }
.empty-list { padding: 12px 8px; color: var(--portal-quiet); }
.directory-pagination p { margin: 0; }
.directory-pagination select { width: auto; }
.directory-pagination select, .directory-pagination label { font-weight: 400; }

form { display: grid; gap: 12px; }
label { display: grid; gap: 5px; color: var(--portal-quiet); font-size: 13px; font-weight: 550; }
label:has(input[type=checkbox]) { display: flex; align-items: center; }
input:not([data-slot]):not([type=checkbox]), textarea, select {
  min-width: 0; width: 100%; font: inherit; color: var(--portal-ink);
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; background: var(--field);
}
.filters { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; }
.filters label { min-width: 0; }
.filters input { width: 100%; }
.filters select { min-width: 110px; }
button:not([data-slot], .menu-entry, .menu-toggle, .home-metric, .home-link, .home-issue-action), #retired-node-export {
  width: fit-content; border: 0; text-decoration: none; font-weight: 550;
  background: var(--default); color: var(--portal-ink); border-radius: 6px; padding: 7px 12px;
}
button:not([data-slot], .menu-entry, .menu-toggle, .home-metric, .home-link, .home-issue-action):hover, #retired-node-export:hover { background: var(--portal-soft); }
button[aria-pressed=true]:not([data-slot]) { color: var(--accent); background: var(--portal-soft); }
button:is([type=submit], .primary):not([data-slot]) { color: var(--accent-foreground); background: var(--accent); }
button:is([type=submit], .primary):not([data-slot]):hover { background: var(--accent-hover); }
#merchant-status-submit[data-danger=true] { background: var(--danger-bg); color: var(--danger); }
#merchant-status-submit[data-danger=true]:hover { background: #f6dce2; }
.signin-mark { background: var(--accent); color: var(--accent-foreground); }

.report-card {
  min-width: 0; display: grid; gap: 14px; padding: 18px; border: 1px solid var(--line);
  border-radius: 9px; background: var(--panel);
}
.report-card .audit-table table { min-width: max-content; }
.report-card .audit-table td { max-width: 36ch; }
#active-nodes-empty, #retired-node-status { color: var(--portal-quiet); }
.report-card p:empty, .report-card .actions:not(:has(button:not([hidden]))) { display: none; }

.operations-heading { flex-wrap: wrap; margin-bottom: 14px; }
.operations-heading p { font-size: 12px; font-variant-numeric: tabular-nums; }
.operations-overview {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0 0 16px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--panel);
}
.operations-overview > div { padding: 10px 17px; min-width: 0; }
.operations-overview > div + div { border-left: 1px solid var(--line); }
.operations-overview dt, .operations-overview small { color: var(--portal-quiet); font-size: 12px; }
.operations-overview dd { margin: 4px 0 0; overflow-wrap: anywhere; }
.operations-overview dd strong { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.2; }
.operations-overview dd small { display: block; margin-top: 4px; }
.operations-overview [data-warning=true] strong { color: var(--warning); }
.operations-hold, .operations-error {
  margin: 0 0 12px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel);
  overflow-wrap: anywhere;
}
.operations-hold { color: var(--warning); }
.operations-tabs {
  display: flex; flex-wrap: wrap; gap: 5px; padding-bottom: 8px; margin-bottom: 12px; border-bottom: 1px solid var(--line);
}
.operations-tabs button[aria-pressed=true] { color: var(--accent); background: var(--portal-soft);  }
.operations-tab-count {
  padding: 0 5px; min-width: 19px; border-radius: 4px; background: var(--field); color: var(--portal-quiet);
  font-size: 11px; font-variant-numeric: tabular-nums; text-align: center;
}
.operations-details { min-width: 0; padding: 0; gap: 0; border-radius: 10px; }
.operations-toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 12px; padding: 10px 16px; }
.operations-search { min-width: 0; flex: 1 1 190px; max-width: 320px; }
.operations-toolbar select { min-width: 112px; }
.operations-table-scroll {
  min-width: 0; max-height: min(64dvh, 620px); overflow: auto;
  border-block: 1px solid var(--line); scrollbar-gutter: stable; overscroll-behavior: contain;
}
.operations-table { width: 100%; min-width: 590px; border-spacing: 0; font-variant-numeric: tabular-nums; }
.operations-table th, .operations-table td { text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.operations-table th {
  position: sticky; top: 0; z-index: 1; background: var(--list); color: var(--portal-quiet); padding: 3px 8px;
}
.operations-table th button { padding-inline: 8px; font-size: 12px; }
.operations-table td { padding: 9px 16px; font-size: 13px; }
.operations-table tr:last-child td { border-bottom: 0; }
.operations-table td code { color: var(--portal-ink); overflow-wrap: anywhere; }
.operations-table [data-numeric=true] { text-align: right; white-space: nowrap; }
.operations-sort { color: var(--portal-quiet); }
.operations-table th[aria-sort] .operations-sort { color: var(--accent); }
.operations-table .operations-empty { padding: 28px 16px; color: var(--portal-quiet); }
.operations-state { display: inline-block; padding: 2px 8px; border-radius: 20px; background: var(--default); white-space: nowrap; }
.operations-state[data-tone=ready] { color: var(--success); background: var(--success-bg); }
.operations-state[data-tone=draining] { color: var(--warning); background: var(--warning-bg); }
.operations-state[data-tone=timeout] { color: var(--danger); background: var(--danger-bg); }
.operations-pagination { position: static; border: 0; margin: 0; padding: 10px 16px; border-radius: 0 0 9px 9px; }
.operations-trace-results { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 7px; }
.operations-trace-results ul { list-style: none; margin: 0; padding: 0; }
.operations-trace-results li { padding: 10px 0; overflow-wrap: anywhere; }
.operations-trace-results li + li { border-top: 1px solid var(--line); }
.operations-trace-results li p { margin-bottom: 0; }
@media (max-width: 850px) {
  .operations-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .operations-overview > div:nth-child(odd) { border-left: 0; }
  .operations-overview > div:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@media (max-width: 480px) {
  .operations-overview > div, .operations-toolbar, .operations-pagination { padding: 10px 12px; }
}

#merchant-detail-back { margin: 0 0 16px; }
#merchant-detail .member-identity { flex-wrap: wrap; }
.merchant-detail-title { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; min-width: 0; }
.merchant-detail-title > div:not(.avatar) { min-width: 0; }
.merchant-detail-title .member-state { margin-top: 6px; }
#merchant-detail :is(h1, dd, strong, small) { overflow-wrap: anywhere; }
.detail-card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.merchant-facts { margin: 0; padding: 0; }
.merchant-facts > div {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 0;
}
.merchant-facts > div + div { border-top: 1px solid var(--line); }
.merchant-facts dt { color: var(--portal-quiet); }
.merchant-facts dt { flex: none; }
.merchant-facts dd { margin: 0; text-align: right; overflow-wrap: anywhere; }

.audit-table, #active-nodes, #retired-nodes { min-width: 0; max-width: 100%; overflow-x: auto; }
.audit-table table, #nodes table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.audit-table :is(th, td), #nodes :is(th, td) {
  text-align: left; padding: 9px 10px; vertical-align: middle; border-bottom: 1px solid var(--line); overflow-wrap: anywhere;
}
.audit-table th, #nodes th { background: var(--list); color: var(--portal-quiet); font-size: 12px; font-weight: 600; white-space: nowrap; }
.audit-table td { font-size: 13px; }
.audit-table tr:last-child td, #nodes tr:last-child td { border-bottom: 0; }

#system-audit-form { gap: 10px; margin-bottom: 16px; }
.audit-toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; }
.audit-actor { flex: 1 0 158px; max-width: 250px; }
.audit-result { flex: 0 0 104px; }
.audit-date { flex: 0 1 170px; }
.audit-filter-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.audit-advanced {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); gap: 12px;
  padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--list);
}
#system-audit-form :is(input, select, button) { height: 36px; font-size: 13px; }
#system-audit-form :is(input, select) { width: 100%; }
#system-audit-advanced-toggle[aria-expanded=true] { color: var(--accent); background: var(--portal-soft); }
#system-audit-advanced-count { font-variant-numeric: tabular-nums; }
.audit-chevron { width: 6px; height: 6px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: translateY(-2px) rotate(45deg); }
[aria-expanded=true] > .audit-chevron { transform: translateY(1px) rotate(225deg); }
#system-audit-related { margin: 0 0 10px; color: var(--portal-quiet); }
.audit-records { gap: 0; min-width: 0; }
.audit-records table { min-width: 750px; }
.audit-records td { padding-block: 12px; }
.audit-records td:first-child, .audit-records td:last-child { white-space: nowrap; color: var(--portal-quiet); }
.audit-records td:nth-child(2) { font-weight: 600; }
.audit-outcome { display: inline-block; padding: 2px 8px; color: var(--success); background: var(--success-bg); border-radius: 20px; font-size: 12px; white-space: nowrap; }
.audit-outcome[data-outcome=denied] { color: var(--danger); background: var(--danger-bg); }
.audit-footer {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 48px; padding-top: 10px; border-top: 1px solid var(--line);
}
.audit-footer p { margin: 0; color: var(--portal-quiet); font-size: 13px; }
.audit-pagination { display: flex; flex-wrap: wrap; gap: 8px; }
.audit-pagination:not(:has(button:not([hidden]))) { display: none; }

#nodes .webhook-head .actions { justify-content: flex-end; }
.node-directory { margin-bottom: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.node-toolbar { padding: var(--surface-block) var(--surface-inset); margin: 0; }
.node-toolbar label { max-width: 100%; }
.node-toolbar input[type=search] { min-width: 150px; }
.node-directory .member-table-wrap, .node-directory .audit-table { border-block: 1px solid var(--line); }
.node-table { table-layout: fixed; }
.node-table th { background: var(--list); }

.node-table :is(th, td):first-child { width: 27%; overflow-wrap: anywhere; }
.node-table :is(th, td):nth-child(2) { width: 27%; }
.node-table :is(th, td):last-child { width: 92px; text-align: right; }
.node-table td small, .node-table td time, .node-detail-body small {
  display: block; margin-top: 3px; color: var(--portal-quiet); font-size: 12px;
}
.node-table time[hidden] { display: none; }
.node-table .node-cleanup-link:not([data-slot]) { background: transparent; color: var(--accent); padding: 4px 0; text-align: left; }
.node-table .node-cleanup-link:not([data-slot]):hover { text-decoration: underline; }
.node-health:is([data-state=offline], [data-state=isolated]) { color: var(--warning); background: var(--warning-bg); }
.node-muted, .node-notice { color: var(--portal-quiet); }
.node-notice:not(:empty) { margin: 0; padding: var(--surface-block) var(--surface-inset); }
.node-pagination { position: static; margin: 0; border: 0; padding: 10px var(--surface-inset); border-radius: 0 0 12px 12px; }
.node-date-filters { flex-basis: 100%; color: var(--portal-quiet); }
.node-date-filters summary { width: fit-content; cursor: pointer; padding: 3px 0; }
.node-date-filters .member-fields { margin-top: 8px; }
#retired-time-guide { font-size: 12px; }
#retired-nodes table { min-width: 660px; }
.node-detail-body { display: grid; gap: 20px; overflow-wrap: anywhere; }
.node-detail-body section + section { border-top: 1px solid var(--line); padding-top: 14px; }
.node-detail-body h3 { margin: 0 0 8px; }
.node-detail-body ul { list-style: none; margin: 0; padding: 0; }
.node-detail-body li + li { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.node-detail-body .actions { justify-content: flex-start; }
.node-detail-body .node-retire-button:not([data-slot]) { color: var(--danger); background: var(--danger-bg); }
#placement-form .actions { justify-content: space-between; }
#nodes-status:not(:empty) { color: var(--danger); }
@media (max-width: 810px) {
  #nodes .webhook-head { flex-wrap: wrap; }
  #nodes .webhook-head .actions { justify-content: start; }
}
@media (max-width: 650px) {
  .node-table :is(td:nth-child(n), th:nth-child(n)) { width: auto; text-align: left; padding-inline: 0; }
  .node-table tr { padding: 12px 14px; }
  .node-table tr:first-child { border-top: 0; }
  .node-table td:nth-child(4) { grid-column: 1; }
  .node-table td:last-child { grid-column: 2; grid-row: 3; text-align: right; }
}
#retired-node-export { display: inline-block; }
#status:not(:empty) { margin-top: 12px; padding: 10px 12px; border-radius: 6px; background: var(--panel); }

dialog { width: min(470px, calc(100% - 28px)); }
dialog > h2, dialog form > h2 { font-size: 21px; }
dialog p { color: var(--portal-quiet); }
dialog .actions { justify-content: flex-end; }
dialog > .actions, .pager:not(:empty) { margin-top: 10px; }
.seat-drawer > h2 { padding-bottom: 14px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.seat-drawer .drawer-form > label { font-weight: 550; }
.seat-drawer .drawer-form ul { margin: 0; padding-inline-start: 20px; }
#password-form input, .drawer-form input { min-height: 36px; }
.audit-dialog { width: min(960px, calc(100% - 28px)); }
#export-chain-items tr[aria-current=true] td { background: var(--portal-soft); }
#export-chain-items tr[aria-current=true] td:first-child { font-weight: 650; }
#node-cleanup-review-form textarea { resize: vertical; }

@media (max-width: 650px) {
  .report-card { padding: 14px; }
  .audit-actor, .audit-result, .audit-date { flex: 1 1 calc(50% - 5px); min-width: 0; max-width: none; }
  .audit-filter-actions { flex-basis: 100%; }
  .audit-advanced { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.storage-form fieldset { border:0; margin:0; padding:0; }
.storage-form fieldset { min-width: 0; }
.storage-form fieldset:not([hidden]) { display:grid; }
.storage-form label:not([hidden]) { display:grid; gap:5px; }
.storage-form label.storage-history { display:flex; align-items:center; gap:8px; }
.storage-form output { overflow-wrap:anywhere; }
#image-storage #storage-fields { border-top: 1px solid var(--line); }
#image-storage select, #image-storage input:not([type=checkbox]) { max-width: 540px; }

.system-layout main { padding-top: 28px; }
#system-home > section, #nodes { max-width: 1440px; }
.audit-records #system-audit-form { margin: 0; padding: var(--surface-block, 14px) var(--surface-inset, 20px); }
.audit-records .audit-table { border-block: 1px solid var(--line); }
.audit-records .audit-footer { margin: 0; padding: 10px var(--surface-inset, 20px); border-top: 0; }
.audit-records #system-audit-related:not([hidden]) { padding-inline: var(--surface-inset, 20px); }
.surface-tabs { padding: 8px 10px; margin: 0; background: var(--list); }
.node-quick-views { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 var(--surface-inset) 10px; }
.node-quick-views button { font-size: 12px; }
.node-quick-views span:not(:empty) { margin-left: 4px; font-weight: 650; font-variant-numeric: tabular-nums; }
#nodes .node-directory { overflow: clip; }
.placement-flow section { display: grid; gap: 10px; }
.placement-flow h3 { margin: 0; }
.placement-flow section + section { border-top: 1px solid var(--line); padding-top: 14px; }
.placement-flow p:empty { display: none; }
@media (max-width: 650px) {
  .system-layout main { padding-top: 15px; }
}

.merchant-admin-roster td:nth-child(2) { overflow-wrap: anywhere; }
.merchant-status-actions { padding-top: 15px; }
.merchant-status-actions p { margin: 0 0 10px; }

.storage-directory-table :is(th,td):last-child { text-align: right; }
.storage-directory-table td:first-child { font-weight: 600; }
.storage-directory-table td:nth-child(4) { white-space: nowrap; }
@media (max-width: 650px) {
  .storage-directory-table td:nth-child(3) { grid-column: 1; grid-row: 3; color: var(--portal-quiet); }
  .storage-directory-table td:nth-child(4) { grid-column: 2; grid-row: 1; white-space: normal; }
  .storage-directory-table td:last-child { grid-column: 2; grid-row: 2 / span 2; justify-self: end; }
}

#image-storage .settings-context > .actions { margin-top: 12px; }
.storage-retry-list { list-style: none; margin: 0; padding: 0; }
.storage-retry-list li { display: grid; gap: 4px; padding: 12px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.storage-retry-list small { color: var(--portal-quiet); }
