/* Components — tactile surfaces, inset wells, amber accent. */

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  --btn-h: var(--control-h);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: var(--btn-h); padding: 0 14px;
  border-radius: var(--r-sm);
  font-size: var(--fs-13); font-weight: 600; letter-spacing: .005em; white-space: nowrap;
  color: var(--text-1);
  background: var(--raised-grad);
  box-shadow: var(--shadow-1), 0 0 0 1px var(--line-2);
  transition: background var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease), transform var(--dur-1) var(--ease), color var(--dur-1);
  user-select: none;
}
.btn:hover { background: var(--raised-grad-hover); }
.btn:active { transform: translateY(1px); box-shadow: var(--shadow-pressed); }
.btn:focus-visible { box-shadow: var(--shadow-1), 0 0 0 1px var(--line-2), var(--focus-ring); border-radius: var(--r-sm); }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; box-shadow: none; }
.btn .icon { margin: 0 -2px; opacity: .92; }

.btn-primary {
  color: var(--text-on-accent);
  background: var(--accent-grad);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), inset 0 -1px 0 rgba(0, 0, 0, .18), var(--accent-glow);
  text-shadow: 0 1px 0 rgba(255, 255, 255, .18);
}
.btn-primary:hover { background: var(--accent-grad); filter: brightness(1.06); }
.btn-primary:active { box-shadow: inset 0 2px 6px rgba(80, 30, 0, .45); filter: brightness(.96); }
.btn-primary:focus-visible { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), var(--accent-glow), var(--focus-ring); }

.btn-ghost { background: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--accent-softer); color: var(--text-1); }
.btn-ghost:active { box-shadow: var(--shadow-pressed); }
.btn-ghost.is-active { color: var(--accent-hi); background: var(--accent-soft); }

