:root {
  --navy: #0f2a47; --navy2: #173d66; --gold: #d4a017; --gold2: #f3d27a;
  --cream: #fff6dc; --cream-b: #e8d79a; --ink: #1b2430; --mute: #5b6676;
  --line: #e3e7ee; --bg: #f4f6fa; --green: #1f8a5b; --red: #c0392b; --blue: #2b6cb0;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.45; -webkit-tap-highlight-color: transparent; }
a { color: var(--blue); text-decoration: none; }
h1, h2, h3 { color: var(--navy); margin: 0 0 8px; line-height: 1.2; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
.hidden { display: none !important; }
.mute { color: var(--mute); } .small { font-size: 13px; }
.ok { color: var(--green); } .bad { color: var(--red); }
.right { text-align: right; } .center { text-align: center; }
.row { display: flex; gap: 8px; align-items: center; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }

/* layout */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--navy); color: #fff; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.topbar .t { font-weight: 800; font-size: 16px; }
.topbar .s { font-size: 12px; color: var(--gold2); }
.topbar .back { color: #fff; font-size: 22px; padding: 0 6px 0 0; background: none; border: 0; cursor: pointer; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--gold); color: var(--navy); font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 13px; border: 0; cursor: pointer; }
main { padding: 14px 14px 90px; max-width: 980px; margin: 0 auto; }
.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); display: flex; justify-content: space-around; padding: 6px 0 calc(6px + env(safe-area-inset-bottom)); z-index: 10; }
.bottomnav a { color: var(--mute); font-size: 11px; text-align: center; flex: 1; padding: 2px 0; }
.bottomnav a i { display: block; font-style: normal; font-size: 20px; line-height: 1.2; }
.bottomnav a.on { color: var(--navy); font-weight: 800; }
.fab { position: fixed; right: 18px; bottom: 76px; width: 56px; height: 56px; border-radius: 50%; background: var(--gold); color: var(--navy); font-size: 30px; font-weight: 800; border: 0; box-shadow: 0 4px 14px rgba(0,0,0,.25); cursor: pointer; z-index: 11; display: flex; align-items: center; justify-content: center; }
@media (min-width: 900px) { .fab { right: calc(50% - 470px); } }

