:root {
  --bg: #f4f2ef;
  --surface: #ffffff;
  --surface-2: #f8f6f3;
  --text: #1d1b19;
  --muted: #6f6a64;
  --line: #e6e1db;
  --accent: #e2561b;
  --accent-ink: #ffffff;
  --accent-soft: #fdece4;
  --coal: #262320;
  --ok: #1f8a4c;   --ok-soft: #e3f4ea;
  --warn: #b26a00; --warn-soft: #fff1d6;
  --info: #2461c9; --info-soft: #e5eefc;
  --bad: #c0352b;  --bad-soft: #fbe6e4;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
img { max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.hidden { display: none !important; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 0 16px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #cc4a13; }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { background: #197541; }
.btn-danger { color: var(--bad); }
.btn-block { width: 100%; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 14px; }
.icon-btn { border: 0; background: none; font-size: 18px; cursor: pointer; color: var(--muted); padding: 6px; }

/* ---------- Forms ---------- */
label.field { display: block; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type=checkbox], input[type=radio] { width: 18px; min-height: 18px; accent-color: var(--accent); }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg label { padding: 9px 14px; cursor: pointer; font-weight: 600; font-size: 14px; }
.seg input { display: none; }
.seg label:has(input:checked) { background: var(--coal); color: #fff; }

/* ---------- Cards / lists ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card-flat { box-shadow: none; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list-item { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); color: inherit; }
.list-item:first-child { border-top: 0; }
a.list-item:hover, button.list-item:hover { background: var(--surface-2); }
button.list-item { width: 100%; border-left: 0; border-right: 0; border-bottom: 0; background: none; font: inherit; text-align: left; cursor: pointer; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.st-pending   { background: var(--warn-soft); color: var(--warn); }
.st-confirmed { background: var(--info-soft); color: var(--info); }
.st-delivered { background: var(--ok-soft);   color: var(--ok); }
.st-cancelled { background: #eeeceb; color: var(--muted); text-decoration: line-through; }
.pay-paid   { background: var(--ok-soft);  color: var(--ok); }
.pay-unpaid { background: var(--bad-soft); color: var(--bad); }
.badge-muted { background: #eeeceb; color: var(--muted); }

.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  border-radius: 50%; object-fit: cover; background: var(--accent-soft); color: var(--accent); font-weight: 700;
}
.pimg { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 10px; background: var(--coal); display: block; }
.pimg-empty { display: flex; align-items: center; justify-content: center; color: var(--accent); background: linear-gradient(135deg, #2e2a26, #1a1816); }
.pthumb { width: 52px; height: 52px; flex: none; border-radius: 8px; aspect-ratio: 1; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 22px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat.hot { border-color: var(--accent); background: var(--accent-soft); }

.tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--text); font-weight: 600; font-size: 14px; white-space: nowrap; }
.tabs a.on { background: var(--coal); color: #fff; border-color: var(--coal); }

table.items { width: 100%; border-collapse: collapse; }
table.items th, table.items td { padding: 9px 6px; border-top: 1px solid var(--line); text-align: left; }
table.items th { font-size: 12px; color: var(--muted); font-weight: 600; border-top: 0; }
table.items .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.items tfoot td { font-weight: 700; font-size: 16px; }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.stepper button { width: 38px; height: 38px; border: 0; background: var(--surface-2); font-size: 18px; cursor: pointer; color: var(--text); }
.stepper input { width: 60px; min-height: 38px; border: 0; border-radius: 0; text-align: center; padding: 0 4px; }
.stepper input:focus { outline: none; }

.dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }

/* ---------- Modal / toast ---------- */
.modal-wrap { position: fixed; inset: 0; background: rgba(20,18,16,.45); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 16px; width: 100%; max-width: 520px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 0; }
.modal-body { padding: 16px; }
.toasts { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; width: min(92vw, 420px); }
.toast { padding: 12px 16px; border-radius: 10px; background: var(--coal); color: #fff; font-weight: 600; box-shadow: var(--shadow); animation: pop .2s ease; }
.toast-err { background: var(--bad); }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.lang button { border: 0; background: var(--surface); padding: 5px 9px; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; color: var(--muted); }
.lang button.on { background: var(--coal); color: #fff; }

.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 18px; color: var(--text); letter-spacing: -.01em; }
.logo i { width: 30px; height: 30px; border-radius: 9px; background: var(--accent); display: inline-flex; align-items: center; justify-content: center; color: #fff; font-style: normal; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: radial-gradient(1200px 500px at 50% -10%, #3a2b22, var(--coal)); }
.auth .card { width: 100%; max-width: 380px; padding: 24px; }
.auth .logo { justify-content: center; margin-bottom: 6px; }