/* White text needs a deep red behind it: 5:1 or more over the whole gradient. */
.btn-danger { color: #fff; background: linear-gradient(180deg, #c8463c, #a8342b); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 4px 14px -4px rgba(234, 107, 97, .55); }
.btn-danger:hover { filter: brightness(1.05); background: linear-gradient(180deg, #c8463c, #a8342b); }
.btn-outline-danger { color: var(--bad); }

.btn-sm { --btn-h: var(--control-h-sm); padding: 0 10px; font-size: var(--fs-12); border-radius: var(--r-xs); gap: 5px; }
.btn-lg { --btn-h: var(--control-h-lg); padding: 0 20px; font-size: var(--fs-14); border-radius: var(--r-md); }
.btn-icon { width: var(--btn-h); padding: 0; }
.btn-round { border-radius: var(--r-pill); }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; gap: 2px; padding: 2px; border-radius: var(--r-sm); background: var(--sunken); box-shadow: var(--well); }
.btn-group .btn { box-shadow: none; background: transparent; height: calc(var(--control-h) - 4px); color: var(--text-2); }
.btn-group .btn:hover { color: var(--text-1); background: var(--surface-hi); }
.btn-group .btn.is-active { background: var(--raised-grad); color: var(--text-1); box-shadow: var(--shadow-1); }

/* ── Form controls ──────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); align-items: center; gap: var(--sp-3); min-height: var(--control-h); }
.field-row > .label { margin: 0; }
.label { display: flex; align-items: center; gap: 6px; font-size: var(--fs-12); font-weight: 600; color: var(--text-2); }
.label .hint-icon { color: var(--text-4); cursor: help; }
.label .hint-icon:hover { color: var(--accent-hi); }
.help { font-size: var(--fs-11); color: var(--text-3); }
.field-error { font-size: var(--fs-11); color: var(--bad); display: flex; gap: 5px; align-items: flex-start; }
.field-error .icon { margin-top: 1px; }

.input, .select, .textarea {
  width: 100%; min-width: 0;
  height: var(--control-h);
  padding: 0 11px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: var(--sunken);
  box-shadow: var(--well);
  color: var(--text-1);
  font-size: var(--fs-13);
  transition: border-color var(--dur-1), box-shadow var(--dur-1), background var(--dur-1);
}
.textarea { height: auto; min-height: 84px; padding: 9px 11px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--text-4); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-2); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent-line); box-shadow: var(--well), 0 0 0 3px var(--accent-softer), 0 0 14px -2px rgba(240, 138, 60, .25); }
.input[readonly] { color: var(--text-2); }
.input.is-invalid, .select.is-invalid { border-color: rgba(234, 107, 97, .6); box-shadow: var(--well), 0 0 0 3px var(--bad-soft); }
.input.num { text-align: right; font-variant-numeric: tabular-nums; }
.input-sm, .select-sm { height: var(--control-h-sm); font-size: var(--fs-12); padding: 0 9px; border-radius: var(--r-xs); }

.select { appearance: none; -webkit-appearance: none; padding-right: 30px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10.5px) 52%;
  background-size: 4.5px 4.5px, 4.5px 4.5px; background-repeat: no-repeat;
  background-color: var(--sunken);
}
.select option { background: var(--surface); color: var(--text-1); }

/* Number with unit: one sunken well, unit picker docked on the right. */
.qty {
  display: flex; align-items: stretch; height: var(--control-h); min-width: 0;
  border-radius: var(--r-sm); border: 1px solid transparent;
  background: var(--sunken); box-shadow: var(--well);
  transition: border-color var(--dur-1), box-shadow var(--dur-1);
}
.qty:hover { border-color: var(--line-2); }
.qty:focus-within { border-color: var(--accent-line); box-shadow: var(--well), 0 0 0 3px var(--accent-softer), 0 0 14px -2px rgba(240, 138, 60, .25); }
.qty.is-invalid { border-color: rgba(234, 107, 97, .6); box-shadow: var(--well), 0 0 0 3px var(--bad-soft); }
.qty.is-computed { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.qty input {
  flex: 1 1 auto; min-width: 0; height: 100%; border: 0; background: transparent; padding: 0 4px 0 11px;
  text-align: right; font-variant-numeric: tabular-nums; font-size: var(--fs-13); color: var(--text-1);
}
.qty input:focus { box-shadow: none; }
.qty .unit {
  flex: none; display: flex; align-items: center; padding: 0 10px 0 6px; min-width: 42px;
  font-size: var(--fs-12); color: var(--text-3); white-space: nowrap;
}
.qty select.unit { appearance: none; -webkit-appearance: none; border: 0; background: transparent; cursor: pointer; padding-right: 18px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-4) 50%), linear-gradient(135deg, var(--text-4) 50%, transparent 50%);
  background-position: calc(100% - 10px) 54%, calc(100% - 6.5px) 54%; background-size: 3.5px 3.5px, 3.5px 3.5px; background-repeat: no-repeat;
  border-left: 1px solid var(--line); border-radius: 0; color: var(--text-2);
}
.qty select.unit:hover { color: var(--accent-hi); }
.qty select.unit:focus { box-shadow: none; color: var(--accent-hi); }
.qty-sm { height: var(--control-h-sm); }
.qty-sm input { font-size: var(--fs-12); padding-left: 8px; }

/* Switch */
.switch { position: relative; display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; font-size: var(--fs-13); color: var(--text-2); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { position: relative; width: 36px; height: 20px; border-radius: var(--r-pill); background: var(--sunken); box-shadow: var(--well); transition: background var(--dur-2) var(--ease); flex: none; }
.switch .knob { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--raised-grad); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 1px 3px rgba(0, 0, 0, .5); transition: transform var(--dur-2) var(--ease-spring); }
.switch input:checked + .track { background: var(--accent-grad); box-shadow: inset 0 1px 2px rgba(0, 0, 0, .25), 0 0 12px -2px rgba(240, 138, 60, .55); }
.switch input:checked + .track .knob { transform: translateX(16px); background: linear-gradient(180deg, #fff, #f1e9df); }
.switch input:focus-visible + .track { box-shadow: var(--well), var(--focus-ring); }

/* Checkbox / radio */
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: var(--fs-13); color: var(--text-2); user-select: none; }
.check input { appearance: none; -webkit-appearance: none; width: 17px; height: 17px; margin: 0; border-radius: 5px; background: var(--sunken); box-shadow: var(--well); display: grid; place-items: center; flex: none; transition: background var(--dur-1); cursor: pointer; }
.check input[type="radio"] { border-radius: 50%; }
.check input:checked { background: var(--accent-grad); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 0 10px -2px rgba(240, 138, 60, .6); }
.check input:checked::after { content: ""; width: 9px; height: 5px; border-left: 2px solid var(--text-on-accent); border-bottom: 2px solid var(--text-on-accent); transform: translateY(-1px) rotate(-45deg); }
.check input[type="radio"]:checked::after { width: 7px; height: 7px; border: 0; border-radius: 50%; background: var(--text-on-accent); transform: none; }
.check input:focus-visible { box-shadow: var(--well), var(--focus-ring); }

/* Segmented control */
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r-sm); background: var(--sunken); box-shadow: var(--well); }
.segmented button { height: calc(var(--control-h) - 6px); padding: 0 12px; border-radius: 6px; font-size: var(--fs-12); font-weight: 600; color: var(--text-3); transition: color var(--dur-1), background var(--dur-1); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.segmented button:hover { color: var(--text-1); }
.segmented button.is-active { color: var(--text-1); background: var(--raised-grad); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }
.segmented.accent button.is-active { color: var(--text-on-accent); background: var(--accent-grad); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 2px 10px -2px rgba(240, 138, 60, .55); }
.segmented.sm button { height: 24px; padding: 0 9px; font-size: var(--fs-11); }
.segmented.block { display: flex; } .segmented.block button { flex: 1; justify-content: center; }

/* Range slider */
.range { -webkit-appearance: none; appearance: none; width: 100%; height: 20px; background: transparent; cursor: pointer; }
.range::-webkit-slider-runnable-track { height: 6px; border-radius: 6px; background: linear-gradient(90deg, var(--accent) 0 var(--pct, 50%), var(--sunken) var(--pct, 50%)); box-shadow: var(--well); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%; background: linear-gradient(180deg, #fff, #ece3d7); box-shadow: 0 2px 6px rgba(0, 0, 0, .5), 0 0 0 3px rgba(240, 138, 60, .35); }
.range::-moz-range-track { height: 6px; border-radius: 6px; background: var(--sunken); }
.range::-moz-range-progress { height: 6px; border-radius: 6px; background: var(--accent); }
.range::-moz-range-thumb { width: 16px; height: 16px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(240, 138, 60, .35); }

/* ── Tabs ───────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 12px; font-size: var(--fs-13); font-weight: 600; color: var(--text-3); white-space: nowrap; transition: color var(--dur-1); }
.tab:hover { color: var(--text-1); }
.tab.is-active { color: var(--text-1); }
.tab.is-active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.tab .count { font-size: var(--fs-11); padding: 0 6px; border-radius: var(--r-pill); background: var(--surface-hi); color: var(--text-3); font-variant-numeric: tabular-nums; }
.pill-tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: var(--r-md); background: var(--sunken); box-shadow: var(--well); }
.pill-tabs .tab { height: 30px; border-radius: var(--r-sm); }
.pill-tabs .tab.is-active { background: var(--raised-grad); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }
.pill-tabs .tab.is-active::after { display: none; }
/* Pages that share one navigation item: the tabs scroll sideways rather than widen the page. */
.section-nav { max-width: 100%; overflow-x: auto; scrollbar-width: none; margin-bottom: 18px; }
.section-nav::-webkit-scrollbar { display: none; }

/* ── Cards and panels ───────────────────────────────────────────────────────── */
.card {
  position: relative; min-width: 0;
  border-radius: var(--r-lg);
  background: var(--surface-grad);
  box-shadow: var(--shadow-2), 0 0 0 1px var(--line);
}
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px var(--sp-3); padding: 14px 16px 0; min-height: 44px; }
/* The title takes the line; when the actions no longer fit beside it, they move below it. */
.card-head > .col { flex: 1 1 14rem; }
.card-head h2, .card-head h3 { font-size: var(--fs-14); font-weight: 600; color: var(--text-1); letter-spacing: -.005em; }
.card-head .sub { font-size: var(--fs-12); color: var(--text-3); }
.card-head .actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.card-body { padding: 14px 16px 16px; }
.card-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: var(--sp-2); align-items: center; }
.card.flat { box-shadow: 0 0 0 1px var(--line); background: var(--surface-lo); }
.card.well { background: var(--sunken); box-shadow: var(--well); }
.card.interactive { cursor: pointer; transition: transform var(--dur-2) var(--ease), box-shadow var(--dur-2); }
.card.interactive:hover { transform: translateY(-2px); box-shadow: var(--shadow-3), 0 0 0 1px var(--line-2); }
.card.accent-edge::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); box-shadow: 0 0 12px var(--accent); }

