/* Daily report: list, start card and the editor. Mobile first; tokens only. */

/* ============================================================ Report status pills */
.pill-report-draft { background: var(--blue-50); color: var(--blue-700); }
.pill-report-submitted { background: var(--amber-50); color: var(--amber-700); }
.pill-report-approved { background: var(--green-50); color: var(--green-700); }

/* ============================================================ Start a report */
.start-daily { display: grid; gap: var(--s-4); padding: var(--s-5); background: linear-gradient(135deg, var(--surface) 55%, var(--amber-50)); }
.start-daily-icon { display: none; }
.start-daily-fields { display: grid; gap: var(--s-3); }
.start-daily .select-trigger { min-height: 56px; font-size: var(--text-base); }
.start-daily .select-trigger.has-error { border-color: var(--red-500); background: var(--red-50); }
@media (min-width: 768px) {
  .start-daily { grid-template-columns: auto 1fr auto; align-items: center; padding: var(--s-5) var(--s-6); }
  .start-daily-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: var(--radius); background: var(--stone-900); color: var(--amber-400); }
  .start-daily-fields { grid-auto-flow: column; grid-auto-columns: 1fr; }
}

/* ============================================================ Report list items */
.filters-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); margin-bottom: 0; }
@media (min-width: 768px) { .filters-row { grid-template-columns: 280px 200px; gap: var(--s-3); } }
.filters-row .select:last-child .select-menu { left: auto; right: 0; }
.date-chip { flex: none; display: grid; justify-items: center; width: 48px; padding: 5px 0 6px; border-radius: var(--radius-sm); background: var(--stone-100); line-height: 1; }
.date-chip-dow { font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.date-chip-day { margin: 3px 0 2px; font-size: var(--text-lg); font-weight: 800; font-variant-numeric: tabular-nums; }
.date-chip-mon { font-size: 10px; font-weight: 600; color: var(--text-muted); }
.report-item { gap: var(--s-3); }
.list-amount { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ============================================================ Editor shell */
.page-daily { max-width: 820px; }
.has-savebar .page { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.daily-head { margin-bottom: var(--s-4); }
.daily-date { display: flex; align-items: center; gap: var(--s-2); }
.daily-date-text { flex: 1; min-width: 0; text-align: center; }
.daily-date-text .eyebrow { margin-bottom: 0; }
.day-nav { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text-soft); box-shadow: var(--shadow-xs); transition: all var(--fast) var(--ease); }
a.day-nav:hover { color: var(--text); border-color: var(--stone-300); transform: translateY(-1px); }
.day-nav.is-disabled { opacity: .35; box-shadow: none; }
.daily-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--s-2) var(--s-3); margin-top: var(--s-2); }
@media (min-width: 640px) {
  .daily-date-text { text-align: left; }
  .daily-date { gap: var(--s-4); }
  .daily-date-text { order: -1; } /* date first, then ‹ › together on the right */
  .daily-meta { justify-content: flex-start; }
}
.daily-lock { margin-bottom: var(--s-4); }

.section-tabs {
  position: sticky; top: calc(var(--topbar-h) + env(safe-area-inset-top)); z-index: 20;
  margin: 0 calc(var(--s-4) * -1) var(--s-4); padding: var(--s-2) var(--s-4);
  background: rgba(247, 245, 242, .9); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
}
.section-tabs .chips { mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 32px), transparent); }
.section-tabs .chip { height: 32px; padding: 0 var(--s-3); }
@media (min-width: 640px) { .section-tabs { margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; } }
@media (min-width: 1024px) { .section-tabs { top: 0; } }
.daily-section { scroll-margin-top: calc(var(--topbar-h) + 64px); }
@media (min-width: 1024px) { .daily-section { scroll-margin-top: 72px; } }
.daily-sections { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-4); }

