/* The client: top bar, main menu, desktop with windows, status bar, lists and viewers. */
.client {
  display: grid;
  grid-template-rows: 40px 1fr 30px;
  height: 100%;
  min-width: 0;
  background: var(--c-bg);
}
.client:focus { outline: none; }

/* top bar and menu bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  background: var(--c-bar);
  border-bottom: 2px solid var(--c-accent);
  color: var(--c-bar-text);
  min-width: 0;
}
.brand-wordmark {
  display: block;
  flex: none;
  height: 22px;
  aspect-ratio: 1400 / 372;
  background: var(--c-gold-gradient);
  -webkit-mask: url("../img/koon-wordmark.png") center / contain no-repeat;
  mask: url("../img/koon-wordmark.png") center / contain no-repeat;
}
.topbar-spacer { flex: 1; }
.topbar-item {
  font-size: var(--fs-small);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
.topbar-item + .topbar-item { padding-left: 12px; border-left: 1px solid var(--c-bar-2); }
.platform { color: var(--c-bar-accent); }
.menubar { display: flex; gap: 2px; }
.menubar-entry { position: relative; }
.menubar-btn {
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--c-bar-text);
}
.menubar-btn:hover, .menubar-btn.open { background: var(--c-bar-2); }
.dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 5000;
  min-width: 200px;
  padding: 4px 0;
  background: var(--c-surface);
  color: var(--c-text);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.dropdown-item {
  display: flex;
  gap: 6px;
  width: 100%;
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  background: none;
  text-align: left;
  align-items: center;
}
.dropdown-item:hover:not(:disabled) { background: var(--c-primary-soft); }
.dropdown-item.separator { border-top: 1px solid var(--c-border); }
.dropdown-item .check { width: 14px; display: inline-block; }
.dropdown-group { padding: 6px 12px 2px; font-size: var(--fs-small); color: var(--c-text-muted); }
.dropdown-item.nested { padding-left: 26px; }

/* body: rail + main menu + desktop */
.client-body {
  display: grid;
  grid-template-columns: 0 260px 1fr;
  min-height: 0;
  min-width: 0;
}
.client.menu-collapsed .client-body { grid-template-columns: 48px 0 1fr; }
.menu-rail { grid-column: 1; }
.mainmenu { grid-column: 2; }
.desktop { grid-column: 3; }
.menu-rail {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 6px 4px;
  background: var(--c-surface-2);
  border-right: 1px solid var(--c-border);
  overflow-y: auto;
}
.client.menu-collapsed .menu-rail { display: flex; }
.client.menu-collapsed .mainmenu { display: none; }
.rail-btn {
  min-height: var(--touch);
  border: 0;
  border-radius: var(--radius);
  background: var(--c-bar);
  color: var(--c-bar-text);
  font-weight: 600;
  font-size: var(--fs-small);
}
.mainmenu {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
}
.mainmenu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 6px 12px;
  font-weight: 600;
}
.menu-search {
  margin: 0 8px 6px;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
}
.menu-tree { overflow-y: auto; padding: 0 4px 12px; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius);
  background: none;
  text-align: left;
}
.menu-item:hover { background: var(--c-primary-soft); }
.menu-item.depth-0 { font-weight: 600; }
.menu-item.depth-1 { padding-left: 20px; }
.menu-item.depth-2 { padding-left: 34px; }
.menu-item.depth-3 { padding-left: 48px; }
.menu-item.depth-4 { padding-left: 62px; }
.menu-item.disabled { color: var(--c-text-muted); opacity: 0.6; cursor: default; }
.menu-item.flash { animation: flash 0.5s ease-in-out 3; background: var(--c-accent-soft); }
@keyframes flash { 50% { background: var(--c-accent); color: var(--c-chrome); } }
.caret { width: 12px; color: var(--c-text-muted); }
.search-hit { flex-direction: column; align-items: flex-start; justify-content: center; padding: 4px 8px; }
.menu-hit-path { font-size: calc(11px * var(--text-scale)); color: var(--c-text-muted); }
.menu-empty { padding: 8px 12px; color: var(--c-text-muted); }

.desktop {
  position: relative;
  overflow: hidden;
  min-width: 0;
  background:
    radial-gradient(circle at 82% 88%, rgba(199, 155, 99, 0.12), transparent 40%),
    var(--c-bg);
}