.section-title { display: flex; align-items: center; gap: 8px; font-size: var(--fs-11); font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--text-3); }
.section-title .icon { color: var(--text-4); }
.section-title .actions { margin-left: auto; display: flex; gap: 4px; text-transform: none; letter-spacing: 0; }

/* ── Badges, tags and source labels ─────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 21px; padding: 0 8px; border-radius: var(--r-pill); font-size: var(--fs-11); font-weight: 600; white-space: nowrap; background: var(--surface-hi); color: var(--text-2); box-shadow: inset 0 0 0 1px var(--line); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 6px currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); box-shadow: inset 0 0 0 1px rgba(95, 190, 137, .22); }
.badge.warn { background: var(--warn-soft); color: var(--warn); box-shadow: inset 0 0 0 1px rgba(233, 177, 76, .22); }
.badge.bad { background: var(--bad-soft); color: var(--bad); box-shadow: inset 0 0 0 1px rgba(234, 107, 97, .22); }
.badge.info { background: var(--info-soft); color: var(--info); box-shadow: inset 0 0 0 1px rgba(125, 183, 234, .22); }
.badge.accent { background: var(--accent-soft); color: var(--accent-hi); box-shadow: inset 0 0 0 1px var(--accent-line); }
.badge.solid { background: var(--accent-grad); color: var(--text-on-accent); box-shadow: none; }
.badge.lg { height: 25px; padding: 0 11px; font-size: var(--fs-12); }

.src { display: inline-flex; align-items: center; height: 17px; padding: 0 6px; border-radius: 4px; font-size: 9.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; white-space: nowrap; }
.src.measured { color: var(--teal); background: rgba(92, 196, 180, .12); }
.src.design { color: var(--cool); background: var(--info-soft); }
.src.calculated { color: var(--text-3); background: var(--surface-hi); }
.src.manufacturer { color: var(--violet); background: rgba(181, 156, 236, .13); }
.src.user { color: var(--text-2); background: var(--surface-hi); }
.src.illustrative { color: var(--warn); background: var(--warn-soft); }
.src.climate { color: var(--gold); background: rgba(227, 179, 102, .13); }

.kbd, kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px; font: 600 10.5px/1 var(--font-ui); color: var(--text-3); background: var(--surface-hi); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .35), 0 0 0 1px var(--line-2); }

.dot-status { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot-status.ok { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot-status.warn { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.dot-status.bad { background: var(--bad); box-shadow: 0 0 8px var(--bad); }
.dot-status.idle { background: var(--text-4); }

/* ── KPI / metric tiles ─────────────────────────────────────────────────────── */
.kpi { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.kpi .k-label { font-size: var(--fs-11); font-weight: 600; color: var(--text-3); letter-spacing: .04em; text-transform: uppercase; display: flex; gap: 6px; align-items: center; }
.kpi .k-value { display: flex; align-items: baseline; gap: 5px; font-family: var(--font-display); font-size: var(--fs-28); font-weight: 600; letter-spacing: -.02em; color: var(--text-1); font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi .k-unit { font-family: var(--font-ui); font-size: var(--fs-13); font-weight: 500; color: var(--text-3); letter-spacing: 0; }
.kpi .k-sub { font-size: var(--fs-12); color: var(--text-3); }
.kpi.sm .k-value { font-size: var(--fs-20); }
.kpi.lg .k-value { font-size: var(--fs-34); }
.kpi.accent .k-value { color: var(--accent-hi); text-shadow: 0 0 22px rgba(240, 138, 60, .35); }
.kpi.cool .k-value { color: var(--cool); text-shadow: 0 0 22px rgba(125, 183, 234, .25); }
.kpi.teal .k-value { color: var(--teal); }

.kpi-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; border-radius: var(--r-lg); overflow: hidden; background: var(--line); box-shadow: var(--shadow-2), 0 0 0 1px var(--line); }
.kpi-strip > .kpi { padding: 14px 16px; background: var(--surface-grad); }

/* Property tables (state inspector, results) */
/* The label column never shrinks below its longest word; a long value wraps instead of running over it. */
.props { display: grid; grid-template-columns: minmax(min-content, 1fr) auto auto; align-items: baseline; column-gap: 8px; }
.props > .p-row { display: contents; }
.props .p-k { padding: 6px 0; font-size: var(--fs-12); color: var(--text-2); border-bottom: 1px solid var(--line); min-width: 0; display: flex; gap: 6px; align-items: center; }
.props .p-v { padding: 6px 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text-1); border-bottom: 1px solid var(--line); overflow-wrap: break-word; }
.props .p-u { padding: 6px 0; font-size: var(--fs-11); color: var(--text-3); border-bottom: 1px solid var(--line); white-space: nowrap; min-width: 44px; }
.props > .p-row:last-child > * { border-bottom: 0; }
.props .p-row.is-input .p-v { color: var(--accent-hi); }
.props .p-row.is-input .p-k::after { content: "INPUT"; font-size: 9px; font-weight: 700; letter-spacing: .08em; color: var(--accent-hi); background: var(--accent-soft); padding: 1px 5px; border-radius: 3px; }