/* ============================================================ Cost totals */
.cost-card { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: var(--s-4); overflow: hidden; }
.cost-item { display: grid; gap: 2px; padding: var(--s-3) var(--s-4); }
.cost-item:nth-child(n+3) { border-top: 1px solid var(--border); }
.cost-item:nth-child(even) { border-left: 1px solid var(--border); }
.cost-label { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text-muted); }
.cost-value { font-size: var(--text-lg); font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.cost-value.is-bumped { animation: bump var(--slow) var(--ease-spring); }
@keyframes bump { 40% { transform: scale(1.06); color: var(--amber-700); } }
.cost-hint { font-size: var(--text-xs); color: var(--text-muted); }
.cost-total { background: var(--stone-900); color: #fff; }
.cost-total .cost-label { color: var(--stone-400); }
.cost-total .cost-value { color: var(--amber-300); }
@media (min-width: 640px) {
  .cost-card { grid-template-columns: repeat(4, 1fr); }
  .cost-item { padding: var(--s-4) var(--s-5); }
  .cost-item:nth-child(n+3) { border-top: 0; }
  .cost-item + .cost-item { border-left: 1px solid var(--border); }
  .cost-value { font-size: var(--text-xl); }
}

/* ============================================================ Sections */
.section-head { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-4) var(--s-3); }
@media (min-width: 640px) { .section-head { padding: var(--s-5) var(--s-5) var(--s-3); } }
.section-icon { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-sm); background: var(--amber-50); color: var(--amber-700); }
.section-name { font-size: var(--text-base); font-weight: 700; }
.section-sub { font-size: var(--text-xs); color: var(--text-muted); }
.section-body { padding: 0 var(--s-4) var(--s-4); }
@media (min-width: 640px) { .section-body { padding: 0 var(--s-5) var(--s-4); } }
.section-foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); padding: var(--s-3) var(--s-4) var(--s-4); }
@media (min-width: 640px) { .section-foot { padding: var(--s-3) var(--s-5) var(--s-5); } }
.section-foot .note-body { flex-basis: 100%; }
.lines-empty { margin: var(--s-4) var(--s-4) 0; padding: var(--s-4); border-radius: var(--radius); background: var(--stone-25); border: 1px dashed var(--border-strong); font-size: var(--text-sm); color: var(--text-muted); text-align: center; }
@media (min-width: 640px) { .lines-empty { margin: var(--s-4) var(--s-5) 0; } }

.big-text {
  display: block; width: 100%; min-height: 120px; padding: var(--s-3) var(--s-4); resize: none; overflow: hidden;
  border: 1.5px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); line-height: 1.55;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.big-text:hover { border-color: var(--stone-400); }
.big-text:focus { border-color: var(--amber-500); box-shadow: var(--focus); }
.big-text[readonly] { border-color: transparent; background: var(--stone-25); padding-left: var(--s-3); }

/* ============================================================ Lines */
.lines { border-top: 1px solid var(--border); }
.lines:empty { display: none; }
.line { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); transition: background var(--medium) var(--ease), opacity var(--medium) var(--ease); }
@media (min-width: 640px) { .line { padding: var(--s-3) var(--s-5); } }
.line.is-new { animation: line-in var(--slow) var(--ease); }
@keyframes line-in { from { opacity: 0; transform: translateY(-6px); background: var(--amber-50); } to { opacity: 1; transform: none; } }
.line.is-leaving { animation: line-out var(--medium) var(--ease) forwards; pointer-events: none; }
@keyframes line-out { to { opacity: 0; transform: translateX(24px); } }
.line-main { display: flex; align-items: center; gap: var(--s-3); min-height: 48px; }
.line-main-fields { align-items: flex-end; }
.line-title { font-size: var(--text-sm); font-weight: 600; }
.line-sub { font-size: var(--text-xs); color: var(--text-muted); }
.line .unit-mark { width: 60px; height: 32px; line-height: 32px; font-size: 11px; }
.line .note-body { margin-top: var(--s-2); }