/* windows */
.win {
  position: absolute;
  display: flex;
  flex-direction: column;
  min-width: 420px;
  background: var(--c-surface);
  border: 1px solid var(--c-border-strong);
  border-radius: 6px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.win.active { border-color: var(--c-title-border); }
.win.maximized { border-radius: 0; }
/* Resize grips on the right edge, the bottom edge and the corner (SPEC §6.2). */
.win-resize { position: absolute; z-index: 2; touch-action: none; }
.win-resize-e { top: 40px; right: 0; bottom: 12px; width: 6px; cursor: ew-resize; }
.win-resize-s { left: 0; right: 12px; bottom: 0; height: 6px; cursor: ns-resize; }
.win-resize-se {
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, var(--c-border-strong) 50%, var(--c-border-strong) 58%, transparent 58%,
    transparent 70%, var(--c-border-strong) 70%, var(--c-border-strong) 78%, transparent 78%);
}
.win.maximized .win-resize { display: none; }
/* A window made larger gives the room to its matrix. */
.win.sized .win-body { flex: 1; }
.win.sized .tabpanel { flex: 1 0 auto; }
.win.sized .tabpanel > .matrix-block, .win.sized .win-body > .matrix-block { flex: 1 0 auto; }
.win.sized .matrix-wrap { flex: 1 0 auto; max-height: none; height: 0; min-height: 220px; }
.win-controls { display: flex; align-items: center; }
.win-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 0 12px;
  min-height: 36px;
  background: var(--c-title-inactive);
  color: var(--c-title-inactive-text);
  cursor: move;
  touch-action: none;
  user-select: none;
}
.win.active .win-titlebar { background: var(--c-title); color: var(--c-title-text); box-shadow: inset 0 -2px 0 var(--c-title-line); }
.win-title { font-weight: 600; }
.win-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px;
  background: var(--c-surface-2);
  border-bottom: 1px solid var(--c-border);
  min-height: 44px;
}
.toolbar-label { display: flex; align-items: center; gap: 8px; }
.toolbar-label select { height: 32px; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  min-width: var(--touch);
  min-height: var(--touch);
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: none;
  font-size: calc(16px * var(--text-scale));
  line-height: 1;
}
.icon-btn:hover:not(:disabled) { background: var(--c-primary-soft); border-color: var(--c-border); }
.win-titlebar .icon-btn { color: inherit; min-height: 32px; min-width: 32px; font-size: calc(18px * var(--text-scale)); }
.win-titlebar .icon-btn:hover { background: color-mix(in srgb, currentColor 14%, transparent); }
.win-body { overflow: auto; padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.win-body > * { flex-shrink: 0; }

/* fields: label column and field column as in the B1 client; columns side by side (layouts.js) */
.form-header { display: grid; gap: 0 32px; align-items: start; }
.form-header.cols-1 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.form-header.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-header.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-col { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.form-wide .field { grid-template-columns: minmax(110px, calc((100% - 32px) / 2 * 0.42)) 1fr; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px 32px;
}
.form-grid.single { grid-template-columns: minmax(0, 1fr); }
.field {
  display: grid;
  grid-template-columns: minmax(110px, 42%) 1fr;
  align-items: center;
  gap: 8px;
  min-height: calc(28px * var(--text-scale));
}
.field label {
  font-size: var(--fs-small);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--c-border);
}
.field.required label::after { content: " *"; color: var(--c-error); }
.field-button { grid-template-columns: 1fr; }
/* Journal entry: rows of fields with the label above them. */
.form-strip { display: flex; flex-direction: column; gap: 6px; }
.strip-row { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: end; }
.field.stacked { grid-template-columns: 1fr; gap: 2px; min-width: 120px; flex: 1 1 120px; max-width: 220px; }
.field.stacked label { border-bottom: 0; padding: 0; }
.field.stacked:has(input[type="checkbox"]) { flex: 0 1 auto; min-width: 0; }
.control { display: flex; align-items: center; gap: 6px; min-width: 0; }
.control > input[type="text"], .control > select, .control > .lookup, .control > .control-pair { flex: 1; min-width: 0; }
/* [Series ▾][No.] and [Code][Type ▾] in one control. */
.control-pair { display: flex; gap: 4px; min-width: 0; }
.control-pair > * { flex: 1 1 0; min-width: 0; }
.control-pair.pair-series > select { flex: 0 1 45%; }
input[type="text"], select {
  height: var(--field-h);
  padding: 0 6px;
  border: 1px solid var(--c-input-border);
  border-radius: 2px;
  background: var(--c-input);
  width: 100%;
}
input[type="text"]:focus, select:focus { border-color: var(--c-primary); outline: none; box-shadow: 0 0 0 2px var(--c-accent-soft); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--c-primary); }
input[readonly], select:disabled { background: var(--c-readonly); border-color: var(--c-border); color: var(--c-text); }
.input-number { text-align: right; }
.find-mode .field:not(.readonly) input[type="text"] { background: var(--c-find); }
/* Choose From List: a small list button inside the field, at its right edge. Typing a code and Tab, or
   Enter, works too; on touch a tap in the field opens the list. */