/* cards */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.card + .card { margin-top: 10px; }
.card h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .4px; }
.card.gold { background: #fffbef; border-color: var(--gold2); }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.kpi .l { font-size: 11px; color: var(--mute); text-transform: uppercase; letter-spacing: .4px; }
.kpi .v { font-size: 22px; font-weight: 800; color: var(--navy); }
.kpi .v.ok { color: var(--green); } .kpi .v.bad { color: var(--red); }
.sec { font-size: 12px; font-weight: 700; color: var(--mute); text-transform: uppercase; letter-spacing: .5px; margin: 16px 0 8px; }

/* lists */
.list { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); color: inherit; cursor: pointer; }
.item:last-child { border-bottom: 0; }
.item:hover { background: #fafbfd; }
.item .n { font-weight: 700; }
.item .d { font-size: 13px; color: var(--mute); }
.empty { padding: 24px; text-align: center; color: var(--mute); }
.line { display: flex; justify-content: space-between; padding: 4px 0; }
.line.tot { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 8px; font-weight: 800; }
.bar { height: 7px; border-radius: 4px; background: #e9edf3; overflow: hidden; margin: 3px 0 8px; }
.bar i { display: block; height: 100%; background: var(--navy2); }

/* pills */
.pill { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 20px; white-space: nowrap; }
.st-received_ny { background: #e6eefb; color: var(--blue); }
.st-in_transit_rd { background: #e6eefb; color: var(--blue); }
.st-border { background: #fdf1d6; color: #9a6b00; }
.st-boat { background: #fdf1d6; color: #9a6b00; }
.st-depot { background: #efe6fb; color: #6b3fa0; }
.st-delivered { background: #e6f4ec; color: var(--green); }
.st-cancelled { background: #eee; color: #777; }

/* forms */
label { display: block; font-size: 12px; color: var(--mute); margin: 8px 0 3px; font-weight: 600; }
input, select, textarea { width: 100%; font: inherit; padding: 10px 11px; border: 1px solid var(--cream-b); background: var(--cream); border-radius: 8px; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 0; }
input.auto, .auto { background: #e9f5ec; border-color: #bfe0c9; font-weight: 700; }
input.plain, select.plain { background: #fff; border-color: var(--line); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
@media (min-width: 800px) { .cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; } .cols2 > .card + .card { margin-top: 0; } }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 700; padding: 11px 16px; border-radius: 8px; border: 1px solid var(--navy); background: var(--navy); color: #fff; cursor: pointer; text-align: center; }
.btn:disabled { opacity: .55; cursor: wait; }
.btn.block { width: 100%; }
.btn.o { background: #fff; color: var(--navy); }
.btn.g { background: #25a35a; border-color: #25a35a; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--navy); }
.btn.sm { padding: 7px 11px; font-size: 13px; }
.btn.danger { background: #fff; color: var(--red); border-color: var(--red); }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.x { background: none; border: 0; color: var(--red); font-size: 20px; cursor: pointer; padding: 4px 6px; }

/* items table in form */
.itemrow { display: grid; grid-template-columns: 56px 1fr 84px 76px 30px; gap: 6px; align-items: center; margin-bottom: 6px; }
.itemrow input { padding: 8px; }
.itemrow .tot { font-weight: 700; text-align: right; font-size: 14px; }
.itemhead { display: grid; grid-template-columns: 56px 1fr 84px 76px 30px; gap: 6px; font-size: 11px; color: var(--mute); margin-bottom: 4px; }

/* contact picker */
.picker { position: relative; }
.suggest { position: absolute; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.12); z-index: 5; max-height: 240px; overflow: auto; }
.suggest div { padding: 9px 11px; border-bottom: 1px solid var(--line); cursor: pointer; }
.suggest div:hover { background: #fafbfd; }
.chosen { display: flex; justify-content: space-between; align-items: center; background: #e9f5ec; border: 1px solid #bfe0c9; border-radius: 8px; padding: 9px 11px; }

/* timeline */
.tl { position: relative; padding-left: 22px; }
.tl .e { position: relative; padding-bottom: 14px; }
.tl .e::before { content: ""; position: absolute; left: -19px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--green); }
.tl .e::after { content: ""; position: absolute; left: -14px; top: 17px; width: 2px; height: calc(100% - 14px); background: #bfe0c9; }
.tl .e:last-child::after { display: none; }
.tl .e.cur::before { background: var(--gold); box-shadow: 0 0 0 4px #fdf1d6; }
.tl .e.fut { color: #9aa4b2; } .tl .e.fut::before { background: #cfd6e0; } .tl .e.fut::after { background: #e3e7ee; }
.tl .e b { display: block; }
.tl .e span { font-size: 13px; color: var(--mute); }

/* table */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; color: var(--mute); font-weight: 700; padding: 8px 6px; border-bottom: 2px solid var(--line); }
td { padding: 8px 6px; border-bottom: 1px solid var(--line); }

/* toast */
#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 14px; z-index: 50; max-width: 90vw; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
#toast.err { background: var(--red); }

/* auth */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, var(--navy), #0b1f36); }
.auth .box { background: #fff; border-radius: 14px; padding: 22px; width: 100%; max-width: 380px; }
.auth img { width: 100%; max-width: 380px; border-radius: 10px; margin-bottom: 16px; }

/* print invoice */
#print { display: none; }
@media print {
  body { background: #fff; }
  body > *:not(#print) { display: none !important; }
  #print { display: block; padding: 10px; font-size: 13px; }
  #print img.logo { width: 100%; max-height: 120px; object-fit: contain; background: #0f2a47; border-radius: 6px; }
  #print table { font-size: 12px; }
  @page { margin: 12mm; }
}
