:root {
  --bg: #1d1d1b;            /* BIG MAX black */
  --panel: #ffffff;
  --ink: #1d1d1b;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #e30613;       /* BIG MAX red */
  --accent-hover: #c20510;
  --accent-ink: #ffffff;
  --good: #16a34a;
  --warn: #d97706;
  --over: #dc2626;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.45 system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: #f1f5f9;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--over); min-height: 1.2em; margin: .4em 0 0; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--bg); }
.login-card {
  background: var(--panel); padding: 32px; border-radius: 14px;
  width: 320px; max-width: calc(100vw - 32px);
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
.login-card input { font-size: 16px; } /* >=16px avoids iOS focus-zoom */
.login-logo { display: block; width: 180px; max-width: 100%; height: auto; margin: 0 0 18px; }
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card input {
  width: 100%; padding: 11px 12px; margin-top: 14px; border: 1px solid var(--line);
  border-radius: 9px; font-size: 15px;
}
.login-card button {
  width: 100%; margin-top: 14px; padding: 11px; border: 0; border-radius: 9px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer;
}

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 17px; }
.brand-logo { height: 30px; width: auto; display: block; }
.brand-title { white-space: nowrap; }
.controls { display: flex; align-items: end; gap: 14px; flex-wrap: wrap; }
.controls label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; }
.controls select, .controls input {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; min-width: 200px;
}
.controls .search-field input { min-width: 260px; }
.controls button {
  padding: 9px 14px; border: 0; border-radius: 8px; background: var(--accent);
  color: var(--accent-ink); font-weight: 600; cursor: pointer;
}
.controls button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.controls button:not(.ghost):hover, .login-card button:hover { background: var(--accent-hover); }

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

/* Company footer */
.site-footer { border-top: 1px solid var(--line); background: var(--panel); margin-top: 24px; }
.footer-inner {
  max-width: 1200px; margin: 0 auto; padding: 20px;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}
.footer-logo { height: 40px; width: auto; display: block; }
.footer-company { display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; color: var(--muted); }
.footer-company strong { color: var(--ink); font-size: 13.5px; }
.footer-company a { color: var(--accent); text-decoration: none; }
.footer-company a:hover { text-decoration: underline; }

/* Summary */
.summary { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 16px; min-width: 150px;
}
.card .label { font-size: 12px; color: var(--muted); }
.card .value { font-size: 20px; font-weight: 700; margin-top: 2px; }
.fill .bar { height: 7px; border-radius: 99px; background: var(--line); margin-top: 8px; overflow: hidden; }
.fill .bar > i { display: block; height: 100%; background: var(--good); }
.fill.warn .bar > i { background: var(--warn); }
.fill.over .bar > i { background: var(--over); }
.fill .pct { font-variant-numeric: tabular-nums; }

/* Table */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
thead th { background: #f8fafc; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); position: sticky; top: 0; }
tbody tr:hover { background: #f8fafc; }
td input.qty {
  width: 84px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px;
  text-align: right; font-size: 16px; font-variant-numeric: tabular-nums;
}
td.calc { color: var(--muted); }
td.calc.active { color: var(--ink); font-weight: 600; }

/* ---------------------------------------------------------------- mobile */
@media (max-width: 640px) {
  main { padding: 12px; }

  /* Top bar: stack controls full-width with comfortable tap targets */
  .topbar { padding: 10px 12px; gap: 10px; }
  .brand { width: 100%; }
  .controls { width: 100%; gap: 10px; }
  .controls label { width: 100%; }
  .controls select, .controls input { width: 100%; min-width: 0; font-size: 16px; padding: 11px 12px; }
  .controls button { flex: 1 1 auto; min-height: 44px; }
  .controls button.ghost { flex: 0 0 auto; }

  /* Summary: two readable cards per row */
  .summary { gap: 10px; }
  .summary .card { flex: 1 1 calc(50% - 10px); min-width: 0; }

  /* Table -> stacked cards (one product per card) */
  .table-wrap { background: transparent; border: 0; border-radius: 0; overflow: visible; }
  #products thead { display: none; }
  #products, #products tbody, #products tr, #products td { display: block; width: 100%; }
  #products tr {
    background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
    margin: 0 0 12px; padding: 10px 14px;
  }
  #products tr:hover { background: var(--panel); }
  #products td {
    border: 0; padding: 6px 0; display: flex; align-items: center;
    justify-content: space-between; gap: 12px; text-align: right;
  }
  #products td::before {
    content: attr(data-label); color: var(--muted); font-size: 12px;
    text-transform: uppercase; letter-spacing: .03em; text-align: left;
  }
  /* Item name as the card title (no label, full width) */
  #products td.cell-item {
    font-size: 16px; font-weight: 700; padding-bottom: 8px; margin-bottom: 4px;
    border-bottom: 1px solid var(--line); display: block; text-align: left;
  }
  #products td.cell-item::before { display: none; }
  /* Make the qty entry the prominent action */
  #products td.cell-qty { padding: 8px 0; }
  #products td.cell-qty::before { font-weight: 600; color: var(--ink); }
  #products td input.qty { width: 130px; padding: 10px 12px; }
}

/* Print area (screen-hidden) */
#print-area { display: none; }

@media print {
  body { background: #fff; }
  #login, #app, #site-footer { display: none !important; }
  #print-area { display: block !important; padding: 0; }
  .po-head {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding-bottom: 12px; margin-bottom: 14px; border-bottom: 2px solid #1d1d1b;
  }
  .po-logo { height: 46px; width: auto; }
  .po-head-co { text-align: right; font-size: 10.5px; line-height: 1.35; color: #333; }
  .po-head-co strong { display: block; color: #000; font-size: 11.5px; }
  .po-h1 { font-size: 22px; margin: 0 0 4px; }
  .po-foot {
    margin-top: 22px; padding-top: 10px; border-top: 1px solid #ccc;
    font-size: 9.5px; color: #555; text-align: center;
  }
  .po-meta { margin: 0 0 16px; color: #333; }
  .po-meta div { margin: 2px 0; }
  table.po { width: 100%; border-collapse: collapse; }
  table.po th, table.po td { border: 1px solid #999; padding: 6px 9px; text-align: left; }
  table.po th.num, table.po td.num { text-align: right; }
  .po-tot td { font-weight: 700; }
  .po-fill { margin-top: 14px; }
}