.lookup { position: relative; display: flex; align-items: center; min-width: 0; }
.lookup input[type="text"] { padding-right: 24px; }
.cfl-btn.icon-btn {
  position: absolute;
  right: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 2px;
  background: none;
  color: var(--c-text-muted);
  font-size: calc(12px * var(--text-scale));
  line-height: 1;
  opacity: 0.7;
}
.cfl-btn.icon-btn:hover:not(:disabled) { background: var(--c-primary-soft); color: var(--c-primary); border: 0; opacity: 1; }
.matrix .cfl-btn.icon-btn { opacity: 0; }
.matrix td:hover .cfl-btn.icon-btn, .matrix td:focus-within .cfl-btn.icon-btn { opacity: 0.8; }
@media (pointer: coarse) { .cfl-btn.icon-btn { display: none; } .lookup input[type="text"] { padding-right: 6px; } }
.account-name { font-size: var(--fs-small); color: var(--c-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.link-arrow { color: var(--c-primary); min-width: 30px; min-height: 30px; font-size: calc(15px * var(--text-scale)); }
/* An account name next to a narrow field drops below it, so the account number stays readable. */
.control:has(> .account-name) { flex-wrap: wrap; row-gap: 2px; }
.control:has(> .account-name) > :first-child { flex: 1 1 80px; }

/* tabs */
.tabstrip { display: flex; gap: 2px; border-bottom: 1px solid var(--c-border); flex-wrap: wrap; }
.tab {
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid var(--c-border);
  border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--c-surface-2);
  color: var(--c-text-muted);
}
.tab.active { background: var(--c-surface); color: var(--c-text); font-weight: 600; box-shadow: 0 2px 0 var(--c-surface); }
.tabpanel { display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.empty-tab { color: var(--c-text-muted); padding: 8px 0; }

/* matrix: a grid with visible cells, like a spreadsheet */
.matrix-block { display: flex; flex-direction: column; gap: 6px; }
.matrix-wrap { overflow: auto; max-height: 300px; border: 1px solid var(--c-border-strong); background: var(--c-surface); }
.matrix { width: 100%; font-size: var(--fs-small); border-collapse: separate; border-spacing: 0; }
.matrix th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: calc(24px * var(--text-scale));
  padding: 0 6px;
  background: var(--c-card);
  border-right: 1px solid var(--c-border);
  border-bottom: 1px solid var(--c-border-strong);
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}
.matrix th.required::after { content: " *"; color: var(--c-error); }
.matrix th.num, .matrix td.num { text-align: right; }
.matrix td {
  height: calc(24px * var(--text-scale));
  padding: 0;
  border-right: 1px solid var(--c-grid);
  border-bottom: 1px solid var(--c-grid);
  min-width: 80px;
  background: var(--c-input);
}
.matrix td.readonly { background: var(--c-readonly); }
.matrix td input[type="text"], .matrix td select {
  display: block;
  height: calc(23px * var(--text-scale));
  min-width: 80px;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
}
.matrix td input[type="text"]:focus, .matrix td select:focus { border-color: var(--c-primary); box-shadow: none; background: var(--c-surface); }
.matrix td input[type="checkbox"] { display: block; margin: 0 auto; }
.matrix .rownum {
  width: 32px;
  min-width: 32px;
  text-align: center;
  background: var(--c-card);
  border-right: 1px solid var(--c-border-strong);
  color: var(--c-text-muted);
}
.matrix tr.selected td { background: var(--c-accent-soft); }
.matrix tr.selected .rownum { background: var(--c-accent); color: var(--c-chrome); }
.matrix tr.filler td { background: var(--c-surface); }
.matrix tr.filler .rownum { background: var(--c-surface-2); }
.rownum-btn { width: 100%; height: calc(23px * var(--text-scale)); padding: 0; border: 0; background: none; color: inherit; font-size: calc(11px * var(--text-scale)); }
.cell-text { display: block; padding: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: calc(23px * var(--text-scale)); }
.matrix-buttons { display: flex; gap: 6px; }
.matrix-totals { display: flex; justify-content: flex-end; gap: 18px; font-weight: 600; }

/* footer and buttons */
.form-footer { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; align-items: start; }
.form-footer .form-col.totals { padding-left: 15%; }
.base-link { display: flex; align-items: center; gap: 6px; color: var(--c-text-muted); font-size: var(--fs-small); }
.form-buttons { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
.form-buttons .spacer { flex: 1; }
.form-buttons button, .modal-buttons button, .small-btn, .form-btn {
  min-height: var(--touch);
  padding: 0 16px;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius);
  background: var(--c-surface);
}
.small-btn { min-height: 34px; padding: 0 10px; font-size: var(--fs-small); }
.btn-primary { background: var(--c-primary) !important; border-color: var(--c-primary-dark) !important; color: var(--c-on-primary); font-weight: 600; }
.form-buttons button:hover:not(:disabled):not(.btn-primary), .small-btn:hover:not(:disabled), .form-btn:hover:not(:disabled) { border-color: var(--c-primary); color: var(--c-primary-dark); }
.btn-primary:hover:not(:disabled) { background: var(--c-primary-dark) !important; }

/* status bar */
.statusbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  font-size: var(--fs-small);
  min-width: 0;
}
.sysinfo { color: var(--c-text-muted); padding-right: 12px; border-right: 1px solid var(--c-border); white-space: nowrap; }
.status-text { flex: 1; padding: 2px 8px; border-radius: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-ok { background: var(--c-ok-soft); color: var(--c-ok); }
.status-info { background: var(--c-info-soft); color: var(--c-info); }
.status-error { background: var(--c-error-soft); color: var(--c-error); }
.status-log { min-height: 26px; border: 1px solid var(--c-border); border-radius: 3px; background: none; padding: 0 8px; }

/* modals (Choose From List, Copy From, questions) */
.modal-overlay {
  position: absolute;
  inset: 0;
  z-index: 9000;
  display: grid;
  place-items: center;
  background: var(--c-overlay);
}
.modal {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(620px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  padding: 12px;
  background: var(--c-surface);
  border-radius: 6px;
  box-shadow: var(--shadow);
}
.modal.wide { width: min(820px, calc(100% - 32px)); }
.modal.small { width: min(420px, calc(100% - 32px)); }
.modal-title { font-weight: 600; font-size: calc(14px * var(--text-scale)); }
.modal-sub { margin: 0; color: var(--c-text-muted); }
.modal-buttons { display: flex; gap: 8px; justify-content: flex-end; }
.cfl-filter { height: 34px; padding: 0 8px; border: 1px solid var(--c-border); border-radius: var(--radius); }
.grid-wrap { overflow: auto; border: 1px solid var(--c-border); border-radius: 3px; min-height: 60px; }
.grid { width: 100%; font-size: var(--fs-small); }
.grid th {
  position: sticky;
  top: 0;
  padding: 6px 8px;
  background: var(--c-surface-2);
  border-bottom: 1px solid var(--c-border);
  text-align: left;
  white-space: nowrap;
}
.grid td { padding: 4px 8px; border-bottom: 1px solid var(--c-border); }
.grid .num { text-align: right; }
.grid tr.selected td { background: var(--c-primary-soft); }
.grid tr.clickable { cursor: pointer; }
.grid td.empty { color: var(--c-text-muted); text-align: center; padding: 12px; }
.link-btn {
  min-height: 30px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--c-primary-dark);
  text-decoration: underline;
}
.qty-input { width: 90px !important; text-align: right; }
.badge-ok { color: var(--c-ok); }
.badge-info { color: var(--c-info); }
.badge-error { color: var(--c-error); }
.matrix .lookup { min-width: 120px; }
.matrix .lookup input[type="text"] { padding-right: 22px; }

/* touch targets (SPEC §12): at least 40 px */
.small-btn, .link-arrow, .menu-item, .win-titlebar .icon-btn { min-height: var(--touch); }
.link-arrow, .win-titlebar .icon-btn { min-width: var(--touch); }
.win-titlebar { min-height: 42px; }
.form-error { color: var(--c-error); background: var(--c-error-soft); padding: 6px 8px; border-radius: 3px; }
/* Matrix rows keep their compact height on touch too (the row number cell is the whole row height). */

/* Help > Documentation */
.help { display: flex; flex-direction: column; gap: 4px; line-height: 1.5; max-width: 70ch; }
.help p { margin: 0 0 6px; }
.help h3 { font-family: var(--font-serif); font-weight: 500; font-size: calc(17px * var(--text-scale)); margin: 10px 0 4px; }
.help a { color: var(--c-primary); }
.help-keys td { padding: 3px 8px; }
.help-keys td:first-child { width: 130px; white-space: nowrap; }
kbd { font: calc(12px * var(--text-scale)) var(--font-mono); padding: 1px 5px; border: 1px solid var(--c-border-strong); border-bottom-width: 2px; border-radius: 3px; background: var(--c-surface-2); }
.win-toolbar:empty { display: none; }

/* Hover context: full text of a cut-off label, or the text of data-tip. */
.client { position: relative; }
.hover-tip {
  position: absolute;
  z-index: 20000;
  max-width: 360px;
  padding: 5px 9px;
  border-radius: var(--radius);
  background: var(--c-chrome);
  color: var(--c-chrome-text);
  font-size: var(--fs-small);
  line-height: 1.4;
  box-shadow: var(--shadow);
  pointer-events: none;
}
.brand-link { display: flex; align-items: center; min-height: 40px; }

/* A low screen (tablet in landscape): tighter fields, so a document window fits with its buttons. */
@media (max-height: 820px) {
  :root { --field-h: calc(24px * var(--text-scale)); }
  .field { min-height: 25px; gap: 6px; }
  .form-col { gap: 1px; }
  .win-body { gap: 7px; padding-top: 8px; padding-bottom: 8px; }
  .win-toolbar { min-height: 36px; }
  .tab { min-height: 30px; }
  .matrix-buttons .small-btn { min-height: 32px; }
}

/* Query Manager (SPEC 21.5.6) */
.qm-platform { display: flex; align-items: center; gap: 8px; }
.qm-badge { padding: 2px 10px; border: 1px solid var(--c-border-strong); border-radius: 10px; background: var(--c-surface-2); font-size: var(--fs-small); font-weight: 600; }
.qm-editor { display: flex; border: 1px solid var(--c-input-border); border-radius: var(--radius); background: var(--c-input); overflow: hidden; }
.qm-gutter, .qm-text {
  margin: 0;
  padding: 8px 0;
  font-family: var(--font-mono);
  font-size: calc(13px * var(--text-scale));
  line-height: 1.5;
}
.qm-gutter {
  flex: none;
  min-width: 3ch;
  padding: 8px 8px 24px;
  overflow: hidden;
  text-align: right;
  color: var(--c-text-muted);
  background: var(--c-surface-2);
  border-right: 1px solid var(--c-border);
  user-select: none;
}
.qm-text {
  flex: 1;
  min-width: 0;
  min-height: 9em;
  padding: 8px 10px;
  border: 0;
  outline: 0;
  resize: vertical;
  background: transparent;
  white-space: pre;
  overflow: auto;
}
.qm-editor:focus-within { outline: 2px solid var(--c-focus); outline-offset: 1px; }
.qm-other { display: inline-flex; align-items: center; gap: 6px; min-height: var(--touch); }
.qm-panes { display: flex; flex-direction: column; gap: 12px; }
.qm-pane-title { margin: 0 0 4px; font-size: var(--fs-small); font-weight: 600; color: var(--c-text-muted); }
.qm-grid { max-height: 300px; }
.qm-grid td { white-space: nowrap; }
.qm-null { color: var(--c-text-muted); font-style: italic; }
.qm-count { margin-top: 4px; font-size: var(--fs-small); color: var(--c-text-muted); }
.qm-error { display: flex; flex-direction: column; gap: 4px; }
.qm-error-line { font-family: var(--font-mono); font-size: calc(13px * var(--text-scale)); overflow-wrap: anywhere; }

/* Service Layer console (SPEC 21.8.3) and code viewer (SPEC 21.8.4) */
.sl-session { font-size: var(--fs-small); color: var(--c-text-muted); overflow-wrap: anywhere; }
.sl-request { display: flex; flex-wrap: wrap; gap: 8px; }
.sl-method { flex: none; width: auto; min-width: 110px; min-height: var(--touch); }
.sl-address { flex: 1 1 260px; min-width: 0; display: flex; align-items: stretch; border: 1px solid var(--c-input-border); border-radius: var(--radius); background: var(--c-input); overflow: hidden; }
.sl-address:focus-within { outline: 2px solid var(--c-focus); outline-offset: 1px; }
.sl-host { flex: none; display: flex; align-items: center; padding: 0 8px; background: var(--c-surface-2); border-right: 1px solid var(--c-border); color: var(--c-text-muted); font-family: var(--font-mono); font-size: calc(13px * var(--text-scale)); max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sl-url { flex: 1; min-width: 0; min-height: var(--touch); padding: 0 8px; border: 0; outline: 0; background: transparent; font-family: var(--font-mono); font-size: calc(13px * var(--text-scale)); }
.sl-field { display: flex; flex-direction: column; gap: 2px; }
.sl-label { font-size: var(--fs-small); font-weight: 600; color: var(--c-text-muted); }
.sl-text { box-sizing: border-box; width: 100%; padding: 8px 10px; border: 1px solid var(--c-input-border); border-radius: var(--radius); background: var(--c-input); font-family: var(--font-mono); font-size: calc(13px * var(--text-scale)); line-height: 1.5; resize: vertical; white-space: pre; overflow: auto; }
.sl-text:focus { outline: 2px solid var(--c-focus); outline-offset: 1px; }
.sl-message:empty { display: none; }
.sl-response { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sl-response-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sl-status { font-weight: 600; }
.sl-status-error { color: var(--c-error); }
.sl-headers, .sl-body { margin: 0; padding: 8px 10px; border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-surface-2); font-family: var(--font-mono); font-size: calc(13px * var(--text-scale)); line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 320px; overflow: auto; }
.sl-headers:empty { display: none; }
.sl-explain { margin: 0; padding: 6px 10px; border-left: 3px solid var(--c-info); background: var(--c-info-soft); }

.code-viewer { display: flex; border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-surface-2); overflow: auto; max-height: 60vh; }
.code-viewer:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 1px; }
.code-gutter, .code-text { margin: 0; padding: 8px 0; font-family: var(--font-mono); font-size: calc(13px * var(--text-scale)); line-height: 1.5; }
.code-gutter { flex: none; min-width: 3ch; padding: 8px 8px; text-align: right; color: var(--c-text-muted); background: var(--c-surface); border-right: 1px solid var(--c-border); user-select: none; position: sticky; left: 0; }
.code-text { flex: 1; padding: 8px 10px; white-space: pre; }
.code-keyword { color: var(--c-primary); font-weight: 600; }
.code-string { color: var(--c-ok); }
.code-number { color: var(--c-info); }
.code-comment { color: var(--c-text-muted); font-style: italic; }

