/* ==========================================================================
   Created UI — design system
   Tokens first; every component below uses only these variables.
   ========================================================================== */

:root {
  color-scheme: light;
  --bg:            #F7F6F2;
  --surface:       #ffffff;
  --surface-2:     #efeee9;
  --border:        #e2e0da;
  --text:          #161d2e;
  --text-muted:    #646a78;
  --accent:        #14213D;   /* traqido navy */
  --accent-hover:  #0b1427;
  --accent-soft:   #e6e9f1;
  --on-accent:     #ffffff;
  --danger:        #b3402f;
  --danger-soft:   #f8e6e2;
  --warning:       #8a5a00;
  --warning-soft:  #fbefd5;
  --success:       #2f7a55;
  --success-soft:  #e2f1e8;
  --info:          #2f5f8a;
  --info-soft:     #e3edf6;
  --focus:         #F26A1B;
  --brand:         #F26A1B;   /* traqido orange: logo, highlights */
  --brand-ink:     #b44a0c;   /* orange dark enough for small text */
  --brand-soft:    #fde9dc;

  --radius:   12px;
  --radius-s: 8px;
  --shadow:   0 1px 2px rgb(0 0 0 / .05), 0 2px 8px rgb(0 0 0 / .04);
  /* Named system fonts first: plain system-ui can map to an odd face on
     some Windows language settings. */
  --font:     -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", system-ui, sans-serif;
  --mono:     ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --sidebar-w: 232px;
  --tabbar-h:  64px;
  --tap:       48px;          /* minimum touch target */
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg:           #0e1424;
    --surface:      #151d31;
    --surface-2:    #1c2640;
    --border:       #2a3654;
    --text:         #F7F6F2;
    --text-muted:   #a6adbf;
    --accent:       #F26A1B;
    --accent-hover: #ff8a45;
    --accent-soft:  #3a2416;
    --on-accent:    #14213D;
    --brand:    #F26A1B;
    --brand-ink:    #ff9a5c;
    --brand-soft:    #3a2416;
    --danger:       #ec8a78;
    --danger-soft:  #3a211c;
    --warning:      #e8b75c;
    --warning-soft: #352a14;
    --success:      #6fbfa6;
    --success-soft: #1f332c;
    --info:         #8fb8e0;
    --info-soft:    #1e2a36;
    --shadow:       none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:           #0e1424;
  --surface:      #151d31;
  --surface-2:    #1c2640;
  --border:       #2a3654;
  --text:         #F7F6F2;
  --text-muted:   #a6adbf;
  --accent:       #F26A1B;
  --accent-hover: #ff8a45;
  --accent-soft:  #3a2416;
  --on-accent:    #14213D;
    --brand:    #F26A1B;
    --brand-ink:    #ff9a5c;
    --brand-soft:    #3a2416;
  --danger:       #ec8a78;
  --danger-soft:  #3a211c;
  --warning:      #e8b75c;
  --warning-soft: #352a14;
  --success:      #6fbfa6;
  --success-soft: #1f332c;
  --info:         #8fb8e0;
  --info-soft:    #1e2a36;
  --shadow:       none;
}

/* ---------------------------------------------------------------- base */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; font-family: var(--font); }

/* Every control, and the choices in a dropdown's list, in the app's font
   (browsers otherwise give form controls their own default font). */
button, input, select, textarea, optgroup, option { font-family: var(--font); }
input::file-selector-button { font-family: var(--font); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
}

a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h1 { font-size: 1.5rem; font-weight: 650; }
h2 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.muted { color: var(--text-muted); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------------------------------------------------------------- layout */

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

.sidebar { display: none; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { flex: 1; }

.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 650; color: var(--text); text-decoration: none;
}
.brand .logo { display: block; height: 28px; width: auto; }
.brand .logo-dark { display: none; }
:root[data-theme="dark"] .brand .logo-light { display: none; }
:root[data-theme="dark"] .brand .logo-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand .logo-light { display: none; }
  :root:not([data-theme="light"]) .brand .logo-dark { display: block; }
}
.auth .brand { justify-content: center; }
.auth .brand .logo { height: 40px; }

.main {
  padding: 20px 16px calc(var(--tabbar-h) + 24px);
  max-width: 1120px; width: 100%;
  margin: 0 auto;
}

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  margin-bottom: 20px;
}

/* Bottom tab bar — phones */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  height: var(--tabbar-h);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a, .tabbar .tab-more {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px;
  color: var(--text-muted); text-decoration: none;
  font-size: .72rem; font-weight: 500;
}
.tabbar .tab-more { background: none; border: 0; padding: 0; font: inherit; font-size: .72rem; font-weight: 500; cursor: pointer; }
.tabbar.tabbar-5 .tab-more { font-size: .68rem; }
body.menu-open .tabbar .tab-more { color: var(--accent); }
.tabbar a[aria-current="page"] { color: var(--accent); }
.tabbar a[aria-current="page"] svg { color: var(--brand); }
.tabbar svg { width: 22px; height: 22px; }

@media (min-width: 900px) {
  .app { grid-template-columns: var(--sidebar-w) 1fr; }
  .topbar, .tabbar { display: none; }
  .main { padding: 32px 40px 48px; }

  .sidebar {
    display: flex; flex-direction: column; gap: 4px;
    position: sticky; top: 0; height: 100vh;
    padding: 20px 12px;
    background: var(--surface);
    border-right: 1px solid var(--border);
  }
  .sidebar .brand { padding: 4px 10px 20px; }
  .sidebar nav { display: flex; flex-direction: column; gap: 2px; }
  .sidebar .nav-label {
    margin: 16px 10px 4px;
    font-size: .72rem; font-weight: 600; letter-spacing: .04em;
    text-transform: uppercase; color: var(--text-muted);
  }
  .sidebar a.nav {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: var(--radius-s);
    color: var(--text); text-decoration: none; font-size: .94rem;
  }
  .sidebar a.nav:hover { background: var(--surface-2); }
  .sidebar a.nav[aria-current="page"] {
    background: var(--accent-soft); color: var(--accent); font-weight: 600;
  }
  .sidebar a.nav svg { width: 18px; height: 18px; flex: none; }
  .sidebar .legacy::after {
    content: "old"; margin-left: auto;
    font-size: .68rem; color: var(--text-muted);
    border: 1px solid var(--border); border-radius: 99px; padding: 0 6px;
  }
  .sidebar .spacer { flex: 1; }
  .sidebar .user {
    display: flex; align-items: center; gap: 8px;
    padding: 10px; border-top: 1px solid var(--border);
    font-size: .9rem;
  }
  .sidebar .user span { flex: 1; overflow: hidden; text-overflow: ellipsis; }
}

/* ---------------------------------------------------------------- grid */

.grid {
  display: grid; gap: 16px;
  grid-template-columns: 1fr;
}
@media (min-width: 700px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
}

/* ---------------------------------------------------------------- card */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex; flex-direction: column; gap: 14px;
  min-width: 0;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
}
.card.is-live { border-color: var(--brand); }

.stat {
  display: flex; flex-direction: column; gap: 2px;
}
.stat .value {
  font-variant-numeric: tabular-nums;
  font-size: 2.25rem; font-weight: 600; line-height: 1.1;
}
.stat .label { color: var(--text-muted); font-size: .9rem; }

.detail-list {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 14px;
  margin: 0; font-size: .95rem;
}
.detail-list dt { color: var(--text-muted); }
.detail-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- badge */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 99px;
  font-size: .78rem; font-weight: 600;
  background: var(--surface-2); color: var(--text-muted);
  white-space: nowrap;
}
.badge.live { background: var(--brand-soft); color: var(--brand-ink); }
.badge.live::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
  animation: pulse 1.6s ease-in-out infinite;
}
.badge.warn { background: var(--warning-soft); color: var(--warning); }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) {
  .badge.live::before { animation: none; }
}

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  min-height: var(--tap); padding: 0 18px;
  border: 1px solid var(--border); border-radius: var(--radius-s);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none;
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); }
.btn-primary {
  background: var(--accent); border-color: var(--accent);
  color: var(--on-accent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .9rem; }
.btn[disabled], .htmx-request .btn { opacity: .6; pointer-events: none; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 140px; }

.icon-btn {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: var(--radius-s);
  border: 0; background: transparent; color: var(--text-muted);
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------------------------------------------------------------- forms */

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .88rem; font-weight: 600; }
.field-row { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 520px) { .field-row { grid-template-columns: 1fr 1fr; } }

.input, .field input, .field select, .field textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-s);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 16px; /* stops iOS zoom on focus */
}
.field select { appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
                    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
  padding-right: 36px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent);
}
.field.has-error input, .field.has-error select { border-color: var(--danger); }
.field .error, .form-error { color: var(--danger); font-size: .88rem; }
.form-error {
  background: var(--danger-soft); padding: 10px 12px; border-radius: var(--radius-s);
}

details.reveal > summary { list-style: none; cursor: pointer; }
details.reveal > summary::-webkit-details-marker { display: none; }
details.reveal[open] > summary { display: none; }

/* ---------------------------------------------------------------- list */

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-top: 1px solid var(--border);
  min-width: 0;
}
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .sub { color: var(--text-muted); font-size: .86rem; }
.list .end { text-align: right; white-space: nowrap; }

.empty {
  padding: 18px; text-align: center; color: var(--text-muted);
  border: 1px dashed var(--border); border-radius: var(--radius-s);
}

/* ---------------------------------------------------------------- toasts */