.out-tag { display: none; margin-left: 6px; padding: 1px 6px; border-radius: 4px; background: var(--stone-200); color: var(--stone-700); font-weight: 700; }
.line.is-out .out-tag { display: inline; }
.line.is-out .line-title { color: var(--text-muted); text-decoration: line-through; text-decoration-color: var(--stone-300); }
.line.is-out .avatar { filter: grayscale(1); opacity: .6; }
.line.is-out .stepper { opacity: .4; }
.out-toggle {
  flex: none; height: 32px; padding: 0 var(--s-3); border: 1px solid var(--border-strong); border-radius: var(--radius-full);
  background: var(--surface); color: var(--text-muted); font-size: var(--text-xs); font-weight: 700; transition: all var(--fast) var(--ease);
}
.out-toggle:hover { color: var(--text); border-color: var(--stone-400); }
.out-toggle[aria-pressed="true"] { background: var(--stone-900); border-color: var(--stone-900); color: #fff; }

/* Hours stepper */
.stepper { flex: none; display: flex; align-items: center; height: 40px; border: 1.5px solid var(--border-strong); border-radius: var(--radius-full); background: var(--surface); transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease); }
.stepper:focus-within { border-color: var(--amber-500); box-shadow: var(--focus); }
.stepper.has-error { border-color: var(--red-500); background: var(--red-50); }
.stepper input { width: 40px; height: 100%; padding: 0; border: 0; background: transparent; text-align: center; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stepper input:focus { box-shadow: none; }
.stepper-btn { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; display: grid; place-items: center; width: 36px; height: 100%; border: 0; background: transparent; color: var(--text-soft); border-radius: var(--radius-full); }
.stepper-btn:hover { color: var(--text); background: var(--stone-100); }
.stepper-btn:active { transform: scale(.9); }
.stepper.is-pulsing input { animation: bump var(--medium) var(--ease-spring); }
.hours-read { flex: none; font-size: var(--text-sm); color: var(--text-soft); font-variant-numeric: tabular-nums; }

.line-actions { flex: none; display: flex; gap: 2px; }
.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--stone-400); transition: all var(--fast) var(--ease); }
.icon-btn:hover { background: var(--stone-100); color: var(--text); }
.icon-btn.has-note { color: var(--amber-600); }
.icon-btn-danger:hover { background: var(--red-50); color: var(--red-600); }

/* Compact labelled inputs inside lines */
.line-fields { flex: 1; min-width: 0; display: grid; gap: var(--s-2); }
.line-fields.cols-2 { grid-template-columns: 1fr 1fr; }
.line-fields.cols-sub { grid-template-columns: 1fr 72px; }
.line-fields.cols-sub > :nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
/* Materials read like the ticket: what, how much, from whom, what it cost. Same order at every width. */
.line-fields.cols-material {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-areas: "mat mat mat" "qty unit amt" "sup sup tkt";
}
.cols-material .mini-qty { grid-area: qty; } .cols-material .mini-unit { grid-area: unit; } .cols-material .mini-money { grid-area: amt; }
.cols-material .mini-material { grid-area: mat; } .cols-material .mini-supplier { grid-area: sup; } .cols-material .mini-ticket { grid-area: tkt; }
@media (min-width: 640px) {
  .line-fields.cols-sub { grid-template-columns: 1.3fr 1.5fr 72px; }
  .line-fields.cols-sub > :nth-child(2) { grid-column: auto; grid-row: auto; }
  .line-fields.cols-material { grid-template-columns: minmax(0, 1fr) 112px 128px; grid-template-areas: "mat qty unit" "sup tkt amt"; }
}
.mini { position: relative; display: grid; gap: 2px; min-width: 0; }
.mini > span:first-child { padding-left: 2px; font-size: 11px; font-weight: 600; color: var(--text-muted); }
.mini input {
  width: 100%; height: 40px; padding: 0 var(--s-3); border: 1.5px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); font-size: 16px; transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.mini input::placeholder { color: var(--stone-400); }
.mini input:hover { border-color: var(--stone-400); }
.mini input:focus { border-color: var(--amber-500); box-shadow: var(--focus); }
.mini input[readonly] { border-color: transparent; background: var(--stone-25); }
.mini.has-error input { border-color: var(--red-500); background: var(--red-50); }
.mini-prefix, .mini-suffix { position: absolute; bottom: 0; height: 40px; display: grid; place-items: center; color: var(--text-muted); font-size: var(--text-sm); pointer-events: none; }
.mini-prefix { left: var(--s-3); }
.mini-prefix + input { padding-left: calc(var(--s-3) + 10px); }
.mini-suffix { right: var(--s-3); }
.mini-temp input { padding-right: 32px; font-variant-numeric: tabular-nums; }

