:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1d2330;
  --muted: #6b7385;
  --border: #e1e4ea;
  --primary: #c2410c;
  --primary-hover: #9a3412;
  --danger: #c63a3a;
  --success-bg: #e6f4ea;
  --success-text: #1e6b34;
  --alert-bg: #fdecec;
  --alert-text: #8f2525;
  --sidebar: #1f2937;
  --sidebar-text: #c9d1e3;
  --radius: 8px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151c;
    --surface: #1b2029;
    --text: #e5e8ef;
    --muted: #9099ab;
    --border: #2c3341;
    --primary: #fb923c;
    --primary-hover: #fdba74;
    --danger: #ef6b6b;
    --success-bg: #183524;
    --success-text: #8fd6a4;
    --alert-bg: #3a1c1c;
    --alert-text: #f2a9a9;
    --sidebar: #0d1017;
    --sidebar-text: #b4bccd;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }

.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 1.25rem .75rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.sidebar .nav-link, .sidebar .link-button {
  color: var(--sidebar-text);
  padding: .45rem .75rem;
  border-radius: 6px;
  display: block;
  text-align: left;
}
.sidebar .nav-link:hover { background: rgb(255 255 255 / .07); text-decoration: none; }
.sidebar .nav-link.active { background: rgb(255 255 255 / .12); color: #fff; }
.nav-section { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; opacity: .6; margin: 1rem .75rem .25rem; }
.sidebar-footer { border-top: 1px solid rgb(255 255 255 / .1); padding-top: .75rem; display: flex; flex-direction: column; gap: .25rem; }

.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.1rem; color: inherit; padding: 0 .75rem; }
.sidebar .brand { color: #fff; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; background: var(--primary); color: #fff; font-size: .9rem; }

.content { padding: 1.75rem 2rem 3rem; min-width: 0; max-width: 1200px; }

.page-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-header .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.subtitle { margin: -.75rem 0 1.25rem; color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 0 1.25rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; color: var(--text); display: flex; flex-direction: column; }
.stat:hover { border-color: var(--primary); text-decoration: none; }
.stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-label { color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .45rem .9rem; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-block { width: 100%; }
.link-button { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer; }
.link-button:hover { text-decoration: underline; }
.link-button.danger { color: var(--danger); }
.link-button:disabled { cursor: default; text-decoration: none; }
form.button_to { display: inline; }

.flash { padding: .7rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.flash ul { margin: .4rem 0 0; padding-left: 1.25rem; }
.flash-notice { background: var(--success-bg); color: var(--success-text); }
.flash-alert { background: var(--alert-bg); color: var(--alert-text); }

.filters, .inline-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.inline-form.compact { margin: 0; }
.filters input[type=search] { flex: 1; min-width: 200px; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; padding: .45rem .6rem; width: 100%;
}
.filters select, .inline-form select, .inline-form input { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
input[type=checkbox], input[type=radio], input[type=submit], input[type=button] { width: auto; }
input:disabled { opacity: .6; }

.form { max-width: 900px; }
.form.narrow { max-width: 480px; }
.form fieldset { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 1rem 1.25rem; margin: 0 0 1rem; }
.form legend { font-weight: 600; padding: 0 .4rem; }
.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .75rem; flex: 1 1 180px; min-width: 0; }
.field.small { flex: 0 1 110px; }
.field.wide { flex: 2 1 280px; }
.field label { font-size: .85rem; color: var(--muted); }
.field.checkbox { flex-direction: row; align-items: center; gap: .5rem; flex: 0 0 auto; }
.field.checkbox label { font-size: inherit; color: var(--text); }
.row { display: flex; gap: 0 1rem; flex-wrap: wrap; }
.row.between { justify-content: space-between; align-items: center; }
.hint { color: var(--muted); font-size: .85rem; margin: 0 0 .5rem; }
.form-actions { display: flex; gap: .5rem; margin-top: .5rem; }
.note-form { margin-bottom: 1rem; }
.note-form .field { margin: 0; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card .table-wrap { border: 0; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .6rem .9rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.inactive { opacity: .55; }
.actions-cell { text-align: right; white-space: nowrap; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; background: var(--border); color: var(--text); white-space: nowrap; }

.details { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: .5rem; padding: .4rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.list li:last-child { border-bottom: 0; }
.muted { color: var(--muted); }
.empty { color: var(--muted); padding: 2rem; text-align: center; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

.notes { list-style: none; margin: 0; padding: 0; }
.note { border-top: 1px solid var(--border); padding: .75rem 0; }
.note p { margin: .25rem 0 0; }
.note-meta { font-size: .85rem; color: var(--muted); display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

.pagination { display: flex; gap: 1rem; align-items: center; justify-content: center; margin: 1rem 0; color: var(--muted); }
.locale-switcher { display: flex; gap: .5rem; padding: .25rem .75rem; }
.locale-switcher .link-button { padding: 0; }
.locale-switcher .current { opacity: .5; }
.prose p:first-child { margin-top: 0; }
.prose p:last-child { margin-bottom: 0; }

body.auth { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 2rem; }
.auth-card .brand { padding: 0; margin-bottom: 1.5rem; }
.auth-card h1 { font-size: 1.3rem; margin-bottom: 1rem; }
.auth-card .locale-switcher { justify-content: center; margin-top: 1rem; }


.status-accepted { background: #e0e7ff; color: #3730a3; }
.status-in_progress { background: #fef3c7; color: #92400e; }
.status-waiting_parts { background: #fde2e2; color: #9b1c1c; }
.status-ready { background: #dcfce7; color: #166534; }
.status-closed { background: var(--border); color: var(--muted); }
.status-cancelled { background: var(--border); color: var(--muted); text-decoration: line-through; }
@media (prefers-color-scheme: dark) {
  .status-accepted { background: #312e81; color: #c7d2fe; }
  .status-in_progress { background: #78350f; color: #fde68a; }
  .status-waiting_parts { background: #7f1d1d; color: #fecaca; }
  .status-ready { background: #14532d; color: #bbf7d0; }
}

.plate {
  display: inline-block; font-family: ui-monospace, monospace; font-size: .85rem; letter-spacing: .04em;
  border: 1.5px solid var(--text); border-radius: 4px; padding: 0 .35rem; background: var(--surface); white-space: nowrap;
}
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; }
.upper { text-transform: uppercase; }
.num { text-align: right !important; white-space: nowrap; }
.danger { color: var(--danger); }
.ok { color: var(--success-text); }
.small { font-size: .85rem; }
.spacer { flex: 1; }

.order-status { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: -.5rem 0 1.25rem; }
.order-status .badge { font-size: .9rem; padding: .25rem .75rem; }
.line-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: 1rem; }
.line-form select { flex: 2 1 220px; width: auto; }
.line-form input[type=text] { flex: 2 1 180px; width: auto; }
input.qty { width: 90px !important; flex: 0 0 auto; }
input.price { width: 120px !important; flex: 0 0 auto; }
.inline-form.compact input.qty { width: 80px !important; }

.totals { display: grid; grid-template-columns: 1fr auto; gap: .35rem 1.5rem; margin: 0; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.totals .grand { font-weight: 700; font-size: 1.15rem; color: var(--text); border-top: 1px solid var(--border); padding-top: .4rem; }
.details.stacked { grid-template-columns: 1fr; }
.details.stacked dt { font-weight: 600; color: var(--text); }
.details.stacked dd p { margin: 0 0 .75rem; }

.history-item { border-top: 1px solid var(--border); padding: .6rem 0; }
.history-item:first-of-type { border-top: 0; }
.history-head { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.history-item p { margin: .25rem 0 0; }

.print-page { background: #fff; color: #000; }
.print-toolbar { display: flex; gap: .5rem; padding: 1rem; justify-content: center; }
.print-doc { max-width: 800px; margin: 0 auto; padding: 1rem 2rem 3rem; font-size: 13px; }
.print-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #000; padding-bottom: .75rem; margin-bottom: 1rem; }
.print-shop { font-size: 1.2rem; font-weight: 700; }
.print-title { text-align: right; }
.print-title h1 { font-size: 1.3rem; }
.print-doc h2 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
.print-info, .print-lines { width: 100%; border-collapse: collapse; }
.print-info th { text-align: left; width: 30%; font-weight: 600; padding: .2rem .5rem .2rem 0; vertical-align: top; }
.print-info td { padding: .2rem 0; }
.print-lines th, .print-lines td { border: 1px solid #000; padding: .3rem .5rem; text-align: left; }
.print-totals { margin: 1rem 0 0 auto; max-width: 320px; }
.print-page .totals dt, .print-page .totals .grand { color: #000; }
.signatures { display: flex; justify-content: space-between; margin-top: 3rem; gap: 2rem; flex-wrap: wrap; }
@media print {
  .no-print { display: none !important; }
  .print-doc { padding: 0; }
}

.status-scheduled { background: #e0e7ff; color: #3730a3; }
.status-confirmed { background: #dcfce7; color: #166534; }
.status-arrived { background: var(--border); color: var(--muted); }
.status-no_show { background: #fde2e2; color: #9b1c1c; }
@media (prefers-color-scheme: dark) {
  .status-scheduled { background: #312e81; color: #c7d2fe; }
  .status-confirmed { background: #14532d; color: #bbf7d0; }
  .status-no_show { background: #7f1d1d; color: #fecaca; }
}

.calendar-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 1.25rem; }
.calendar { display: grid; position: relative; min-width: max-content; }
.calendar-corner, .calendar-head { position: sticky; top: 0; background: var(--surface); z-index: 3; border-bottom: 1px solid var(--border); }
.calendar-head { padding: .5rem .75rem; font-weight: 600; border-left: 1px solid var(--border); }
.calendar-time { font-size: .75rem; color: var(--muted); padding: 0 .5rem; text-align: right; transform: translateY(-.55em); }
.calendar-cell { border-left: 1px solid var(--border); border-top: 1px dashed var(--border); display: block; }
.calendar-cell.hour { border-top-style: solid; }
a.calendar-cell:hover { background: color-mix(in srgb, var(--primary) 12%, transparent); text-decoration: none; }
.calendar-cell.past { background: color-mix(in srgb, var(--border) 35%, transparent); }
.calendar-event {
  z-index: 2; margin: 1px 3px; padding: .2rem .45rem; border-radius: 6px; overflow: hidden;
  display: flex; flex-direction: column; font-size: .8rem; line-height: 1.25; color: inherit;
  border-left: 3px solid currentColor; box-shadow: 0 1px 2px rgb(0 0 0 / .15);
}
.calendar-event:hover { text-decoration: none; filter: brightness(.97); }
.calendar-event span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.version { font-size: .75rem; opacity: .5; padding: 0 .75rem; }

.receipt-draft { background: #fef3c7; color: #92400e; }
.receipt-posted { background: #dcfce7; color: #166534; }
@media (prefers-color-scheme: dark) {
  .receipt-draft { background: #78350f; color: #fde68a; }
  .receipt-posted { background: #14532d; color: #bbf7d0; }
}
.line-form.tight { margin-top: .5rem; }
.inline-form.right { justify-content: flex-end; }
.inline-form.card { padding: .75rem 1rem; }
.narrow-totals { max-width: 340px; margin: 1rem 0 0 auto; }
h2.spaced { margin-top: 1.5rem; }
.table tfoot th { color: var(--text); font-size: .9rem; text-transform: none; border-top: 2px solid var(--border); border-bottom: 0; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; flex-wrap: wrap; }
.tab { padding: .5rem .9rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.bars { display: flex; flex-direction: column; gap: .3rem; }
.bar-row { display: grid; grid-template-columns: 90px 1fr 130px; gap: .75rem; align-items: center; font-size: .85rem; }
.bar { background: var(--border); border-radius: 4px; height: 14px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; }

label.check { display: inline-flex; align-items: center; gap: .3rem; font-size: .85rem; color: var(--muted); white-space: nowrap; }
.performers { min-width: 160px; }
.performer { display: inline-flex; align-items: center; gap: .25rem; margin-right: .5rem; white-space: nowrap; }
.add-performer summary { list-style: none; font-size: .85rem; }
.add-performer summary::-webkit-details-marker { display: none; }
.add-performer[open] summary { margin-bottom: .3rem; }

.dropdown { position: relative; display: inline-block; }
.dropdown summary { list-style: none; }
.dropdown summary::-webkit-details-marker { display: none; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 10; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 4px 12px rgb(0 0 0 / .12); display: flex; flex-direction: column; min-width: 220px; padding: .25rem 0; }
.dropdown-menu a { padding: .45rem .9rem; color: var(--text); }
.dropdown-menu a:hover { background: var(--bg); text-decoration: none; }
.print-lines tr.section td { font-weight: 600; background: #f3f3f3; }
.amount-words { margin-top: .75rem; }
.terms { margin-top: 1rem; font-size: 12px; border-top: 1px solid #000; padding-top: .5rem; }
.fill-box { border: 1px solid #000; min-height: 3em; padding: .4rem .6rem; }
.bank-table { width: 100%; border-collapse: collapse; margin-bottom: 1rem; }
.bank-table td { border: 1px solid #000; padding: .25rem .4rem; vertical-align: top; }
.invoice-title { font-size: 1.2rem; border-bottom: 2px solid #000; padding-bottom: .4rem; }

.legend { display: inline-flex; align-items: center; gap: .35rem; font-size: .85rem; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-appointment, .month-item.appointment { --tone: #4f46e5; }
.dot-due, .month-item.due { --tone: #d97706; }
.dot { background: var(--tone); }
.month-wrap { overflow-x: auto; }
.month { display: grid; grid-template-columns: repeat(7, minmax(110px, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; min-width: 770px; }
.month-weekday { background: var(--surface); padding: .4rem .6rem; font-size: .8rem; color: var(--muted); text-transform: uppercase; }
.month-day { background: var(--surface); min-height: 108px; padding: .35rem .45rem; display: flex; flex-direction: column; gap: 2px; color: var(--text); }
.month-day:hover { background: var(--bg); text-decoration: none; }
.month-day.other-month { opacity: .45; }
.month-day.weekend .month-date { color: var(--danger); }
.month-day.today { box-shadow: inset 0 0 0 2px var(--primary); }
.month-date { font-weight: 600; font-size: .9rem; }
.month-item { font-size: .75rem; padding: 1px 5px; border-radius: 4px; border-left: 3px solid var(--tone); background: color-mix(in srgb, var(--tone) 12%, transparent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.month-more { font-size: .72rem; color: var(--muted); }

.board { display: grid; grid-template-columns: repeat(4, minmax(230px, 1fr)); gap: 1rem; overflow-x: auto; align-items: start; }
.board-column { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: .6rem; min-height: 200px; display: flex; flex-direction: column; gap: .5rem; transition: background .15s; }
.board-column.drop-allowed { border-style: dashed; border-color: var(--primary); }
.board-column.drop-over { background: color-mix(in srgb, var(--primary) 10%, var(--bg)); }
.board-head { display: flex; justify-content: space-between; align-items: center; }
.board-card { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: .55rem .65rem; display: flex; flex-direction: column; gap: .2rem; font-size: .9rem; }
.board-card[draggable="true"] { cursor: grab; }
.board-card-head { display: flex; justify-content: space-between; gap: .5rem; }

/* ---------- Responsive ---------- */
.topbar, .tabbar, .nav-overlay { display: none; }
select, input, textarea { max-width: 100%; }
.stat-value { white-space: nowrap; }

@media (max-width: 1100px) {
  .board { grid-template-columns: repeat(4, minmax(240px, 1fr)); }
}

@media (max-width: 900px) {
  :root { --topbar-height: 52px; --tabbar-height: 60px; }

  .shell { display: block; }
  .topbar {
    display: flex; align-items: center; gap: .5rem; position: sticky; top: 0; z-index: 40;
    height: var(--topbar-height); padding: 0 .5rem; padding-top: env(safe-area-inset-top);
    background: var(--sidebar); color: #fff;
  }
  .topbar .brand { color: #fff; padding: 0; }
  .topbar-button { background: none; border: 0; color: inherit; width: 44px; height: 44px; display: grid; place-items: center; cursor: pointer; border-radius: 8px; }
  .topbar-button:active { background: rgb(255 255 255 / .1); }
  .burger, .burger::before, .burger::after { display: block; width: 20px; height: 2px; background: currentColor; border-radius: 2px; position: relative; content: ""; }
  .burger::before { position: absolute; top: -6px; }
  .burger::after { position: absolute; top: 6px; }

  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 60; width: min(300px, 85vw); height: 100dvh;
    padding-top: calc(1.25rem + env(safe-area-inset-top)); padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    transform: translateX(-100%); transition: transform .2s ease, visibility .2s; visibility: hidden;
  }
  .nav-open .sidebar { transform: none; visibility: visible; box-shadow: 0 0 24px rgb(0 0 0 / .3); }
  .nav-overlay { display: block; position: fixed; inset: 0; z-index: 50; background: rgb(0 0 0 / .45); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .nav-open .nav-overlay { opacity: 1; pointer-events: auto; }
  .nav-open { overflow: hidden; }
  .sidebar .nav-link { padding: .6rem .75rem; }

  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    height: calc(var(--tabbar-height) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--border);
  }
  .tab-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--muted); font: inherit; font-size: .7rem; background: none; border: 0; cursor: pointer; min-width: 0;
  }
  .tab-item span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
  .tab-item:hover { text-decoration: none; }
  .tab-item.active { color: var(--primary); }
  .tab-icon { font-size: 1.25rem; line-height: 1; }

  .content { padding: 1rem 1rem calc(var(--tabbar-height) + 1.5rem + env(safe-area-inset-bottom)); max-width: none; }
  h1 { font-size: 1.35rem; }
  .page-header { margin-bottom: 1rem; }

  /* 16px inputs keep iOS Safari from zooming in on focus. */
  input, select, textarea { font-size: 16px; min-height: 40px; }
  input[type=checkbox], input[type=radio] { min-height: 0; width: 18px; height: 18px; }
  .btn { min-height: 40px; }

  .grid-2 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .6rem; }
  .stat { padding: .75rem .9rem; }
  .stat-value { font-size: clamp(1.05rem, 5vw, 1.5rem); }
  .card { padding: .9rem 1rem; }

  .filters input[type=search] { flex-basis: 100%; }
  .filters select { flex: 1 1 140px; }

  .line-form > select, .line-form > input[type=text] { flex: 1 1 100%; }
  .inline-form > select, .inline-form > input[type=text] { flex: 1 1 160px; min-width: 0; }

  .dropdown-menu { right: auto; left: 0; }
  .details { grid-template-columns: minmax(90px, 40%) 1fr; }
  .details dd { overflow-wrap: anywhere; }

  .calendar-time { position: sticky; left: 0; z-index: 2; background: var(--surface); }
  .calendar { grid-template-columns: 52px repeat(var(--calendar-columns, 3), minmax(150px, 1fr)) !important; }

  .board { grid-template-columns: repeat(4, 82vw); scroll-snap-type: x mandatory; padding-bottom: .5rem; }
  .board-column { scroll-snap-align: start; }

  .month { min-width: 640px; }
  .month-day { min-height: 84px; }

  .bar-row { grid-template-columns: 70px 1fr 100px; }
}

/* Row-as-card tables on phones; labels come from data-label (responsive_tables.js). */
@media (max-width: 640px) {
  .table-wrap { overflow: visible; background: none; border: 0; }
  .card .table-wrap { margin: 0 -.25rem; }
  .table thead { display: none; }
  .table, .table tbody, .table tfoot, .table tr, .table td, .table th { display: block; width: 100%; }
  .table tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .55rem .8rem; margin-bottom: .6rem; }
  .card .table tr { border-radius: 6px; }
  .table td, .table th { border: 0 !important; padding: .2rem 0; display: flex; justify-content: space-between; align-items: center; gap: .75rem; text-align: right !important; min-height: 1.6rem; }
  .table td::before, .table tfoot th::before { content: attr(data-label); color: var(--muted); font-size: .78rem; text-align: left; flex-shrink: 0; max-width: 45%; }
  .table td[data-label=""]::before, .table th[data-label=""]::before { display: none; }
  .table td:first-child { justify-content: flex-start; text-align: left !important; font-weight: 600; font-size: 1rem; flex-wrap: wrap; }
  .table td:first-child::before { display: none; }
  .table td:empty { display: none; }
  .table td.actions-cell { justify-content: flex-end; }
  .table td.performers { flex-wrap: wrap; justify-content: flex-end; }
  .table tr.inactive { opacity: .6; }
  .inline-form.compact { justify-content: flex-end; }
}

@media (hover: hover) and (min-width: 901px) {
  .board-card-actions { display: none; }
}
.board-card-actions { display: flex; flex-wrap: wrap; gap: .25rem .75rem; margin-top: .25rem; font-size: .85rem; }
.only-touch { display: none; }
@media (hover: none), (max-width: 900px) {
  .only-touch { display: inline; }
  .only-pointer { display: none; }
}
.status-estimate { background: #f3e8ff; color: #6b21a8; }
@media (prefers-color-scheme: dark) { .status-estimate { background: #3b0764; color: #e9d5ff; } }

.nav-badge { display: inline-block; min-width: 1.3rem; padding: 0 .35rem; border-radius: 999px; background: var(--danger); color: #fff; font-size: .72rem; text-align: center; line-height: 1.3rem; margin-left: .25rem; }
.tasks { list-style: none; margin: 0 0 .75rem; padding: 0; }
.task { display: flex; gap: .6rem; align-items: flex-start; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.task:last-child { border-bottom: 0; }
.task form.button_to { display: block; }
.task-check { width: 22px; height: 22px; border: 2px solid var(--muted); border-radius: 6px; background: var(--surface); color: #fff; cursor: pointer; display: grid; place-items: center; font-size: .8rem; padding: 0; margin-top: 1px; }
.task-check:hover { border-color: var(--primary); }
.task.done .task-check { background: var(--success-text); border-color: var(--success-text); }
.task.done .task-title { text-decoration: line-through; color: var(--muted); }
.task.overdue .task-check { border-color: var(--danger); }
.task-body { flex: 1; min-width: 0; }
.task-meta { display: flex; flex-wrap: wrap; gap: .25rem .75rem; font-size: .8rem; color: var(--muted); }
.task-actions { display: flex; gap: .5rem; align-items: center; }
.task-form input[type=text] { flex: 2 1 220px; }

.reminders { display: flex; flex-direction: column; gap: .6rem; }
.reminder { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; display: flex; gap: 1rem; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.reminders.compact .reminder { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: .5rem 0; }
.reminder.overdue { border-left: 3px solid var(--danger); }
.reminder-main { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.reminder-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.reminder-pending { background: #e0e7ff; color: #3730a3; }
.reminder-contacted { background: #fef3c7; color: #92400e; }
.reminder-booked { background: #dcfce7; color: #166534; }
.dropdown-menu.wide { min-width: 300px; }
.dropdown-menu .pad { padding: .5rem; margin: 0; }
.menu-button { background: none; border: 0; padding: .45rem .9rem; font: inherit; color: var(--text); text-align: left; width: 100%; cursor: pointer; }
.menu-button:hover { background: var(--bg); }
.menu-button.danger { color: var(--danger); }
.dropdown-menu form.button_to { display: block; }
@media (prefers-color-scheme: dark) {
  .reminder-pending { background: #312e81; color: #c7d2fe; }
  .reminder-contacted { background: #78350f; color: #fde68a; }
  .reminder-booked { background: #14532d; color: #bbf7d0; }
}
.lead-board { grid-template-columns: repeat(5, minmax(220px, 1fr)); }
@media (max-width: 900px) { .lead-board { grid-template-columns: repeat(5, 82vw); } }
.lead-fresh { background: #e0e7ff; color: #3730a3; }
.lead-in_progress { background: #fef3c7; color: #92400e; }
.lead-booked { background: #dcfce7; color: #166534; }
.lead-won { background: #d1fae5; color: #065f46; font-weight: 600; }
.lead-lost { background: var(--border); color: var(--muted); }
@media (prefers-color-scheme: dark) {
  .lead-fresh { background: #312e81; color: #c7d2fe; }
  .lead-in_progress { background: #78350f; color: #fde68a; }
  .lead-booked, .lead-won { background: #14532d; color: #bbf7d0; }
}