/* ── Data tables ────────────────────────────────────────────────────────────── */
.table-wrap { overflow: auto; border-radius: var(--r-md); }
.table { width: 100%; font-size: var(--fs-13); }
.table th { position: sticky; top: 0; z-index: 1; text-align: left; font-size: var(--fs-11); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); padding: 10px 12px; background: var(--surface-lo); border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.table th.num, .table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--text-1); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--text-1); vertical-align: middle; }
.table tbody tr { transition: background var(--dur-1); }
.table tbody tr:hover { background: var(--accent-softer); }
.table tbody tr.is-selected { background: var(--accent-soft); }
.table tbody tr.clickable { cursor: pointer; }
.table tr.group-row td { padding-top: 12px; font-size: var(--fs-11); font-weight: 650; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); background: var(--surface-lo); }
.table .cell-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.table .cell-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--raised-grad); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); color: var(--accent-hi); flex: none; }
.table .t-title { font-weight: 600; }
/* A clickable row's title is a link, so the keyboard can open the record too. */
.table a.t-title { color: var(--text-1); text-decoration: none; }
.table a.t-title:hover, .table a.t-title:focus-visible { text-decoration: underline; }
/* A row that takes focus itself: table rows paint an outline but not a box-shadow. */
.table tbody tr[tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; box-shadow: none; }
.table .t-sub { font-size: var(--fs-11); color: var(--text-3); }
.table.compact td, .table.compact th { padding: 6px 10px; }
.table .th-unit { display: block; margin-top: 1px; font-size: var(--fs-10); font-weight: 600; letter-spacing: .02em; text-transform: none; color: var(--text-4); }
/* Narrow state tables (side panels): units under the headers, tight cells. */
.table.states td, .table.states th { padding: 6px 5px; }
.table.states td { font-size: var(--fs-12); }
.table.states td:first-child, .table.states th:first-child { padding-left: 2px; }
.table td .input, .table td .qty { height: 28px; }