.toasts {
  position: fixed; z-index: 50;
  left: 16px; right: 16px; bottom: calc(var(--tabbar-h) + 12px);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
@media (min-width: 900px) {
  .toasts { left: auto; right: 24px; bottom: 24px; align-items: flex-end; }
}
.toast {
  pointer-events: auto;
  max-width: 420px; width: 100%;
  padding: 12px 16px; border-radius: var(--radius-s);
  background: var(--text); color: var(--bg);
  box-shadow: 0 6px 24px rgb(0 0 0 / .18);
  font-weight: 500;
  animation: toast-in .2s ease-out, toast-out .3s ease-in 4s forwards;
}
.toast.warning { background: var(--warning-soft); color: var(--warning); border: 1px solid currentColor; }
.toast.error { background: var(--danger-soft); color: var(--danger); border: 1px solid currentColor; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
@keyframes toast-out { to { opacity: 0; visibility: hidden; } }

/* ---------------------------------------------------------------- login */

.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 16px;
}
.auth .card { width: 100%; max-width: 380px; padding: 28px; gap: 20px; }

/* ==========================================================================
   Stage 2 — lists, records, forms
   ========================================================================== */

h3 { font-size: .95rem; font-weight: 600; margin: 0; }
.stack { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.nowrap { white-space: nowrap; }
.r { text-align: right; }
.section { margin-top: 16px; }
.prose { white-space: normal; color: var(--text); }
.help { color: var(--text-muted); font-size: .84rem; }

.back {
  display: inline-block; margin-bottom: 8px;
  color: var(--text-muted); text-decoration: none; font-size: .92rem;
}
.back:hover { color: var(--text); }

.head-actions { flex: 0 1 auto; min-width: 0; }   /* may shrink, so its buttons wrap on a phone instead of widening the page */
.head-actions > .btn { flex: 0 0 auto; }

/* badges for job status */
.badge.ok   { background: var(--accent-soft); color: var(--accent); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.done { background: var(--surface-2); color: var(--text-muted); }
.badge.bad  { background: var(--danger-soft); color: var(--danger); }

/* search + chips */
.toolbar { margin-bottom: 12px; }
.input.search {
  width: 100%; min-height: var(--tap); padding: 10px 14px 10px 40px;
  border: 1px solid var(--border); border-radius: var(--radius-s);
  background: var(--surface) no-repeat 14px 50% / 16px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8983' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
  color: var(--text); font: inherit; font-size: 16px;
}
.input.search:focus { outline: none; border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }

.chips {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px;
  margin: 0 -16px 14px; padding-inline: 16px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
@media (min-width: 900px) { .chips { flex-wrap: wrap; margin-inline: 0; padding-inline: 0; } }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 14px; border-radius: 99px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); text-decoration: none; font-size: .9rem; font-weight: 500;
}
.chip span { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.chip:hover { background: var(--surface-2); }
.chip[aria-current="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip[aria-current="true"] span { color: inherit; opacity: .7; }

/* record rows */
.rows {
  list-style: none; margin: 0; padding: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.rows > li + li { border-top: 1px solid var(--border); }
.rows > li.empty { border: 0; border-radius: 0; }
.rows > li.more { padding: 10px; }
.row {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
  align-items: center;
  padding: 12px 16px; color: var(--text); text-decoration: none;
}
.row:hover { background: var(--surface-2); }
.row-main { display: flex; flex-direction: column; min-width: 0; }
.row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub, .sub { color: var(--text-muted); font-size: .86rem; overflow: hidden; text-overflow: ellipsis; }
.row-main .sub { white-space: nowrap; }
.row-aside { display: none; }
.row-end { grid-row: 1; grid-column: 2; }
@media (min-width: 900px) {
  .row { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) 130px; }
  .row-aside { display: block; white-space: nowrap; }
  .row-end { grid-column: 3; text-align: right; }
}

/* links inside .list rows */
.list a.grow { color: var(--text); text-decoration: none; display: flex; flex-direction: column; }
.list a.grow:hover .title { text-decoration: underline; }

/* stat tiles */
.tiles {
  display: grid; gap: 12px; margin: 16px 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 700px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile {
  display: flex; flex-direction: column; gap: 2px;
  padding: 14px 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.tile .label { color: var(--text-muted); font-size: .84rem; }
.tile .value {
  font-variant-numeric: tabular-nums;
  font-size: 1.5rem; font-weight: 600; line-height: 1.2;
  overflow: hidden; text-overflow: ellipsis;
}

/* status switcher */
.status-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.input-sm {
  min-height: 36px; padding: 4px 10px; font: inherit; font-size: .9rem;
  border: 1px solid var(--border); border-radius: var(--radius-s);
  background: var(--surface); color: var(--text);
}

/* documents */
.doc-groups { display: grid; gap: 20px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .doc-groups { grid-template-columns: 1fr 1fr; } }
.doc-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

/* table */
.table-wrap { overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
.table { width: 100%; border-collapse: collapse; font-size: .94rem; }
.table th {
  text-align: left; font-weight: 600; font-size: .8rem; color: var(--text-muted);
  padding: 6px 8px; border-bottom: 1px solid var(--border);
}
.table td { padding: 8px; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: 0; }
.table th:first-child, .table td:first-child { padding-left: 0; }
.table th:last-child, .table td:last-child { padding-right: 0; }

/* full-page forms */
.form-page { max-width: 640px; }
.form-actions > .btn { flex: 0 1 auto; }
.field textarea { min-height: 96px; resize: vertical; }
.field .label { font-size: .88rem; font-weight: 600; }
.check-filter {
  width: 100%; min-height: 40px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-s);
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px;
}
.checks {
  max-height: 240px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius-s);
  padding: 4px;
}
.check {
  display: flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 0 10px; border-radius: 6px; cursor: pointer;
  font-weight: 400 !important;
}
.check:hover { background: var(--surface-2); }
.check input { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); margin: 0; }
.check:has(input:checked) { background: var(--accent-soft); }
.check.inline { padding: 0; }

.quick > .btn { flex: 1 1 80px; }

/* ==========================================================================
   Stage 3 — document editors
   ========================================================================== */

.warn-text { color: var(--warning); }

.form-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 620px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .span-2, .form-grid .span-all { grid-column: 1 / -1; }
}
.checks-inline { display: flex; flex-wrap: wrap; gap: 4px 20px; }

.lines { display: flex; flex-direction: column; gap: 12px; }
.line {
  display: flex; flex-direction: column; gap: 10px;
  padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-s);
  background: var(--surface);
}
.line.is-removed { opacity: .55; background: var(--surface-2); }
.line.is-removed .line-grid, .line.is-removed .form-grid,
.line.is-removed .pay-grid > .field { display: none; }
.line-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.line-no { font-weight: 600; color: var(--text-muted); font-size: .9rem; }
.line-actions { display: flex; align-items: center; gap: 4px; }

.line-grid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.line-grid .span-task, .line-grid .span-label, .line-grid .span-desc { grid-column: 1 / -1; }
.line-grid .qty { display: flex; align-items: flex-end; gap: 8px; }
.line-grid .qty .field { flex: 1; }
.units { color: var(--text-muted); font-size: .86rem; padding-bottom: 14px; white-space: nowrap; }
.line-total {
  grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: baseline;
  padding-top: 8px; border-top: 1px dashed var(--border);
}
.line-total .label { color: var(--text-muted); font-size: .86rem; }
.line-total .num { font-weight: 600; }
@media (min-width: 760px) {
  .line-grid { grid-template-columns: 2fr 1.2fr 110px 150px 130px; align-items: end; }
  .line-grid .span-task { grid-column: 1; }
  .line-grid .span-label { grid-column: 2 / -1; }
  .line-total { grid-column: auto; flex-direction: column; align-items: flex-end;
                border-top: 0; padding: 0 0 12px; }
}

.pay-grid { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; align-items: end; }
.pay-grid .line-actions { grid-column: 1 / -1; justify-content: flex-end; }
@media (min-width: 760px) {
  .pay-grid { grid-template-columns: 140px 1fr 160px auto; }
  .pay-grid .line-actions { grid-column: auto; padding-bottom: 4px; }
}
.line-compact { padding: 10px 14px; }
.line-compact.is-removed .pay-grid::before { content: "Will be removed"; color: var(--text-muted); }

/* sticky save bar */
.save-bar {
  position: sticky; bottom: calc(var(--tabbar-h) + 8px); z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 16px; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 4px 18px rgb(0 0 0 / .10);
}
.save-bar .total { font-size: 1.3rem; font-weight: 650; }
.save-bar .btn-row > .btn { flex: 0 0 auto; }
@media (min-width: 900px) { .save-bar { bottom: 16px; } }

/* Users see fewer stat tiles on a job */
@media (min-width: 700px) { .tiles.tiles-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.checks.radios { max-height: none; display: flex; flex-wrap: wrap; gap: 4px; }
.checks.radios .check { flex: 1 1 140px; }

/* ==========================================================================
   Compact quick forms + denser phone layout
   ========================================================================== */

/* Quick forms: the label lives in the first option / placeholder.
   Labels stay in the page for screen readers. */
.form-compact { gap: 10px; }
.form-compact .field { gap: 4px; }
.form-compact .field > label:not(.file-btn):not(.check) {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.form-compact .field-row { gap: 10px; }
.form-compact .field-row.tight { grid-template-columns: 1fr 1fr; }

/* An unchosen dropdown reads like a placeholder. */
.field select:has(option[value=""]:checked) { color: var(--text-muted); }
.field select option { color: var(--text); }
.field input::placeholder, .field textarea::placeholder { color: var(--text-muted); opacity: 1; }

/* Receipt photo picker */
.file-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 14px; cursor: pointer;
  border: 1px dashed var(--border); border-radius: var(--radius-s);
  color: var(--text-muted); font-weight: 500 !important; font-size: .95rem !important;
  overflow: hidden;
}
.file-btn:hover { background: var(--surface-2); color: var(--text); }
.file-btn.has-file { border-style: solid; color: var(--text); }
.file-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-btn:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Three quick-action cards */
@media (min-width: 700px)  { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1200px) { .grid-3 { grid-template-columns: 1fr 1fr 1fr; } }

/* Phones: less chrome, smaller type, tighter spacing */
@media (max-width: 699px) {
  :root { --tap: 44px; }
  .main { padding: 12px 10px calc(var(--tabbar-h) + 16px); }
  .topbar { padding: 8px 10px; }
  .page-head { margin-bottom: 10px; gap: 8px; }
  h1 { font-size: 1.2rem; }
  h2 { font-size: .98rem; }
  .grid, .tiles { gap: 10px; }
  .section { margin-top: 10px; }
  .tiles { margin: 10px 0; }
  .card { padding: 12px; gap: 10px; border-radius: 10px; }
  .card-head { min-height: 24px; }
  .stat .value { font-size: 1.8rem; }
  .tile { padding: 10px 12px; }
  .tile .value { font-size: 1.2rem; }
  .field input, .field select, .field textarea, .input.search {
    padding-top: 8px; padding-bottom: 8px;
  }
  .row { padding: 10px 12px; }
  .list li { padding: 8px 0; }
  .line { padding: 10px; }
  .chips { margin-inline: -10px; padding-inline: 10px; margin-bottom: 10px; }
  .table-wrap { margin: 0 -12px; padding: 0 12px; }
  .back { margin-bottom: 4px; }
  .save-bar { padding: 8px 12px; }
}

/* Screenshot review fixes */
.field-row.tight, .form-compact .field-row.tight { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.field-row > .field { min-width: 0; }
.field input[type=date] { min-width: 0; }
.grid-3 { align-items: start; }

/* Job status: one tappable pill instead of badge + dropdown */
.pill-select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  min-height: 32px; padding: 2px 30px 2px 12px; border-radius: 99px;
  border: 1px solid transparent; font: inherit; font-size: .85rem; font-weight: 600;
  background-color: var(--surface-2); color: var(--text-muted);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.pill-select:hover { border-color: currentColor; }
.pill-select.live, .pill-select.ok { background-color: var(--accent-soft); color: var(--accent); }
.pill-select.info { background-color: var(--info-soft); color: var(--info); }
.pill-select.bad  { background-color: var(--danger-soft); color: var(--danger); }
.pill-select option { color: var(--text); background: var(--surface); }
/* Date gets its natural width only where there's room; on phones the row
   splits evenly, because iOS Safari's natural date width is wider than
   half a phone screen. */
@media (min-width: 700px) {
  .form-compact .field-row.tight.date-row { grid-template-columns: minmax(0, 1fr) auto; }
}

/* iOS Safari ignores width on native date inputs and centres the value;
   drop the native styling (tapping still opens the iOS date picker). */
.field input[type=date] {
  -webkit-appearance: none; appearance: none;
  display: block; width: 100%; max-width: 100%; min-width: 0;
  text-align: left;
}
.field input[type=date]::-webkit-date-and-time-value { text-align: left; margin: 0; }
/* The expense card has the most fields; give it a little more room. */
@media (min-width: 1200px) { .grid-3 { grid-template-columns: 1.35fr 1fr 1fr; } }
.form-compact .field-row.tight.odo-row { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); }

/* ==========================================================================
   Document editors — dense layout, collapsible items
   ========================================================================== */

.editor-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 8px 12px; flex-wrap: wrap; margin-bottom: 10px;
}
.editor-head h1 { font-size: 1.25rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.editor-head .back { margin-bottom: 2px; font-size: .85rem; }
.editor-head .btn-row > .btn { flex: 0 0 auto; }

.doc-editor .card { padding: 12px 14px; gap: 10px; }
.doc-editor .section { margin-top: 10px; }
.doc-editor .field { gap: 3px; }
.doc-editor .field > label:not(.check), .doc-editor .field > .label {
  font-size: .74rem; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .03em;
}
.doc-editor .field input:not([type=checkbox]):not([type=radio]),
.doc-editor .field select, .doc-editor .field textarea {
  min-height: 38px; padding: 6px 10px;
}
.doc-editor .field textarea { min-height: 64px; }
@media (min-width: 700px) {
  .doc-editor .field input:not([type=checkbox]):not([type=radio]),
  .doc-editor .field select, .doc-editor .field textarea { font-size: .95rem; }
}

/* Details: one summary line until opened */
.details-card { gap: 0 !important; }
.details-card > summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: 10px; min-height: 28px;
}
.details-card > summary::-webkit-details-marker { display: none; }
.details-card[open] > summary { margin-bottom: 10px; }
.details-card[open] > summary .item-meta { display: none; }
.details-card > summary .chev { margin-left: auto; }
.details-card[open] > summary .chev { transform: rotate(180deg); }
.form-grid.dense { gap: 10px 12px; }
@media (min-width: 900px) {
  .form-grid.dense { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .form-grid.dense .span-2 { grid-column: span 2; }
}

/* Item list */
.items {
  display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: var(--radius-s); overflow: hidden;
}
.items:empty { display: none; }
.item { background: var(--surface); }
.item:nth-child(even) { background: var(--surface-2); }
.item + .item { border-top: 1px solid var(--border); }
.item.is-open { background: var(--surface); box-shadow: inset 3px 0 0 var(--accent); }

.item-head { display: flex; align-items: center; }
.item-toggle {
  flex: 1; min-width: 0; min-height: 44px;
  display: grid; grid-template-columns: 26px minmax(0, 1fr) auto auto 16px;
  align-items: center; gap: 8px; padding: 6px 10px;
  background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.item-toggle:hover .item-title { text-decoration: underline; }
.item-no {
  font-size: .78rem; font-weight: 600; color: var(--text-muted);
  font-variant-numeric: tabular-nums; text-align: center;
}
.item-sum { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.item-title { font-weight: 600; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-meta { font-size: .8rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-meta:empty { display: none; }
.item-total { font-weight: 600; font-size: .92rem; white-space: nowrap; }
.item-flag {
  font-size: .72rem; font-weight: 600; padding: 1px 8px; border-radius: 99px;
  background: var(--danger-soft); color: var(--danger); white-space: nowrap;
}
.chev { width: 16px; height: 16px; color: var(--text-muted); transition: transform .15s; }
.item.is-open .chev { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { .chev { transition: none; } }

.item-undo { display: none; margin-right: 8px; }
.item.is-removed { opacity: .65; }
.item.is-removed .item-title { text-decoration: line-through; }
.item.is-removed .item-undo { display: inline-flex; }
.item.is-removed .item-total, .item.is-removed .chev { visibility: hidden; }

.item-body { padding: 4px 12px 12px 12px; }
.item-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-top: 10px; }
.item-actions .btn { flex: 0 0 auto; }

/* Fields inside a line item */
.item-body .line-grid { display: grid; gap: 8px 10px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.item-body .line-grid .span-cat, .item-body .line-grid .span-task,
.item-body .line-grid .span-label,
.item-body .line-grid .span-desc { grid-column: 1 / -1; }
.item-body .line-grid .qty { display: flex; align-items: flex-end; gap: 6px; }
.item-body .line-grid .qty .field { flex: 1; min-width: 0; }
.item-body .units { padding-bottom: 9px; font-size: .8rem; }
@media (min-width: 760px) {
  .item-body .line-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1.4fr) 110px 150px; align-items: end; }
  .item-body .line-grid .span-cat { grid-column: 1; }
  .item-body .line-grid .span-task { grid-column: 2; }
  .item-body .line-grid .span-label { grid-column: 3 / -1; }
  .item-body .line-grid .span-desc { grid-column: 1 / -1; }
}
.item-body .pay-grid { display: grid; gap: 8px 10px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.item-body .pay-grid > .field:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
@media (min-width: 760px) {
  .item-body .pay-grid { grid-template-columns: 140px minmax(0, 1fr) 160px; }
  .item-body .pay-grid > .field:nth-child(2) { grid-column: auto; grid-row: auto; }
}

.btn-add { border-style: dashed; color: var(--text-muted); min-height: 40px; }
.btn-add:hover { color: var(--text); }

@media (max-width: 699px) {
  .doc-editor .card { padding: 10px; }
  .item-toggle { padding: 6px 8px; gap: 6px; grid-template-columns: 22px minmax(0, 1fr) auto auto 14px; }
  .item-body { padding: 2px 10px 10px; }
}

/* The content column must never grow to fit unbreakable text (it made a
   long one-line summary widen the whole page on phones). */
.app { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .app { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); } }
.details-card > summary .item-sum { flex: 1; min-width: 0; }

/* Save bar: always one slim row on phones */
.save-bar .btn-row { flex-wrap: nowrap; }
@media (max-width: 699px) {
  .save-bar { padding: 6px 10px; gap: 8px; bottom: calc(var(--tabbar-h) + 6px); }
  .save-bar .stack .muted { display: none; }
  .save-bar .total { font-size: 1.05rem; white-space: nowrap; }
  .save-bar .btn { min-height: 38px; padding: 0 12px; font-size: .9rem; }
  .item-total { font-size: .86rem; }
}
.items:not(:has(> [data-row])):not(#cat-list) { display: none; }

/* Drag grip replaces the row number */
.item-head { gap: 0; }
.drag-handle {
  flex: none; align-self: stretch;
  display: grid; place-items: center; width: 34px;
  color: var(--text-muted); cursor: grab;
  touch-action: none; -webkit-user-select: none; user-select: none;
}
.drag-handle:hover { color: var(--text); }
.drag-handle:active { cursor: grabbing; }
.drag-handle svg { width: 18px; height: 18px; fill: currentColor; }
.item-toggle { grid-template-columns: minmax(0, 1fr) auto auto 16px; padding-left: 0; }
@media (max-width: 699px) {
  .item-toggle { grid-template-columns: minmax(0, 1fr) auto auto 14px; padding-left: 0; }
  .drag-handle { width: 30px; }
}
.item.is-ghost { opacity: .35; }
.item.is-dragging { box-shadow: 0 8px 24px rgb(0 0 0 / .18); border-radius: var(--radius-s); background: var(--surface); }
.item.is-dragging .item-body { display: none; }


/* "$" before / units after a field, outside the box */
.adorn { display: flex; align-items: center; gap: 6px; min-width: 0; }
.adorn > input { flex: 1; min-width: 0; }
.adorn-pre, .adorn-post { flex: none; color: var(--text-muted); font-weight: 600; }
.adorn-post { font-size: .82rem; font-weight: 500; white-space: nowrap; }
.adorn-post:empty { display: none; }
.doc-editor input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.doc-editor input[type=number]::-webkit-inner-spin-button,
.doc-editor input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* Phones: no labels inside rows; the first option / placeholder says it */
@media (max-width: 699px) {
  .item-body .field > label:not(.check), .item-body .field > .label {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
  }
  .item-body .help { display: none; }
  .item-body .line-grid, .item-body .pay-grid, .item-body .form-grid { gap: 8px; }
  .item-body { padding-top: 6px; }
}

/* ==========================================================================
   Time sheet
   ========================================================================== */
.day-picker { display: flex; align-items: center; gap: 4px; }
.day-picker .icon-btn { font-size: 1.1rem; text-decoration: none; }
.day-picker input[type=date] { width: auto; min-height: 36px; }
.day-label { margin: -6px 0 10px; font-size: .9rem; }
.workers { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) { .workers { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.worker { gap: 8px !important; }
.worker-total { font-weight: 600; }
.tlines { display: flex; flex-direction: column; gap: 6px; }
.tline {
  display: grid; gap: 6px; align-items: center;
  grid-template-columns: minmax(0, 1fr) 96px 32px;
  grid-template-areas: "job job rm" "cat hrs rm";
  padding: 6px; border-radius: var(--radius-s); background: var(--surface-2);
}
.tline:nth-child(even) { background: var(--surface); border: 1px solid var(--border); }
.tline-job { grid-area: job; min-width: 0; }
.tline-cat { grid-area: cat; min-width: 0; }
.tline-hrs { grid-area: hrs; min-width: 0; }
.tline-remove { grid-area: rm; width: 32px; height: 32px; }
.tline .field > label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tline .field input, .tline .field select { min-height: 38px; }
.tline.has-errors { box-shadow: inset 3px 0 0 var(--danger); }
.tline-locked { font-size: .92rem; color: var(--text-muted); }
.tline-locked .tline-job { color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (min-width: 700px) {
  .tline { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) 96px 32px; grid-template-areas: "job cat hrs rm"; }
}
.worker .btn-add { align-self: flex-start; }
.tabbar.tabbar-5 { grid-template-columns: repeat(5, 1fr); }
.tabbar.tabbar-5 a { font-size: .68rem; }

/* Compact editors: keep room for the dropdown arrow */
.doc-editor .field select { padding-right: 30px; background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; }
/* Time sheet: one worker per row until there is real room for two */
@media (min-width: 1100px) { .workers { grid-template-columns: minmax(0, 1fr); } }
@media (min-width: 1400px) { .workers { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 700px) {
  .tline { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) 84px 32px; }
}

/* ==========================================================================
   Phone menu: the sidebar slides in from the left
   ========================================================================== */

/* Sidebar contents look the same at every width (they used to be styled
   only on desktop, where the sidebar was the only place they appeared). */
.sidebar .brand { padding: 4px 10px 20px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar .nav-label {
  margin: 16px 10px 4px;
  font-size: .72rem; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-muted);
}
.sidebar a.nav {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-s);
  color: var(--text); text-decoration: none; font-size: .94rem;
}
.sidebar a.nav:hover { background: var(--surface-2); }
.sidebar a.nav[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; box-shadow: inset 3px 0 0 var(--brand); }
.sidebar a.nav svg { width: 18px; height: 18px; flex: none; }
.sidebar .legacy::after {
  content: "old"; margin-left: auto;
  font-size: .68rem; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 99px; padding: 0 6px;
}
.sidebar .spacer { flex: 1; }
.sidebar .user {
  display: flex; align-items: center; gap: 8px;
  padding: 10px; border-top: 1px solid var(--border); font-size: .9rem;
}
.sidebar .user > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.menu-btn { margin-left: -6px; color: var(--text); }
.menu-btn svg { width: 22px; height: 22px; }
.menu-backdrop { display: none; }

@media (max-width: 899px) {
  .sidebar.is-open {
    display: flex; flex-direction: column; gap: 4px;
    position: fixed; z-index: 60; top: 0; bottom: 0; left: 0;
    width: min(290px, 84vw); padding: 16px 12px calc(12px + env(safe-area-inset-bottom));
    background: var(--surface); border-right: 1px solid var(--border);
    box-shadow: 0 0 40px rgb(0 0 0 / .25);
    overflow-y: auto; overscroll-behavior: contain;
    animation: menu-in .18s ease-out;
  }
  .sidebar.is-open a.nav { padding: 11px 10px; font-size: 1rem; }   /* bigger touch targets */
  .menu-backdrop:not([hidden]) {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgb(0 0 0 / .35); animation: fade-in .18s ease-out;
  }
  body.menu-open { overflow: hidden; }
}
@media (min-width: 900px) { .menu-btn { display: none; } }
@keyframes menu-in { from { transform: translateX(-100%); } }
@keyframes fade-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sidebar.is-open, .menu-backdrop { animation: none !important; } }

/* Users: no password box while "Can sign in" is off */
.form-page:has(input[name=is_active]:not(:checked)) .field-password { display: none; }

/* People: login details only while "Can sign in" is on */
.access-details { display: flex; flex-direction: column; gap: 14px; }
.access-card:has(input[name="access-can_sign_in"]:not(:checked)) .access-details { display: none; }
.person-form .card + .card { margin-top: 12px; }
/* A removed time-sheet line must really disappear (display:grid beat [hidden]) */
.tline[hidden] { display: none; }

/* Time sheet people: collapsible rows like the estimate lines */
.workers {
  display: flex !important; flex-direction: column; gap: 0;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); overflow: hidden;
}
.worker { background: var(--surface); }
.worker:nth-of-type(even) { background: var(--surface-2); }
.worker + .worker { border-top: 1px solid var(--border); }
.worker.is-open { background: var(--surface); box-shadow: inset 3px 0 0 var(--accent); }
.worker-head {
  width: 100%; min-height: 52px;
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto 16px; align-items: center; gap: 10px;
  padding: 8px 14px; background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.worker-head .item-title { font-size: .98rem; }
.worker-head .item-title .badge { font-size: .7rem; padding: 0 7px; margin-left: 4px; vertical-align: 1px; }
.worker-head:hover .item-title { text-decoration: underline; }
.worker.is-open .chev { transform: rotate(180deg); }
.worker-body { display: flex; flex-direction: column; gap: 6px; padding: 2px 12px 12px; }
.worker-body .btn-add { align-self: flex-start; }
.worker .item-total { font-weight: 600; }
@media (max-width: 699px) {
  .worker-head { padding: 8px 10px; gap: 8px; grid-template-columns: minmax(0, 1fr) auto auto 14px; }
  .worker-body { padding: 2px 8px 10px; }
}
.worker-body[hidden] { display: none; }


/* Jobs list: name and status edited in place (admins) */
.row-edit:hover { background: none; }
.row-edit { grid-template-columns: minmax(0, 1fr) auto; }
@media (min-width: 900px) { .row-edit { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto; } }
.row-edit .row-end { display: flex; align-items: center; gap: 4px; }
.row-edit .row-main a.sub { color: var(--text-muted); text-decoration: none; }
.row-edit .row-main a.sub:hover { text-decoration: underline; }
.inline-input {
  width: 100%; margin: -4px 0 -2px -6px; padding: 3px 6px;
  border: 1px solid transparent; border-radius: 6px; background: transparent;
  color: var(--text); font: inherit; font-weight: 600; font-size: 16px;
  text-overflow: ellipsis;
}
.inline-input:hover { border-color: var(--border); background: var(--surface); }
.inline-input:focus { outline: none; border-color: var(--focus); background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.open-btn { width: 36px; height: 36px; }

/* Jobs list name: text + ✎, edit box only while renaming */
.name-view { display: flex; align-items: center; gap: 2px; min-width: 0; }
.name-view[hidden] { display: none; }
.name-view .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.edit-name { flex: none; width: 30px; height: 30px; margin: -4px 0; color: var(--text-muted); }
.edit-name svg { width: 16px; height: 16px; }
.inline-input[hidden] { display: none; }
.inline-input { border-color: var(--focus); background: var(--surface); }
.name-view a.title { color: var(--text); text-decoration: none; }
.name-view a.title:hover { text-decoration: underline; }

/* Job short description: under the name in the list and on the job page */
.job-subtitle { font-size: .9rem; color: var(--text); opacity: .85; line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-head .job-subtitle { white-space: normal; font-size: 1rem; }

/* Job page: the Details form takes the full width while editing */
.grid-2 > .card.editing { grid-column: 1 / -1; }

/* Autosaving details: quiet status note in the card corner */
.save-state { font-size: .82rem; color: var(--text-muted); text-align: right; }
.save-state .saving { display: none; }
.htmx-request .save-state .saving { display: inline; }
.htmx-request .save-state .saved { display: none; }
.save-state .save-error { color: var(--danger); font-weight: 600; }

/* ==========================================================================
   Job page: click-to-edit details (admins)
   ========================================================================== */
.details-inline { gap: 6px !important; }
.inline-field { margin: 0; }
.details-inline .inline-input {
  display: block; width: 100%; margin: 0 0 0 -7px; padding: 4px 6px;
  border: 1px solid transparent; border-radius: 6px; background: transparent;
  color: var(--text); font: inherit; font-size: 1rem; line-height: 1.4;
  text-overflow: ellipsis; cursor: text;
}
.details-inline .inline-input:hover { border-color: var(--border); background: var(--surface-2); }
.details-inline .inline-input:focus { outline: none; border-color: var(--focus); background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.details-inline .inline-input::placeholder { color: var(--text-muted); font-style: italic; }
.details-inline .inline-title { font-size: 1.2rem; font-weight: 650; }
.details-inline .inline-subtitle { color: var(--text-muted); }
.details-inline .inline-area { resize: none; overflow: hidden; min-height: 2.2em; white-space: pre-wrap; }
.details-inline .inline-select { appearance: none; -webkit-appearance: none; cursor: pointer; }
.details-inline .detail-list { margin: 6px 0 2px; align-items: center; }
.details-inline .detail-list dd { min-width: 0; }
.details-inline .maps-link { font-size: .86rem; margin-left: -1px; }
.inline-customers > summary { list-style: none; cursor: pointer; }
.inline-customers > summary::-webkit-details-marker { display: none; }
.inline-customers[open] > summary { border-color: var(--focus); background: var(--surface); }
.inline-customers form { margin-top: 6px; }
.inline-customers .field > .label { display: none; }
.details-inline .contacts { margin-top: 0; }

/* Job page: status at the upper right of the heading */
.job-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.job-top > .page-head { flex: 1; min-width: 0; margin-bottom: 10px; }
.job-top-status { flex: none; padding-top: 4px; }
.job-top-status .status-form { flex-wrap: nowrap; }
.job-top + .tiles { margin-top: 4px; }
#job-details { margin-top: 0; }

/* Office: expenses list */
.chips-label { align-self: center; font-size: .8rem; color: var(--text-muted); font-weight: 600; flex: none; }
.expense-row .row:hover { background: none; }
.expense-row .title { color: var(--text); text-decoration: none; }
.expense-row .title:hover { text-decoration: underline; }
.expense-row .sub a { color: inherit; }
.expense-row .row-end { display: flex; align-items: center; gap: 2px; justify-content: flex-end; }
.expense-row .amount { font-weight: 600; white-space: nowrap; }
.expense-row .receipt-link { width: 36px; height: 36px; display: grid; place-items: center; text-decoration: none; font-size: 1.05rem; }
@media (min-width: 900px) { .expense-row .row { grid-template-columns: minmax(0, 1.6fr) minmax(0, .7fr) 150px; } }
@media (max-width: 899px) {
  /* phones: show who entered it under the description */
  .expense-row .row-aside { display: block; grid-column: 1; font-size: .82rem; }
}
.expense-row .receipt-link svg { width: 20px; height: 20px; color: var(--accent); }
.chip svg { width: 16px; height: 16px; }
@media (max-width: 899px) { .expense-row .row-aside.no-user { display: none; } }

/* Expenses: job / paid-with selectors and the job total */
.expense-filters { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.filter-row { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.filter-select {
  width: 100%; min-height: 40px; padding: 6px 30px 6px 12px; font: inherit; font-size: 16px;
  border: 1px solid var(--border); border-radius: var(--radius-s); background-color: var(--surface);
  color: var(--text); appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
                    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.filter-select.is-set { border-color: var(--accent); background-color: var(--accent-soft); color: var(--accent); font-weight: 600; }
.expense-summary { margin-bottom: 10px; }
.expense-summary.for-job {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: baseline;
  padding: 12px 14px; background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--accent); border-radius: var(--radius);
}
.expense-summary .sum-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.expense-summary .sum-label a { color: var(--accent); }
.expense-summary .sum-total { font-size: 1.4rem; font-weight: 700; grid-row: span 2; text-align: right; }
.expense-summary .sum-count { font-size: .86rem; }
@media (min-width: 900px) { .filter-row { grid-template-columns: 320px 260px; } }

/* Expense page */
.expense-head { align-items: flex-start; }
.expense-amount { font-size: 1.6rem; font-weight: 700; white-space: nowrap; }
.details-inline .adorn { display: flex; align-items: center; gap: 2px; }
.details-inline .adorn .inline-input { flex: 1; }
.details-inline dd.readonly { padding: 4px 0; }
.receipt-photo { display: block; }
.receipt-photo img { display: block; max-width: 100%; max-height: 520px; border-radius: var(--radius-s); border: 1px solid var(--border); }
.receipt-actions { margin-top: 6px; }
.receipt-actions form { display: contents; }
.file-pick { position: relative; overflow: hidden; }
.file-pick svg { width: 16px; height: 16px; }
.file-pick input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* Expenses: three selectors and a date range */
.filter-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.filter-row select:nth-of-type(3) { grid-column: 1 / -1; }
@media (min-width: 900px) {
  .filter-row { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr); }
  .filter-row select:nth-of-type(3) { grid-column: auto; }
}
.date-range { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.date-field {
  display: flex; align-items: center; gap: 6px; flex: 1 1 150px; min-width: 0;
  padding: 0 4px 0 12px; min-height: 40px; border: 1px solid var(--border);
  border-radius: var(--radius-s); background: var(--surface);
}
.date-field span { font-size: .82rem; font-weight: 600; color: var(--text-muted); flex: none; }
.date-field input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 16px; padding: 6px 4px; -webkit-appearance: none; appearance: none;
}
.date-field input:focus { outline: none; }
.date-field:focus-within { border-color: var(--focus); }
.date-field.is-set { border-color: var(--accent); background: var(--accent-soft); }
.clear-dates { flex: none; }
@media (min-width: 900px) { .date-field { flex: 0 1 220px; } }
.date-field { padding-left: 10px; gap: 4px; }
.date-field span { font-size: .74rem; }
.date-field input { padding: 6px 0; }
.date-field input::-webkit-calendar-picker-indicator { width: 16px; height: 16px; margin: 0 2px 0 0; padding: 0; }
.period-select { flex: 1 1 100%; }
@media (min-width: 900px) { .period-select { flex: 0 1 220px; } }

/* Filter toggle */
.filter-toggle { gap: 6px; }
.filter-toggle svg { width: 18px; height: 18px; }
.filter-toggle.is-open, .filter-toggle.has-filters { border-color: var(--accent); color: var(--accent); }
.filter-toggle.is-open { background: var(--accent-soft); }
.filter-count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; display: inline-grid; place-items: center;
  background: var(--accent); color: var(--on-accent); font-size: .75rem; font-weight: 700;
}
.filter-panel {
  margin-bottom: 12px; padding: 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.filter-panel[hidden] { display: none; }
.filter-panel .expense-filters { margin-bottom: 8px; }
.filter-panel .clear-all { color: var(--text-muted); }

/* Expenses on desktop: one tight line per expense */
@media (min-width: 900px) {
  .expense-rows .expense-row .row {
    grid-template-columns: minmax(0, 1fr) 150px 130px;
    padding: 4px 12px; gap: 0 12px; min-height: 0; font-size: .9rem; line-height: 1.35;
  }
  .expense-rows .expense-row .row-main { flex-direction: row; align-items: baseline; gap: 10px; min-width: 0; }
  .expense-rows .expense-row .row-main .title { flex: 0 1 auto; max-width: 45%; font-size: .92rem; }
  .expense-rows .expense-row .row-main .sub { flex: 1 1 auto; min-width: 0; font-size: .84rem; white-space: nowrap; }
  .expense-rows .expense-row .row-aside { font-size: .84rem; }
  .expense-rows .expense-row .amount { font-size: .92rem; }
  .expense-rows .expense-row .receipt-link { width: 28px; height: 28px; }
  .expense-rows .expense-row .receipt-link svg { width: 17px; height: 17px; }
  .expense-rows > li:nth-child(even) .row { background: var(--surface-2); }
  .expense-rows > li + li { border-top-color: transparent; }
  .expense-summary { margin-bottom: 6px; }
  .expense-summary.for-job { padding: 8px 12px; }
  .expense-summary .sum-total { font-size: 1.2rem; }
}

/* ---------------------------------------------------------------- schedule (Gantt) */

.gantt {
  --day: 28px; --label-w: 116px; --row-h: 40px; --head-h: 44px;
  --weekend: color-mix(in srgb, var(--text) 5%, transparent);
  --gridline: color-mix(in srgb, var(--border) 70%, transparent);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
@media (min-width: 900px) { .gantt { --day: 32px; --label-w: 210px; --row-h: 38px; } }
.job-schedule .gantt { border: 0; border-radius: 0; margin: 0 -2px; }
.gantt-nav {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  padding: 6px 8px; border-bottom: 1px solid var(--border);
}
.gantt-range { margin-left: auto; color: var(--text-muted); font-size: .88rem; padding-right: 4px; }
.gantt-scroll { overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; }
.gantt-grid { position: relative; width: max-content; min-width: 100%; }
.g-row { display: flex; min-height: var(--row-h); border-top: 1px solid var(--gridline); }
.g-row.g-head { border-top: 0; min-height: var(--head-h); }
.g-row[hidden] { display: none; }
/* collapsed jobs: only the next 7 days' tasks, with a "more" row */
.g-job-line { display: flex; align-items: center; gap: 2px; min-width: 0; max-width: 100%; }
.g-toggle { flex: none; display: inline-grid; place-items: center; width: 24px; height: 24px; margin-left: auto;
            border: 0; border-radius: 6px; background: none; color: var(--text-muted); cursor: pointer; }
.g-toggle:hover { background: var(--surface); color: var(--text); }
.g-toggle svg { width: 16px; height: 16px; transition: transform .15s; }
.g-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
.g-more { min-height: 26px; }
.g-more .g-label { padding: 0 8px; }
.g-more-btn { border: 0; background: none; padding: 2px 0; color: var(--accent); font: inherit; font-size: .78rem;
              cursor: pointer; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.g-more-btn:hover { text-decoration: underline; }
.g-nav-toggle { margin-left: 4px; }
.g-label {
  position: sticky; left: 0; z-index: 3; flex: none;
  width: var(--label-w); background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; align-items: center; min-width: 0;
}
.g-corner { padding: 4px 8px; font-size: .72rem; line-height: 1.2; }
.g-time {
  position: relative; flex: none;
  width: calc(var(--ndays) * var(--day));
  background:
    repeating-linear-gradient(to right, transparent 0 calc(var(--day) - 1px), var(--gridline) calc(var(--day) - 1px) var(--day)),
    repeating-linear-gradient(to right, transparent 0 calc(5 * var(--day)), var(--weekend) calc(5 * var(--day)) calc(7 * var(--day)));
}
.g-head .g-time { background: none; }
.g-months, .g-days { display: grid; grid-template-columns: repeat(var(--ndays), var(--day)); }
.g-months span {
  font-size: .75rem; font-weight: 650; padding: 4px 6px 0;
  white-space: nowrap; overflow: hidden; border-left: 1px solid var(--gridline);
}
.g-days span {
  display: flex; flex-direction: column; align-items: center;
  font-size: .72rem; line-height: 1.1; padding: 2px 0 4px;
  font-variant-numeric: tabular-nums; color: var(--text-muted);
}
.g-days b { font-weight: 500; font-size: .62rem; }
.g-days .we { background: var(--weekend); }
.g-days .is-today { color: var(--accent); font-weight: 700; }
.g-job { min-height: 30px; background: var(--surface-2); }
.g-job .g-label { background: var(--surface-2); padding: 0 8px; font-weight: 650; font-size: .86rem; }
.g-job .g-label a { color: inherit; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-job .g-label a:hover { text-decoration: underline; }
.g-job .g-time { background: none; }
.g-job .g-label { flex-direction: column; align-items: flex-start; justify-content: center; }
.g-stale { display: block; font-weight: 500; font-size: .74rem; color: var(--warning); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.g-name {
  all: unset; box-sizing: border-box; cursor: pointer; width: 100%;
  padding: 3px 8px; display: flex; flex-direction: column; min-width: 0;
}
.g-name:hover .g-title { text-decoration: underline; }
.g-name:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.g-title, .g-name .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-title { font-size: .88rem; font-weight: 550; display: flex; align-items: center; gap: 4px; }
.g-name .sub { font-size: .72rem; color: var(--text-muted); }
.g-flag svg { width: 14px; height: 14px; color: var(--danger); display: block; }

:root {
  --task-open: #e9b949;    --task-open-ink: #3b2b00;
  --task-staffed: #3f8f5f; --task-staffed-ink: #fff;
  --task-subbed: #3a74b5;  --task-subbed-ink: #fff;
}
.task-open    { --c: var(--task-open);    --c-ink: var(--task-open-ink); }
.task-staffed { --c: var(--task-staffed); --c-ink: var(--task-staffed-ink); }
.task-subbed  { --c: var(--task-subbed);  --c-ink: var(--task-subbed-ink); }
.gantt-key { display: flex; flex-wrap: wrap; gap: 4px 12px; list-style: none; margin: 0 0 0 auto; padding: 0;
             font-size: .8rem; color: var(--text-muted); align-items: center; }
.gantt-key li { display: inline-flex; align-items: center; gap: 5px; }
.gantt-key i { width: 12px; height: 12px; border-radius: 3px; background: var(--c); }
.g-task {
  position: absolute; top: 5px; bottom: 5px;
  left: calc(var(--off) * var(--day) + 1px);
  width: calc(var(--span) * var(--day) - 3px);
  display: flex; border-radius: 6px; overflow: hidden;
  background: var(--c); color: var(--c-ink, #fff); cursor: pointer;
  box-shadow: 0 1px 2px rgb(0 0 0 / .15);
  touch-action: pan-x pan-y; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; z-index: 1;
}
.g-task:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.is-editable .g-task { cursor: grab; }
.g-task.cut-start { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.g-task.cut-end { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.g-task.is-conflict { box-shadow: 0 0 0 2px var(--danger); }
.g-task.is-dragging { cursor: grabbing; opacity: .9; z-index: 4; box-shadow: 0 4px 14px rgb(0 0 0 / .25); transition: none; }
.g-task.is-armed { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 40%, transparent); }
.g-cell {
  flex: 0 0 var(--day); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1px; overflow: hidden;
  border-right: 1px solid rgb(255 255 255 / .18);
}
.g-cell:last-of-type { border-right: 0; }
.g-cell.off {
  background: repeating-linear-gradient(135deg, rgb(255 255 255 / .55) 0 3px, rgb(255 255 255 / .75) 3px 6px);
}
.g-cell i { font-style: normal; font-size: 9px; line-height: 1; font-weight: 650; letter-spacing: -.02em; }
.g-cell.is-double { box-shadow: inset 0 0 0 2px #ffd2c9; background: rgb(179 64 47 / .55); }
.g-pin { position: absolute; top: 1px; left: 2px; pointer-events: none; }
.g-pin svg { width: 11px; height: 11px; display: block; opacity: .85; }
.g-resize {
  position: absolute; top: 0; right: 0; bottom: 0; width: 10px;
  cursor: ew-resize; touch-action: none;
}
.g-resize::after {
  content: ""; position: absolute; top: 25%; bottom: 25%; right: 3px; width: 2px;
  border-radius: 1px; background: rgb(255 255 255 / .7);
}
@media (pointer: coarse) { .g-resize { width: 16px; } }
.g-today {
  position: absolute; top: var(--head-h); bottom: 0; width: 2px; z-index: 2;
  left: calc(var(--label-w) + (var(--off) + .5) * var(--day) - 1px);
  background: var(--accent); opacity: .6; pointer-events: none;
}
.g-links {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 2; overflow: visible;
}
.g-links path { fill: none; stroke: var(--text-muted); stroke-width: 1.5; }
.g-links path.is-bad { stroke: var(--danger); stroke-dasharray: 3 2; }
.g-empty {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  position: sticky; left: 0; width: min(100vw - 48px, 520px);
  padding: 18px 12px; color: var(--text-muted);
}

/* the task sheet (a <dialog>): bottom sheet on phones, centred panel on desktop */
dialog.sheet {
  border: 0; padding: 0; color: var(--text); background: var(--surface);
  width: 100%; max-width: 100%; max-height: 88dvh;
  margin: auto 0 0; border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -6px 30px rgb(0 0 0 / .2);
  padding-bottom: env(safe-area-inset-bottom);
}
dialog.sheet::backdrop { background: rgb(0 0 0 / .35); }
@media (min-width: 700px) {
  dialog.sheet { width: 520px; margin: auto; border-radius: var(--radius); max-height: 86vh; }
}
.tp { padding: 6px 14px 16px; }
.tp-head {
  position: sticky; top: 0; z-index: 1; background: var(--surface);
  display: flex; align-items: center; gap: 8px; padding: 6px 0;
}
.tp-head h2 { font-size: 1.1rem; flex: 1; }
.tp-head form { margin-left: auto; }
.tp-swatch { width: 12px; height: 12px; border-radius: 3px; background: var(--c); flex: none; }
.tp-job { color: var(--text-muted); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-job:hover { text-decoration: underline; }
.tp-name { margin: 0 0 8px; }
.tp-name-input { font-size: 1.2rem; font-weight: 650; width: 100%; }
h2.tp-name { font-size: 1.2rem; margin-bottom: 2px; }
.tp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tp-grid form:first-child { grid-column: 1 / -1; }
@media (min-width: 700px) { .tp-grid { grid-template-columns: 1.4fr 1fr .7fr; } .tp-grid form:first-child { grid-column: auto; } }
.tp-grid label { display: block; font-size: .78rem; font-weight: 600; color: var(--text-muted); margin-bottom: 2px; }
.tp-grid .input { min-height: 40px; padding: 6px 10px; }
.input-sm { min-height: 34px; padding: 4px 8px; font-size: 16px; width: auto; max-width: 100%; }
.tp-toggles { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tp-toggles .check { border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; font-size: .88rem; }
.tp-toggles .check svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 2px; }
.tp-when { margin: 12px 0 6px; font-size: .92rem; }
.tp-warn { display: flex; gap: 6px; align-items: center; margin: 6px 0; }
.tp-warn svg { width: 16px; height: 16px; flex: none; }
.tp-sec { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 10px; }
.tp-sec h3 { font-size: .9rem; display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.tp-sec h3 svg { width: 16px; height: 16px; color: var(--text-muted); }
.tp-links { list-style: none; margin: 0 0 6px; padding: 0; }
.tp-links li { display: flex; align-items: center; gap: 6px; }
.tp-links .icon-btn { width: 32px; height: 32px; }
.tp-days { list-style: none; margin: 0; padding: 0; }
.tp-day { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-top: 1px solid var(--gridline, var(--border)); }
.tp-days .tp-day:first-child { border-top: 0; }
.tp-day.is-weekend .tp-date { color: var(--warning); }
.tp-all { border-top: 0; padding-bottom: 6px; }
.tp-date { flex: 0 0 82px; font-size: .84rem; font-variant-numeric: tabular-nums; color: var(--text-muted); }
.tp-people { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; flex: 1; min-width: 0; }
.person-chip {
  display: inline-flex; align-items: center; gap: 2px;
  background: var(--accent-soft); border-radius: 999px; padding: 2px 4px 2px 10px; font-size: .86rem;
}
.person-chip form { display: contents; }
.person-chip button {
  border: 0; background: none; color: var(--text-muted); font-size: 1rem; line-height: 1;
  width: 24px; height: 24px; border-radius: 50%; cursor: pointer;
}
.person-chip button:hover { background: rgb(0 0 0 / .08); color: var(--text); }
.person-chip.is-double { background: var(--danger-soft); color: var(--danger); }
.person-chip.is-sub { background: var(--info-soft); }
.tp-warn-sub { color: var(--warning); margin: 6px 0 0; }
.tp-subbed { margin: 4px 0 0; }
.tp-subs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tp-sec h3 .sub { font-weight: 400; margin-left: 4px; }
.add-person { border-style: dashed; color: var(--text-muted); }
.tp-delete { margin-top: 14px; display: flex; justify-content: flex-end; }
.g-links .g-head-ok { fill: var(--text-muted); }
.g-links .g-head-bad { fill: var(--danger); }
.schedule-head { flex-wrap: nowrap; align-items: center; }
.schedule-actions { display: flex; gap: 8px; align-items: center; min-width: 0; }
.schedule-actions .filter-select { width: auto; max-width: 44vw; min-width: 0; }
.btn > svg { width: 16px; height: 16px; flex: none; }
.g-months span { overflow: visible; }
.g-months b { position: sticky; left: calc(var(--label-w) + 6px); font-weight: 650; }
@media (max-width: 899px) { .g-hint { display: none; } }
dialog.sheet:focus { outline: none; }
.g-days span { cursor: pointer; border-radius: 6px 6px 0 0; }
.g-days span:hover { background: var(--surface-2); }
.g-days .is-sel { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.g-days .is-sel:hover { background: var(--accent-hover); }
.g-today[hidden] { display: none; }
.g-today { opacity: .75; }
.gantt-date {
  margin-left: auto; min-height: 36px; padding: 4px 8px; font: inherit; font-size: 16px;
  border: 1px solid var(--border); border-radius: var(--radius-s);
  background: var(--surface); color: var(--text); max-width: 46%;
}
.g-row:not(.g-head):not(.g-job):not(.g-more) .g-time { cursor: pointer; }
/* steps from an estimate */
@media (min-width: 700px) { dialog.sheet:has(.fe) { width: 620px; } }
.fe-top { display: flex; flex-direction: column; gap: 8px; }
.fe-when { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fe-when > label:first-child { font-size: .85rem; font-weight: 600; color: var(--text-muted); }
.fe-when .input { width: auto; min-height: 40px; padding: 6px 10px; }
.fe-when .check { border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; font-size: .88rem; }
.fe-when .check svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 2px; }
.fe-rows { list-style: none; margin: 0; padding: 0; }
.fe-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--border); }
.fe-row:first-child { border-top: 0; }
.fe-row > input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); flex: none; margin: 0; }
.fe-row.is-off .fe-main, .fe-row.is-off .fe-days { opacity: .5; }
.fe-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fe-name { font-weight: 600; width: 100%; padding: 2px 6px; margin-left: -6px; }
.fe-main .sub { font-size: .78rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fe-days { display: flex; align-items: center; gap: 4px; font-size: .82rem; color: var(--text-muted); flex: none; }
.fe-days .input { width: 58px; min-height: 36px; padding: 4px 6px; text-align: right; }
.fe-name {
  font: inherit; font-weight: 600; color: var(--text); font-size: 16px;
  border: 1px solid transparent; border-radius: 6px; background: transparent;
}
.fe-name:hover { border-color: var(--border); }
.fe-name:focus { outline: none; border-color: var(--focus); background: var(--surface); }
@media (pointer: coarse) { .fe-name { border-color: var(--border); } }
.fe-days input { -moz-appearance: textfield; }
.fe-days input::-webkit-outer-spin-button, .fe-days input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Subcontractors */
.sub-add { margin-bottom: 14px; display: flex; flex-direction: row; flex-wrap: wrap; gap: 8px; align-items: center; }
.sub-add .input { flex: 1 1 200px; min-width: 0; width: auto; height: auto; }
.sub-add .btn { flex: 0 0 auto; }
.sub-head .btn-row { flex-wrap: nowrap; width: auto; }
.sub-head .btn-row .btn { width: auto; }
.sub-money .end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.sub-money .end .badge { margin-left: 0; }
.sub-add .error { flex-basis: 100%; }
.tile .value.is-owed { color: var(--warning); }

/* Crew panel above the master schedule */
.crew { margin-bottom: 12px; padding: 12px 14px; }
.crew-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 8px; }
.crew-head h2 { font-size: 1rem; margin: 0; }
.crew-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.crew-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-width: 0;
             padding: 4px 10px 4px 8px; border-radius: 999px; font-size: .86rem;
             border: 1px solid var(--border); background: var(--surface); }
.crew-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--text-muted); }
.crew-name { font-weight: 600; white-space: nowrap; }
.crew-on { color: var(--text-muted); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.crew-chip.is-working { background: var(--success-soft); border-color: transparent; }
.crew-chip.is-working .crew-dot { background: var(--task-staffed); }
.crew-chip.is-free .crew-dot { background: none; border: 1.5px solid var(--text-muted); }
.crew-chip.is-double { background: var(--danger-soft); }
.crew-chip.is-double .crew-dot { background: var(--danger); }
.crew-chip.is-double .crew-on { color: var(--danger); }

/* Line item picker: a button + in-page list over the hidden item dropdown */
.item-pick-wrap { position: relative; }
.item-pick-wrap select[data-task] { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.item-pick { width: 100%; min-height: 40px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
             padding: 8px 32px 8px 12px; border: 1px solid var(--border); border-radius: 8px; text-align: left;
             background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23888' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 12px center;
             color: var(--text); font: inherit; cursor: pointer; }
.item-pick > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-pick.is-empty { color: var(--text-muted); }
.item-pick[disabled] { opacity: .6; cursor: not-allowed; }
.item-pick[aria-expanded="true"] { border-color: var(--focus); }
.field-task.has-error .item-pick { border-color: var(--danger); }
.item-list { margin-top: 6px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
             max-height: min(320px, 50vh); overflow-y: auto; box-shadow: 0 6px 18px rgb(0 0 0 / .10); }
.item-opt { display: flex; width: 100%; align-items: baseline; justify-content: space-between; gap: 10px;
            padding: 11px 12px; border: 0; border-top: 1px solid var(--border); background: none;
            font: inherit; color: var(--text); text-align: left; cursor: pointer; }
.item-opt:first-child { border-top: 0; }
.item-opt:hover, .item-opt:focus-visible { background: var(--surface-2); outline: none; }
.item-opt.is-chosen { background: var(--accent-soft); }
.item-opt-name { font-weight: 600; }
.item-opt-meta { color: var(--text-muted); font-size: .82rem; white-space: nowrap; }

/* Grey out the page while an item list is open */
.pick-backdrop { position: fixed; inset: 0; z-index: 40; background: rgb(20 20 20 / .38);
                 animation: pick-fade .15s ease-out; -webkit-tap-highlight-color: transparent; }
@keyframes pick-fade { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pick-backdrop { animation: none; } }
.line-grid .is-raised { position: relative; z-index: 41; }
.line-grid .is-raised label { color: #fff; }
.line-grid .is-raised .item-list { box-shadow: 0 10px 28px rgb(0 0 0 / .28); }
@media (min-width: 760px) {
  /* wider screens: the list floats under the item box instead of
     stretching the row (which knocks the fields out of line) */
  .field-task { position: relative; }
  .field-task .item-list { position: absolute; left: 0; top: 100%; z-index: 2; width: max(100%, 340px); }
}

/* Editor: while a line (or payment / section) is expanded, everything else
   is dimmed a little. The dim layer lets taps through, so tapping another
   line still opens it (and closes this one). */
body:has(.item.is-open:not(.is-removed))::after,
body:has(.worker.is-open)::after {
  content: ""; position: fixed; inset: 0; z-index: 38; pointer-events: none;
  background: rgb(20 20 20 / .14); animation: pick-fade .15s ease-out;
}
.item.is-open, .worker.is-open { position: relative; z-index: 39;
                box-shadow: inset 3px 0 0 var(--accent), 0 6px 22px rgb(0 0 0 / .14); }
/* with the item menu open, the stronger grey takes over: the line sits
   under it and only the category / item fields stay bright */
body.is-picking .item.is-open { z-index: auto; }
body.is-picking::after { display: none; }
@media (prefers-reduced-motion: reduce) { body::after { animation: none !important; } }

/* Options panel: plain checkboxes, no tinted pill */
.options-card .check, .options-card .check:hover,
.options-card .check:has(input:checked) { background: none; padding: 4px 0; }

/* Schedule: rows slide shut / open as the 7-day window moves */
.g-row[data-group], .g-more {
  /* clip-path, not overflow:hidden, trims a row while it slides: overflow
     would make the row its own scroller, unsticking the name column so the
     bars behind it flash through at the left */
  clip-path: inset(0);
  max-height: calc(var(--row-h) + 16px);
  transition: max-height .2s ease, min-height .2s ease, opacity .18s ease, border-top-width .2s ease, visibility 0s;
}
.g-row.is-collapsed {
  max-height: 0; min-height: 0; opacity: 0; border-top-width: 0; visibility: hidden;
  transition: max-height .2s ease, min-height .2s ease, opacity .15s ease, border-top-width .2s ease, visibility 0s .2s;
}
.g-links { transition: opacity .12s ease; }
.g-moving .g-links { opacity: 0; }
.g-instant .g-row, .g-instant .g-links { transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  .g-row[data-group], .g-more, .g-row.is-collapsed, .g-links { transition: none !important; }
}

/* "+" on each job's heading in the master schedule */
.g-job-line .g-add { margin-left: auto; }
.g-job-line .g-add + .g-toggle { margin-left: 0; }
.g-add:hover { color: var(--accent); }
/* Job headings have nothing in their timeline, so the heading runs wider
   over it: room for the name plus its + and show-all buttons. The negative
   margin keeps the row the same total width. */
.gantt { --job-w: min(340px, calc(100vw - 72px)); }
.g-job .g-label { width: max(var(--label-w), var(--job-w)); margin-right: calc(var(--label-w) - max(var(--label-w), var(--job-w))); }
.g-job-line { width: 100%; }
.g-job .g-label { border-right: 0; }
/* Job title block: its own shade, running a little past the + and arrow */
.g-job .g-label {
  background: color-mix(in srgb, var(--accent) 20%, var(--surface));
  padding-right: 14px;
  border-radius: 0 10px 10px 0;
}
.g-job .g-label a { color: var(--text); }

/* Headings and their tasks: a heading row (category + title) and, under
   it, indented task rows (item, price, qty) that use the heading's category */
.item.item-heading { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.item.item-heading .item-title { font-weight: 700; }
.item.item-heading.is-open { background: var(--surface); }
.item.item-task { margin-left: 22px; box-shadow: inset 2px 0 0 color-mix(in srgb, var(--accent) 40%, transparent); }
.item.item-task.is-open { box-shadow: inset 3px 0 0 var(--accent), 0 6px 22px rgb(0 0 0 / .14); }
.item.item-task .item-title { font-weight: 500; }
.item.item-task .span-cat { display: none; }
@media (min-width: 760px) {
  .item.item-task .item-body .line-grid .span-task { grid-column: 1 / 3; }
  .item.item-heading .item-body .line-grid .span-cat { grid-column: 1; }
  .item.item-heading .item-body .line-grid .span-label { grid-column: 2 / -1; }
}
.item.is-carried { display: none; }     /* riding along while their heading is dragged */
.add-joined { margin-right: auto; }

/* Folded headings hide their tasks */
.item.item-task.is-folded { display: none; }
.items-card .card-head [data-row-count] { white-space: nowrap; }

/* A heading is one row: its category (picked in place), task count and
   subtotal, add / remove, and an arrow that shows or hides its tasks */
.item-heading .head-row { display: flex; align-items: center; gap: 6px; padding: 6px 4px 6px 0; }
.item-heading .head-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item-heading .head-cat { min-height: 36px; padding: 4px 30px 4px 10px; font-weight: 700; max-width: 100%;
                          background-color: transparent; border-color: transparent; }
.item-heading .head-cat:hover, .item-heading .head-cat:focus { border-color: var(--border); background-color: var(--surface); }
.item-heading .head-main .item-meta { padding-left: 11px; }
.item-heading .item-total { white-space: nowrap; }
.head-btn { width: 34px; height: 34px; flex: none; color: var(--text-muted); }
.head-btn svg { width: 18px; height: 18px; }
.head-fold .chev { width: 20px; height: 20px; transition: transform .15s; }
.item-heading.is-unfolded .head-fold .chev { transform: rotate(180deg); }
.item-heading.is-removed .head-add, .item-heading.is-removed .head-remove,
.item-heading.is-removed .head-fold, .item-heading.is-removed [data-head-total] { display: none; }
.item-heading.is-removed .head-cat { text-decoration: line-through; pointer-events: none; }
.item-heading.has-errors .head-cat { border-color: var(--danger); }
.item-heading .head-main { align-items: flex-start; }
.item-heading .head-cat { width: auto; min-width: 9rem; }

.item-heading .head-sub { font-weight: 600; color: var(--text); }
.item-heading .head-sub [data-prints-as] { font-weight: 400; color: var(--text-muted); }

/* Categories page: categories as section rows, tasks edited in place */
.catalog .cat + .cat { border-top: 1px solid var(--border); }
.catalog .cat-head { border: 0; }
.catalog .cat-name { font-weight: 700; font-size: 1rem; padding: 4px 10px; min-height: 36px; width: 100%; max-width: 26rem; }
.catalog .cat.is-unfolded .head-fold .chev { transform: rotate(180deg); }
.catalog .cat.is-archived .cat-head { opacity: .7; }
.catalog .cat-tasks .item-task { margin-left: 22px; }
.catalog .cat-tasks:has(.item-task) .cat-empty { display: none; }
.catalog .cat-empty { margin: 6px 22px 10px; padding: 10px; }
.catalog .item-task.is-archived .item-title { color: var(--text-muted); }
.catalog .ct-grid { display: grid; gap: 8px 10px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.catalog .ct-name, .catalog .ct-desc, .catalog .ct-cat { grid-column: 1 / -1; }
@media (min-width: 760px) {
  .catalog .ct-grid { grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) 130px 150px; align-items: end; }
  .catalog .ct-name { grid-column: 1; } .catalog .ct-cat { grid-column: 2; }
  .catalog .ct-units { grid-column: 3; } .catalog .ct-price { grid-column: 4; }
  .catalog .ct-desc { grid-column: 1 / -1; }
}
.catalog .cat-new { display: flex; gap: 8px; align-items: center; padding: 10px 0 2px; flex-wrap: wrap; }
.catalog .cat-new .input { flex: 1 1 200px; min-width: 0; }
.catalog .cat-new .btn-add { flex: 0 0 auto; width: auto; }
.catalog .cat-new .error { flex-basis: 100%; }
/* category names read as plain text until hovered / tapped */
.catalog .cat-name.inline-input { border: 1px solid transparent; background: transparent; box-shadow: none; }
.catalog .cat-name.inline-input:hover { border-color: var(--border); background: var(--surface); }
.catalog .cat-name.inline-input:focus { border-color: var(--focus); background: var(--surface); outline: none; }
.catalog .cat-head .head-row { padding-left: 4px; }
.catalog .cat-sub { font-weight: 500; color: var(--text-muted); font-size: .8rem; }
.catalog .item-task .item-toggle { padding-left: 14px; }

/* Profit & loss */
.pl-filters { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; }
.pl-periods { display: flex; flex-wrap: wrap; gap: 6px; }
.pl-periods .chip { cursor: pointer; }
.pl-periods .chip.is-on { background: var(--text); border-color: var(--text); color: var(--bg); }
.pl-custom { cursor: default; }
.pl-row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.pl-compare { min-height: 36px; }
.tile .value.is-loss { color: var(--danger); }
.pl { padding: 6px 0; overflow: hidden; }
.pl-line { display: grid; grid-template-columns: minmax(0, 1fr) 110px 96px; align-items: baseline; gap: 10px;
           padding: 7px 14px; margin: 0; font-size: .92rem; }
.pl:has(.pl-prev) .pl-line { grid-template-columns: minmax(0, 1fr) 100px 100px 100px 96px; }
.pl-amt, .pl-pct { text-align: right; white-space: nowrap; }
.pl-pct { color: var(--text-muted); font-size: .82rem; }
.pl-cols { color: var(--text-muted); font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.pl-head { font-size: 1rem; font-weight: 700; padding-top: 14px; border-top: 1px solid var(--border); }
.pl-section:first-of-type .pl-head { border-top: 0; }
.pl-row-btn { width: 100%; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.pl-row-btn .pl-name { padding-left: calc(var(--depth, 0) * 16px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-row-btn.is-heading { font-weight: 600; }
.pl-row-btn:hover { background: var(--surface-2); }
.pl-item.is-open > .pl-row-btn { background: var(--accent-soft); }
.pl-total { font-weight: 700; border-top: 1px solid var(--border); }
.pl-sub-total { font-weight: 700; background: var(--surface-2); }
.pl-net { font-weight: 800; font-size: 1.02rem; border-top: 2px solid var(--text); margin-top: 6px; }
.pl-net.is-loss .pl-amt { color: var(--danger); }
.pl-chg.is-up { color: var(--success); } .pl-chg.is-down { color: var(--danger); }
.pl-none { display: block; }
.pl-detail { background: var(--surface-2); padding: 4px 14px 8px; }
.pl-tx { list-style: none; margin: 0; padding: 0; }
.pl-tx li { display: grid; grid-template-columns: 72px minmax(0, 1fr) 100px; gap: 10px; padding: 5px 0; font-size: .85rem;
            border-top: 1px solid var(--border); }
.pl-tx li:first-child { border-top: 0; }
.pl-tx-what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-tx-amt { text-align: right; }
.pl-tx-more { margin: 6px 0; }
@media (max-width: 699px) {
  .pl-line { grid-template-columns: minmax(0, 1fr) 96px; }
  .pl-pct { display: none; }
  .pl:has(.pl-prev) .pl-line { grid-template-columns: minmax(0, 1fr) 84px 84px; }
  .pl .pl-chg { display: none; }
  .pl-tx li { grid-template-columns: 62px minmax(0, 1fr) 84px; }
}

/* Statement import */
.acct-tabs { margin-top: 0; }
.chip.is-static { cursor: default; }
.wait-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; }
.wait-main { display: flex; flex-direction: column; min-width: 0; }
.wait-main .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wait-amt, .rv-amt { white-space: nowrap; text-align: right; font-weight: 600; }
.wait-amt.is-in, .rv-amt.is-in { color: var(--success); }
.wait-form { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.wait-form select { flex: 1 1 180px; min-width: 0; }
.review { padding: 0; overflow: hidden; }
.review-list { list-style: none; margin: 0; padding: 0; }
.rv { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; padding: 10px 14px;
      border-top: 1px solid var(--border); }
.rv:first-child { border-top: 0; }
.rv-main { display: flex; flex-direction: column; min-width: 0; }
.rv-main .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-take input { width: 18px; height: 18px; accent-color: var(--accent); }
.rv-pick { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.rv-pick select { flex: 1 1 200px; min-width: 0; }
.rv-pick .is-suggested { border-color: var(--accent); background-color: var(--accent-soft); }
.rv-skip { opacity: .55; }
.rv-tag { font-weight: 600; color: var(--text); }
.rv-match .rv-tag { color: var(--info); }
@media (min-width: 900px) {
  .rv { grid-template-columns: 28px minmax(0, 1fr) 380px 110px; }
  .rv-pick { grid-column: 3; grid-row: 1; flex-wrap: nowrap; }
  .rv-amt { grid-column: 4; grid-row: 1; }
  .wait-row { grid-template-columns: minmax(0, 1fr) 380px 110px; }
  .wait-form { grid-column: 2; grid-row: 1; flex-wrap: nowrap; }
  .wait-amt { grid-column: 3; grid-row: 1; }
}

/* Accounts and registers */
.bank-tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.bank-tile { text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 2px; }
.bank-tile:hover { border-color: var(--accent); }
.chart { padding: 4px 0; }
.chart-head { font-size: 1rem; margin: 0; padding: 14px 14px 6px; border-top: 1px solid var(--border); }
.chart-head:first-child { border-top: 0; }
.chart-list { list-style: none; margin: 0; padding: 0; }
.chart-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 120px; gap: 10px; align-items: baseline;
             padding: 7px 14px; color: inherit; text-decoration: none; font-size: .92rem; }
.chart-row:hover { background: var(--surface-2); }
.chart-row .chart-name { padding-left: calc(var(--depth, 0) * 16px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-row.is-heading { font-weight: 600; }
.chart-bal { text-align: right; }
.reg { padding: 0; overflow: hidden; }
.reg-list { list-style: none; margin: 0; padding: 0; }
.reg-line { display: grid; grid-template-columns: 70px minmax(0, 1fr) 110px 110px 120px; gap: 10px; align-items: center;
            padding: 8px 14px; }
.reg-cols { color: var(--text-muted); font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
            border-bottom: 1px solid var(--border); }
.reg-sum { width: 100%; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.reg-item + .reg-item { border-top: 1px solid var(--border); }
.reg-item.is-open > .reg-sum { background: var(--accent-soft); }
.reg-sum:hover { background: var(--surface-2); }
.reg-what { display: flex; flex-direction: column; min-width: 0; }
.reg-what .title, .reg-what .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reg-dr, .reg-cr, .reg-bal, .reg-chg { text-align: right; white-space: nowrap; }
.reg-bal { font-weight: 600; }
.reg-chg { display: none; }
.reg-chg.is-up { color: var(--success); } .reg-chg.is-down { color: var(--danger); }
.reg-flag { color: var(--warning); font-weight: 600; }
.reg-date { color: var(--text-muted); font-size: .85rem; }
.reg-body { padding: 4px 14px 14px; background: var(--surface); }
.reg-form { display: grid; gap: 8px 10px; grid-template-columns: 150px minmax(0, 1fr) 140px; align-items: end; }
.reg-form .field { display: flex; flex-direction: column; gap: 3px; }
.reg-form .label { font-size: .74rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em; }
.reg-cat { grid-column: 1 / 3; } .reg-job { grid-column: 3; }
.reg-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; }
.reg-search { flex: 1 1 220px; min-width: 0; }
@media (max-width: 699px) {
  .reg-line { grid-template-columns: 58px minmax(0, 1fr) auto; }
  .reg-cols { display: none; }
  .reg-dr, .reg-cr, .reg-bal { display: none; }
  .reg-chg { display: block; }
  .reg-form { grid-template-columns: 1fr 1fr; }
  .reg-desc, .reg-cat, .reg-job { grid-column: 1 / -1; }
  .chart-row { grid-template-columns: minmax(0, 1fr) 110px; }
  .chart-code { display: none; }
}
.reg-cols span:nth-child(n+3) { text-align: right; }

/* Reconcile */
.rec-start { align-items: end; }
.rec-start .field { display: flex; flex-direction: column; gap: 3px; }
.rec-bar { position: sticky; top: calc(var(--topbar-h, 0px) + 6px); z-index: 6; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
           gap: 10px; padding: 12px 14px; margin-top: 12px; border-radius: var(--radius); background: var(--surface);
           box-shadow: var(--shadow); border: 1px solid var(--border); }
.rec-bar .num { font-weight: 700; font-size: 1.05rem; }
.rec-bar .muted { font-size: .78rem; }
.rec-diff .num { color: var(--danger); }
.rec-bar.is-even { border-color: var(--success); }
.rec-bar.is-even .rec-diff .num { color: var(--success); }
.rec-tools { justify-content: space-between; align-items: center; flex-wrap: wrap; }
.rec-card { padding: 0; overflow: hidden; }
.rec-list { list-style: none; margin: 0; padding: 0; }
.rec-row { display: grid; grid-template-columns: 44px 70px minmax(0, 1fr) 120px; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; }
.rec-row + .rec-row { border-top: 1px solid var(--border); }
.rec-row.is-ticked { background: color-mix(in srgb, var(--success) 7%, var(--surface)); }
.rec-tick { width: 40px; height: 40px; display: grid; place-items: center; border: 0; background: none; cursor: pointer; }
.rec-box { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--border); display: grid; place-items: center;
           font-weight: 800; font-size: .85rem; color: #fff; background: var(--surface); }
.rec-row.is-ticked .rec-box, .rec-box.is-done { background: var(--success); border-color: var(--success); }
.rec-date { color: var(--text-muted); font-size: .85rem; }
.rec-what { display: flex; flex-direction: column; min-width: 0; }
.rec-what .title, .rec-what .sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-amt { text-align: right; white-space: nowrap; font-weight: 600; }
.rec-amt.is-up { color: var(--success); } .rec-amt.is-down { color: var(--danger); }
.rec-accounts .end { display: flex; align-items: center; }
@media (max-width: 699px) {
  .rec-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); top: 64px; }
  .rec-row { grid-template-columns: 40px minmax(0, 1fr) 96px; }
  .rec-date { display: none; }
}
.reg-lock { color: var(--success); font-weight: 600; }
.reg-form input[readonly] { background: var(--surface-2); color: var(--text-muted); }
.rec-tools form.btn-row { flex-wrap: wrap; width: auto; gap: 6px; }
.rec-tools form.btn-row .btn { width: auto; white-space: nowrap; flex: 0 0 auto; }

/* Time sheet: schedule defaults, approving, hold */
.held-badge { display: none; }
.worker:has(.ts-hold input:checked) .held-badge { display: inline-flex; }
.ts-from { margin: 4px 0 6px; }
.ts-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.ts-hold { font-size: .88rem; }
.tline-state { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; width: auto; }

/* Approved / clocked-in lines: their status (and Change) gets its own row */
.tline.tline-locked { grid-template-columns: minmax(0, 1fr) 96px; grid-template-areas: "job job" "cat hrs" "st st"; }
.tline-locked .tline-state { grid-area: st; width: auto; height: auto; justify-content: flex-start; }
@media (min-width: 700px) {
  .tline.tline-locked { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) 84px auto; grid-template-areas: "job cat hrs st"; }
  .tline-locked .tline-state { justify-content: flex-end; }
}

/* Sidebar: + next to Documents opens New estimate / New invoice */
.sidebar .nav-row { display: flex; align-items: center; gap: 2px; }
.sidebar .nav-row a.nav { flex: 1; min-width: 0; }
.nav-plus {
  flex: none; width: 34px; height: 34px; display: grid; place-items: center;
  border: 0; border-radius: 8px; background: none; color: var(--text-muted); cursor: pointer;
}
.nav-plus:hover, .nav-plus[aria-expanded="true"] { background: var(--surface-2); color: var(--accent); }
.nav-plus svg { width: 18px; height: 18px; transition: transform .18s ease; }
.nav-plus[aria-expanded="true"] svg { transform: rotate(45deg); }
.sidebar .nav-sub { display: flex; flex-direction: column; gap: 2px; padding-left: 28px; }
.sidebar .nav-sub[hidden] { display: none; }
.sidebar .nav-sub:not([hidden]) { animation: fade-in .15s ease-out; }
.sidebar .nav-sub a.nav { font-size: .9rem; }

/* New estimate / invoice: which job it's for */
.start-pane { display: none; }
.start-card:has(.field-job option[value="new"]:checked) :is(.pane-cust, .pane-newjob),
.start-card:has(.field-job option[value="new"]:checked):has(.field-customer option[value="new"]:checked) .pane-newcust {
  display: block; animation: fade-in .15s ease-out; }
.start-card .start-pane { margin-top: 14px; }
.pane-h { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); margin: 0 0 8px; }

/* Address suggestions under an address box */
.addr-wrap { position: relative; }
.addr-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 45;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgb(0 0 0 / .14); overflow: hidden;
}
.inline-field .addr-list { top: auto; margin-top: 4px; }
.addr-list[hidden] { display: none; }
.addr-list ul { list-style: none; margin: 0; padding: 4px 0; }
.addr-list li { display: flex; flex-direction: column; gap: 1px; padding: 9px 12px; cursor: pointer; }
.addr-list li strong { font-weight: 600; font-size: .95rem; }
.addr-list li span { font-size: .8rem; color: var(--text-muted); }
.addr-list li.is-active, .addr-list li:hover { background: var(--accent-soft); }
.addr-credit { padding: 4px 12px 6px; font-size: .7rem; color: var(--text-muted); text-align: right;
  border-top: 1px solid var(--border); }

/* New job: a new customer's details show when "New customer" is ticked */
.new-job .new-customer { display: none; border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px 4px; margin: 0; min-width: 0; }
.new-job:has(select[data-chips] option[value="new"]:checked) .new-customer { display: block; animation: fade-in .15s ease-out; }
.new-job .new-customer .span-2 { grid-column: 1 / -1; }
.new-job .new-customer legend { padding: 0 6px; margin-left: -6px; }

/* Chip multi-select: picked items as chips, one dropdown to add more */
.chips-src { display: none !important; }   /* still posted with the form */
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chips:empty { display: none; }
.chip { display: inline-flex; align-items: center; gap: 2px; padding: 4px 4px 4px 10px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: .88rem; font-weight: 500; line-height: 1.2; }
.chip.chip-new { background: var(--surface-2); color: var(--text); border: 1px dashed var(--border); }
.chip button { border: 0; background: none; color: inherit; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; font-size: 1.05rem; line-height: 1; }
.chip button:hover { background: rgb(0 0 0 / .07); }
.field .chips { margin-bottom: 2px; }

/* Templates tab: the New button with a line of help beside it */
.list-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: -4px 0 12px; }

/* Undo bar: offered after each change, above the tab bar on phones */
.undo-bar {
  position: fixed; z-index: 60; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 4px; max-width: calc(100vw - 24px);
  padding: 6px 6px 6px 16px; border-radius: 12px;
  background: #14213D; color: #F7F6F2; box-shadow: 0 8px 28px rgb(0 0 0 / .25);
  font-size: .92rem; animation: fade-in .18s ease-out;
}
.undo-bar[hidden] { display: none; }
.undo-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.undo-btn { border: 0; background: none; color: #ff9a5c; font: inherit; font-weight: 700; padding: 8px 10px;
  border-radius: 8px; cursor: pointer; flex: none; }
.undo-btn:hover { background: rgb(255 255 255 / .08); }
.undo-btn[hidden] { display: none; }
.undo-close { border: 0; background: none; color: rgb(255 255 255 / .6); font: inherit; font-size: 1.2rem;
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer; flex: none; }
.undo-close:hover { background: rgb(255 255 255 / .08); color: #fff; }
@media (min-width: 900px) { .undo-bar { bottom: 24px; left: calc(50% + var(--sidebar-w) / 2); } }

/* Change log */
.hist details > summary { list-style: none; cursor: pointer; }
.hist details > summary::-webkit-details-marker { display: none; }
.hist.is-undone .title { color: var(--text-muted); }
.hist-changes { margin: 0; padding: 4px 16px 12px 32px; font-size: .9rem; display: grid; gap: 4px; }
.hist-changes .sub { display: block; color: var(--text-muted); font-size: .85rem; overflow-wrap: anywhere; }
.pager { justify-content: center; margin-top: 12px; }
/* the bar already says what was done: plain "Saved" notes step aside (warnings and errors stay) */
body:has(.undo-bar:not([hidden])) .toast:not(.error):not(.warning) { display: none; }
@media (max-width: 899px) { body:has(.undo-bar:not([hidden])) .toasts { bottom: calc(var(--tabbar-h) + 76px); } }

/* Archive or delete card */
.remove-card .remove-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.remove-card .remove-row + .remove-row { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.remove-card .remove-row p { margin: 0; flex: 1 1 260px; font-size: .9rem; }
.archived-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 14px; border-radius: var(--radius-s);
  background: var(--warning-soft); color: var(--warning); font-weight: 500; }
.reg-delete { display: flex; justify-content: flex-end; margin-top: 8px; }
@media (max-width: 599px) {
  .remove-card .remove-row form { width: 100%; }
  .remove-card .remove-row .btn { width: 100%; min-height: 44px; }
}

/* Job page: delete a document from its row */
.list .doc-del { flex: none; margin: -6px -6px -6px 2px; }
.list .doc-del .icon-btn { color: var(--text-muted); }
.list .doc-del .icon-btn:hover { color: var(--danger); background: var(--danger-soft); }
.list .doc-del svg { width: 18px; height: 18px; }
.list .doc-del-gap { flex: none; width: 38px; }

/* While a toast or the undo bar is showing, the page gets that much more
   room at the bottom so the content under it can be scrolled clear (set by ui.js). */
.main::after { content: ""; display: block; height: var(--notice-space, 0px); }

/* Home cards: on phones each shows just its header until tapped, one open
   at a time (ui.js); on wider screens they are always open. */
.card-body { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card-fold { display: none; }
@media (max-width: 899px) {
  [data-fold-card] > .card-head { position: relative; cursor: pointer; -webkit-tap-highlight-color: transparent; user-select: none; }
  /* the chevron button covers the whole header, so a tap anywhere on it is a button press */
  [data-fold-card] .card-fold::after { content: ""; position: absolute; inset: -14px -18px; }
  [data-fold-card] > .card-head > h2 { margin-right: auto; }
  [data-fold-card] .card-fold { display: inline-flex; margin: -6px -8px -6px 0; }
  [data-fold-card] .card-fold .chev { width: 20px; height: 20px; transition: transform .15s; }
  [data-fold-card].is-open .card-fold .chev { transform: rotate(180deg); }
  [data-fold-card]:not(.is-open) > .card-body { display: none; }
  [data-fold-card]:not(.is-open) { gap: 0; padding-top: 14px; padding-bottom: 14px; }
}

/* "+ Add a task" at the end of an open section (the section header has no
   add button) */
.add-task-row { background: var(--surface); padding: 6px 10px 8px 34px; border-top: 1px dashed var(--border); }
.add-task-row .btn-add { width: 100%; justify-content: flex-start; min-height: 36px; }
@media (max-width: 699px) { .add-task-row { padding-left: 30px; } }

/* To-dos (home screen and job pages) */
.todo-add { display: flex; flex-direction: column; gap: 8px; }
.todo-add > input[type=text] { width: 100%; }
.todo-add-more { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.todo-due-field { flex: 0 1 200px; min-width: 0; display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: .9rem; }
.todo-due-field input { flex: 1; min-width: 0; }
.todo-add-more select { flex: 1 1 160px; min-width: 0; }
.todo-add-more .btn { margin-left: auto; }
.todo-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.todo { display: flex; align-items: flex-start; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); }
.todo:first-child { border-top: 0; }
.todo form { display: contents; }
.todo-check {
  flex: none; width: 26px; height: 26px; margin-top: -1px; border-radius: 50%;
  border: 2px solid var(--text-muted); background: none; cursor: pointer; padding: 0;
  display: grid; place-items: center;
}
.todo-check:hover { border-color: var(--accent); }
.todo-check.is-checked { background: var(--accent); border-color: var(--accent); }
.todo-check.is-checked::after { content: ""; width: 10px; height: 6px; border: solid var(--on-accent); border-width: 0 0 2px 2px; transform: translateY(-1px) rotate(-45deg); }
.todo-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; overflow-wrap: anywhere; }
.todo-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: .84rem; color: var(--text-muted); }
.todo-meta a { color: inherit; }
.todo.is-late .todo-due { color: var(--danger); font-weight: 600; }
.todo.is-today .todo-due { color: var(--brand-ink); font-weight: 600; }
.todo.is-done .todo-text { color: var(--text-muted); text-decoration: line-through; }
.todo-del { flex: none; width: 30px; height: 30px; margin-top: -3px; color: var(--text-muted); }
.todo-del svg { width: 16px; height: 16px; }
.todo-done summary { cursor: pointer; color: var(--text-muted); font-size: .9rem; padding-top: 4px; }

/* Payments: what's owed / paid / left on a job */
.pay-sum { display: flex; flex-wrap: wrap; gap: 6px 22px; }
.pay-sum > span { display: flex; flex-direction: column; }
.pay-sum .label { font-size: .8rem; color: var(--text-muted); }
.pay-sum .num { font-weight: 650; font-size: 1.05rem; }
.pay-sum .owed { color: var(--brand-ink); }
.pay-posting { margin: 0; }

/* the to-do quick-add uses the app's field look */
.todo-add input[type=text], .todo-add input[type=date], .todo-add select {
  min-height: 42px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-s);
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px;
}
.todo-add select { appearance: none; padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
                    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat; }
.todo-add select:has(option[value=""]:checked) { color: var(--text-muted); }
.todo-add input:focus, .todo-add select:focus {
  outline: none; border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent);
}
.todo-due-field { display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: .9rem; flex: 0 1 220px; min-width: 0; }
.todo-due-field input { flex: 1; min-width: 0; }
.todo-add-more .btn { min-height: 42px; }

/* Pop-up messages: an × to dismiss (they still fade on their own) */
.toast { display: flex; align-items: flex-start; gap: 10px; padding-right: 6px; }
.toast-text { flex: 1; min-width: 0; padding-top: 1px; }
.toast-close {
  flex: none; width: 28px; height: 28px; margin: -4px 0 -4px 0; border: 0; border-radius: 6px;
  background: none; color: inherit; opacity: .7; font: inherit; font-size: 1.25rem; line-height: 1; cursor: pointer;
}
.toast-close:hover { opacity: 1; background: rgb(127 127 127 / .18); }

/* Header: the company's name with the traqido logo */
.brand-side { flex-direction: column; align-items: flex-start; gap: 6px; }
.brand-side .brand-company { font-size: .86rem; font-weight: 600; color: var(--text-muted); line-height: 1.25; padding-left: 2px; }
.brand-top { min-width: 0; gap: 10px; }
.brand-top .logo-mark { display: block; height: 28px; width: auto; flex: none; }
.brand-top .brand-company { font-weight: 700; font-size: 1.05rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* Crew panel: tap someone to put them on a task running that day */
.crew-list > li { display: contents; }
.crew-pick { position: relative; max-width: 100%; }
.crew-pick > summary { list-style: none; cursor: pointer; }
.crew-pick > summary::-webkit-details-marker { display: none; }
.crew-pick[open] > summary { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.crew-menu {
  position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; width: min(340px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-s);
  box-shadow: 0 10px 30px rgb(0 0 0 / .16); padding: 10px 12px;
}
.crew-menu-head { margin: 0 0 6px; font-weight: 650; font-size: .9rem; }
.crew-menu ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.crew-task { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 0; border-top: 1px solid var(--border); font-size: .88rem; }
.crew-task:first-child { border-top: 0; }
.crew-task-name { min-width: 0; overflow-wrap: anywhere; }
.crew-task-btns { display: flex; gap: 6px; flex: none; }
.crew-task.is-on { color: var(--text-muted); }

/* Expense import */
.steps { display: flex; gap: 6px; list-style: none; margin: 0 0 14px; padding: 0; counter-reset: step; flex-wrap: wrap; }
.steps li { counter-increment: step; color: var(--text-muted); font-size: .9rem; }
.steps li::before { content: counter(step) ". "; }
.steps li + li::before { content: " → " counter(step) ". "; }
.steps li[aria-current] { color: var(--text); font-weight: 650; }
.imp-cols { display: grid; gap: 4px 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.imp-sum { margin: 0; }
.imp-ai { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.imp-ai .help { flex: 1 1 260px; }
.imp-rows { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; padding-bottom: 80px; }
.imp-row { padding: 12px 14px; gap: 10px; }
.imp-row.is-dupe { opacity: .7; }
.imp-row.needs { border-left: 3px solid var(--brand); }
.imp-take { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.imp-take input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--accent); }
.imp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.imp-what { font-weight: 600; overflow-wrap: anywhere; }
.imp-sub { color: var(--text-muted); font-size: .85rem; overflow-wrap: anywhere; }
.imp-amt { font-weight: 650; white-space: nowrap; }
.imp-picks { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.imp-picks label { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.imp-lab { font-size: .8rem; color: var(--text-muted); display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.imp-raw { font-style: italic; }
.imp-picks select { min-height: 40px; padding: 6px 30px 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-s);
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px; width: 100%; min-width: 0; }
.imp-how { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: 1px 6px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-muted); }
.imp-how.ai { background: var(--brand-soft); color: var(--brand-ink); }
.imp-how.past { background: var(--accent-soft); color: var(--accent); }
.imp-bar { position: sticky; bottom: calc(var(--tabbar-h) + 8px); display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.imp-bar .muted { margin-right: auto; font-size: .88rem; }
@media (min-width: 900px) { .imp-bar { bottom: 16px; } }

/* Desktop sidebar: scrolls when the screen is shorter than the menu (and
   tightens up on short screens so it usually fits without scrolling) */
@media (min-width: 900px) {
  .sidebar { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
}
@media (min-width: 900px) and (max-height: 860px) {
  .sidebar { padding-top: 14px; padding-bottom: 12px; }
  .sidebar .brand { padding-bottom: 10px; }
  .sidebar a.nav { padding-top: 6px; padding-bottom: 6px; }
  .sidebar .nav-label { margin-top: 8px; }
}
/* a row's new job name shows only when "+ New job…" is picked */
.imp-newjob { display: none; min-height: 40px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-s);
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px; width: 100%; }
.imp-picks label:has(select option[value="new"]:checked) .imp-newjob { display: block; }
.imp-status { display: flex; align-items: center; gap: 6px; margin-right: auto; min-width: 0; }
.imp-status select { min-height: 36px; padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius-s); background: var(--surface); font: inherit; font-size: 15px; }
/* rows the import couldn't read: kept for fixing by hand */
.imp-failed-h { font-size: 1.05rem; margin: 18px 0 2px; }
.imp-row.is-failed { border-left: 3px solid var(--danger); }
.imp-fix { min-height: 40px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-s);
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px; width: 100%; }
.imp-discard { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 4px 0 24px; }
.btn-pending { gap: 6px; }
.btn-pending .badge { font-size: .72rem; padding: 1px 7px; }

/* Expenses: a checkbox on every row; the action bar stays at the top of
   the window (below the phone's top bar) while the list scrolls */
li.expense-row { display: flex; align-items: center; }
li.expense-row > .row { flex: 1; min-width: 0; }
.row-pick { display: block; flex: none; width: 20px; height: 20px; margin: 0 0 0 12px; accent-color: var(--accent); cursor: pointer; }
@media (min-width: 900px) { .expense-rows .row-pick { width: 17px; height: 17px; margin-left: 10px; } }
.expense-row:has(.row-pick:checked) { background: var(--accent-soft); }
.bulk-bar {
  position: sticky; top: calc(var(--topbar-h, 0px) + 8px); z-index: 9; margin: 0 0 10px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 4px 16px rgb(0 0 0 / .08); padding: 8px 10px;
}
.bulk-count { margin-right: auto; font-weight: 600; font-size: .9rem; min-width: 0; }
.bulk-bar.is-empty .bulk-count { font-weight: 500; color: var(--text-muted); }
/* combine preview */
.combine-list { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.combine-item { flex-direction: row; align-items: flex-start; gap: 12px; padding: 12px 14px; cursor: pointer; }
.combine-item input { width: 20px; height: 20px; flex: none; margin-top: 2px; accent-color: var(--accent); }
.combine-item.is-keeper { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.combine-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.combine-main .title { font-weight: 600; overflow-wrap: anywhere; }
.combine-main .sub { color: var(--text-muted); font-size: .85rem; overflow-wrap: anywhere; }
.combine-end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.combine-end .num { font-weight: 650; }
@media (max-width: 699px) { .bulk-bar { flex-wrap: nowrap; gap: 6px; padding: 6px 8px; } .bulk-bar .btn { padding: 0 10px; } .bulk-count { font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } }

/* Possible duplicates */
.dupe-groups { display: flex; flex-direction: column; gap: 12px; }
.dupe-group.is-likely { border-left: 3px solid var(--brand); }
.dupe-group h2 { font-size: 1rem; margin: 0; }
.dupe-why { margin: 0; color: var(--text-muted); font-size: .86rem; }
.dupe-items { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-s); }
.dupe-items li + li { border-top: 1px solid var(--border); }
.dupe-items a { display: flex; flex-direction: column; gap: 1px; padding: 8px 12px; color: var(--text); text-decoration: none; }
.dupe-items a:hover { background: var(--surface-2); }
.dupe-items .title { font-weight: 600; overflow-wrap: anywhere; }
.dupe-items .sub { color: var(--text-muted); font-size: .84rem; overflow-wrap: anywhere; }
.dupe-group .btn-row form { display: contents; }

/* Parent documents: a section that's another document */
.item-heading .head-doc { display: none; margin-top: 6px; }
.item-heading.is-doc .head-doc { display: block; }
.item-heading.is-doc .head-fold { visibility: hidden; }
.item-heading.is-doc .head-cat { font-weight: 600; }
.doc-kept { color: var(--brand-ink); }
.btn-sent { color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, var(--border)); }
.prefill-note { margin: 0 0 12px; padding: 10px 12px; border-radius: var(--radius-s); background: var(--brand-soft); color: var(--text); font-size: .92rem; }
.refresh-included { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 12px; font-size: .9rem; }
.item.is-dropped { display: none !important; }

/* A form that's just a button in a row of buttons. (Not display:contents:
   with two of those on a page, WebKit/iPhone stopped following links and
   submitting forms from it.) */
.inline-form { display: inline-flex; margin: 0; }
.inline-form > .btn { flex: 0 0 auto; }