.weather-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2) var(--s-3); }
.weather-grid .mini-conditions { grid-column: 1 / -1; }
@media (min-width: 640px) { .weather-grid { grid-template-columns: 1fr 120px 120px; } .weather-grid .mini-conditions { grid-column: auto; } }
.quick-picks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--s-3); }
.quick-pick { height: 30px; padding: 0 var(--s-3); border: 1px solid var(--border); border-radius: var(--radius-full); background: var(--stone-25); color: var(--text-soft); font-size: var(--text-xs); font-weight: 600; transition: all var(--fast) var(--ease); }
.quick-pick:hover { background: var(--amber-50); border-color: var(--amber-300); color: var(--amber-700); }
.quick-pick:active { transform: scale(.96); }

/* ============================================================ Notes */
.note-toggle { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 var(--s-2); border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-muted); font-size: var(--text-sm); font-weight: 600; }
.note-toggle:hover { background: var(--stone-100); color: var(--text); }
.note-toggle.has-note { color: var(--amber-700); }
.note-body { position: relative; }
.note-input {
  display: block; width: 100%; min-height: 40px; padding: 9px var(--s-3) 9px 36px; resize: none; overflow: hidden;
  border: 1px solid var(--amber-100); border-radius: var(--radius-sm); background: var(--amber-50); font-size: var(--text-sm); line-height: 1.5; color: var(--stone-800);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a85d0a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z'/%3E%3Cpath d='M14 3v6h6M8 13h8M8 17h5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-size: 16px; background-position: 12px 11px;
  animation: drop-in var(--medium) var(--ease);
}
.note-input::placeholder { color: var(--amber-700); opacity: .55; }
.note-input:focus { border-color: var(--amber-400); box-shadow: var(--focus); }
.note-input[readonly] { box-shadow: none; }

/* ============================================================ Save bar */
.savebar {
  position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; padding: var(--s-2) 0 calc(var(--s-2) + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .92); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-top: 1px solid var(--border);
}
@media (min-width: 1024px) { .savebar { left: var(--sidebar-w); } }
/* Same width and side padding as .page.page-daily, so the bar's edges line up with the cards */
.savebar-inner { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); max-width: 820px; min-height: 48px; margin: 0 auto; padding: 0 var(--s-4); }
@media (min-width: 640px) { .savebar-inner { padding: 0 var(--s-6); } }
@media (min-width: 1024px) { .savebar-inner { padding: 0 var(--s-10); } }
.save-state { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--text-sm); font-weight: 500; color: var(--text-muted); }
.save-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green-500); box-shadow: 0 0 0 3px var(--green-50); transition: background var(--medium) var(--ease), box-shadow var(--medium) var(--ease); }
[data-save-state="saving"] .save-dot { background: var(--amber-500); box-shadow: 0 0 0 3px var(--amber-50); animation: breathe 1s var(--ease) infinite; }
[data-save-state="retrying"] .save-dot, [data-save-state="error"] .save-dot, [data-save-state="upload"] .save-dot { background: var(--red-500); box-shadow: 0 0 0 3px var(--red-50); }
[data-save-state="retrying"], [data-save-state="error"], [data-save-state="upload"] { color: var(--red-600); }
[data-save-state="locked"] .save-dot { background: var(--stone-400); box-shadow: 0 0 0 3px var(--stone-100); }
@keyframes breathe { 50% { opacity: .35; } }
.has-savebar .toast-stack { bottom: calc(76px + env(safe-area-inset-bottom)); }

