/* ─────────────────────────────────────────────────────────────────────
   Shop-manager look (owner, 21 Oct 2026: "That system is so easy,
   everything's clear … I want a proper working system").

   1. Light, the front desk's default: a white page, light grey panels, one
      strong blue for the main actions and headers, dark text, thin borders.
      Midnight, Sand, Charcoal and High contrast stay in Colours; a saved
      choice is kept.
   2. Documents as one workspace: the list on the left, the open document on
      the right with its stage tabs, the line items as a table you type in,
      and a right panel with status, totals and approval.

   Loaded after polish.css and before phone.css, so the iPhone rules still
   have the last word on a phone.
   ───────────────────────────────────────────────────────────────────── */

:root[data-theme="light"] {
  --bg: #ffffff;
  --panel: #f6f8fb;
  --panel-2: #eef2f7;
  --line: #d3dae4;
  --text: #17202e;
  --muted: #535e6d;
  --brand: #1d5bb8;
  --brand-2: #164a97;
  --on-brand: #ffffff;
  --brand-soft: #e7effb;
  --safety: #b42318; --late: #b42318; --ok: #17703e;
  --ok-bg: #e3f4e9; --ok-fg: #12512d; --ok-line: #1f8a4c;
  --warn-bg: #fdf3d8; --warn-fg: #6b3d0a; --warn-line: #c27a0e;
  --bad-bg: #fde8e6; --bad-fg: #8a1c12; --bad-line: #c8321f;
  --info-bg: #e5eefb; --info-fg: #173f7a; --info-line: #1d5bb8;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  color-scheme: light;
}
:root { --brand-soft: color-mix(in srgb, var(--brand) 14%, transparent); }
/* The DAS logo keeps its own orange in every theme; blue is for actions. */
:root { --logo-1: #ffb066; --logo-2: #ef7d22; --logo-3: #ce5e0d; }
.sidebar .rail-logo { background: radial-gradient(120% 120% at 20% 10%, var(--logo-1) 0%, var(--logo-2) 45%, var(--logo-3) 100%) !important; box-shadow: 0 6px 16px rgba(206, 94, 13, .3), inset 0 1px 0 rgba(255,255,255,.35) !important; }
.bb-das { background: linear-gradient(180deg, var(--logo-1) 0%, var(--logo-2) 45%, var(--logo-3) 100%) !important; -webkit-background-clip: text !important; background-clip: text !important; }
.bb-word { border-left-color: color-mix(in srgb, var(--logo-2) 45%, transparent) !important; }

/* ── Light: the frame (header, side menu, buttons) ── */
:root[data-theme="light"] body { background: var(--bg); }
:root[data-theme="light"] .appbar { background: #ffffff !important; border-bottom: 1px solid var(--line); box-shadow: 0 1px 0 rgba(16,24,40,.03); }
:root[data-theme="light"] .appbar::after { content: none !important; }
:root[data-theme="light"] .sidebar { background: #ffffff !important; border-right: 1px solid var(--line); }
:root[data-theme="light"] .sidebar .side { color: #3b4655 !important; }
:root[data-theme="light"] .sidebar .side:hover { background: var(--panel-2); color: var(--text) !important; }
:root[data-theme="light"] .sidebar .side.on { background: var(--brand) !important; color: #ffffff !important; }
:root[data-theme="light"] .sidebar .side.on::before { content: none; }
:root[data-theme="light"] .sidebar .rail-badge { box-shadow: 0 0 0 2px #ffffff; }
:root[data-theme="light"] .bottombar { background: rgba(255,255,255,.98); }
:root[data-theme="light"] .bottombar button.on { color: var(--brand); }
:root[data-theme="light"] h2 { color: #3b4655; }
:root[data-theme="light"] main a:not(.askbtn):not(.button-link):not(.dc-chip) { color: var(--brand); }
:root[data-theme="light"] .askbtn { background: #ffffff; }
:root[data-theme="light"] .askbtn .icon { color: var(--brand); }
:root[data-theme="light"] .hero { background: var(--panel); border-color: var(--line); }
:root[data-theme="light"] .notice { background: #ffffff; color: var(--text); border-color: var(--brand); box-shadow: 0 8px 24px rgba(16,24,40,.14); }
:root[data-theme="light"] input, :root[data-theme="light"] select, :root[data-theme="light"] textarea { background: #ffffff; color: var(--text); border-color: #c3ccd8; }
:root[data-theme="light"] input:focus-visible, :root[data-theme="light"] select:focus-visible, :root[data-theme="light"] textarea:focus-visible, :root[data-theme="light"] button:focus-visible, :root[data-theme="light"] summary:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
:root[data-theme="light"] .card, :root[data-theme="light"] .column { box-shadow: none; }
:root[data-theme="light"] .card:hover { border-color: var(--brand); }
:root[data-theme="light"] .job-tabs { background: var(--bg); }
:root[data-theme="light"] .job .next { background: var(--brand-soft); }

/* ── Light: the rest of the front desk follows the one blue (tabs, pills, messages) ── */
:root[data-theme="light"] { --accent: var(--brand); --card: #ffffff; }
:root[data-theme="light"] .stage-tab { border-color: var(--line); background: var(--bg); color: var(--text); }
:root[data-theme="light"] .stage-tab:hover { border-color: var(--brand); }
:root[data-theme="light"] .stage-tab.on { background: var(--brand); color: #ffffff; }
:root[data-theme="light"] .stage-tab.on .stage-count { background: rgba(255,255,255,.25); color: #ffffff; }
:root[data-theme="light"] .page-tabs .page-tab { background: var(--bg); }
:root[data-theme="light"] .page-tabs .page-tab.on, :root[data-theme="light"] .reminders-page .rm-tab.on { background: var(--brand); color: #ffffff; }
:root[data-theme="light"] .job .button-link { background: var(--brand); }
:root[data-theme="light"] .sale-pill.pending { background: var(--brand-soft); }
:root[data-theme="light"] .afg-warnings { background: var(--brand-soft); }
:root[data-theme="light"] .appt-paper.todo { border-left-color: var(--brand); }
:root[data-theme="light"] .ibx-tab.on { border-color: var(--brand); }
:root[data-theme="light"] .ibx-count.hot, :root[data-theme="light"] .ibx-dot, :root[data-theme="light"] .dal-open { background: var(--brand); }
:root[data-theme="light"] .ibx-row.on { box-shadow: inset 3px 0 0 var(--brand); }
:root[data-theme="light"] .ibx-name:hover, :root[data-theme="light"] .ibx-link, :root[data-theme="light"] .ibx-row.unread .ibx-time { color: var(--brand); }
:root[data-theme="light"] .ibx-visit:hover { border-color: var(--brand); }
:root[data-theme="light"] .dal-card.message { border-left-color: var(--brand); }
:root[data-theme="light"] .big.primary, :root[data-theme="light"] button.primary { background: var(--brand); color: #ffffff; }
:root[data-theme="light"] .cd-sort.on, :root[data-theme="light"] .cd-letter.on { color: #ffffff; }
:root[data-theme="light"] .column { background: var(--panel); }
:root[data-theme="light"] .card { background: var(--bg); }

/* ── Documents: the list ── */
.docs-page { grid-template-columns: minmax(240px, 270px) minmax(0, 1fr) !important; gap: 16px !important; align-items: start; }
.docs-side { position: sticky; top: 84px; max-height: calc(100vh - 104px); display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.docs-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.docs-head h1 { margin: 0; font-size: 1.25rem !important; }
.docs-count { font-size: 12.5px; }
.docs-create { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 44px; padding: 0 14px; border: 0; border-radius: 8px; background: var(--brand); color: var(--on-brand); font: inherit; font-size: 15px; font-weight: 700; cursor: pointer; }
.docs-create:hover { background: var(--brand-2); }
.docs-create-plus { font-size: 20px; line-height: 1; font-weight: 600; }
.docs-side input.docs-search { width: 100%; min-height: 38px !important; padding: 0 12px !important; border-radius: 8px !important; font-size: 14px; }
.docs-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.docs-select { min-height: 36px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; font-size: 13.5px; min-width: 0; }
.docs-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex !important; flex-direction: column; gap: 0 !important; padding: 0 !important; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.docs-empty { padding: 14px 12px; margin: 0; }
.doc-row { display: flex; flex-direction: column; align-items: stretch !important; gap: 1px !important; width: 100%; padding: 8px 10px 8px 12px !important; border: 0 !important; border-bottom: 1px solid var(--line) !important; border-left: 3px solid transparent !important; border-radius: 0 !important; background: transparent !important; box-shadow: none !important; color: var(--text); text-align: left; cursor: pointer; min-height: 0 !important; }
.doc-row:last-child { border-bottom: 0 !important; }
.doc-row:hover { background: var(--panel) !important; }
.doc-row.on { background: var(--brand-soft) !important; border-left-color: var(--brand) !important; }
.doc-row.picked { background: var(--bad-bg) !important; border-left-color: var(--bad-line) !important; }
.doc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.doc-name { font-size: 14px !important; font-weight: 650; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-vehicle { font-size: 12.5px !important; color: var(--muted) !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-foot { display: flex; align-items: center; gap: 8px; margin: 0 !important; font-size: 12.5px; }
.doc-num { font-size: 12.5px !important; font-weight: 700; color: var(--brand) !important; }
.doc-vin { font-family: var(--mono); font-size: 12px !important; color: var(--muted); }
.doc-date { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.doc-pill { align-self: flex-start; margin: 2px 0 0 !important; font-size: 11.5px !important; }
.doc-badge { flex: 0 0 auto; padding: 1px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; letter-spacing: .02em; border: 1px solid transparent; white-space: nowrap; }
.doc-badge.t-estimate { background: var(--panel-2); color: #34404f; border-color: var(--line); }
.doc-badge.t-ro { background: var(--info-bg); color: var(--info-fg); border-color: color-mix(in srgb, var(--info-line) 40%, transparent); }
.doc-badge.t-invoice { background: var(--bg); color: var(--ok-fg); border-color: var(--ok-line); }
.doc-badge.t-paid { background: var(--ok-line); color: #ffffff; }
.doc-badge.t-draft { background: transparent; color: var(--muted); border: 1px dashed var(--line); }
.doc-badge.t-owing { background: var(--bad-bg); color: var(--bad-fg); border-color: color-mix(in srgb, var(--bad-line) 50%, transparent); }
:root:not([data-theme="light"]):not([data-theme="sand"]):not([data-theme="contrast"]) .doc-badge.t-estimate { color: var(--text); }
.docs-tools { margin: 0 !important; }
.docs-tool { min-height: 32px !important; font-size: 12.5px !important; font-weight: 600 !important; border-radius: 6px !important; }
.docs-tool.ghost { border: 0; background: none; color: var(--muted); padding: 0 4px; text-decoration: underline; }
.docs-pick { padding: 24px; }

/* ── The open document ── */
.docs-pane { container-type: inline-size; container-name: doc; min-width: 0; }
.dc { gap: 12px !important; padding-bottom: 24px !important; }
.dc-top { position: static !important; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 10px 14px !important; border: 1px solid var(--line) !important; border-radius: 10px !important; background: var(--bg) !important; box-shadow: none !important; }
.dc-top-l { flex: 1 1 220px; min-width: 0; }
.dc-kind { font-size: 1.3rem !important; font-weight: 750 !important; color: var(--text); letter-spacing: -0.015em; }
.dc-top-sub { margin-top: 3px; }
.dc-saved { color: var(--ok) !important; font-size: 12px; }
.dc-saved.busy { color: var(--warn-line) !important; }
.dc-stages { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); }
.dc-stage { min-height: 36px; padding: 0 14px; border: 0; border-right: 1px solid var(--line); background: transparent; color: var(--muted); font: inherit; font-size: 13.5px; font-weight: 650; cursor: pointer; white-space: nowrap; }
.dc-stage:last-child { border-right: 0; }
.dc-stage.done { color: var(--ok); }
.dc-stage.current { background: var(--brand); color: var(--on-brand); cursor: default; }
.dc-stage.next:hover { background: var(--panel-2); color: var(--text); }
.dc-top-actions { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.dc .dc-btn { min-height: 38px; padding: 0 12px; border-radius: 8px; border: 1px solid #c3ccd8; background: var(--bg); color: var(--text); font-size: 14px; font-weight: 650; }
:root:not([data-theme="light"]) .dc .dc-btn { border-color: var(--line); background: var(--panel); }
.dc .dc-btn:hover:not([disabled]) { border-color: var(--brand); }
.dc .dc-btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.dc .dc-btn.primary:hover:not([disabled]) { background: var(--brand-2); }
.dc .dc-btn.danger { background: transparent; border-color: var(--bad-line); color: var(--bad-fg); }
:root:not([data-theme="light"]):not([data-theme="sand"]):not([data-theme="contrast"]) .dc .dc-btn.danger { color: #ff9c8a; }
.dc-chip.ok { background: var(--ok-bg) !important; color: var(--ok-fg) !important; }
.dc-chip.todo { background: var(--warn-bg) !important; color: var(--warn-fg) !important; }
.dc-chip.owing { background: var(--bad-bg) !important; color: var(--bad-fg) !important; }
.dc-chip.wait, .dc-chip.link { background: var(--info-bg) !important; color: var(--info-fg) !important; }
.dc-chip { background: var(--panel-2); color: var(--text); }

/* Actions ▾ */
.dc-menu { position: relative; }
.dc-menu > summary { list-style: none; display: inline-flex; align-items: center; cursor: pointer; user-select: none; }
.dc-menu > summary::-webkit-details-marker { display: none; }
.dc-menu[open] > summary { border-color: var(--brand); }
.dc-menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; width: max-content; min-width: 240px; max-width: min(320px, 90vw); max-height: 70vh; overflow-y: auto; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); box-shadow: 0 12px 32px rgba(16,24,40,.18); }
.dc-menu-item { display: block; width: 100%; min-height: 38px; padding: 0 12px; border: 0; border-radius: 6px; background: none; color: var(--text); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.dc-menu-item:hover, .dc-menu-item:focus-visible { background: var(--panel-2); }
.dc-menu-item.danger { color: var(--bad-fg); }
.dc-menu-sep { height: 1px; margin: 4px 6px; background: var(--line); }

/* Customer + vehicle row */
.dc-summary { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 4px 20px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.dc-sum-col { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.dc-sum-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dc-sum-label { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.dc-sum-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; font-size: 14px; }
.dc-summary .dc-strong { font-size: 15.5px; font-weight: 700; text-align: left; }
.dc-summary .muted { font-size: 13.5px; }
.dc-sum-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 4px; }
.dc-sum-f { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); min-width: 0; }
.dc-sum-f strong { font-size: 14px; color: var(--text); font-weight: 600; min-height: 32px; display: flex; align-items: center; }
.dc-sum-in { width: 100%; min-height: 32px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); font: inherit; font-size: 14px; font-variant-numeric: tabular-nums; }
.dc-sum-concern { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--line); font-size: 14px; }
.dc .dc-link { color: var(--brand); font-weight: 600; }
.dc .dc-mini { min-height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); font-size: 12.5px; font-weight: 600; }

/* Line items table */
.dc-items { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.dc-table-wrap { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--bg); }
.dc-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 14px; }
.dc-table thead th { padding: 8px 6px; background: var(--panel-2); color: #3b4655; font-size: 12px; font-weight: 700; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
:root:not([data-theme="light"]) .dc-table thead th { color: var(--muted); }
.dc-table th.c-kind { width: 88px; } .dc-table th.c-code { width: 116px; } .dc-table th.c-qty { width: 58px; } .dc-table th.c-price { width: 80px; }
.dc-table th.c-total { width: 84px; } .dc-table th.c-tax { width: 34px; } .dc-table th.c-x { width: 56px; }
.dc-table th.c-qty, .dc-table th.c-price, .dc-table th.c-total, .dc-table td.c-total { text-align: right; }
.dc-table th.c-tax, .dc-table td.c-tax { text-align: center; }
.dc-table td { padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.dc-tr:hover td { background: color-mix(in srgb, var(--brand) 4%, transparent); }
.dc-cell-in { width: 100%; min-height: 32px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); color: var(--text); font: inherit; font-size: 14px; }
.dc-cell-in:hover:not(:disabled) { border-color: #9aa8bb; }
.dc-cell-in:focus { border-color: var(--brand); outline: 1px solid var(--brand); outline-offset: 0; }
.dc-cell-in.num { text-align: right; font-variant-numeric: tabular-nums; padding: 4px 5px; -moz-appearance: textfield; appearance: textfield; }
.dc-cell-in.num::-webkit-outer-spin-button, .dc-cell-in.num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
textarea.dc-desc { overflow: hidden; field-sizing: content; }
select.dc-cell-in { padding: 0 2px; }
textarea.dc-desc { display: block; resize: vertical; line-height: 1.35; min-height: 32px; }
.dc-table .dc-cell-in:disabled { opacity: 1 !important; cursor: default !important; border-color: transparent !important; background: transparent !important; resize: none; color: var(--text); -webkit-text-fill-color: var(--text); }
select.dc-cell-in:disabled { appearance: none; -webkit-appearance: none; }
.dc-line-sub { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.dc-table .dc-line-amt { display: block; padding: 6px 2px; font-weight: 700; font-variant-numeric: tabular-nums; }
.dc-table td.c-tax input { width: 18px; height: 18px; margin: 7px 0 0; opacity: 1 !important; accent-color: var(--brand); }
.dc-table td.c-x { white-space: nowrap; text-align: right; }
.dc-row-more, .dc-table .dc-del { min-width: 26px; min-height: 32px; padding: 0 4px; border: 0; border-radius: 5px; background: none; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; }
.dc-table .dc-del { color: var(--bad-line); font-size: 20px; }
.dc-row-more:hover, .dc-table .dc-del:hover { background: var(--panel-2); }
.dc-tr.k-labor td.c-kind select { color: var(--info-fg); font-weight: 600; }
.dc-tr.k-part td.c-kind select { font-weight: 600; }
.dc-tr.k-discount td.c-kind select, .dc-tr.k-discount .dc-line-amt { color: var(--ok); }
.dc-jobrow td { padding: 6px 8px; background: var(--panel); border-bottom: 1px solid var(--line); }
.dc-jobrow-in { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.dc-jobrow .dc-jobno { width: 22px; height: 22px; flex: 0 0 auto; border-radius: 50%; background: var(--brand); color: var(--on-brand); font-size: 12px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.dc-jobrow .dc-job-title { flex: 1 1 200px; display: flex; flex-direction: column; min-width: 0; padding: 2px 0; border: 0; background: none; color: var(--text); font: inherit; font-size: 14.5px; font-weight: 700; text-align: left; cursor: pointer; }
.dc-jobrow .dc-job-title:disabled { cursor: default; }
.dc-jobrow .dc-job-ccc { font-size: 12.5px; font-weight: 400; color: var(--muted); }
.dc-jobrow .dc-job-amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dc-jobrow .dc-del { min-width: 30px; min-height: 30px; border: 0; background: none; font-size: 15px; }
.dc-empty-row td { padding: 14px 12px; color: var(--muted); }
.dc-entry-tr td { padding: 6px; background: var(--brand-soft); }
.dc-entry-tr .dc-entry { margin: 0 !important; background: var(--bg); }

/* Add item: small buttons under the table */
.dc-toolbar { margin: 0 !important; padding: 0 !important; border: 0 !important; background: none !important; display: flex; flex-direction: column; gap: 8px; }
.dc-toolbar .dc-entry { margin: 0; background: var(--bg); border-color: var(--brand); }
.dc-toolbar-grid { display: flex !important; flex-wrap: wrap; align-items: center; gap: 6px !important; }
.dc-toolbar-grid > .dc-toolbar-title { margin: 0 4px 0 0 !important; font-size: 12px !important; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.dc-toolbar-grid button { flex-direction: row !important; gap: 6px !important; min-height: 34px !important; padding: 0 10px !important; border: 1px solid var(--line) !important; border-radius: 6px !important; background: var(--bg) !important; color: var(--text) !important; font-size: 13px !important; font-weight: 600 !important; text-align: left; }
.dc-toolbar-grid button:hover { border-color: var(--brand) !important; color: var(--brand) !important; }
.dc-toolbar-grid button.on { border-color: var(--brand) !important; background: var(--brand-soft) !important; box-shadow: none !important; }
.dc-toolbar-grid .ic { min-width: 0 !important; width: auto !important; height: auto !important; border: 0 !important; background: none !important; font-size: 14px !important; }
.dc-entry { border-color: var(--brand) !important; }
.dc-entry-add { background: var(--brand) !important; }
.dc-ef-seg button.on, .dc-seg button.on { background: var(--brand) !important; color: var(--on-brand) !important; }
.dc-library-box { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.dc-library-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; }
.dc-library-item { display: flex; justify-content: space-between; gap: 8px; min-height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); font: inherit; font-size: 13.5px; text-align: left; cursor: pointer; }
.dc-library-item:hover { border-color: var(--brand); }
.dc-items .dc-addrow { padding: 0; }
.dc-items .dc-addrow button { min-height: 34px; font-size: 13px; border-radius: 6px; }

/* Right panel */
.dc-side { gap: 10px !important; }
.dc-side .dc-card { padding: 10px 12px !important; gap: 6px !important; border-radius: 10px !important; background: var(--panel) !important; box-shadow: none !important; }
.dc-side .dc-card-head h2 { font-size: 12px !important; color: #3b4655; }
:root:not([data-theme="light"]) .dc-side .dc-card-head h2 { color: var(--muted); }
.dc-kv { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 14px; }
.dc-kv > span { color: var(--muted); }
.dc-side .dc-f { font-size: 12.5px; }
.dc-side .dc-in { min-height: 36px; padding: 4px 10px; border-radius: 6px; font-size: 14px; }
.dc-side textarea.dc-in { min-height: 64px; }
.dc-side .dc-btn { width: 100%; }
.dc-side .dc-send-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 0; }
.dc-totals .dc-trow { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 2px 0 !important; font-size: 14px !important; }
.dc-totals .dc-trow.strong { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 6px !important; }
.dc-totals .dc-trow.owing span { color: var(--bad-fg) !important; font-weight: 700; }
.dc-totals .dc-change { margin-left: 6px; font-size: 13px; }
.dc-total-bar, .dc-paid-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 6px 0 2px; padding: 9px 12px; border-radius: 8px; background: var(--brand); color: var(--on-brand); font-size: 15px; font-weight: 700; }
.dc-total-bar strong, .dc-paid-bar strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.dc-paid-bar { background: var(--ok-line); color: #ffffff; }
.dc-pay span:first-child { font-size: 13px; }
.dc-auth .dc-approve-btns { grid-template-columns: 1fr 1fr !important; gap: 6px; }
.dc-auth.dc-approve { border: 2px solid var(--warn-line) !important; }
.dc-auth.dc-approve.additional { border-color: var(--bad-line) !important; }
.dc-invoice.owing { border-color: var(--bad-line) !important; }
.dc-invoice.paid { border-color: var(--ok-line) !important; }
.dc-rec { font-size: 13px !important; }
.dc-attach { display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; font-weight: 600; }
.dc-file { font-size: 13px; max-width: 100%; }
.dc-totals-slot { display: contents; }

/* Layout of the document: right panel beside the table once there is room */
.dc-main { container-type: inline-size; container-name: dcmain; }
.dc-grid { grid-template-columns: minmax(0, 1fr) !important; gap: 12px !important; }
.dc-side { position: static !important; }
@container doc (min-width: 900px) {
  .dc-grid { grid-template-columns: minmax(0, 1fr) 260px !important; }
  .dc-side { position: sticky !important; top: 84px; max-height: calc(100vh - 100px); overflow-y: auto; padding-right: 2px; }
}
@container doc (min-width: 1300px) {
  .dc-grid { grid-template-columns: minmax(0, 1fr) 330px !important; }
}
/* Below 760 px of document: the summary stacks and the header actions wrap under the tabs. */
@container doc (max-width: 760px) {
  .dc-summary { grid-template-columns: minmax(0, 1fr); }
  .dc-top-actions { margin-left: 0; }
}
/* Narrow table area (tablet portrait, phone): each line becomes a small card. */
@container dcmain (max-width: 680px) {
  .dc-table, .dc-table tbody, .dc-table tr, .dc-table td { display: block; width: 100%; }
  .dc-table { table-layout: auto; }
  .dc-table thead { display: none; }
  .dc-table-wrap { border: 0; background: none; overflow: visible; }
  .dc-jobrow td { border: 1px solid var(--line); border-radius: 8px; margin-top: 10px; }
  .dc-tr { display: grid !important; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-areas: "kind code code total" "desc desc desc desc" "qty price tax x"; gap: 6px 8px; margin: 6px 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
  .dc-tr td { display: flex; flex-direction: column; gap: 2px; padding: 0 !important; border: 0 !important; min-width: 0; }
  .dc-tr td[data-label]::before { content: attr(data-label); font-size: 11px; font-weight: 600; color: var(--muted); }
  .dc-tr td.c-kind { grid-area: kind; } .dc-tr td.c-code { grid-area: code; } .dc-tr td.c-total { grid-area: total; text-align: right; }
  .dc-tr td.c-desc { grid-area: desc; } .dc-tr td.c-qty { grid-area: qty; } .dc-tr td.c-price { grid-area: price; }
  .dc-tr td.c-tax { grid-area: tax; align-items: center; }
  .dc-tr td.c-tax input { margin: 8px 0 0; }
  .dc-tr td.c-x { grid-area: x; flex-direction: row; justify-content: flex-end; align-items: flex-end; gap: 4px; }
  .dc-tr .dc-row-more, .dc-tr .dc-del { min-width: 40px; min-height: 40px; border: 1px solid var(--line); }
  .dc-empty-row td, .dc-entry-tr td { border: 0; }
  .dc-sum-fields { grid-template-columns: 1fr 1fr; }
}

/* iPhone: the list is one screen, the document the next (phone.ts); the header tabs fill the width. */
@media (max-width: 760px) {
  .docs-page .docs-side { position: static !important; max-height: none !important; }
  .docs-page .docs-list { max-height: none; }
  .docs-create { min-height: 48px; }
  .doc-row { min-height: 64px !important; padding: 10px 12px !important; }
  .doc-name { font-size: 15.5px !important; }
  .dc-top { padding: 10px !important; }
  .dc-stages { display: flex; width: 100%; }
  .dc-stage { flex: 1 1 0; min-height: 44px; padding: 0 4px; font-size: 13px; white-space: normal; line-height: 1.15; }
  .dc-top-actions { width: 100%; }
  .dc-top-actions > * { flex: 1 1 0; }
  .dc-top-actions .dc-btn, .dc-menu > summary { width: 100%; justify-content: center; min-height: 44px; }
  .dc-menu-list { position: fixed; left: 8px; right: 8px; top: auto; bottom: calc(76px + env(safe-area-inset-bottom)); width: auto; max-width: none; }
  .dc-menu-item { min-height: 48px; font-size: 16px; }
  .dc-summary { padding: 10px 12px; }
  .dc-toolbar-grid button { min-height: 44px !important; }
  .dc-cell-in, .dc-sum-in { min-height: 44px; }
  .dc-side .dc-btn { min-height: 46px; }
}
@media print { .dc-menu, .dc-toolbar, .dc-row-more, .dc-del, .dc-stages { display: none !important; } }
