/* South County Auto V3 — one stylesheet, no frameworks. Mobile first. */
:root {
  --red: #B3262D; --red-dark: #8E1D23; --ink: #1E1F22; --muted: #6B6F76; --line: #E3E3E0;
  --bg: #F6F6F4; --card: #FFFFFF; --ok: #2F7D4A; --warn: #B7791F; --bad: #B3262D;
  --radius: 10px; --pad: 14px;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.4; }
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; margin: 0 0 4px; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* top bar */
.topbar { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 10; }
.topbar .inner { display: flex; align-items: center; gap: 12px; padding: 8px var(--pad); max-width: 1200px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 700; white-space: nowrap; }
.brand img { width: 30px; height: 30px; background: #fff; border-radius: 50%; }
.topbar form { flex: 1; }
.topbar input[type=search] { width: 100%; padding: 8px 12px; border-radius: 20px; border: 0; font-size: 15px; }
.nav { display: flex; gap: 2px; overflow-x: auto; background: #2A2C30; padding: 0 var(--pad); }
.nav a { color: #D9D9D9; padding: 10px 12px; white-space: nowrap; font-size: .92rem; }
.nav a.on, .nav a:hover { color: #fff; text-decoration: none; box-shadow: inset 0 -3px 0 var(--red); }
.sandbox { background: #FFF3CD; color: #7A5A00; text-align: center; font-size: .8rem; padding: 3px; }

main { max-width: 1200px; margin: 0 auto; padding: var(--pad); }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--pad); margin-bottom: 14px; }
.grid { display: grid; gap: 14px; margin-bottom: 14px; }
.grid > .card { margin-bottom: 0; }
@media (min-width: 800px) { .grid.two { grid-template-columns: 1fr 1fr; } .grid.three { grid-template-columns: repeat(3, 1fr); } }

.stat { font-size: 1.6rem; font-weight: 700; }
.stat-label { color: var(--muted); font-size: .85rem; }

/* buttons & forms */
.btn { display: inline-block; padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff;
       color: var(--ink); font-size: .95rem; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { text-decoration: none; border-color: #bbb; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dark); }
.btn.small { padding: 5px 9px; font-size: .85rem; }
.btn.link { border: 0; background: none; color: var(--red); padding: 4px; }
label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 3px; }
input, select, textarea { width: 100%; padding: 9px 10px; border: 1px solid #CFCFCB; border-radius: 8px; font: inherit; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(179, 38, 45, .25); border-color: var(--red); }
textarea { min-height: 70px; }
.fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.fields .wide { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-size: .95rem; color: var(--ink); }
.check input { width: auto; }

/* tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding: 8px 6px; }
.table td { border-bottom: 1px solid var(--line); padding: 9px 6px; vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: #FAFAF7; }
.scroll { overflow-x: auto; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 12px; font-size: .78rem; font-weight: 600; background: #EEE; color: #555; }
.pill.paid, .pill.approved, .pill.converted { background: #E3F2E8; color: var(--ok); }
.pill.partial, .pill.sent { background: #FDF1DC; color: var(--warn); }
.pill.unpaid, .pill.declined { background: #FBE4E4; color: var(--bad); }
.pill.void { background: #EEE; color: #888; text-decoration: line-through; }

.flash { background: #E3F2E8; color: var(--ok); border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; }
.error { background: #FBE4E4; color: var(--bad); border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; }

/* totals */
.totals { margin-left: auto; max-width: 320px; }
.totals div { display: flex; justify-content: space-between; padding: 3px 0; }
.totals .grand { font-weight: 700; font-size: 1.15rem; border-top: 1px solid var(--ink); margin-top: 4px; padding-top: 6px; }
.profit { font-size: .85rem; color: var(--muted); border-top: 1px dashed var(--line); margin-top: 8px; padding-top: 6px; }

/* line editor: table on desktop, stacked cards on phone */
.lines { width: 100%; border-collapse: collapse; }
.lines th { font-size: .78rem; color: var(--muted); text-align: left; padding: 4px; }
.lines td { padding: 4px; vertical-align: top; }
.lines input, .lines select { padding: 7px; font-size: .92rem; }
.lines .num { width: 90px; }
.lines .qty { width: 64px; }
.lines .out { text-align: right; padding-top: 12px; white-space: nowrap; font-weight: 600; }
.lines .tools { white-space: nowrap; padding-top: 6px; }
.lines .tools button { border: 0; background: none; cursor: pointer; font-size: 1rem; padding: 2px 4px; color: var(--muted); }
.lines .tools button:hover { color: var(--red); }
@media (max-width: 760px) {
  .lines thead { display: none; }
  .lines tr { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-bottom: 10px; background: #FCFCFB; }
  .lines td { padding: 0; }
  .lines td[data-l]::before { content: attr(data-l); display: block; font-size: .72rem; color: var(--muted); }
  .lines td.desc { grid-column: 1 / -1; }
  .lines .num, .lines .qty { width: 100%; }
  .lines .out { text-align: left; padding-top: 0; }
}
.footer-bar { position: sticky; bottom: 0; background: rgba(246, 246, 244, .96); border-top: 1px solid var(--line);
              padding: 10px var(--pad); display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 0 calc(-1 * var(--pad)); }
.history .job { border-left: 3px solid var(--line); padding: 4px 0 4px 12px; margin: 10px 0; }
.login { max-width: 360px; margin: 10vh auto; text-align: center; }
.login img { width: 110px; }
@media (max-width: 640px) {
  .hide-sm { display: none; }
  .fields { grid-template-columns: 1fr 1fr; }
  .fields > .wide, .fields > .check { grid-column: 1 / -1; }
  .table td, .table th { padding: 8px 4px; font-size: .9rem; }
  h1 { font-size: 1.2rem; }
}
.split { display: grid; gap: 14px; align-items: start; }
.receipt-view { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 8px; object-fit: contain; }
@media (min-width: 900px) {
  .split { grid-template-columns: minmax(320px, 42%) 1fr; }
  .split > aside { position: sticky; top: 130px; margin-bottom: 0; }
  .receipt-view { height: calc(100vh - 260px); }
}
@media print { .topbar, .nav, .actions, .sandbox { display: none; } }

/* receipt review */
.tabs { display: flex; gap: 6px; margin: 10px 0; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: inherit; }
.tabs a.on { background: var(--ink, #222); color: #fff; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.approve { background: #E3F4E8; color: #1D6B36; }
.pill.skip { background: #F1F1F1; color: #555; }
.pill.ask { background: #FFF1D6; color: #8A5A00; }
.card.flag { border-left: 4px solid #E0A100; }
dialog.card { max-width: 420px; width: 90vw; }
