:root {
  --navy: #1f3a5f;
  --green: #3d6b35;
  --burgundy: #6e1e2c;
  --ink: #20242b;
  --muted: #6b7280;
  --rule: #dfe2e7;
  --bg: #eef1f5;
  --card: #ffffff;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
}

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border-bottom: 2px solid var(--navy);
  padding: 10px 20px;
}
.topbar .brand { display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--navy); font-weight: 600; }
.topbar .brand img { height: 34px; }
.topbar nav { display: flex; align-items: center; gap: 16px; }
.topbar nav a { text-decoration: none; color: var(--navy); }

main { max-width: 1180px; margin: 24px auto; padding: 0 20px; }

/* ---- buttons ---- */
button, .btn-primary {
  font: inherit; cursor: pointer; border: 1px solid var(--navy);
  background: var(--card); color: var(--navy); border-radius: 6px;
  padding: 8px 14px;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: #16304f; }
.topbar nav a.btn-primary, .topbar nav a.btn-primary:hover { color: #fff; }
.btn-danger { border-color: var(--burgundy); color: var(--burgundy); }
.btn-add { margin-top: 8px; border-style: dashed; }
.btn-del { border: none; color: var(--burgundy); background: none;
  font-size: 18px; line-height: 1; padding: 2px 6px; }

/* ---- cards ---- */
.card {
  background: var(--card); border: 1px solid var(--rule); border-radius: 8px;
  padding: 16px 18px; margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 14px; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--navy); }

/* ---- login ---- */
.login-card {
  max-width: 360px; margin: 60px auto; background: var(--card);
  border: 1px solid var(--rule); border-radius: 10px; padding: 30px;
  text-align: center;
}
.login-logo { height: 70px; margin-bottom: 10px; }
.login-card h1 { font-size: 18px; margin: 6px 0; }
.login-card form { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.login-card input { padding: 10px; border: 1px solid var(--rule); border-radius: 6px; font: inherit; }

/* ---- list ---- */
.page-head { display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; margin: 0; }
.search { display: flex; gap: 8px; align-items: center; }
.search input { padding: 8px 10px; border: 1px solid var(--rule);
  border-radius: 6px; font: inherit; min-width: 240px; }
.search .clear { color: var(--muted); text-decoration: none; }

.list-table { width: 100%; border-collapse: collapse; background: var(--card);
  border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.list-table th, .list-table td { padding: 10px 12px; text-align: left;
  border-bottom: 1px solid var(--rule); }
.list-table th { background: var(--navy); color: #fff; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.5px; }
.list-table tbody tr:hover { background: #f6f8fb; }
.list-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 10px; }
.row-actions a { color: var(--navy); text-decoration: none; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 9px;
  color: #fff; font-size: 12px; text-transform: capitalize; background: var(--muted); }
.pill-ocean { background: var(--navy); }
.pill-air { background: var(--green); }

/* ---- list status + paid flags (inline edit) ---- */
.col-status .flag { flex-direction: row; align-items: center; gap: 6px;
  cursor: pointer; color: var(--ink); }
.col-status input, .col-paid input { width: auto; cursor: pointer; }
.status-pill { display: inline-block; padding: 1px 8px; border-radius: 9px;
  font-size: 11px; font-weight: 600; background: #e6e8ec; color: var(--muted); }
.status-pill.is-final { background: var(--green); color: #fff; }
.col-paid { white-space: nowrap; }
.col-paid .flag { display: inline-flex; flex-direction: row; align-items: center;
  gap: 4px; font-size: 12px; color: var(--muted); margin-right: 8px; cursor: pointer; }

.typo-warn { border-left: 4px solid var(--burgundy); }
.typo-warn h2 { color: var(--burgundy); }
.typo-list { margin: 8px 0 0; padding-left: 18px; font-size: 13px; }
.typo-list li { margin: 3px 0; }

.empty { text-align: center; padding: 50px; color: var(--muted); }
.empty .btn-primary { display: inline-block; margin-top: 12px; text-decoration: none; }

/* ---- form layout ---- */
.form-layout { display: grid; grid-template-columns: 1fr 340px; gap: 20px;
  align-items: start; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-2 .span-2 { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px;
  color: var(--muted); }
label input, label select, label textarea {
  font: inherit; color: var(--ink); padding: 8px 10px;
  border: 1px solid var(--rule); border-radius: 6px; background: #fff;
}
.checkline { flex-direction: row; align-items: center; gap: 8px; margin: 12px 0 4px;
  color: var(--ink); }
.checkline input { width: auto; }

/* ---- row tables ---- */
.rows-table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.rows-table th { font-size: 11px; text-transform: uppercase; color: var(--muted);
  text-align: left; padding: 4px 6px; letter-spacing: 0.4px; }
.rows-table th.num { text-align: right; }
.rows-table td { padding: 3px 6px; }
.rows-table input { width: 100%; padding: 6px 8px; border: 1px solid var(--rule);
  border-radius: 5px; font: inherit; }
.rows-table td.num input { text-align: right; }
.rows-table .num { text-align: right; }
.rows-table th.col-pending, .rows-table td.col-pending { text-align: center; width: 110px; }
.rows-table td.col-pending input { width: auto; padding: 0; }

/* ---- totals panel ---- */
.hint { font-size: 12px; color: var(--muted); margin: -4px 0 12px; }
.advanced { margin-top: 10px; }
.advanced summary { cursor: pointer; font-size: 13px; color: var(--navy); }
.advanced .grid-2 { margin-top: 10px; }
.reprice-row { display: flex; align-items: center; gap: 16px; margin-top: 14px;
  padding-top: 12px; border-top: 1px solid var(--rule); }
.reprice-row a { color: var(--navy); text-decoration: none; font-size: 13px; }

.totals-panel .sticky { position: sticky; top: 20px; }
.totals-basis { font-size: 11px; color: var(--navy); background: #eef2f8;
  border-radius: 5px; padding: 5px 8px; margin-bottom: 8px; text-align: center; }
.totals-counts { display: flex; justify-content: space-between; font-size: 12px;
  color: var(--muted); border-bottom: 1px solid var(--rule); padding-bottom: 8px; }
.totals-lines { margin: 8px 0; }
.tline { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0;
  font-size: 13px; }
.tline em { color: var(--muted); font-style: normal; font-size: 11px; }
.tline.credit { color: var(--green); }
.totals-grand { display: flex; justify-content: space-between; align-items: baseline;
  border-top: 2px solid var(--navy); padding-top: 8px; margin-top: 6px; }
.totals-grand strong { font-size: 20px; color: var(--burgundy);
  font-variant-numeric: tabular-nums; }
.totals-payment { margin-top: 8px; }
.tpay { display: flex; justify-content: space-between; align-items: baseline;
  padding: 3px 0; font-size: 13px; }
.tpay strong { font-variant-numeric: tabular-nums; color: var(--burgundy); }
.tpay.zelle strong { color: #2e7d32; }
.tpay-rate { font-size: 11px; color: var(--muted); text-align: right; }

.warnings { margin-top: 10px; }
.warn { background: #fff6f6; border-left: 3px solid var(--burgundy);
  padding: 6px 8px; font-size: 12px; margin-bottom: 6px; color: #7a2531; }
.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.actions button { width: 100%; }
.btn-finalize { border-color: var(--green); color: #fff; background: var(--green); }
.btn-finalize:hover { background: #335c2c; }
.finalized-state { font-size: 12px; font-weight: 600; color: var(--muted);
  margin-top: 14px; }
.finalized-state.is-final { color: var(--green); }
.save-status { margin-top: 8px; font-size: 12px; min-height: 16px; }

.muted { color: var(--muted); }
.error { background: #fff6f6; border: 1px solid var(--burgundy);
  color: var(--burgundy); padding: 8px; border-radius: 6px; font-size: 13px; }

/* ---- list sorting + filters ---- */
.search { flex-wrap: wrap; }
.search select { padding: 8px 10px; border: 1px solid var(--rule);
  border-radius: 6px; font: inherit; background: #fff; }
.search input[type="date"] { min-width: 0; }
.list-table th .sort-link { color: #fff; text-decoration: none; white-space: nowrap; }
.list-table th .sort-link:hover,
.list-table th .sort-link.active { text-decoration: underline; }

@media (max-width: 860px) {
  .form-layout { grid-template-columns: 1fr; }
  .totals-panel .sticky { position: static; }
}

/* "Load from BDD" — order# field inline button + status line */
.bdd-load { display: flex; gap: 6px; }
.bdd-load input { flex: 1; }
#btn-bdd-load { white-space: nowrap; flex: 0 0 auto; }
.bdd-status { display: block; margin-top: 4px; font-size: 12px; min-height: 1em; }
.bdd-status.ok { color: var(--green); }
.bdd-status.err { color: var(--burgundy); }

/* ---- "Start here" order-number card (step 1) ---- */
.card-start { border: 2px solid var(--navy); }
.card-start h2 { display: flex; align-items: center; gap: 8px; }
.step-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--navy); color: #fff; font-size: 13px; font-weight: 700;
}
.order-ref { display: block; font-weight: 600; }
.order-ref input { font-size: 18px; padding: 8px 10px; }
.caption {
  margin: 8px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--muted);
  border-left: 3px solid var(--navy); padding-left: 10px;
}

/* ---- required fields + validation visuals ---- */
.req > :first-child::after,
label.req::after { content: " *"; color: var(--burgundy); font-weight: 700; }
.field-invalid,
input.field-invalid {
  border: 2px solid var(--burgundy) !important;
  background: #fcebed !important;
  outline: none;
  box-shadow: 0 0 0 3px rgba(110, 30, 44, 0.15);
}
label.has-error { color: var(--burgundy); font-weight: 600; }
#payment-card.bypassed { opacity: 0.55; }
#payment-card.bypassed .req::after { content: ""; }
.bypass-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  margin-left: 8px; font-size: 12px; color: var(--navy); cursor: pointer;
}

/* ---- new-supplier-name highlight (verify, not an error) ---- */
input.supplier-new {
  border: 2px solid #c9a227 !important;   /* brand gold = "verify this" */
  background: #fdf6e3 !important;
  box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.18);
}
.bdd-status.warn-status { color: #8a6d1e; font-weight: 600; }

/* purchases table: fixed layout -> exact, equal columns + top-aligned grid */
#purchases { table-layout: fixed; }
#purchases td { vertical-align: top; }              /* inputs line up at the top, regardless of the BDD subtext height */
#purchases th { white-space: nowrap; font-size: 10px; letter-spacing: 0.3px;
  vertical-align: bottom; padding-bottom: 5px; }    /* headers on one line, sitting just above the inputs */
#purchases th:nth-child(1), #purchases td:nth-child(1) { width: 30%; }   /* retailer */
#purchases th:nth-child(2), #purchases td:nth-child(2),
#purchases th:nth-child(3), #purchases td:nth-child(3),
#purchases th:nth-child(4), #purchases td:nth-child(4) { width: 72px; text-align: center; }  /* bottles/magnums/jeroboams — equal, centered */
#purchases td:nth-child(2) input, #purchases td:nth-child(3) input,
#purchases td:nth-child(4) input { width: 60px; text-align: center; }  /* narrow box, centered in its column */
#purchases th:nth-child(5), #purchases td:nth-child(5) { width: 18%; }   /* wine value HT — readable */

/* BDD ground-truth reference under a retailer field (which supplier this row is) */
.bdd-ref { font-size: 10.5px; color: var(--muted); margin-top: 3px; line-height: 1.3; }
/* supplier-alias edit form (inline name + save) */
.alias-edit { display: flex; gap: 6px; align-items: center; }
.alias-edit input[type="text"] { flex: 1; min-width: 180px; padding: 5px 7px;
  border: 1px solid var(--rule); border-radius: 5px; }
