/* LinRevers workspace — tokens, primitives, shell, features, responsive states. */
:root {
  color-scheme: light;
  --bg: #f4f6fa;
  --surface: #fff;
  --surface-soft: #f8f9fc;
  --ink: #202d40;
  --muted: #59687d;
  --line: #dce2ec;
  --line-strong: #a3b0c4;
  --accent: #3158c9;
  --accent-soft: #edf1ff;
  --nav: #182535;
  --nav-text: #e6edf7;
  --nav-muted: #b7c4d5;
  --success: #216b51;
  --success-soft: #eaf5ef;
  --warning: #79520b;
  --warning-soft: #fff5de;
  --danger: #b2303c;
  --danger-soft: #fff0f1;
  --radius: 12px;
  --sidebar-width: 224px;
  --journal-width: 340px;
  font: 14px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--bg); }
[hidden] { display: none !important; }
h1, h2, h3, h4, p { margin: 0; }
h2 { font-size: 24px; line-height: 1.25; letter-spacing: -.025em; }
h3 { font-size: 17px; line-height: 1.35; }
h4 { font-size: 15px; line-height: 1.4; }
p + p { margin-top: 8px; }
button, input, select { font: inherit; }
button, input, select, summary, a { -webkit-tap-highlight-color: transparent; }
button { border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface); color: var(--ink); padding: 10px 14px; min-height: 44px; font-weight: 600; cursor: pointer; line-height: 1.35; max-width: 100%; overflow-wrap: anywhere; }
button:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
button:disabled { cursor: not-allowed; color: #738094; border-color: var(--line); background: #eef1f5; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: #2444a4; color: #fff; }
button.primary:disabled { background: #e4e9f5; border-color: #d4dced; color: #67758e; }
button.danger { color: var(--danger); border-color: #e3bbc0; }
button.danger:hover:not(:disabled) { color: #8f2430; border-color: var(--danger); background: var(--danger-soft); }
button.danger:disabled { color: #738094; border-color: var(--line); }
button.quiet { background: transparent; }
button.text-button { color: var(--accent); border-color: transparent; background: transparent; padding-left: 0; padding-right: 0; font-size: 13px; text-align: left; }
input, select { display: block; width: 100%; min-width: 0; min-height: 44px; border: 1px solid var(--line-strong); border-radius: 7px; padding: 10px 12px; color: var(--ink); background: #fff; line-height: 1.4; }
input::placeholder { color: #68758a; }
input:disabled, select:disabled { background: #eef1f5; color: #66758a; }
input[aria-invalid="true"] { border-color: var(--danger); background: var(--danger-soft); }
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 7px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
input:focus-visible, select:focus-visible { outline-width: 2px; outline-offset: 2px; }
summary { cursor: pointer; padding: 12px 0; font-weight: 600; min-height: 44px; overflow-wrap: anywhere; }
details > p, details > pre { margin-top: 8px; }
pre { white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.6 ui-monospace, monospace; background: #eef1f7; padding: 16px; border-radius: 6px; max-height: 360px; overflow: auto; }
small { display: block; color: var(--muted); font-size: 11px; margin-top: 4px; overflow-wrap: anywhere; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.hint, .muted { color: var(--muted); font-size: 13px; line-height: 1.5; }
.label-text { font-size: 12px; font-weight: 600; color: var(--muted); }
.error { color: var(--danger); white-space: pre-wrap; overflow-wrap: anywhere; }
.error:empty, .empty-state:empty { display: none; }
.notice, .warning { padding: 15px 20px; border: 1px solid #d4b671; border-left: 4px solid #b5801e; border-radius: 7px; background: var(--warning-soft); color: #684608; white-space: pre-wrap; overflow-wrap: anywhere; }
.notice { margin: 16px 24px; background: #edf2ff; border-color: #99abe3; color: #243e83; }
.warning { margin: 16px 0; }
.warning .actions { margin-top: 14px; }
.warning h3 { margin-bottom: 8px; }
.actions, .section-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.section-head { justify-content: space-between; }
.empty-state { border: 1px dashed var(--line-strong); border-radius: 7px; background: var(--surface-soft); color: var(--muted); padding: 20px; font-size: 13px; line-height: 1.6; }
.status-badge, .count-badge, .section-marker { display: inline-block; padding: 5px 10px; border-radius: 5px; background: #eef1f5; color: #4b5a6f; font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
.status-badge[data-status="open"], .status-badge[data-tone="success"] { background: var(--success-soft); color: var(--success); }
.pending, [data-tone="warning"] { color: var(--warning); }
.status-label { font-size: 12px; font-weight: 600; color: var(--muted); }

/* Application chrome: one compact navigation rail, one work surface. */
.masthead { display: flex; justify-content: space-between; align-items: center; gap: 24px; background: #fff; border-bottom: 1px solid var(--line); min-height: 88px; padding: 16px 30px; }
.brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; background: var(--nav); color: #fff; font-size: 28px; letter-spacing: -4px; padding-right: 4px; font-weight: 750; border-radius: 12px 4px 12px 4px; }
.brand h1 { font-size: 21px; letter-spacing: -.7px; line-height: 1.15; }
.brand-caption { color: var(--muted); font-size: 11px; }
.header-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 12px; min-width: 0; }
#connection { font-size: 12px; color: var(--muted); max-width: 360px; }
.app-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--journal-width); min-height: calc(100vh - 88px); }
.sidebar { background: var(--nav); color: var(--nav-text); padding: 28px 16px 24px; display: flex; flex-direction: column; gap: 28px; min-width: 0; }
.sidebar .hint, .sidebar .label-text { color: var(--nav-muted); }
.sidebar label { color: var(--nav-muted); font-weight: 400; }
.sidebar :focus-visible { outline-color: #adc2ff; }
.main-nav { display: flex; flex-direction: column; gap: 7px; }
.main-nav button { display: flex; align-items: center; gap: 12px; text-align: left; background: transparent; border-color: transparent; color: var(--nav-muted); padding: 13px 12px; font-size: 14px; }
.main-nav button:hover:not(:disabled) { background: #24364d; color: #fff; border-color: transparent; }
.main-nav button[aria-current="page"] { color: #fff; background: #31476a; box-shadow: inset 3px 0 #abc1ff; }
.nav-symbol { font-size: 21px; width: 22px; line-height: 1; text-align: center; }
.nav-count { margin-left: auto; min-width: 22px; font-size: 11px; text-align: center; background: #20314a; border-radius: 4px; padding: 2px 5px; color: #e6edf7; }
.account-picker { border-top: 1px solid #39485b; padding-top: 24px; }
.sidebar select { color-scheme: dark; background: #223246; color: #fff; border-color: #65768d; font-size: 12px; padding-left: 9px; }
.account-profile { overflow-wrap: anywhere; }
.account-profile h2 { font-size: 16px; letter-spacing: 0; margin-bottom: 8px; }
.account-status { font-size: 12px; color: #b8d1ed; margin-bottom: 14px; }
.account-profile .error { color: #ffb9c0; margin-top: 8px; }
.account-actions { display: grid; gap: 8px; margin-top: 20px; }
.sidebar button:not([data-view]) { color: #e6edf7; background: #2b3f58; border-color: #66778f; font-size: 12px; }
.sidebar button.quiet { background: transparent; }
.sidebar button:disabled { color: #93a4bb; border-color: #43536a; background: #203147; }
.sidebar-foot { margin-top: auto; padding-top: 30px; color: #d2dceb; font-size: 12px; overflow-wrap: anywhere; }
.sidebar-foot p { color: var(--nav-muted); font-size: 11px; margin-top: 7px; line-height: 1.65; }
.sidebar-foot details { margin-top: 16px; border-top: 1px solid #39485b; }
.sidebar-foot summary { color: var(--nav-muted); font-size: 11px; }
.manual-dot { display: inline-block; width: 6px; height: 6px; background: #b7c9ed; border-radius: 50%; margin: 0 6px 1px 0; }
.skip-link { position: absolute; left: 16px; top: 12px; z-index: 10; background: #fff; color: var(--accent); padding: 12px; transform: translateY(-200%); }
.skip-link:focus { transform: translateY(0); }
.workspace { padding: 28px 30px 20px; min-width: 0; width: 100%; max-width: 1700px; margin: 0 auto; }
.workspace-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.breadcrumb { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.workspace-heading h2 { font-weight: 650; }
.sync-text { font-size: 11px; color: var(--muted); text-align: right; }
.account-overview { display: grid; grid-template-columns: minmax(130px, .65fr) minmax(230px, 1.6fr) auto; gap: 24px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; }
.balance-block { display: flex; flex-direction: column; align-items: flex-start; padding-right: 16px; border-right: 1px solid var(--line); min-width: 0; }
.balance-block strong { font-size: 28px; font-weight: 650; line-height: 1.35; font-variant-numeric: tabular-nums; letter-spacing: -.6px; margin-top: 6px; overflow-wrap: anywhere; max-width: 100%; }
.shop-overview { min-width: 0; overflow-wrap: anywhere; }
.shop-name { font-size: 18px; font-weight: 650; margin: 8px 0 3px; }
.shop-control { display: flex; flex-direction: column; gap: 8px; max-width: 190px; }
.shop-control button { font-size: 12px; }
.shop-control .hint { font-size: 10px; text-align: center; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 30px 0 18px; }
.page-heading h2 { font-size: 22px; }
.page-heading .hint { margin-top: 6px; max-width: 70ch; }
.section-marker { font-weight: 400; white-space: nowrap; background: transparent; padding-right: 0; }
.workbench { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 20px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; overflow: clip; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 20px; border-bottom: 1px solid var(--line); }
.panel-heading .hint { margin-top: 4px; }
.source-switch { display: flex; gap: 4px; margin: 18px 20px 0; background: #edf0f6; border-radius: 7px; padding: 4px; }
.source-switch button { flex: 1; font-size: 12px; background: transparent; border-color: transparent; padding: 9px 6px; }
.source-switch button[aria-pressed="true"] { background: #fff; color: var(--accent); border-color: #c7d0e5; box-shadow: 0 1px 3px #1b325214; }
.source-tools { padding: 20px; }
.source-tools > button { margin-top: 10px; min-height: 36px; padding: 7px 0; border-color: transparent; font-size: 12px; color: var(--accent); }
.source-tools > p { margin-top: 12px; }
.source-note { font-size: 12px; color: var(--muted); background: var(--surface-soft); border-top: 1px solid var(--line); padding: 16px 20px; margin-top: 20px; }
.source-panel .empty-state { margin: 0 20px; }
.search-row { display: flex; gap: 8px; }
.search-row input { flex: 1; }
.search-row button { flex-shrink: 0; }
.manual-entry { margin: 14px 20px; border-top: 1px solid var(--line); }
.manual-entry summary { font-size: 12px; color: var(--accent); }
.inline-form { padding: 6px 0; }
.inline-form .hint { display: block; margin-top: 8px; }
.draft-panel { border-top: 3px solid var(--accent); }
.draft-panel .panel-heading { padding-top: 18px; }
.count-badge { color: var(--accent); background: var(--accent-soft); font-variant-numeric: tabular-nums; }
.draft-identity { padding: 20px; }
.draft-identity .hint { margin-top: 6px; font-size: 11px; }
.draft-status { font-size: 12px; color: var(--muted); margin-top: 12px; }
.draft-side { border-top: 1px solid var(--line); padding: 18px 20px 14px; }
.side-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.side-heading h4 { display: flex; gap: 8px; align-items: center; }
.side-heading .hint { font-size: 11px; }
.side-icon { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; font-size: 18px; }
.sell-icon { background: var(--success-soft); color: var(--success); }
.buy-icon { background: var(--accent-soft); color: var(--accent); }
.total { text-align: right; font-size: 13px; font-weight: 650; margin-top: 14px; font-variant-numeric: tabular-nums; }
.draft-check { background: #f7f9ff; border-top: 1px solid #d9e1f7; padding: 20px; }
.draft-check h4 { margin-bottom: 8px; }
.draft-check .hint { font-size: 12px; }
.draft-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.draft-actions button { flex: 1; font-size: 12px; }
.draft-check .text-button { margin-top: 5px; }

/* Data is readable, escaped content. Only long technical tables scroll. */
.table-wrap { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 12px; }
th { color: var(--muted); background: #f7f9fc; font-weight: 500; font-size: 11px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; overflow-wrap: anywhere; }
th:first-child, td:first-child { padding-left: 20px; }
th:last-child, td:last-child { padding-right: 20px; }
tbody tr:last-child td { border-bottom: 0; }
td button { font-size: 11px; min-height: 36px; padding: 8px 9px; white-space: normal; }
td input { font-size: 13px; min-height: 42px; padding: 8px; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #f8faff; }
.inventory table { table-layout: fixed; }
.inventory th:nth-child(1) { width: 10%; }
.inventory th:nth-child(2) { width: 30%; }
.inventory th:nth-child(3) { width: 12%; }
.inventory th:nth-child(4) { width: 12%; }
.inventory th:nth-child(5) { width: 36%; }
.inventory td:first-child { color: var(--muted); }
.inventory td:nth-child(4) { color: var(--muted); font-size: 10px; }
.inventory td button { color: var(--accent); border-color: #bdcbee; background: #f8faff; }
.inventory td button:disabled { color: #738094; background: #eef1f5; border-color: var(--line); }
.draft-table th, .draft-table td { padding: 10px 5px; }
.draft-table td { vertical-align: top; }
.draft-table th:first-child, .draft-table td:first-child { padding-left: 0; width: 30%; }
.draft-table th:nth-child(2) { width: 14%; }
.draft-table th:nth-child(3) { width: 23%; }
.draft-table th:nth-child(4) { width: 18%; }
.draft-table th:last-child { width: 15%; }
.draft-table td button { font-size: 11px; color: var(--danger); border-color: transparent; background: transparent; padding: 8px 3px; }
.draft-table input { min-width: 50px; }
.draft-table:has(tbody:empty) { display: none; }
/* Order is local draft array order; drag handles support pointer, touch and keyboard. */
.order-help { padding: 0 20px 16px; }
.row-order { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
.row-number { color: var(--accent); font-variant-numeric: tabular-nums; }
.draft-table td .drag-handle { cursor: grab; color: var(--muted); background: var(--surface-soft); border: 1px solid var(--line); font-size: 19px; padding: 4px 8px; min-width: 44px; min-height: 44px; touch-action: none; user-select: none; }
.draft-table td .drag-handle:active { cursor: grabbing; }
.draft-item-name { overflow-wrap: anywhere; }
.draft-table tr.dragging { opacity: .6; }
.draft-table tr.drop-target { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--accent-soft); }
.draft-table [data-quantity-limit] { font-size: 11px; line-height: 1.4; }
.inventory-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.inventory-actions button { width: 100%; min-width: 0; min-height: 44px; padding: 8px 4px; }
.inventory-limits { line-height: 1.4; }
.buy-budget { margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-soft); font-size: 12px; overflow-wrap: anywhere; }
.buy-budget[data-tone="danger"] { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.buy-budget[data-tone="warning"] { color: var(--warning); background: var(--warning-soft); }
.buy-budget[data-tone="success"] { color: var(--success); background: var(--success-soft); }
.server-details { margin-top: 20px; padding: 0 20px 12px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.server-details > summary { color: var(--muted); font-size: 13px; padding: 16px 0 4px; }
.server-details[open] > summary { margin-bottom: 12px; }
.server-details details { margin-top: 12px; border-top: 1px solid var(--line); }
#screen-nearby > .panel, #screen-journal > .panel { margin-top: 20px; }
#screen-nearby table { table-layout: fixed; }
#screen-nearby th:first-child { width: 34%; }
#screen-nearby th:nth-child(2) { width: 16%; }
#screen-nearby th:nth-child(3) { width: 30%; }
#screen-nearby th:nth-child(4) { width: 20%; }
.record-list { overflow-wrap: anywhere; }
.record-list > p, .record-list > article, .record-list > ul { margin: 14px 20px; }
.record-list ul { padding-left: 20px; }
.record-list li { padding: 8px 0; }
.record-list table { font-variant-numeric: tabular-nums; }
.record-list:empty { display: none; }
.history-panel { padding-bottom: 18px; }
.history-panel > button { margin: 14px 20px 0; }
.event-list { padding-left: 22px; margin: 8px 0; max-height: 400px; overflow: auto; }
.event-list li { padding: 8px 6px; font-size: 12px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
#operations-body td { max-width: 340px; }
.workspace-footer { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 11px; color: var(--muted); }

/* Account rail, central workspace and always-visible server responses. */
.account-picker { border-top: 0; padding-top: 0; }
.account-picker h2 { font-size: 20px; }
.account-picker > .hint { margin-top: 6px; }
.account-list { display: grid; gap: 10px; margin: 22px 0 16px; }
.sidebar .account-list button { display: grid; align-content: start; gap: 5px; text-align: left; width: 100%; padding: 13px 12px; background: transparent; border-color: #43536a; }
.sidebar .account-list button:hover:not(:disabled) { color: #fff; background: #24364d; }
.sidebar .account-list button[aria-pressed="true"] { border-color: #abc1ff; background: #31476a; box-shadow: inset 3px 0 #abc1ff; }
.account-list strong { font-size: 14px; }
.cat-character, .cat-status { font-size: 12px; font-weight: 400; color: var(--nav-text); }
.cat-status { color: var(--nav-muted); }
#add-account { width: 100%; }
.account-profile { border-top: 1px solid #43536a; padding-top: 20px; }
.workspace-heading > div { min-width: 0; overflow-wrap: anywhere; }
.workspace-tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--line-strong); margin-bottom: 22px; }
.workspace-tabs button { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: transparent; padding: 12px 20px; }
.workspace-tabs button[aria-current="page"] { border-bottom-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.journal-rail { min-width: 0; padding: 26px 16px; border-left: 1px solid var(--line); background: var(--surface-soft); overflow-wrap: anywhere; }
.journal-rail .page-heading { margin: 0 0 22px; align-items: flex-start; }
.journal-rail .page-heading h2 { font-size: 19px; }
.journal-rail .panel-heading { padding: 14px; }
.journal-rail .panel-heading h3 { font-size: 15px; }
.journal-rail .server-details { padding: 0 14px 12px; }
.journal-rail .table-wrap { max-height: 440px; overflow: auto; }
#screen-journal .table-wrap table { min-width: 0; }
.journal-rail table, .journal-rail tbody { display: block; }
.journal-rail thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.journal-rail tr { display: grid; grid-template-columns: auto minmax(0,1fr); gap: 6px 10px; padding: 14px; border-bottom: 1px solid var(--line); }
.journal-rail td { display: block; padding: 0; border: 0; }
.journal-rail td:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
.journal-rail td:nth-child(3) { text-align: right; }
.journal-rail td:nth-child(4) { grid-column: 1 / -1; color: var(--danger); }
.journal-rail .empty-state { padding: 14px; margin: 12px; }
.journal-rail .events-empty { margin: 12px 0 0; }
.journal-rail .event-list { max-height: 500px; }
.nearby-details { margin-top: 24px; border-top: 1px solid var(--line-strong); }
.nearby-details > summary { color: var(--muted); }
.settings-panel { max-width: 720px; padding: 24px; }
.settings-panel .security-note { color: var(--muted); padding-bottom: 18px; border-bottom: 1px solid var(--line); margin-bottom: 18px; font-size: 13px; }
#settings-form, #account-form, #site-password-form { margin-top: 20px; }
#settings-form > label:not(:first-child), #account-form > label:not(:first-child), #site-password-form > label:not(:first-child) { margin-top: 20px; }
#settings-form > .hint, #account-form > .hint, #site-password-form > .hint { margin-top: 7px; }
#settings-form > .actions { margin-top: 24px; }
.check-label { display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: 14px; }
.check-label input { width: 20px; min-height: 20px; height: 20px; flex-shrink: 0; accent-color: var(--accent); }
#account-form-status, #site-password-status { margin-top: 20px; }
#site-password-status:empty { display: block; margin-top: 0; }
/* Percent of the fixed containing block also bounds the dialog under CSS zoom. */
#site-password-dialog { max-height: calc(100% - 40px); }
#site-password-dialog .dialog-actions { flex-wrap: wrap; }

/* Authentication and explicit review, never a trade-on-load surface. */
.login-panel { display: grid; grid-template-columns: .75fr 1fr; max-width: 820px; margin: 9vh auto; background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: clip; }
.login-art { display: flex; flex-direction: column; justify-content: space-between; gap: 60px; padding: 38px; background: #243b61; color: #fff; font-size: 32px; line-height: 1.2; letter-spacing: -1px; font-weight: 600; }
.shop-glyph { display: block; font-size: 78px; font-weight: 400; color: #bbceff; }
.login-content { padding: 38px; }
.login-content h2 { font-size: 30px; margin: 10px 0 16px; }
.login-content > p { color: var(--muted); font-size: 13px; }
#login-form { margin-top: 28px; }
#login-form .hint { margin-top: 8px; font-size: 12px; }
#login-submit { width: 100%; margin-top: 20px; }
.login-content .security-note { font-size: 11px; border-top: 1px solid var(--line); padding-top: 20px; margin-top: 26px; }
dialog { border: 1px solid var(--line); border-radius: 16px; background: #fff; color: var(--ink); padding: 28px; width: min(620px, calc(100% - 32px)); max-height: calc(100dvh - 40px); overflow: auto; box-shadow: 0 24px 80px #15284340; }
dialog::backdrop { background: #102238a6; }
dialog h2 { font-size: 25px; margin: 8px 0 18px; }
#confirm-text { white-space: pre-wrap; font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }
#confirm-lines { background: var(--surface-soft); border-radius: 8px; margin-top: 18px; padding: 2px 0; font-size: 13px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }

@media (min-width: 1800px) {
  .workspace { padding-left: 48px; padding-right: 48px; }
  .workbench { grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 24px; }
}
@media (max-width: 1250px) {
  :root { --sidebar-width: 208px; }
  .workspace { padding: 24px; }
  .workbench { grid-template-columns: minmax(0, 1fr); }
  .account-overview { grid-template-columns: minmax(110px, .7fr) minmax(0, 1.3fr); gap: 18px; }
  .shop-control { grid-column: 1 / -1; max-width: none; flex-direction: row; align-items: center; justify-content: flex-end; padding-top: 14px; border-top: 1px solid var(--line); }
  .source-panel { max-height: none; }
  .inventory { max-height: 360px; }
}
@media (max-width: 760px) {
  .masthead { min-height: 76px; padding: 14px 20px; gap: 16px; align-items: flex-start; }
  .brand { gap: 8px; }
  .brand-mark { width: 34px; height: 36px; font-size: 24px; }
  .brand h1 { font-size: 18px; }
  .brand-caption { font-size: 10px; }
  .header-actions { gap: 8px; flex-wrap: wrap; max-width: 48%; }
  #connection { font-size: 10px; text-align: right; }
  #logout, #site-password-open { min-height: 44px; padding: 8px 10px; font-size: 12px; }
  .app-shell { display: block; }
  .sidebar { padding: 14px 20px; gap: 16px; }
  .main-nav { flex-direction: row; gap: 5px; }
  .main-nav button { flex: 1; justify-content: center; padding: 10px 6px; gap: 6px; font-size: 12px; }
  .main-nav button[aria-current="page"] { box-shadow: inset 0 -2px #abc1ff; }
  .nav-symbol { width: 16px; font-size: 18px; }
  .nav-count { margin-left: 0; }
  .account-picker { border-top: 0; padding-top: 0; }
  .account-picker label { font-size: 11px; margin-bottom: 5px; }
  .sidebar select { min-height: 40px; }
  .account-profile { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 14px; align-items: center; }
  .account-profile h2 { font-size: 13px; margin-bottom: 4px; }
  .account-status { font-size: 11px; text-align: right; margin: 0; }
  .account-profile #self { grid-column: 1 / -1; margin: 0; font-size: 11px; }
  .account-profile #account-error { grid-column: 1 / -1; }
  .account-actions { grid-column: 1 / -1; display: flex; gap: 8px; margin-top: 10px; }
  .account-actions button { flex: 1; min-height: 36px; padding: 7px; }
  .sidebar-foot { display: none; }
  .workspace { padding: 22px 20px; }
  .workspace-heading { align-items: flex-start; gap: 10px; margin-bottom: 18px; }
  .workspace-heading h2 { font-size: 20px; }
  .breadcrumb { font-size: 11px; }
  .sync-text { font-size: 10px; max-width: 120px; padding-top: 3px; }
  .account-overview { padding: 18px; gap: 16px; }
  .balance-block { padding-right: 12px; }
  .balance-block strong { font-size: 23px; }
  .label-text { font-size: 11px; }
  .shop-overview .section-head { gap: 6px; }
  .shop-name { font-size: 15px; }
  .shop-overview .hint { font-size: 11px; }
  .shop-control { justify-content: flex-start; }
  .shop-control .hint { text-align: left; }
  .page-heading { margin-top: 26px; }
  .page-heading h2 { font-size: 21px; }
  .section-marker { display: none; }
  .panel-heading { padding: 18px; }
  .panel-heading h3 { font-size: 16px; }
  .source-tools, .draft-identity, .draft-side, .draft-check { padding: 18px; }
  .source-switch { margin-left: 18px; margin-right: 18px; }
  .source-note { padding: 16px 18px; }
  .source-panel .empty-state { margin: 0 18px; }
  #screen-nearby table, #screen-journal .table-wrap table { min-width: 560px; }
  .notice { margin: 12px 20px; padding: 12px 14px; }
  .warning { padding: 12px 14px; font-size: 12px; }
  .workspace-footer { font-size: 10px; }
  .login-panel { margin: 28px 20px; display: block; }
  .login-art { padding: 22px 28px; flex-direction: row; align-items: center; font-size: 24px; gap: 20px; }
  .shop-glyph { font-size: 48px; }
  .login-content { padding: 28px; }
  .login-content h2 { font-size: 27px; }
}
@media (max-width: 500px) {
  .masthead { padding: 14px 16px; flex-wrap: wrap; }
  .brand { flex: 0 1 auto; min-width: 0; max-width: 100%; }
  .brand > div { min-width: 0; overflow-wrap: anywhere; }
  .brand-mark { flex-shrink: 0; }
  .header-actions { flex: 1 1 100%; max-width: none; }
  .sidebar { padding: 12px 16px 16px; }
  .workspace { padding: 20px 14px; }
  .main-nav button { font-size: 11px; gap: 4px; }
  .nav-symbol { display: none; }
  .account-overview { grid-template-columns: 1fr; padding: 16px; gap: 14px; }
  .balance-block { border-right: 0; border-bottom: 1px solid var(--line); padding: 0 0 12px; }
  .shop-control { align-items: flex-start; flex-direction: column; gap: 6px; }
  .shop-control .hint { font-size: 10px; }
  .shop-control button { width: 100%; }
  .status-badge { font-size: 10px; padding: 4px 7px; }
  .workspace-heading h2 { font-size: 18px; }
  .balance-block strong { font-size: 22px; }
  .page-heading .hint { font-size: 12px; }
  .panel-heading, .source-tools, .draft-identity, .draft-side, .draft-check { padding: 16px; }
  .source-switch { margin-left: 16px; margin-right: 16px; }
  .source-switch button { font-size: 11px; }
  .inventory { max-height: 420px; }
  .inventory table, .inventory tbody, .inventory tr, .inventory td { display: block; width: 100%; }
  .inventory thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .inventory tr { display: grid; grid-template-columns: 1fr 1fr; padding: 14px 16px; border-bottom: 1px solid var(--line); gap: 7px 12px; }
  .inventory td { border: 0; padding: 0; font-size: 12px; }
  .inventory td:first-child { grid-column: 1; font-size: 11px; }
  .inventory td:first-child::before { content: "Слот "; }
  .inventory td:nth-child(2) { grid-column: 1 / -1; grid-row: 2; font-weight: 600; }
  .inventory td:nth-child(3) { grid-column: 2; grid-row: 1; text-align: right; font-size: 11px; }
  .inventory td:nth-child(3)::after { content: " шт."; }
  .inventory td:nth-child(4) { grid-column: 1; align-self: center; }
  .inventory td:nth-child(4)::before { content: "Флаги: "; }
  .inventory td:last-child { grid-column: 1 / -1; text-align: left; }
  .inventory td button { min-height: 44px; width: auto; }
  .order-help { padding: 0 16px 16px; }
  .draft-table { overflow: visible; }
  .draft-table table, .draft-table tbody, .draft-table tr, .draft-table td { display: block; width: 100%; }
  .draft-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .draft-table tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
  .draft-table td, .draft-table td:first-child { border: 0; padding: 0; width: auto; font-size: 12px; }
  .draft-table td:first-child { grid-column: 1 / -1; font-weight: 600; }
  .draft-table td:nth-child(2)::before, .draft-table td:nth-child(3)::before { display: block; margin-bottom: 5px; font-size: 11px; color: var(--muted); }
  .draft-table td:nth-child(2)::before { content: "Количество"; }
  .draft-table td:nth-child(3)::before { content: "Цена за штуку"; }
  .draft-table td:nth-child(4) { align-self: center; font-variant-numeric: tabular-nums; }
  .draft-table td:nth-child(4)::before { content: "Сумма: "; color: var(--muted); }
  .draft-table td:last-child { text-align: right; }
  .draft-table td button { min-height: 40px; padding: 7px 12px; background: var(--danger-soft); }
  .draft-actions { flex-direction: column; }
  .draft-actions button { flex: auto; min-height: 46px; }
  .empty-state { padding: 16px; font-size: 12px; }
  .side-heading .hint { font-size: 10px; }
  .notice { margin: 12px 14px; }
  .server-details { padding-left: 16px; padding-right: 16px; }
  .history-panel .panel-heading { align-items: flex-start; }
  .history-panel .panel-heading > button { width: 100%; }
  .login-panel { margin: 20px 14px; }
  .login-art { padding: 20px; font-size: 22px; }
  .login-content { padding: 22px; }
  dialog { padding: 20px; width: calc(100% - 24px); border-radius: 12px; }
  dialog h2 { font-size: 22px; }
  #confirm-text { font-size: 12px; }
  .dialog-actions { gap: 8px; }
  .dialog-actions button { flex: 1; font-size: 12px; }
}
/* Container widths also follow CSS/text zoom, unlike viewport media queries. */
body { container: app / inline-size; }
@container app (max-width: 760px) {
  .app-shell { display: block; }
  .workbench { grid-template-columns: minmax(0, 1fr); }
  .sidebar-foot { display: none; }
  .account-overview { grid-template-columns: 1fr; }
  .balance-block { border-right: 0; border-bottom: 1px solid var(--line); padding: 0 0 12px; }
  .balance-block strong { overflow-wrap: normal; }
  .shop-control { grid-column: auto; max-width: none; }
}
@container app (max-width: 280px) {
  .masthead { align-items: stretch; padding: 14px 12px; }
  .brand { width: 100%; }
  .brand-caption { overflow-wrap: anywhere; }
  .header-actions { justify-content: space-between; width: 100%; }
  #connection { text-align: left; flex: 1; }
  #logout { flex-shrink: 0; }
  .sidebar { padding: 12px; }
  .main-nav { display: grid; grid-template-columns: 1fr; }
  .main-nav button { justify-content: flex-start; padding: 10px; }
  .nav-count { margin-left: auto; }
  .account-profile { grid-template-columns: 1fr; }
  .account-status { text-align: left; margin-bottom: 8px; }
  .account-actions { flex-direction: column; }
  .workspace { padding: 18px 10px; }
  .workspace-heading { flex-direction: column; }
  .sync-text { max-width: none; text-align: left; }
  .account-overview { grid-template-columns: 1fr; padding: 14px; }
  .balance-block { border-right: 0; border-bottom: 1px solid var(--line); padding: 0 0 12px; }
  .balance-block { container-type: inline-size; }
  .balance-block strong { font-size: clamp(12px, 11cqi, 23px); overflow-wrap: normal; }
  .shop-control { grid-column: auto; }
  .source-switch { flex-direction: column; margin-left: 12px; margin-right: 12px; }
  .panel-heading, .source-tools, .draft-identity, .draft-side, .draft-check { padding: 14px 12px; }
  .search-row { flex-direction: column; }
  .inventory tr, .draft-table tr { grid-template-columns: 1fr; }
  .inventory td:nth-child(n), .draft-table td:nth-child(n) { grid-column: 1; grid-row: auto; text-align: left; }
  .inventory td:last-child { margin-top: 5px; }
  .draft-table td:last-child button { width: 100%; }
  .dialog-actions { flex-direction: column; }
  .login-art { flex-direction: column; align-items: flex-start; gap: 10px; }
  .login-content { padding: 20px 14px; }
}
/* Fit the center to its own width; keep responses right on desktop. */
.workspace { container: workspace / inline-size; padding-left: 24px; padding-right: 24px; }
@container workspace (max-width: 1100px) {
  .workbench { grid-template-columns: minmax(0, 1fr); }
  .account-overview { grid-template-columns: minmax(0,.8fr) minmax(0,1.2fr); gap: 16px; }
  .shop-control { grid-column: 1 / -1; max-width: none; flex-direction: row; align-items: center; }
}
@container workspace (max-width: 500px) {
  .account-overview { grid-template-columns: minmax(0,1fr); }
  .balance-block { border-right: 0; border-bottom: 1px solid var(--line); padding: 0 0 12px; }
  .shop-control { flex-direction: column; align-items: stretch; }
  .settings-panel { padding: 16px; }
}
@media (max-width: 1150px) {
  .app-shell { grid-template-columns: var(--sidebar-width) minmax(0,1fr); }
  .sidebar { grid-row: 1 / 3; }
  .journal-rail { grid-column: 2; border-left: 0; border-top: 1px solid var(--line); padding: 24px; }
}
@media (max-width: 760px) {
  .account-list { grid-template-columns: repeat(auto-fit,minmax(135px,1fr)); margin-top: 14px; max-height: 270px; overflow: auto; padding: 4px; }
  .journal-rail { padding: 20px 14px; }
  .workspace { padding-left: 14px; padding-right: 14px; }
}
@container app (max-width: 760px) {
  .app-shell { display: block; }
  .journal-rail { border-left: 0; border-top: 1px solid var(--line); }
}
@container app (max-width: 280px) {
  .workspace-tabs button { padding: 10px; flex: 1; }
  .account-list { grid-template-columns: 1fr; }
  .settings-panel { padding: 12px; }
  .settings-panel .actions { flex-direction: column; align-items: stretch; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
