/* HaulPilot app styles */
:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #f97316;
  --brand-dark: #ea580c;
  --navy: #0b1730;
  --good: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 12px;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; }
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1rem 0 .5rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.center { text-align: center; }
.mt { margin-top: 1.5rem; }
.nowrap { white-space: nowrap; }
.lane { min-width: 190px; }
.link.left { align-self: flex-start; font-weight: 600; }
td { min-width: 0; }

/* top + shell */
.app-top { height: 56px; background: var(--navy); color: #fff; display: flex; align-items: center; gap: 1rem; padding: 0 1rem; position: sticky; top: 0; z-index: 10; }
.brand { color: #fff; font-weight: 700; display: flex; align-items: center; gap: .5rem; font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.who { margin-left: auto; font-size: .9rem; color: #cbd5e1; }
.who a { color: #fdba74; }
.nav-toggle { display: none; background: none; border: 0; color: #fff; font-size: 1.4rem; cursor: pointer; }
.app-shell { display: flex; min-height: calc(100vh - 56px); }
.side { width: 210px; background: var(--navy); padding: 1rem .75rem; display: flex; flex-direction: column; gap: 2px; flex-shrink: 0; }
.side a { color: #cbd5e1; padding: .6rem .85rem; border-radius: 8px; font-weight: 500; }
.side a:hover { background: #15264a; color: #fff; text-decoration: none; }
.side a.on { background: var(--brand); color: #fff; }
.content { flex: 1; padding: 1.5rem; max-width: 1280px; min-width: 0; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .6rem 1rem; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { text-decoration: none; border-color: #cbd5e1; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.block { width: 100%; }
.link { background: none; border: 0; padding: 0; color: var(--brand-dark); font: inherit; cursor: pointer; }
.link:hover { text-decoration: underline; }
.danger { color: var(--bad); }

/* forms */
.form label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .85rem; margin-bottom: .85rem; }
.form input, .form select, .form textarea { font: inherit; font-weight: 400; padding: .6rem .7rem; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; width: 100%; }
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid #fed7aa; border-color: var(--brand); }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1rem; }
.span-3 { grid-column: 1 / -1; }
.form-actions { grid-column: 1 / -1; display: flex; gap: .5rem; margin-top: .25rem; }

.auth-card { max-width: 420px; margin: 3rem auto; background: #fff; padding: 2rem; border-radius: var(--radius); border: 1px solid var(--line); }
.auth-card h1 { margin-bottom: .25rem; }

/* flash */
.flash { padding: .8rem 1rem; border-radius: 8px; margin-bottom: 1rem; background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash.bad { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

/* tables */
.table-wrap { overflow-x: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .7rem 1rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #f8fafc; }
.card > table th:first-child { border-top-left-radius: var(--radius); }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.pos { color: var(--good); font-weight: 600; }
.neg { color: var(--bad); font-weight: 600; }
.actions { text-align: right; min-width: 120px; }
.actions > * { display: inline-block; margin: 0 0 .2rem .6rem; white-space: nowrap; }
.actions form { display: inline; }
.empty { padding: 1.5rem; color: var(--muted); margin: 0; }
.inline { margin: 0; }

.pill, .badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: #f1f5f9; color: #334155; }
.pill.good { background: #dcfce7; color: #166534; }
.pill.warn { background: #fef3c7; color: #92400e; }
.pill.bad { background: #fee2e2; color: #991b1b; }
.s-booked { background: #e0e7ff; color: #3730a3; }
.s-dispatched { background: #dbeafe; color: #1e40af; }
.s-in_transit { background: #fef3c7; color: #92400e; }
.s-delivered { background: #dcfce7; color: #166534; }
.s-invoiced { background: #f3e8ff; color: #6b21a8; }
.s-paid { background: #d1fae5; color: #065f46; }
.s-cancelled { background: #f1f5f9; color: #64748b; }
.status-select { border: 0; border-radius: 999px; padding: .25rem .5rem; font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; }

.filters { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .9rem; }
.filters a { padding: .35rem .8rem; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--ink); font-size: .85rem; }
.filters a.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.filters a:hover { text-decoration: none; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .2rem; }
.kpi span { color: var(--muted); font-size: .8rem; font-weight: 600; }
.kpi strong { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.kpi em { font-style: normal; font-size: .8rem; color: var(--muted); }
.kpi.alert { border-color: #fdba74; background: #fff7ed; }

.dash-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 1.25rem; }
.dash-grid .card table th:first-child, .dash-grid .card table td:first-child { padding-left: 0; }
.alerts { list-style: none; padding: 0; margin: 0; }
.alerts li { display: flex; justify-content: space-between; gap: 1rem; padding: .6rem .75rem; border-radius: 8px; margin-bottom: .4rem; font-size: .9rem; }
.alerts li.warn { background: #fffbeb; }
.alerts li.bad { background: #fef2f2; }
.alerts li span { color: var(--muted); white-space: nowrap; }
.bars { list-style: none; margin: 0; padding: 0; }
.bars li { display: grid; grid-template-columns: 60px 1fr 90px; align-items: center; gap: .6rem; margin-bottom: .5rem; font-size: .88rem; }
.bars i { display: block; height: 10px; border-radius: 999px; background: var(--brand); min-width: 4px; }
.bars i.neg { background: var(--bad); }
.bars b { text-align: right; font-variant-numeric: tabular-nums; }
.onboarding ol { margin: 0; padding-left: 1.2rem; line-height: 2; }

/* load form */
.load-grid { display: grid; grid-template-columns: 1fr 300px; gap: 1.5rem; }
.load-grid h3:first-child { margin-top: 0; }
.profit-box { background: var(--navy); color: #e2e8f0; border-radius: var(--radius); padding: 1.25rem; align-self: start; position: sticky; top: 72px; }
.profit-box h3 { color: #fdba74; margin-top: 0; }
.profit-box dl { display: grid; grid-template-columns: 1fr auto; gap: .45rem 1rem; margin: 0; }
.profit-box dt { color: #94a3b8; font-size: .88rem; }
.profit-box dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.profit-box .total { border-top: 1px solid #1e335e; padding-top: .55rem; font-size: 1.1rem; color: #fff; }
.profit-box dd.total.good { color: #4ade80; }
.profit-box dd.total.bad { color: #f87171; }
.verdict { margin: 1rem 0 0; padding: .7rem; border-radius: 8px; background: #15264a; font-size: .88rem; }
.verdict.good { background: #14532d; color: #dcfce7; }
.verdict.warn { background: #713f12; color: #fef3c7; }
.verdict.bad { background: #7f1d1d; color: #fee2e2; }

/* invoice */
.invoice-page { background: #e2e8f0; }
.invoice-bar { max-width: 800px; margin: 1.5rem auto 0; display: flex; justify-content: space-between; align-items: center; }
.invoice { max-width: 800px; margin: 1rem auto 3rem; background: #fff; padding: 3rem; border-radius: 4px; }
.invoice header { display: flex; justify-content: space-between; border-bottom: 3px solid var(--brand); padding-bottom: 1rem; margin-bottom: 1.5rem; }
.invoice h1 { font-size: 1.5rem; }
.invoice h2 { font-size: 1.6rem; letter-spacing: .1em; color: var(--brand-dark); margin: 0; }
.invoice .right { text-align: right; }
.invoice .right p { margin: .2rem 0; }
.invoice table { margin: 1.5rem 0; }
.invoice tfoot th { font-size: 1.05rem; color: var(--ink); background: #fff7ed; }
.bill-to h3 { margin-top: 0; }
.paid-stamp { color: var(--good); font-weight: 800; border: 2px solid var(--good); display: inline-block; padding: .2rem .6rem; transform: rotate(-4deg); }
@media print {
  .no-print { display: none !important; }
  .invoice-page { background: #fff; }
  .invoice { margin: 0; padding: 0; }
}

/* licensing */
.license-bar { padding: .8rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; font-size: .92rem; }
.license-bar.warn { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.license-bar.bad { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.license-bar a { font-weight: 600; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.25rem; margin: 0 0 1rem; }
.facts dt { color: var(--muted); font-size: .88rem; }
.facts dd { margin: 0; font-weight: 600; }
.app.admin .app-top { background: #1e1b4b; }
.app.admin .side { background: #1e1b4b; }
.app.admin .side a:hover { background: #312e81; }
.tag-admin { background: var(--brand); color: #fff; font-size: .7rem; font-weight: 700; padding: .1rem .45rem; border-radius: 6px; letter-spacing: .04em; }
.quick { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .85rem; }
.secret { font-family: ui-monospace, Menlo, monospace; background: #fff; border: 1px dashed #a7f3d0; padding: .1rem .4rem; border-radius: 6px; user-select: all; }
.btn.sm { padding: .35rem .7rem; font-size: .82rem; }
.table-wrap > h2 { padding: 1rem 1rem 0; }
.filters .push { margin-left: auto; }
.filters .search { font: inherit; font-size: .85rem; padding: .35rem .8rem; border: 1px solid var(--line); border-radius: 999px; background: #fff; min-width: 220px; }
.admin-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 1.25rem; align-items: start; }

/* responsive */
@media (max-width: 900px) {
  .load-grid, .dash-grid, .btn.sm { padding: .35rem .7rem; font-size: .82rem; }
.table-wrap > h2 { padding: 1rem 1rem 0; }
.filters .push { margin-left: auto; }
.filters .search { font: inherit; font-size: .85rem; padding: .35rem .8rem; border: 1px solid var(--line); border-radius: 999px; background: #fff; min-width: 220px; }
.admin-grid { grid-template-columns: 1fr; }
  .profit-box { position: static; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .nav-toggle { display: block; }
  .who { display: none; }
  .side { position: fixed; top: 56px; left: 0; bottom: 0; transform: translateX(-100%); transition: transform .2s; z-index: 9; }
  .nav-open .side { transform: none; }
  .content { padding: 1rem; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
