:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #1a2332;
  --muted: #5b6b7c;
  --accent: #0b6e4f;
  --accent-soft: #e6f4ef;
  --warn: #b45309;
  --danger: #b91c1c;
  --ok: #047857;
  --border: #d8dee6;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
  --radius: 10px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

header.app-header {
  background: linear-gradient(120deg, #0b6e4f, #125e8a);
  color: #fff;
  padding: 1.1rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.75rem 1.5rem;
  box-shadow: var(--shadow);
}

header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

header .sub {
  opacity: 0.9;
  font-size: 0.92rem;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  background: var(--card);
}
.flash.ok { border-color: #a7f3d0; background: #ecfdf5; color: var(--ok); }
.flash.err { border-color: #fecaca; background: #fef2f2; color: var(--danger); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
}

.filters a {
  display: inline-block;
  padding: 0.35rem 0.85rem;
  margin-right: 0.35rem;
  border-radius: 999px;
  text-decoration: none;
  color: var(--muted);
  border: 1px solid var(--border);
  background: #fff;
  font-size: 0.9rem;
}
.filters a.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.upload-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.upload-form input[type=file] {
  font-size: 0.9rem;
  max-width: 260px;
}
button, .btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
}
button.secondary {
  background: #fff;
  color: var(--accent);
  border: 1px solid var(--accent);
}
button:hover { filter: brightness(1.05); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.po-list { display: flex; flex-direction: column; gap: 0.85rem; }

.po-card details { width: 100%; }
.po-card summary {
  list-style: none;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem 1rem;
  align-items: center;
}
.po-card summary::-webkit-details-marker { display: none; }

.po-title {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.85rem;
  align-items: baseline;
}
.po-title .num {
  font-weight: 700;
  font-size: 1.1rem;
}
.badge {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}
.meta {
  color: var(--muted);
  font-size: 0.88rem;
}
.meta strong { color: var(--ink); font-weight: 600; }

.po-stats {
  text-align: right;
  font-size: 0.9rem;
  color: var(--muted);
}
.po-stats .total { color: var(--ink); font-weight: 650; font-size: 1rem; }

.lines {
  margin-top: 0.9rem;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  overflow-x: auto;
}

table.lines-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
table.lines-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  padding: 0.35rem 0.4rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.lines-table td {
  padding: 0.45rem 0.4rem;
  border-bottom: 1px solid #eef1f5;
  vertical-align: top;
}
table.lines-table tr:last-child td { border-bottom: none; }
.item-no { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; }
.desc { color: var(--muted); white-space: pre-line; max-width: 320px; }
.num-cell { text-align: right; font-variant-numeric: tabular-nums; }
.remaining { font-weight: 700; color: var(--warn); }
.remaining.zero { color: var(--ok); }

.ship-cell form {
  display: flex;
  gap: 0.3rem;
  align-items: center;
}
.ship-cell input[type=number] {
  width: 72px;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.batch-bar {
  margin-top: 0.85rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
}
.batch-bar input[type=text] {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 180px;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 2rem 1rem;
}

footer.note {
  margin-top: 2rem;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

/* Nav in header */
header.app-header .nav {
  margin-left: auto;
  display: flex;
  gap: 0.5rem;
}
header.app-header .nav a {
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.35);
}
header.app-header .nav a.active,
header.app-header .nav a:hover {
  background: rgba(255,255,255,0.18);
}

.card-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.mat-code {
  width: 140px;
  max-width: 11rem;
  padding: 0.25rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  background: #fff;
}
.mat-qty {
  width: 64px;
  padding: 0.25rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-align: right;
}
.mat-code.suggested,
.mat-qty.suggested {
  border-color: #6b9ac4;
  background: #f0f7fc;
}

.materials-form { margin-top: 0.5rem; }
.ship-form {
  border-top: 1px dashed var(--border);
  padding-top: 0.65rem;
  margin-top: 0.35rem;
}
.ship-cell { text-align: right; }
.ship-cell .meta { white-space: nowrap; }
.batch-bar .meta {
  flex: 1;
  min-width: 200px;
  text-align: left;
  margin-right: auto;
}

.slip-list {
  margin-top: 0.85rem;
  font-size: 0.9rem;
}
.slip-list a {
  color: var(--accent);
  font-weight: 600;
  margin-left: 0.35rem;
}

.inv-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 0.85rem;
  align-items: flex-end;
}
.inv-form label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.inv-form input {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 120px;
  color: var(--ink);
}
.num-cell.neg { color: var(--danger); font-weight: 600; }
.num-cell.pos { color: var(--ok); font-weight: 600; }

.invoice-bar {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px dashed var(--border);
}
button.invoice-btn {
  background: #1d4f91;
  color: #fff;
}
button.invoice-btn:hover {
  filter: brightness(1.08);
}

.shipped-cell {
  min-width: 7.5rem;
}
.shipped-qty {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.correct-ship-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
  justify-content: flex-end;
  margin-top: 0.25rem;
}
.correct-ship-label {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 600;
}
.correct-ship-label input[type=number] {
  width: 64px;
  padding: 0.2rem 0.3rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-align: right;
  font-size: 0.82rem;
  color: var(--ink);
}
button.correct-ship-btn {
  padding: 0.25rem 0.55rem;
  font-size: 0.78rem;
}
.invoice-table { border-collapse: collapse; margin-top: 4px; }
.invoice-table td { padding: 2px 10px 2px 0; vertical-align: middle; }
button.danger-btn { background: #b42318; color: #fff; border: 0; border-radius: 4px; padding: 3px 8px; font-size: 0.85em; cursor: pointer; }
button.danger-btn:hover { background: #912018; }
button.invoice-btn.secondary { background: #8a6d00; }

/* Payments */
.pay-badge { display:inline-block; padding:1px 8px; border-radius:10px; font-size:.85em; font-weight:600; }
.pay-badge.unpaid { background:#fef2f2; color:#b91c1c; }
.pay-badge.partial { background:#fffbeb; color:#b45309; }
.pay-badge.paid { background:#ecfdf5; color:#047857; }
.pay-badge.past-due { background:#fff7ed; color:#c2410c; border:1px solid #fdba74; margin-left:4px; }
.past-due-summary { color:#c2410c; }
.receivables-card { font-size:1.1em; margin-bottom:12px; }
.flash.warn, .unapplied-warn { border:1px solid #fde68a; background:#fffbeb; color:#92400e; padding:8px 12px; border-radius:8px; margin:8px 0; }
.pay-table { border-collapse:collapse; width:100%; }
.pay-table th, .pay-table td { padding:4px 8px; border-bottom:1px solid #eee; text-align:left; }
.pay-table td.num, .pay-table th.num { text-align:right; }
.pay-table input.amt { width:8em; text-align:right; }
.pay-table th.sorted-asc::after { content: " ▲"; font-size: .7em; }
.pay-table th.sorted-desc::after { content: " ▼"; font-size: .7em; }
.pay-form label { display:inline-block; margin:4px 12px 4px 0; }

/* ---- Production time tracking ---- */
.est-card, .prod-running-card { margin-bottom: 1rem; }
.est-card { border-left: 4px solid #125e8a; }
.prod-running-card { border-left: 4px solid #d97706; }
.running-chip { display: inline-block; margin: 4px 8px 4px 0; padding: 4px 10px; border-radius: 999px; background: #fff7ed; border: 1px solid #fdba74; text-decoration: none; color: var(--ink); }
.running-chip.paused { background: #f1f5f9; border-color: #cbd5e1; }
.est-hdr { font-size: 0.85em; }
.prod-panel { margin: 14px 0; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; background: #fbfcfd; }
.prod-panel > summary { cursor: pointer; padding: 4px 0; font-size: 1.02rem; }
.prod-line { border-top: 1px solid var(--border); padding: 10px 2px; }
.prod-line.running { background: #f0fdf4; border-left: 4px solid #16a34a; padding-left: 8px; }
.prod-line.paused { background: #fffbeb; border-left: 4px solid #d97706; padding-left: 8px; }
.prod-head { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; }
.prod-item { font-size: 1.05rem; }
.prod-controls { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; margin-top: 8px; }
.inline-form { display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin: 0; }
.prod-field { display: inline-flex; flex-direction: column; font-size: 0.85rem; color: var(--muted); gap: 2px; }
.prod-field input { font-size: 1.05rem; padding: 10px; min-height: 46px; border: 1px solid var(--border); border-radius: 8px; width: 9.5rem; }
.prod-field.wide input { width: 22rem; max-width: 100%; }
button.prod-btn { font-size: 1.1rem; font-weight: 600; min-height: 48px; min-width: 7.5rem; padding: 10px 18px; border-radius: 10px; border: 0; color: #fff; cursor: pointer; touch-action: manipulation; }
button.prod-btn.start, button.prod-btn.resume { background: #15803d; }
button.prod-btn.pause { background: #d97706; }
button.prod-btn.stop { background: #b91c1c; }
button.prod-btn.manual { background: #125e8a; }
.timer-box { display: inline-flex; flex-direction: column; margin-right: 6px; }
.timer.big { font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.timer { font-variant-numeric: tabular-nums; }
.timer-state { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.timer-state.running { color: #15803d; }
.timer-state.paused { color: #b45309; }
.prod-more { margin-top: 8px; }
.prod-more > summary { cursor: pointer; color: #125e8a; padding: 6px 0; }
.manual-form { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; margin: 6px 0 10px; }
.runs-table { border-collapse: collapse; margin: 6px 0; font-size: 0.92rem; }
.runs-table th, .runs-table td { padding: 4px 10px; text-align: left; border-bottom: 1px solid #eef1f4; }
.runs-table td.num-cell, .runs-table th.num-cell { text-align: right; }
.runs-table tr.running td, .runs-table tr.paused td { background: #f8fafc; }
.run-actions { white-space: nowrap; }
.run-actions .danger-btn { margin-left: 6px; }
.edit-run .card-title { margin-bottom: 10px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tp-table th.sorted-asc::after { content: " ▲"; font-size: .7em; }
.tp-table th.sorted-desc::after { content: " ▼"; font-size: .7em; }
.tp-table tr.no-time td { color: var(--muted); }
.badge.no-time-badge { background: #fde2e1; color: #a4231c; margin-left: 4px; }
.tp-filters a { margin: 0 6px; }
.tp-filters a.active { font-weight: 700; text-decoration: underline; }
@media (max-width: 640px) {
  .prod-controls, .manual-form, .inline-form { width: 100%; }
  .prod-field { flex: 1 1 45%; }
  .prod-field input { width: 100%; }
  button.prod-btn { flex: 1 1 100%; min-height: 54px; font-size: 1.2rem; }
  .timer-box { width: 100%; }
}
header.app-header .nav { flex-wrap: wrap; }
header.app-header .nav a { white-space: nowrap; }
@media (max-width: 640px) { header.app-header .nav { margin-left: 0; } }

.flash.notice-banner { display:flex; gap:12px; align-items:flex-start; justify-content:space-between; background:#eff6ff; border:1px solid #93c5fd; color:#1e3a8a; }
.flash.notice-banner.po { background:#ecfdf5; border-color:#6ee7b7; color:#065f46; }
.flash.notice-banner.packing { background:#fff7ed; border-color:#fdba74; color:#9a3412; }
.flash.notice-banner.packing_err { background:#fef2f2; border-color:#fca5a5; color:#991b1b; }
.notice-dismiss button { white-space:nowrap; }
.packing-pending-card { border-left:4px solid #ea580c; }
.watcher-strip { margin: 6px 0 12px; }
.watcher-pill { display:inline-block; padding:1px 8px; border-radius:10px; margin-right:4px; background:#f3f4f6; }
.watcher-pill.ok { background:#ecfdf5; color:#047857; }
.watcher-pill.bad { background:#fef2f2; color:#b91c1c; }
.watcher-card.ok { border-left:4px solid #059669; }
.watcher-card.bad { border-left:4px solid #dc2626; }
.notice-row { margin: 6px 0; padding: 6px 0; border-bottom:1px solid #eee; }

.badge.in_production { background: #fef3c7; color: var(--warn); }
.badge.ready_to_bill { background: #e0f2fe; color: #0369a1; }
.badge.open { background: #ffe4e6; color: #be123c; }
.badge.closed { background: var(--accent-soft); color: var(--ok); }
.filters a .count { opacity: .75; font-weight: 500; font-size: .9em; }
.filters a.active .count { opacity: 1; }

/* --- Mobile / phone usability --- */
.table-wrap, .table-scroll, .pay-table-wrap, .po-list .lines-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
@media (max-width: 720px) {
  body { font-size: 16px; }
  header.app-header { padding: 12px 12px 8px; }
  header.app-header h1 { font-size: 1.25rem; }
  header.app-header .nav { gap: 8px; margin-top: 8px; }
  header.app-header .nav a { padding: 6px 8px; font-size: .92rem; }
  .nav-logout { margin-left: auto; color: #b91c1c; }
  .card { padding: 12px; }
  .filters { display: flex; flex-wrap: wrap; gap: 6px; }
  .filters a { padding: 8px 10px; min-height: 40px; display: inline-flex; align-items: center; }
  table.lines-table, .pay-table, .stock-table, .runs-table, .tp-table, .invoice-table {
    display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap;
  }
  .po-card { padding: 12px; }
  .upload-form input[type=file], .upload-form button { width: 100%; margin-top: 8px; }
  button, .btn, input[type=submit] { min-height: 44px; }
  .meta { font-size: .9rem; }
}

/* Inventory cost tracking */
.inv-forms.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 720px) {
  .inv-forms.grid-2 { grid-template-columns: 1fr; }
}
.inv-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.inv-form label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; flex: 1 1 140px; }
.inv-form input { min-height: 40px; padding: 8px 10px; }
.inv-price-form { margin-top: 4px; }
.inv-table th, .inv-table td { white-space: nowrap; }
.inv-table td:nth-child(2) { white-space: normal; min-width: 8rem; }
.inv-form select { min-height: 40px; padding: 8px 10px; font-size: 16px; max-width: 100%; }
.inv-form label[hidden] { display: none; }

/* Compact production-time layout (one row per line) */
.prod-toolbar { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin: 4px 0 6px; }
.prod-filter { padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 16px; width: 16rem; max-width: 100%; }
.prod-toggle { display: inline-flex; gap: 4px; align-items: center; cursor: pointer; }
.prod-panel.hide-shipped .prod-line.shipped, .prod-line.filtered-out { display: none; }
@media (min-width: 0px) {
  .prod-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding: 5px 2px; }
  .prod-head { flex: 1 1 340px; min-width: 0; }
  .prod-item { font-size: 1rem; }
  .prod-head .meta { font-size: .82rem; }
  .prod-controls { margin-top: 0; gap: 6px 8px; align-items: center; }
  .prod-controls .inline-form, .stop-form { display: inline-flex; gap: 6px; align-items: center; }
  .prod-field { flex-direction: row; align-items: center; gap: 4px; font-size: .8rem; }
  .prod-field input { min-height: 34px; padding: 4px 8px; font-size: .95rem; width: 6.5rem; }
  button.prod-btn { min-height: 36px; min-width: 5.5rem; padding: 6px 12px; font-size: .95rem; border-radius: 8px; }
  .timer-box { flex-direction: row; align-items: baseline; gap: 6px; }
  .timer.big { font-size: 1.35rem; }
  .prod-more { flex-basis: 100%; margin-top: 0; }
  .prod-more > summary { padding: 0; font-size: .78rem; }
  .prod-more:not([open]) { margin-top: -2px; }
}

@media (max-width: 640px) {
  .prod-controls, .prod-controls .inline-form, .stop-form { width: auto; }
  .prod-field { flex: 0 0 auto; }
  .prod-field input { width: 5.5rem; min-height: 40px; }
  button.prod-btn { flex: 0 0 auto; min-height: 44px; font-size: 1rem; }
  .timer-box { width: auto; }
  .prod-head { flex-basis: 100%; }
}

.badge.subcon-badge { background: #e0e7ff; color: #3730a3; }
.prod-line.subcon { opacity: .75; }
.prod-set > summary { color: #6b7280; }
@media (min-width: 0px) { .prod-more.prod-set { flex-basis: auto; } }

/* ===== Cleaner layout (2026-10-20) ===== */
.title-row { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.notice-badge { position:relative; }
.notice-badge > summary { list-style:none; cursor:pointer; display:inline-flex; align-items:center; gap:4px; background:#2563eb; color:#fff; border-radius:999px; padding:3px 10px; font-size:.85rem; font-weight:600; }
.notice-badge > summary::-webkit-details-marker { display:none; }
.notice-pop { position:absolute; z-index:50; top:calc(100% + 6px); left:0; width:min(440px, 92vw); max-height:70vh; overflow:auto; background:#fff; border:1px solid #d1d5db; border-radius:10px; box-shadow:0 10px 30px rgba(0,0,0,.15); padding:8px; }
.notice-pop .flash.notice-banner { margin:6px 0; font-size:.9rem; }
.nav-more { position:relative; }
.nav-more > summary { list-style:none; cursor:pointer; padding:6px 10px; border-radius:8px; white-space:nowrap; }
.nav-more > summary::-webkit-details-marker { display:none; }
.nav-more.active > summary, .nav-more > summary:hover { background:rgba(0,0,0,.06); }
.nav-menu { position:absolute; z-index:60; top:calc(100% + 4px); right:0; min-width:170px; background:#fff; border:1px solid #d1d5db; border-radius:10px; box-shadow:0 10px 30px rgba(0,0,0,.15); padding:6px; display:flex; flex-direction:column; }
header.app-header .nav .nav-menu a { display:block; color:#1f2937; padding:8px 10px; }
.tiles { display:grid; grid-template-columns:repeat(auto-fit, minmax(150px, 1fr)); gap:8px; margin:10px 0; align-items:start; }
.tile { background:#fff; border:1px solid #e5e7eb; border-left:4px solid #94a3b8; border-radius:10px; }
.tile > summary { list-style:none; cursor:pointer; padding:8px 10px; display:flex; flex-direction:column; }
.tile > summary::-webkit-details-marker { display:none; }
.tile-num { font-size:1.25rem; font-weight:700; line-height:1.2; }
.tile-lbl { font-size:.78rem; color:#6b7280; }
.tile-body { padding:4px 10px 10px; font-size:.88rem; overflow-x:auto; }
.tile[open] { grid-column:1 / -1; }
.tile-good { border-left-color:#2e8b57; } .tile-bad { border-left-color:#c0392b; } .tile-warn { border-left-color:#ea580c; } .tile-run { border-left-color:#2563eb; }
.watcher-strip { font-size:.78rem; margin:-2px 0 8px; }
.po-card summary.po-row { display:flex; flex-wrap:wrap; align-items:center; gap:6px 14px; padding:10px 12px; }
.po-row .num { font-weight:700; min-width:96px; }
.po-row .total { font-weight:650; margin-left:auto; }
.po-row .po-pct { display:inline-flex; align-items:center; gap:6px; font-size:.82rem; color:#4b5563; min-width:120px; }
.pct-bar { width:56px; height:6px; background:#e5e7eb; border-radius:3px; overflow:hidden; display:inline-block; }
.pct-bar > span { display:block; height:100%; background:#16a34a; }
.po-caret { color:#9ca3af; transition:transform .15s; }
.po-card details[open] > summary .po-caret { transform:rotate(90deg); }
.po-detail { padding:0 12px 6px; font-size:.82rem; }
.log-time > summary.log-time-btn { list-style:none; cursor:pointer; display:inline-block; margin:4px 0; padding:4px 10px; border:1px solid #cbd5e1; border-radius:999px; font-size:.82rem; color:#125e8a; background:#f8fafc; }
.log-time > summary::-webkit-details-marker { display:none; }
.log-time[open] > summary.log-time-btn { background:#e0f2fe; border-color:#7dd3fc; }
@media (max-width:640px) {
  .po-row .total { margin-left:0; }
  .po-row .num { min-width:0; }
  .tiles { grid-template-columns:repeat(2, 1fr); }
  .nav-menu { right:auto; left:0; }
}

/* Sticky top nav on desktop */
@media (min-width: 761px) {
  header.app-header { position: sticky; top: 0; z-index: 100; }
}

/* Suppliers / subcontractors */
button.linkish { background: none; border: none; color: #b00; padding: 0 0 0 .4em; cursor: pointer; text-decoration: underline; font: inherit; }
@media print { header.app-header, .no-print-hide, .flash { display: none !important; } .card { box-shadow: none; border: none; } }

/* Flat top nav (no More menu): wrap cleanly on phones */
header.app-header .nav { flex-wrap: wrap; max-width: 100%; row-gap: 6px; }
@media (max-width: 480px) {
  header.app-header .nav { gap: 6px; }
  header.app-header .nav a { padding: 5px 8px; font-size: .86rem; }
}

/* Status filter pills: bold count badge with spacing */
.filters a .count { display: inline-block; margin-left: 6px; padding: 0 7px; min-width: 1.4em; text-align: center; border-radius: 999px; background: #eef1f4; color: #1f2937; font-weight: 700; font-size: .85em; line-height: 1.5; opacity: 1; }
.filters a.active .count { background: rgba(255,255,255,.28); color: #fff; }

/* Mobile hamburger nav (button injected by pwa.js; without JS the flat row stays) */
.nav-burger { display: none; }
@media (max-width: 700px) {
  header.app-header.has-burger { position: sticky; }
  header.app-header.has-burger .title-row { display: flex; flex-wrap: nowrap; align-items: center; gap: 8px; width: 100%; }
  header.app-header.has-burger .title-row h1 { min-width: 0; }
  header.app-header.has-burger .nav-burger { flex: 0 0 auto; }
  header.app-header.has-burger .nav-burger {
    display: inline-flex; align-items: center; justify-content: center; margin-left: auto;
    width: 42px; height: 38px; padding: 0; border-radius: 10px; cursor: pointer;
    background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.4); color: #fff;
  }
  header.app-header.has-burger .nav-burger:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
  .nav-burger .bars, .nav-burger .bars::before, .nav-burger .bars::after {
    display: block; width: 20px; height: 2px; background: #fff; border-radius: 2px; position: relative; transition: transform .18s, opacity .18s;
  }
  .nav-burger .bars::before, .nav-burger .bars::after { content: ""; position: absolute; left: 0; }
  .nav-burger .bars::before { top: -6px; } .nav-burger .bars::after { top: 6px; }
  header.app-header.nav-open .nav-burger .bars { background: transparent; }
  header.app-header.nav-open .nav-burger .bars::before { transform: translateY(6px) rotate(45deg); }
  header.app-header.nav-open .nav-burger .bars::after { transform: translateY(-6px) rotate(-45deg); }
  header.app-header.has-burger .nav { display: none; }
  header.app-header.has-burger.nav-open .nav {
    display: flex; flex-direction: column; flex-wrap: nowrap; gap: 2px; margin: 0;
    position: absolute; top: 100%; right: 8px; left: 8px; z-index: 200;
    background: #fff; border-radius: 12px; padding: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.25);
  }
  header.app-header.has-burger.nav-open .nav a {
    color: #1f2937; border: 0; border-radius: 8px; padding: 12px 14px; font-size: 1rem; white-space: normal;
  }
  header.app-header.has-burger.nav-open .nav a.active { background: #e7f4ee; color: #0b6e4f; font-weight: 700; box-shadow: inset 3px 0 0 #0b6e4f; }
  header.app-header.has-burger.nav-open .nav a:hover:not(.active) { background: #f3f4f6; }
  header.app-header.has-burger.nav-open .nav a.nav-logout { border-top: 1px solid #e5e7eb; border-radius: 0 0 8px 8px; margin: 4px 0 0; color: #b42318; text-align: left; }
}

/* Material purchase prompts */
.mat-prompt { display:flex; align-items:center; gap:12px 16px; border:2px solid #c80 !important; background:#fff6e0 !important; color:#7c4a03; }
.mat-prompt .mp-text { flex:1 1 auto; min-width:0; line-height:1.4; }
.mat-prompt .mp-actions { display:flex; align-items:center; gap:8px; flex:0 0 auto; }
.mat-prompt .mp-form { display:contents; margin:0; }
.mat-prompt .mp-btn { display:inline-flex; align-items:center; justify-content:center; box-sizing:border-box; height:38px; padding:0 16px; margin:0; border-radius:8px; font-size:.92rem; font-weight:600; line-height:1; white-space:nowrap; text-decoration:none; cursor:pointer; font-family:inherit; }
.mat-prompt .mp-primary { background:var(--accent); color:#fff; border:1px solid var(--accent); }
.mat-prompt .mp-secondary { background:#fff; color:var(--accent); border:1px solid var(--accent); }
.mat-prompt .mp-secondary:hover { background:var(--accent-soft); }
@media (max-width: 760px) {
  .mat-prompt { flex-direction:column; align-items:stretch; }
  .mat-prompt .mp-actions { flex-wrap:wrap; width:100%; }
  .mat-prompt .mp-btn { flex:1 1 0; min-width:0; padding:0 10px; height:42px; }
  .mat-prompt .mp-primary { flex-basis:100%; }
}

/* Unpaid subcontractor invoices panel */
.unpaid-panel { border:2px solid #c80 !important; background:#fff6e0 !important; color:#7c4a03; }
.unpaid-panel .unpaid-row { display:flex; align-items:center; gap:10px 16px; padding:10px 0; border-top:1px solid #f0d9a8; }
.unpaid-panel .card-title + .unpaid-row { border-top:0; }
.unpaid-panel .up-info { flex:1 1 auto; min-width:0; line-height:1.4; }
.unpaid-panel .up-form { display:flex; align-items:center; gap:8px; flex:0 0 auto; margin:0; }
.unpaid-panel .up-form input { box-sizing:border-box; height:38px; margin:0; padding:0 10px; border:1px solid #d9b46a; border-radius:8px; background:#fff; font-size:.95rem; font-family:inherit; }
.unpaid-panel .up-form input[name=check_no] { width:110px; }
.unpaid-panel .up-form input[type=date] { width:150px; }
.unpaid-panel .mp-btn { display:inline-flex; align-items:center; justify-content:center; box-sizing:border-box; height:38px; padding:0 16px; margin:0; border-radius:8px; font-size:.92rem; font-weight:600; line-height:1; white-space:nowrap; cursor:pointer; font-family:inherit; }
.unpaid-panel .mp-primary { background:var(--accent); color:#fff; border:1px solid var(--accent); }
@media (max-width: 760px) {
  .unpaid-panel .unpaid-row { flex-direction:column; align-items:stretch; }
  .unpaid-panel .up-form { flex-wrap:wrap; width:100%; }
  .unpaid-panel .up-form input { flex:1 1 0; min-width:0; height:42px; width:auto !important; }
  .unpaid-panel .mp-btn { flex-basis:100%; height:42px; }
}

/* Est. time per PO line (under Remaining) */
.line-est { font-size: 0.75em; font-weight: 500; color: var(--muted, #6b7280); white-space: nowrap; margin-top: 2px; cursor: help; }
.line-est.done { opacity: 0.6; }
.line-est.none { opacity: 0.7; }
.est-total-row td { text-align: right; padding-top: 8px; border-top: 1px solid var(--border, #e5e7eb); }
.est-total-row .meta { display: inline-block; margin-left: 6px; }

/* compact red outline delete (part page runs / estimate) */
button.danger-outline-btn { background: transparent; color: #b42318; border: 1px solid #b42318; border-radius: 4px; padding: 1px 7px; font-size: 0.8em; line-height: 1.5; cursor: pointer; }
button.danger-outline-btn:hover { background: #b42318; color: #fff; }
button.danger-outline-btn:disabled { opacity: .4; cursor: not-allowed; background: transparent; color: #b42318; }
.run-actions .danger-outline-btn { margin-left: 6px; }
.est-setting { margin: .5rem 0; }
.est-setting .inline-form { display: inline-block; margin-left: 6px; }
