:root {
  --brand: #0f766e; --brand-dark: #115e59; --brand-soft: #ccfbf1;
  --bg: #f4f7f6; --card: #fff; --text: #1f2937; --muted: #6b7280; --line: #e5e7eb;
  --red: #dc2626; --red-soft: #fee2e2; --amber: #b45309; --amber-soft: #fef3c7;
  --green: #15803d; --green-soft: #dcfce7; --blue: #1d4ed8; --blue-soft: #dbeafe;
  --radius: 10px; --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--brand); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; }
.loading { padding: 3rem; text-align: center; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: .85rem; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.grid { display: grid; gap: .8rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* buttons & inputs */
button, .btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--text); padding: .5rem .9rem; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
button:hover, .btn:hover { border-color: #cbd5e1; background: #f9fafb; }
.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.danger { color: var(--red); border-color: #fecaca; }
.danger:hover { background: var(--red-soft); }
.danger-fill { background: var(--red); border-color: var(--red); }
.danger-fill:hover { background: #b91c1c; border-color: #b91c1c; }
.wa { background: #16a34a; border-color: #16a34a; color: #fff; }
.wa:hover { background: #15803d; }
.sm { padding: .3rem .6rem; font-size: .85rem; }
.lg { padding: .75rem 1.3rem; font-size: 1.05rem; }
button:disabled { opacity: .55; cursor: default; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
input, select, textarea { font: inherit; width: 100%; padding: .5rem .65rem; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
textarea { min-height: 70px; resize: vertical; }
.field { margin-bottom: .75rem; }
.check { display: flex; gap: .5rem; align-items: center; color: var(--text); font-size: .95rem; }
.check input, input[type=checkbox], input[type=radio] { width: auto; }
.err { color: var(--red); font-size: .9rem; min-height: 1.2em; }

/* cards & tables */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .55rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f9fafb; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: #f9fafb; }
.empty { padding: 2rem; text-align: center; color: var(--muted); }

/* chips */
.chip { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: #f3f4f6; color: #374151; white-space: nowrap; }
.chip.red { background: var(--red-soft); color: var(--red); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.blue { background: var(--blue-soft); color: var(--blue); }
.chip.teal { background: var(--brand-soft); color: var(--brand-dark); }
.tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .8rem; }
.tabs button { border-radius: 999px; padding: .35rem .8rem; font-size: .9rem; }
.tabs button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.tabs .count { background: rgba(0,0,0,.08); border-radius: 999px; padding: 0 .4rem; font-size: .78rem; }

/* staff layout */
.topbar { background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-in { max-width: 1200px; margin: 0 auto; padding: .55rem 1rem; display: flex; align-items: center; gap: 1rem; }
.brand { font-weight: 700; font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; color: #fff; text-decoration: none; }
.logo { width: 28px; height: 28px; border-radius: 7px; background: #fff; display: grid; place-items: center; flex: none; }
.logo svg { width: 18px; height: 18px; }
.nav { display: flex; gap: .2rem; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav a { color: #d1fae5; text-decoration: none; padding: .4rem .7rem; border-radius: 7px; white-space: nowrap; font-size: .95rem; position: relative; }
.nav a.on, .nav a:hover { background: rgba(255,255,255,.15); color: #fff; }
.badge { background: #f59e0b; color: #fff; border-radius: 999px; font-size: .72rem; padding: 0 .38rem; margin-left: .25rem; font-weight: 700; }
.topbar .who { font-size: .85rem; color: #d1fae5; white-space: nowrap; }
.topbar button { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }
.topbar button:hover { background: rgba(255,255,255,.12); }
main { max-width: 1200px; margin: 0 auto; padding: 1.2rem 1rem 3rem; }
.page-head { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.warn-banner { background: var(--amber-soft); color: var(--amber); padding: .6rem 1rem; text-align: center; font-size: .9rem; }

/* dashboard tiles */
.tile { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; text-decoration: none; color: var(--text); display: block; box-shadow: var(--shadow); }
.tile:hover { border-color: var(--brand); }
.tile .n { font-size: 1.7rem; font-weight: 700; line-height: 1.1; }
.tile .l { color: var(--muted); font-size: .85rem; }
.tile.red .n { color: var(--red); } .tile.amber .n { color: var(--amber); } .tile.blue .n { color: var(--blue); } .tile.teal .n { color: var(--brand); }
.list-row { display: flex; gap: .6rem; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }

/* order sheet */
.add-line { display: grid; grid-template-columns: 2.2fr .7fr 1.4fr 1.4fr auto; gap: .5rem; align-items: end; }
.supplier-head td { background: #f0fdfa; font-weight: 600; color: var(--brand-dark); }
td select.status { width: auto; padding: .25rem .4rem; font-size: .85rem; }
tr.done td { color: var(--muted); }
tr.done td.name { text-decoration: line-through; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 4vh 1rem; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); gap: .5rem; }
.modal-head h2 { margin: 0; flex: 1; }
.modal-head .x { border: 0; font-size: 1.4rem; line-height: 1; padding: .2rem .5rem; }
.modal-body { padding: 1.1rem; }
.modal-foot { display: flex; gap: .5rem; justify-content: flex-end; padding: .8rem 1.1rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
#toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); z-index: 60; }
#toast div { background: #111827; color: #fff; padding: .6rem 1rem; border-radius: 8px; margin-top: .4rem; box-shadow: 0 6px 20px rgba(0,0,0,.2); }
#toast div.bad { background: var(--red); }
.rx-img { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); }
fieldset { border: 1px dashed #cbd5e1; border-radius: 8px; padding: .8rem; margin: .5rem 0 .8rem; }
legend { font-size: .85rem; color: var(--muted); padding: 0 .3rem; }

/* public site */
.pub-head { background: linear-gradient(135deg, #0f766e, #0e7490); color: #fff; }
.pub-head-in { max-width: 980px; margin: 0 auto; padding: .8rem 1rem; display: flex; align-items: center; gap: .8rem; }
.pub-head .login-link { white-space: nowrap; color: #ccfbf1; text-decoration: none; font-size: .9rem; border: 1px solid rgba(255,255,255,.35); padding: .3rem .7rem; border-radius: 7px; }
.hero { max-width: 980px; margin: 0 auto; padding: 2.2rem 1rem 2.6rem; }
.hero h1 { font-size: 2rem; margin-bottom: .4rem; }
.hero p { color: #ccfbf1; margin: 0 0 1.2rem; max-width: 560px; }
.hero .btn { border: 0; }
.hero .btn.light { background: rgba(255,255,255,.15); color: #fff; }
.pub-main { max-width: 980px; margin: -1.4rem auto 0; padding: 0 1rem 3rem; position: relative; }
.steps { counter-reset: s; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .8rem; }
.steps div { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem; }
.steps b { display: block; margin-bottom: .2rem; }
.steps b::before { counter-increment: s; content: counter(s); display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); font-size: .8rem; margin-right: .4rem; }
.result { display: flex; gap: .6rem; align-items: center; padding: .6rem .2rem; border-bottom: 1px solid var(--line); }
.result:last-child { border-bottom: 0; }
.search-pop { position: absolute; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 25px rgba(0,0,0,.12); z-index: 10; max-height: 300px; overflow-y: auto; }
.search-pop .result { padding: .55rem .7rem; cursor: pointer; }
.search-pop .result:hover { background: #f0fdfa; }
.rel { position: relative; }
.cart-line { display: grid; grid-template-columns: 1fr 90px auto; gap: .5rem; align-items: center; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.drop { border: 2px dashed #cbd5e1; border-radius: 10px; padding: 1rem; text-align: center; cursor: pointer; color: var(--muted); }
.drop:hover { border-color: var(--brand); color: var(--brand); }
.timeline { display: flex; gap: .3rem; margin: 1rem 0; }
.timeline div { flex: 1; text-align: center; font-size: .8rem; color: var(--muted); padding-top: .5rem; border-top: 4px solid var(--line); }
.timeline div.on { border-color: var(--brand); color: var(--brand-dark); font-weight: 600; }
.code-big { font-size: 2rem; font-weight: 800; letter-spacing: .15em; color: var(--brand); }
footer.pub { text-align: center; color: var(--muted); font-size: .85rem; padding: 1rem; }

#o-form .err { margin: .3rem 0 0; min-height: 0; }
.grid + .card { margin-top: 1rem; }

@media (max-width: 760px) {
  .pub-head .brand span { font-size: .95rem; }
  .pub-head-in { gap: .5rem; }
  .add-line { grid-template-columns: 1fr 1fr; }
  .add-line .wide { grid-column: 1 / -1; }
  .topbar-in { flex-wrap: wrap; gap: .5rem; }
  .nav { order: 3; flex-basis: 100%; }
  .topbar .who { display: none; }
  .hero h1 { font-size: 1.6rem; }
  .hide-sm { display: none; }
}
@media print {
  .topbar, .no-print, #toast { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .table-wrap { border: 0; }
  .print-only { display: block !important; }
}
.print-only { display: none; }