/* ── Lists ──────────────────────────────────────────────────────────────────── */
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-md); transition: background var(--dur-1); min-width: 0; }
.list-item:hover { background: var(--accent-softer); }
.list-item.clickable { cursor: pointer; }
.list-item .li-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--raised-grad); color: var(--accent-hi); box-shadow: var(--shadow-1), 0 0 0 1px var(--line); }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-weight: 600; color: var(--text-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .li-sub { font-size: var(--fs-12); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Alerts ─────────────────────────────────────────────────────────────────── */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-md); font-size: var(--fs-12); line-height: 1.5; background: var(--surface-hi); color: var(--text-2); box-shadow: inset 0 0 0 1px var(--line); }
.alert .icon { flex: none; margin-top: 1px; }
.alert strong { color: var(--text-1); font-weight: 600; }
.alert.info { background: var(--info-soft); box-shadow: inset 0 0 0 1px rgba(125, 183, 234, .2); } .alert.info .icon { color: var(--info); }
.alert.warn { background: var(--warn-soft); box-shadow: inset 0 0 0 1px rgba(233, 177, 76, .22); } .alert.warn .icon { color: var(--warn); }
.alert.bad { background: var(--bad-soft); box-shadow: inset 0 0 0 1px rgba(234, 107, 97, .22); } .alert.bad .icon { color: var(--bad); }
.alert.ok { background: var(--ok-soft); box-shadow: inset 0 0 0 1px rgba(95, 190, 137, .22); } .alert.ok .icon { color: var(--ok); }
.alert.accent { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); } .alert.accent .icon { color: var(--accent-hi); }
.alert .alert-actions { margin-left: auto; display: flex; gap: 6px; }

/* ── Empty states and skeletons ─────────────────────────────────────────────── */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 40px 24px; text-align: center; color: var(--text-3); }
.empty .e-icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--sunken); box-shadow: var(--well); color: var(--accent); margin-bottom: 6px; }
.empty .e-icon .icon { filter: drop-shadow(0 0 8px rgba(240, 138, 60, .45)); }
.empty h2, .empty h3 { font-size: var(--fs-15); color: var(--text-1); font-weight: 600; }
.empty p { max-width: 420px; font-size: var(--fs-13); line-height: 1.55; }
.empty .row { margin-top: 6px; }
.skeleton { border-radius: 6px; background: linear-gradient(90deg, var(--surface-hi) 0, var(--line-2) 50%, var(--surface-hi) 100%); background-size: 800px 100%; animation: shimmer 1.4s linear infinite; }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent); animation: spin .7s linear infinite; }