/* Customization windows (SPEC §21.6): tree layout (User-Defined Fields - Management) and wizard (Objects Registration Wizard) */
.tree-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 12px; align-items: start; }
.tree-pane { border: 1px solid var(--c-border-strong); background: var(--c-surface); max-height: 420px; overflow: auto; padding: 4px 0; }
.tree-pane ul { list-style: none; margin: 0; padding: 0; }
.tree-pane ul ul { padding-left: 14px; }
.tree-pane button {
  display: flex; align-items: center; gap: 6px; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 5px 8px; min-height: 30px; color: var(--c-text); border-left: 3px solid transparent;
}
.tree-pane button:hover { background: var(--c-surface-2); }
.tree-pane .tree-branch { font-weight: 600; }
.tree-pane .tree-leaf.selected { background: var(--c-primary-soft); border-left-color: var(--c-accent); color: var(--c-primary-dark); font-weight: 600; }
.tree-caret { width: 1em; color: var(--c-text-muted); }
.tree-main { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.wizard-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; border-bottom: 2px solid var(--c-accent); padding-bottom: 4px; }
.wizard-title { margin: 0; font-size: 1.05em; color: var(--c-primary-dark); }
.wizard-count { color: var(--c-text-muted); font-size: 0.9em; }
.matrix-caption { margin: 4px 0 0; font-weight: 600; color: var(--c-text-muted); }
.wizard-list { width: 100%; }
@media (max-width: 1100px) { .tree-layout { grid-template-columns: 190px minmax(0, 1fr); } }
/* a narrow window (the play screen on a tablet): the tree on top, the form below in one column */
.tree-wrap { container-type: inline-size; }
@container (max-width: 640px) {
  .tree-layout { grid-template-columns: minmax(0, 1fr); }
  .tree-pane { max-height: 150px; }
  .tree-main .form-grid { grid-template-columns: minmax(0, 1fr); }
}