/* ============================================================ Sheets */
.sheet { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(28, 25, 23, .5); backdrop-filter: blur(3px); opacity: 0; transition: opacity var(--medium) var(--ease); }
.sheet.is-open .sheet-backdrop { opacity: 1; }
.sheet-panel {
  position: relative; display: flex; flex-direction: column; width: 100%; max-height: 86dvh; padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-radius: var(--radius-xl) var(--radius-xl) 0 0; box-shadow: var(--shadow-lg);
  transform: translateY(100%); transition: transform var(--slow) var(--ease);
}
.sheet-panel:focus { outline: none; box-shadow: var(--shadow-lg); }
.sheet.is-open .sheet-panel { transform: none; }
@media (min-width: 640px) {
  .sheet { align-items: center; padding: var(--s-6); }
  .sheet-panel { max-width: 480px; max-height: min(640px, 86dvh); border-radius: var(--radius-xl); padding-bottom: 0;
    transform: translateY(12px) scale(.97); opacity: 0; transition: transform var(--medium) var(--ease-spring), opacity var(--medium) var(--ease); }
  .sheet.is-open .sheet-panel { opacity: 1; }
}
.sheet-grabber { width: 40px; height: 4px; margin: var(--s-2) auto 0; border-radius: 4px; background: var(--stone-200); }
@media (min-width: 640px) { .sheet-grabber { display: none; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) var(--s-5) var(--s-2); }
.sheet-head h2 { font-size: var(--text-lg); font-weight: 700; }
.sheet-search { margin: 0 var(--s-5) var(--s-2); }
.sheet-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: var(--s-2) var(--s-3) var(--s-5); }
.sheet-body .picker-group-label { margin: var(--s-3) var(--s-2) var(--s-1); }
.sheet-list { margin: 0; padding: 0; list-style: none; }
.sheet-option {
  display: flex; align-items: center; gap: var(--s-3); width: 100%; min-height: 56px; padding: var(--s-2); border: 0; border-radius: var(--radius);
  background: transparent; text-align: left; transition: background var(--fast) var(--ease);
}
.sheet-option:hover { background: var(--stone-50); }
.sheet-option:active { transform: scale(.99); }
.sheet-option-state { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--amber-50); color: var(--amber-700); transition: all var(--medium) var(--ease-spring); }
.sheet-option .icon-added { display: none; }
.sheet-option.is-used { cursor: default; }
.sheet-option.is-used .pick-name { color: var(--text-muted); }
.sheet-option.is-used .sheet-option-state { background: var(--green-500); color: #fff; }
.sheet-option.is-used .icon-add { display: none; }
.sheet-option.is-used .icon-added { display: block; animation: pop var(--medium) var(--ease-spring); }
.sheet-option.is-adding .sheet-option-state { animation: breathe .8s var(--ease) infinite; }

/* ============================================================ Photos & receipts */
.file-strip { display: flex; gap: var(--s-2); margin: var(--s-3) 0 0; padding: 0; list-style: none; overflow-x: auto; scrollbar-width: none; }
.file-strip::-webkit-scrollbar { display: none; }
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); overflow: visible; margin: 0; }
.tile-file { position: relative; flex: none; width: 72px; }
.file-grid .tile-file { width: auto; }
.tile-file.is-new { animation: pop var(--slow) var(--ease-spring); }
.tile-file.is-leaving { animation: collapse var(--medium) var(--ease) forwards; }
.file-thumb, .file-add {
  position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 1; overflow: hidden; padding: 0;
  border-radius: var(--radius); border: 1px solid var(--border); background: var(--stone-100); cursor: pointer;
  transition: transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
button.file-thumb:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
button.file-thumb:active { transform: scale(.97); }
.file-thumb.is-doc { background: var(--red-50); border-color: #f6d3cf; color: var(--red-600); }
.doc-icon { display: grid; justify-items: center; gap: 2px; font-size: 10px; font-weight: 800; letter-spacing: .06em; }
.file-add { gap: 4px; align-content: center; border: 1.5px dashed var(--amber-300); background: var(--amber-50); color: var(--amber-700); font-size: 11px; font-weight: 700; text-align: center; }
.file-add:hover { background: var(--amber-100); }
.file-add:active { transform: scale(.97); }
.file-add:focus-within { box-shadow: var(--focus); }
.file-add input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.tile-caption { margin-top: 4px; font-size: 11px; color: var(--text-muted); }

.is-uploading .file-thumb img, .is-failed .file-thumb img { opacity: .45; filter: saturate(.6); }
.upload-ring {
  position: absolute; width: 36px; height: 36px; border-radius: 50%;
  background: conic-gradient(var(--amber-500) calc(var(--p) * 1%), rgba(255,255,255,.6) 0);
  -webkit-mask: radial-gradient(circle, transparent 12px, #000 13px); mask: radial-gradient(circle, transparent 12px, #000 13px);
  transition: background var(--fast) linear;
}
.is-failed .upload-ring { display: none; }
.upload-retry { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 2px; border: 0; background: rgba(253, 240, 239, .85); color: var(--red-600); font-size: 11px; font-weight: 700; }

/* ============================================================ Viewer */
.viewer {
  --fade: 1;
  position: fixed; inset: 0; z-index: 140; display: flex; flex-direction: column; isolation: isolate;
  color: #fff; opacity: 0; visibility: hidden; transition: opacity var(--medium) var(--ease), visibility var(--medium);
  touch-action: none; user-select: none;
}
.viewer.is-open { opacity: 1; visibility: visible; }
.viewer::before { content: ""; position: absolute; inset: 0; z-index: -1; background: #0c0a09; opacity: var(--fade); }
.viewer:focus { outline: none; box-shadow: none; }
.viewer-top { position: relative; z-index: 2; display: flex; align-items: center; gap: var(--s-2); padding: calc(var(--s-2) + env(safe-area-inset-top)) var(--s-3) var(--s-2); }
.viewer-count { flex: none; font-size: var(--text-sm); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--stone-300); }
.viewer-name { flex: 1; font-size: var(--text-sm); color: var(--stone-400); }
.viewer-btn { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: rgba(255,255,255,.08); color: #fff; }
.viewer-btn:hover { background: rgba(255,255,255,.16); }
.viewer-delete:hover { background: var(--red-600); }
.viewer-stage { position: relative; flex: 1; overflow: hidden; }
.viewer-track { display: flex; height: 100%; transition: transform var(--slow) var(--ease); }
.viewer-track.no-anim { transition: none; }
.viewer-track.is-nudging { animation: nudge .26s var(--ease); }
@keyframes nudge { 50% { translate: var(--nudge) 0; } }
.viewer-slide { flex: none; display: grid; place-items: center; width: 100%; height: 100%; padding: var(--s-2); }
.viewer-img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; transform-origin: center; transition: transform var(--medium) var(--ease); cursor: zoom-in; }
.viewer.is-zoomed .viewer-img { cursor: grab; transition: none; }
.viewer-doc { place-items: start center; overflow-y: auto; touch-action: pan-y pinch-zoom; -webkit-overflow-scrolling: touch; }
.viewer-pages { display: grid; gap: var(--s-3); width: min(100%, 1100px); padding-bottom: var(--s-8); }
.viewer-page { display: block; max-width: 100%; height: auto; background: #fff; border-radius: 4px; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.viewer-loading, .viewer-file { display: grid; justify-items: center; gap: var(--s-3); padding: var(--s-12) 0; color: var(--stone-300); text-align: center; }
.viewer-loading .spinner { color: var(--amber-400); }
.viewer-nav { position: absolute; z-index: 2; top: 50%; display: none; place-items: center; width: 52px; height: 52px; margin-top: -26px; border: 0; border-radius: 50%; background: rgba(255,255,255,.1); color: #fff; }
.viewer-nav:hover { background: rgba(255,255,255,.2); }
.viewer-prev { left: var(--s-4); } .viewer-next { right: var(--s-4); }
@media (hover: hover) and (min-width: 768px) { .viewer-nav:not([hidden]) { display: grid; } }
.viewer-bottom { position: relative; z-index: 2; padding: var(--s-2) var(--s-4) calc(var(--s-4) + env(safe-area-inset-bottom)); }
.viewer-caption { display: block; width: 100%; max-width: 560px; height: 44px; margin: 0 auto; padding: 0 var(--s-4); border: 1px solid rgba(255,255,255,.14); border-radius: var(--radius-full); background: rgba(255,255,255,.08); color: #fff; font-size: 16px; text-align: center; }
.viewer-caption::placeholder { color: var(--stone-500); }
.viewer-caption:focus { border-color: var(--amber-400); box-shadow: 0 0 0 3px rgba(245, 158, 11, .3); }
.viewer-caption-text { max-width: 560px; margin: 0 auto; text-align: center; color: var(--stone-200); font-size: var(--text-sm); }

/* ============================================================ Submit bar actions */
.savebar-actions { display: flex; align-items: center; gap: var(--s-2); }
.savebar-actions form { margin: 0; }
@media (max-width: 479px) { .savebar-actions .btn { padding: 0 var(--s-3); } }

/* ============================================================ Activity */
.activity { display: grid; gap: var(--s-2); margin: var(--s-6) 0 0; padding: 0 0 0 var(--s-2); list-style: none; font-size: var(--text-sm); color: var(--text-muted); }
.activity li { position: relative; display: flex; align-items: flex-start; gap: var(--s-3); }
.activity li > span:not(.activity-dot) { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.activity-dot { margin-top: 6px; }
.activity li + li::before { content: ""; position: absolute; left: 4px; bottom: 50%; height: calc(100% + var(--s-2)); width: 2px; background: var(--border); z-index: -1; }
.activity time { margin-left: auto; flex: none; white-space: nowrap; font-variant-numeric: tabular-nums; }
.activity-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--stone-300); box-shadow: 0 0 0 3px var(--bg); }
.activity-submitted .activity-dot { background: var(--amber-500); }
.activity-approved .activity-dot { background: var(--green-500); }
.activity-reopened .activity-dot { background: var(--blue-500); }

/* ============================================================ Repairs */
.pill-repair-pending { background: var(--amber-50); color: var(--amber-700); }
.pill-repair-approved { background: var(--green-50); color: var(--green-700); }
.pill-repair-rejected { background: var(--stone-100); color: var(--stone-600); }
.repair-list { margin: 0; padding: 0; list-style: none; }
.repair-list-inset { border-top: 1px solid var(--border); }
.repair { padding: var(--s-4) var(--s-5); }
.repair + .repair { border-top: 1px solid var(--border); }
.repair.is-new { animation: line-in var(--slow) var(--ease); }
.repair-main { display: flex; gap: var(--s-3); }
.repair-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.repair-subject { font-weight: 700; }
.repair-subject a:hover { color: var(--amber-700); }
.repair-desc { margin-top: 2px; color: var(--text-soft); font-size: var(--text-sm); }
.repair-meta { margin-top: var(--s-1); font-size: var(--text-xs); color: var(--text-muted); }
.repair-decision { display: flex; gap: 6px; align-items: flex-start; margin-top: var(--s-2); padding: var(--s-2) var(--s-3); border-radius: var(--radius-sm); background: var(--stone-50); font-size: var(--text-xs); color: var(--text-soft); }
.repair-decision .icon { margin-top: 1px; }
.repair-approved .repair-decision { background: var(--green-50); color: var(--green-700); }
.repair-actions { display: flex; justify-content: flex-end; gap: var(--s-2); margin-top: var(--s-3); }
.repair-actions form { margin: 0; }
.rejected-dim, .repair-rejected .repair-desc { color: var(--text-muted); }

/* ============================================================ Sheet forms */
.sheet-pad { padding: var(--s-2) var(--s-5) var(--s-4); }
.sheet-foot { display: flex; justify-content: flex-end; gap: var(--s-2); padding: var(--s-3) var(--s-5) var(--s-4); border-top: 1px solid var(--border); }
.sheet-foot .btn { flex: 1; }
@media (min-width: 640px) { .sheet-foot .btn { flex: none; } }
.big-text-sm { min-height: 80px; font-size: 16px; }
.mini.has-error .big-text { border-color: var(--red-500); background: var(--red-50); }
.choice-list { display: grid; gap: 6px; margin-bottom: var(--s-4); }
.choice-row { position: relative; cursor: pointer; }
.choice-row input { position: absolute; opacity: 0; pointer-events: none; }
.choice-row-card { display: flex; align-items: center; gap: var(--s-3); min-height: 52px; padding: var(--s-2) var(--s-3); border: 1.5px solid var(--border-strong); border-radius: var(--radius); font-size: var(--text-sm); font-weight: 600; transition: all var(--fast) var(--ease); }
.choice-row:hover .choice-row-card { border-color: var(--stone-400); }
.choice-row input:checked + .choice-row-card { border-color: var(--amber-500); background: var(--amber-50); }
.choice-row input:checked + .choice-row-card .choice-radio { border-color: var(--amber-500); }
.choice-row input:checked + .choice-row-card .choice-radio::after { transform: scale(1); }
.choice-row input:focus-visible + .choice-row-card { box-shadow: var(--focus); }
.repair-desc-field { margin-top: var(--s-2); }

/* ============================================================ Export */
.daily-tools { display: flex; justify-content: center; gap: var(--s-2); margin-top: var(--s-3); }
@media (min-width: 640px) { .daily-tools { justify-content: flex-start; } }
.recipients { display: grid; gap: 6px; }
.recipient {
  display: flex; align-items: center; gap: var(--s-3); width: 100%; min-height: 52px; padding: var(--s-2) var(--s-3);
  border: 1.5px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); text-align: left; transition: all var(--fast) var(--ease);
}
.recipient:hover { border-color: var(--stone-400); }
.recipient.is-on { border-color: var(--amber-500); background: var(--amber-50); }
.recipient.is-new { animation: line-in var(--slow) var(--ease); }
.recipient-check { flex: none; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; border: 1.5px solid var(--stone-300); background: var(--surface); color: transparent; transition: all var(--medium) var(--ease-spring); }
.recipient.is-on .recipient-check { background: var(--amber-500); border-color: var(--amber-500); color: var(--stone-900); }
.recipient-check .icon { stroke-width: 3; width: 13px; height: 13px; }
.recipient-name { display: block; font-size: var(--text-sm); font-weight: 600; }
.recipient-sub { display: block; font-size: var(--text-xs); color: var(--text-muted); }
.recipient-add { position: relative; display: flex; align-items: center; }
.recipient-add .icon { position: absolute; left: var(--s-3); color: var(--text-muted); pointer-events: none; }
.recipient-add input { width: 100%; height: 48px; padding: 0 var(--s-3) 0 36px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius); background: transparent; font-size: 16px; }
.recipient-add input:focus { border-style: solid; border-color: var(--amber-500); box-shadow: var(--focus); }
.switch-row-sm { padding: var(--s-3); }
.email-foot { display: flex; gap: var(--s-2); align-items: center; font-size: var(--text-xs); }
.activity-detail { color: var(--stone-400); }
.sheet-foot .btn[disabled] { opacity: .5; }

/* ============================================================ Row actions: inline on wide screens, "⋯" menu on phones */
.line-inline { display: none; align-items: center; gap: var(--s-2); }
.line-more { position: relative; flex: none; }
@media (min-width: 560px) { .line-inline { display: flex; } .line-more { display: none; } }
.line-more .icon-btn.has-note { color: var(--amber-600); }
.menu-pop {
  position: absolute; z-index: 25; right: 0; top: calc(100% + 4px); min-width: 196px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(-4px) scale(.98); transform-origin: top right; pointer-events: none;
  transition: opacity var(--fast) var(--ease), transform var(--medium) var(--ease);
}
.line-more.is-open .menu-pop { opacity: 1; transform: none; pointer-events: auto; }
.menu-pop [role=menuitem] { display: flex; align-items: center; gap: var(--s-3); width: 100%; height: 44px; padding: 0 var(--s-3); border: 0; border-radius: var(--radius-sm); background: transparent; font-size: var(--text-sm); font-weight: 500; text-align: left; }
.menu-pop [role=menuitem]:hover, .menu-pop [role=menuitem]:focus-visible { background: var(--stone-100); box-shadow: none; }
.menu-pop [role=menuitem] .icon { color: var(--text-muted); }
.menu-pop .is-danger { color: var(--red-600); }
.menu-pop .is-danger .icon { color: var(--red-500); }

/* Field rows (rentals, subs, materials): fields take the full width on phones, actions sit under them */
@media (max-width: 559px) {
  .line-main-fields { flex-direction: column; align-items: stretch; gap: var(--s-1); }
  .line-main-fields .line-actions { align-self: flex-end; margin-right: -8px; }
}
.line-main .stepper { margin-left: auto; }
.line-main-fields .line-actions { padding-bottom: 2px; }
.line-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s-3); }
.line-foot .file-strip { flex: 1; min-width: 0; }
.line-foot .line-actions { margin-left: auto; margin-right: -8px; }
.section-body + .section-foot { padding-top: 0; }

/* Phones: a slimmer stepper leaves room for names */
@media (max-width: 479px) {
  .stepper { height: 38px; }
  .stepper-btn { width: 30px; }
  .stepper input { width: 32px; }
}

/* Read-only reports: no input chrome, no hint text, no tall empty boxes */
.daily[data-editable="0"] .mini input, .daily[data-editable="0"] .big-text { border-color: transparent; background: var(--stone-25); }
.daily[data-editable="0"] .big-text { min-height: 0; }
.daily[data-editable="0"] [readonly]::placeholder { color: var(--stone-400); }
/* Sections with no footer (locked, no note): the last row closes the card */
.no-foot .line:last-child { border-bottom: 0; }
.no-foot .lines-empty { margin-bottom: var(--s-4); }
@media (min-width: 640px) { .no-foot .lines-empty { margin-bottom: var(--s-5); } }