/* ── Progress ───────────────────────────────────────────────────────────────── */
.progress { position: relative; height: 8px; border-radius: var(--r-pill); background: var(--sunken); box-shadow: var(--well); overflow: hidden; }
.progress > span { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--accent-grad); box-shadow: 0 0 12px rgba(240, 138, 60, .6); transition: width var(--dur-3) var(--ease); }
.progress.ok > span { background: linear-gradient(90deg, #4aa877, var(--ok)); box-shadow: 0 0 10px rgba(95, 190, 137, .5); }
.progress.cool > span { background: linear-gradient(90deg, #4f8fc8, var(--cool)); box-shadow: 0 0 10px rgba(125, 183, 234, .5); }
.progress.sm { height: 5px; }

/* Stepper (commissioning workflow): a row of steps, and a list down the side where the row has no
   room for every label (a container query, so a narrow card does it too, not only a phone). */
.stepper { container-type: inline-size; }
.steps { display: flex; align-items: center; gap: 0; margin: 0; padding: 0; list-style: none; }
.step { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
.step:last-child { flex: 0 0 auto; }
.step .s-dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: var(--fs-12); font-weight: 700; color: var(--text-3); background: var(--sunken); box-shadow: var(--well); }
.step .s-label { font-size: var(--fs-12); font-weight: 600; color: var(--text-3); white-space: nowrap; }
.step .s-line { flex: 1; height: 2px; margin: 0 10px; border-radius: 2px; background: var(--line-2); min-width: 16px; }
.step.done .s-dot { color: var(--text-on-accent); background: var(--accent-grad); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 0 14px -2px rgba(240, 138, 60, .7); }
.step.done .s-line { background: var(--accent); box-shadow: 0 0 8px rgba(240, 138, 60, .6); }
.step.current .s-dot { color: var(--accent-hi); box-shadow: var(--well), 0 0 0 2px var(--accent), 0 0 16px rgba(240, 138, 60, .45); }
.step.current .s-label, .step.done .s-label { color: var(--text-1); }
@container (max-width: 720px) {
  .steps { flex-direction: column; align-items: stretch; gap: 10px; }
  .step, .step:last-child { flex: none; position: relative; }
  .step .s-label { white-space: normal; }
  .step .s-line { position: absolute; left: 14px; top: 32px; bottom: -8px; width: 2px; height: auto; margin: 0; min-width: 0; }
}

/* ── Gauges, pill bars and sparklines ───────────────────────────────────────── */
/* A dial keeps its size in a row (it never gives way to the text beside it), and only a container
   narrower than the dial makes it smaller: the drawing and its text (sized in cqw) then scale together.
   The text metrics below are the ones dialLayout() in components.js lays the text out with. */
.gauge { position: relative; flex: none; max-width: 100%; container-type: inline-size; }
.gauge svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.gauge .g-track { stroke: var(--sunken); }
.gauge .g-tick { stroke: var(--line-3); }
.gauge .g-tick.major { stroke: var(--text-4); }
.gauge .g-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; pointer-events: none; }
.gauge .g-value { font-family: var(--font-display); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.02em; color: var(--text-1); line-height: 1; white-space: nowrap; }
.gauge .g-unit { font-size: var(--fs-11); color: var(--text-3); margin-top: .2727em; line-height: 1.25; white-space: nowrap; }
.gauge .g-label { font-size: var(--fs-11); font-weight: 600; color: var(--text-3); letter-spacing: .05em; text-transform: uppercase; margin-top: .5455em; line-height: 1.25; text-wrap: balance; }
.gauge .g-label > span { display: block; white-space: nowrap; }

.pillbars { display: flex; align-items: flex-end; gap: 8px; height: 140px; padding-top: 8px; }
.pillbars .pb { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; min-width: 0; }
.pillbars .pb-track { position: relative; flex: 1; width: 100%; max-width: 26px; border-radius: var(--r-pill); background: var(--sunken); box-shadow: var(--well); overflow: hidden; }
.pillbars .pb-fill { position: absolute; left: 0; right: 0; bottom: 0; border-radius: var(--r-pill); background: linear-gradient(180deg, var(--accent-hi), var(--accent) 45%, rgba(240, 138, 60, .35)); box-shadow: 0 0 14px rgba(240, 138, 60, .4); transition: height var(--dur-3) var(--ease); }
.pillbars .pb-fill::before { content: ""; position: absolute; top: 3px; left: 50%; width: 6px; height: 6px; margin-left: -3px; border-radius: 50%; background: #fff4e6; box-shadow: 0 0 8px #ffc58f; }
.pillbars .pb-fill.cool { background: linear-gradient(180deg, #b6dcff, var(--cool) 45%, rgba(125, 183, 234, .3)); box-shadow: 0 0 14px rgba(125, 183, 234, .35); }
.pillbars .pb-fill.cool::before { background: #eef7ff; box-shadow: 0 0 8px #bfe0ff; }
.pillbars .pb-label { font-size: var(--fs-11); color: var(--text-3); white-space: nowrap; }
.pillbars .pb-value { font-size: var(--fs-11); font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* ── Overlays: dialogs, drawers, menus, popovers, tooltips, toasts ─────────── */
/* Dialogs and the command palette are centred with `translate`, not `transform`: rise-in animates transform, which would otherwise drop the centring while it plays. */
.scrim { position: fixed; inset: 0; z-index: 60; background: var(--scrim); backdrop-filter: blur(3px); animation: fade-in var(--dur-2) var(--ease); }
.dialog { position: fixed; z-index: 61; left: 50%; top: 12vh; translate: -50% 0; width: min(560px, calc(100vw - 32px)); max-height: 76vh; display: flex; flex-direction: column; border-radius: var(--r-xl); background: var(--surface-grad); box-shadow: var(--shadow-3), 0 0 0 1px var(--line-2); animation: rise-in var(--dur-2) var(--ease); }
.dialog.wide { width: min(860px, calc(100vw - 32px)); }
.dialog .d-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 6px; }
.dialog .d-head h2 { font-size: var(--fs-16); font-weight: 600; }
.dialog .d-body { padding: 10px 20px 18px; overflow: auto; }
.dialog .d-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.drawer { position: fixed; z-index: 61; top: 0; right: 0; bottom: 0; width: min(480px, 100vw); display: flex; flex-direction: column; background: var(--surface-grad); box-shadow: var(--shadow-3), 0 0 0 1px var(--line-2); animation: drawer-in var(--dur-2) var(--ease); }
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.menu { position: fixed; z-index: 70; min-width: 220px; max-width: 340px; padding: 6px; border-radius: var(--r-md); background: var(--surface-hi); box-shadow: var(--shadow-3), 0 0 0 1px var(--line-2); animation: rise-in var(--dur-1) var(--ease); }
.menu .m-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: var(--r-sm); font-size: var(--fs-13); color: var(--text-1); text-align: left; }
.menu .m-item:hover, .menu .m-item.is-active { background: var(--accent-soft); }
.menu .m-item .icon { color: var(--text-3); }
.menu .m-item:hover .icon { color: var(--accent-hi); }
.menu .m-item.danger { color: var(--bad); } .menu .m-item.danger .icon { color: var(--bad); }
.menu .m-sep { height: 1px; margin: 5px 4px; background: var(--line); }
.menu .m-label { padding: 6px 10px 4px; font-size: var(--fs-11); font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text-4); }
.menu .m-meta { margin-left: auto; font-size: var(--fs-11); color: var(--text-4); }

.popover { position: fixed; z-index: 70; width: 340px; border-radius: var(--r-lg); background: var(--surface-hi); box-shadow: var(--shadow-3), 0 0 0 1px var(--line-2); animation: rise-in var(--dur-1) var(--ease); overflow: hidden; }
.popover .po-head { display: flex; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 600; }
.popover .po-body { max-height: 420px; overflow: auto; padding: 6px; }

.tip { position: fixed; z-index: 90; max-width: 300px; padding: 8px 10px; border-radius: var(--r-sm); font-size: var(--fs-12); line-height: 1.45; color: var(--text-1); background: #2a2c33; box-shadow: var(--shadow-3), 0 0 0 1px var(--line-2); animation: fade-in var(--dur-1); }
:root[data-theme="light"] .tip { background: #2b2824; color: #f5f1ea; }

.toasts { position: fixed; z-index: 95; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 36px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-hi); box-shadow: var(--shadow-3), 0 0 0 1px var(--line-2); font-size: var(--fs-13); animation: rise-in var(--dur-2) var(--ease); position: relative; overflow: hidden; }
.toast::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.toast.ok::before { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.toast.bad::before { background: var(--bad); box-shadow: 0 0 10px var(--bad); }
.toast.warn::before { background: var(--warn); }
.toast .t-icon { color: var(--accent-hi); margin-top: 1px; } .toast.ok .t-icon { color: var(--ok); } .toast.bad .t-icon { color: var(--bad); } .toast.warn .t-icon { color: var(--warn); }
.toast .t-title { font-weight: 600; } .toast .t-msg { color: var(--text-2); font-size: var(--fs-12); margin-top: 2px; }
.toast .t-close { flex: none; margin-left: auto; width: 24px; height: 24px; display: grid; place-items: center; border-radius: var(--r-xs); color: var(--text-4); } .toast .t-close:hover { color: var(--text-1); }

/* Command palette */
.cmdk { position: fixed; z-index: 80; left: 50%; top: 11vh; translate: -50% 0; width: min(640px, calc(100vw - 28px)); border-radius: var(--r-xl); background: var(--surface-hi); box-shadow: var(--shadow-3), 0 0 0 1px var(--line-2), 0 0 60px -20px rgba(240, 138, 60, .25); overflow: hidden; animation: rise-in var(--dur-2) var(--ease); }
.cmdk .c-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; height: 56px; border-bottom: 1px solid var(--line); }
.cmdk .c-input .icon { color: var(--accent); }
.cmdk .c-input input { flex: 1; height: 100%; border: 0; background: transparent; font-size: var(--fs-16); color: var(--text-1); }
.cmdk .c-input input:focus { box-shadow: none; }
.cmdk .c-list { max-height: 52vh; overflow: auto; padding: 6px; }
.cmdk .c-group { padding: 10px 10px 4px; font-size: var(--fs-11); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-4); }
.cmdk .c-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--r-sm); cursor: pointer; }
.cmdk .c-item .c-ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--sunken); box-shadow: var(--well); color: var(--text-3); flex: none; }
.cmdk .c-item.is-active { background: var(--accent-soft); }
.cmdk .c-item.is-active .c-ic { color: var(--accent-hi); }
.cmdk .c-item .c-title { font-weight: 600; } .cmdk .c-item .c-sub { font-size: var(--fs-12); color: var(--text-3); }
.cmdk .c-item .c-meta { margin-left: auto; font-size: var(--fs-11); color: var(--text-4); }
.cmdk .c-foot { display: flex; gap: 14px; padding: 9px 16px; border-top: 1px solid var(--line); font-size: var(--fs-11); color: var(--text-4); }

/* Avatars */
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: var(--fs-11); font-weight: 700; color: var(--text-on-accent); background: var(--accent-grad); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 0 0 2px var(--bg-1), 0 0 0 3px var(--accent-line); }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.cool { background: linear-gradient(180deg, #a9d3fa, #5d9bd5); }
.avatar.teal { background: linear-gradient(180deg, #8ee3d6, #3ea595); }
.avatar.violet { background: linear-gradient(180deg, #d0bdf7, #8f73d6); }

.divider { height: 1px; background: var(--line); margin: var(--sp-3) 0; }
.vdivider { width: 1px; align-self: stretch; background: var(--line); }

/* Info tooltip trigger */
/* A 24 px target (WCAG 2.5.8) that takes the space of the 16 px icon around it. */
.hint { display: inline-grid; place-items: center; width: 24px; height: 24px; margin: -4px; border-radius: 50%; color: var(--text-4); cursor: help; }
.hint:hover, .hint:focus-visible { color: var(--accent-hi); }

/* Appearance picker: preview tiles. The miniatures use fixed colours (they preview a theme
   other than the current one), taken from the dark and light token sets. */
.theme-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.theme-tile { display: flex; flex-direction: column; gap: 8px; padding: 8px; border-radius: var(--r-md); background: var(--surface-lo); box-shadow: 0 0 0 1px var(--line); text-align: left; transition: box-shadow var(--dur-1), background var(--dur-1); }
.theme-tile:hover { background: var(--surface); box-shadow: 0 0 0 1px var(--line-2); }
.theme-tile.is-active { box-shadow: 0 0 0 2px var(--accent), 0 0 18px -4px var(--accent); }
.theme-tile:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: 2px; }
.theme-tile .tp { display: flex; height: 74px; border-radius: 9px; overflow: hidden; box-shadow: 0 0 0 1px rgba(127, 120, 110, .25); }
.theme-tile .tt { display: inline-flex; align-items: center; gap: 7px; padding: 0 2px 2px; font-size: var(--fs-12); font-weight: 650; color: var(--text-2); }
.theme-tile.is-active .tt { color: var(--text-1); }
.theme-tile.is-active .tt .icon { color: var(--accent-hi); }
.tp-mock { position: relative; flex: 1 1 0; min-width: 0; display: block; }
.tp-mock i { position: absolute; display: block; border-radius: 3px; }
.tp-mock .tp-rail { left: 0; top: 0; bottom: 0; width: 22%; border-radius: 0; }
.tp-mock .tp-bar { left: 27%; right: 6%; top: 9px; height: 7px; }
.tp-mock .tp-card { left: 27%; width: 31%; top: 24px; bottom: 9px; border-radius: 5px; }
.tp-mock .tp-card.tp-two { left: 63%; width: 31%; }
.tp-mock .tp-dot { left: 7%; top: 9px; width: 9%; height: 7px; border-radius: 2px; }
.tp-dark { background: #0f1012; }
.tp-dark .tp-rail { background: #141518; box-shadow: inset -1px 0 0 rgba(255, 255, 255, .06); }
.tp-dark .tp-bar { background: #24262c; }
.tp-dark .tp-card { background: #1c1d22; box-shadow: 0 0 0 1px rgba(255, 255, 255, .05); }
.tp-dark .tp-dot { background: #f08a3c; box-shadow: 0 0 6px #f08a3c; }
.tp-light { background: #e6e2dc; }
.tp-light .tp-rail { background: #ece8e2; box-shadow: inset -1px 0 0 rgba(60, 45, 30, .09); }
.tp-light .tp-bar { background: #fdfcfa; }
.tp-light .tp-card { background: #f6f3ee; box-shadow: 0 0 0 1px rgba(60, 45, 30, .08); }
.tp-light .tp-dot { background: #dc7323; }
@media (max-width: 520px) { .theme-pick { grid-template-columns: minmax(0, 1fr); } .theme-tile { flex-direction: row; align-items: center; } .theme-tile .tp { width: 108px; height: 56px; flex: none; } }
.theme-tile .tt-chip { margin-left: auto; padding: 1px 7px; border-radius: 999px; font-size: var(--fs-10); font-weight: 650; letter-spacing: .03em; color: var(--text-3); background: var(--surface-hi); box-shadow: 0 0 0 1px var(--line); }
