:root {
  --bg: #0b0f10;
  --card: #141a1c;
  --card2: #1b2326;
  --line: #263034;
  --text: #eef3f3;
  --muted: #8a9a9d;
  --teal: #19c2b0;
  --teal-dim: rgba(25, 194, 176, .14);
  --red: #ef5a5a;
  --amber: #f0b44c;
  --blue: #5aa6ef;
  --green: #4fd18b;
  --r: 14px;
  --text2: #c6d1d2;
  --on-teal: #04201d;
  --brand-farm: #fff;
}
:root[data-theme="light"] {
  --bg: #f3f6f6;
  --card: #ffffff;
  --card2: #eef2f2;
  --line: #dde4e4;
  --text: #0e1617;
  --muted: #667577;
  --teal: #0f9d8f;
  --teal-dim: rgba(15, 157, 143, .1);
  --red: #d64545;
  --amber: #b7791f;
  --blue: #2f7fd1;
  --green: #22995a;
  --text2: #34474a;
  --on-teal: #ffffff;
  --brand-farm: #0e1617;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding: 0 14px calc(24px + env(safe-area-inset-bottom));
  max-width: 640px; margin: 0 auto;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select {
  font: inherit; color: var(--text); background: var(--card2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; width: 100%; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--teal); }
textarea { resize: vertical; }
.hidden { display: none !important; }

.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 14px 0 10px; }
.brand { font-weight: 900; letter-spacing: .08em; font-size: 22px; text-align: center; margin-bottom: 12px; }
.b-farm { color: var(--brand-farm); }
.b-boss { color: var(--teal); }
.brand small { display: block; font-size: 11px; letter-spacing: .2em; color: var(--muted); font-weight: 600; }
.tabs { display: flex; gap: 6px; background: var(--card); border-radius: 12px; padding: 4px; overflow-x: auto; }
.tab { flex: 1; border: 0; background: transparent; padding: 9px 10px; border-radius: 9px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.tab.active { background: var(--card2); color: var(--text); }

.products { display: grid; gap: 12px; margin-top: 6px; }
.product {
  text-align: left; background: var(--card); border: 1.5px solid var(--line); border-radius: var(--r);
  padding: 16px; transition: border-color .15s, background .15s;
}
.product.selected { border-color: var(--teal); background: linear-gradient(180deg, var(--teal-dim), var(--card) 70%); }
.p-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.p-name { font-weight: 800; font-size: 17px; }
.p-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.p-price { font-weight: 900; font-size: 22px; color: var(--teal); white-space: nowrap; }
.p-desc { margin-top: 10px; color: var(--text2); font-size: 14px; white-space: pre-line; }
.p-check { margin-top: 12px; font-size: 13px; color: var(--muted); font-weight: 600; }
.product.selected .p-check { color: var(--teal); }

.checkout { margin-top: 14px; background: var(--card); border-radius: var(--r); padding: 14px; display: grid; gap: 12px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.label { color: var(--muted); }
.stepper { display: flex; align-items: center; background: var(--card2); border-radius: 10px; border: 1px solid var(--line); }
.stepper button { border: 0; background: transparent; width: 40px; height: 40px; font-size: 20px; }
.stepper input { width: 56px; text-align: center; border: 0; background: transparent; padding: 0; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.total { font-size: 24px; font-weight: 900; }
.btn-primary {
  width: 100%; border: 0; border-radius: 12px; padding: 14px; font-weight: 800; font-size: 16px;
  background: var(--teal); color: var(--on-teal);
}
.btn-primary:disabled { opacity: .6; }
.btn-ghost { width: 100%; border: 1px solid var(--line); background: transparent; border-radius: 12px; padding: 12px; font-weight: 600; }
.hint { margin: 0; color: var(--muted); font-size: 12.5px; text-align: center; }

.orders { display: grid; gap: 10px; margin-top: 6px; }
.order { background: var(--card); border-radius: 12px; padding: 12px 14px; }
.o-head { display: flex; justify-content: space-between; align-items: center; }
.o-id { font-weight: 800; }
.o-body { margin-top: 4px; }
.o-date { color: var(--muted); font-size: 12px; margin-top: 2px; }
.status { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--card2); }
.st-new { color: var(--blue); background: rgba(90,166,239,.12); }
.st-awaiting_payment { color: var(--amber); background: rgba(240,180,76,.12); }
.st-paid { color: var(--teal); background: var(--teal-dim); }
.st-delivered { color: var(--green); background: rgba(79,209,139,.12); }
.st-cancelled { color: var(--muted); }

.done { text-align: center; padding: 40px 10px; display: grid; gap: 12px; }
.done h2 { margin: 0; }
.done p { color: var(--muted); margin: 0 0 8px; }
.done-icon {
  width: 64px; height: 64px; border-radius: 50%; margin: 0 auto; display: grid; place-items: center;
  background: var(--teal-dim); color: var(--teal); font-size: 32px; font-weight: 900;
}
.empty { color: var(--muted); text-align: center; padding: 30px 0; }
.skeleton { height: 110px; border-radius: var(--r); background: linear-gradient(90deg, var(--card), var(--card2), var(--card)); background-size: 200% 100%; animation: sk 1.2s infinite; }
@keyframes sk { to { background-position: -200% 0; } }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--card2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px;
  transition: .25s; z-index: 50; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-err { border-color: var(--red); color: var(--red); }

.periods { display: flex; gap: 6px; margin: 12px 0; flex-wrap: wrap; }
.chip { white-space: nowrap; flex-shrink: 0; border: 1px solid var(--line); background: var(--card); padding: 6px 12px; border-radius: 99px; font-size: 13px; font-weight: 600; color: var(--muted); }
.chip.active { border-color: var(--teal); color: var(--teal); background: var(--teal-dim); }
.range { display: flex; gap: 8px; margin-bottom: 12px; }
.range input { padding: 7px 10px; font-size: 13px; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.kpi { background: var(--card); border-radius: 12px; padding: 12px; }
.kpi .k-label { color: var(--muted); font-size: 12px; }
.kpi .k-val { font-size: 21px; font-weight: 900; margin-top: 2px; }
.kpi.big { grid-column: span 2; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.panel { background: var(--card); border-radius: var(--r); padding: 14px; margin-top: 12px; }
.panel h3 { margin: 0 0 10px; font-size: 15px; }
.chart { display: flex; align-items: flex-end; gap: 3px; height: 120px; }
.bar-wrap { flex: 1; display: flex; align-items: flex-end; gap: 1px; height: 100%; min-width: 3px; }
.bar { flex: 1; border-radius: 3px 3px 0 0; min-height: 1px; }
.bar.rev { background: var(--teal); }
.bar.exp { background: var(--red); opacity: .75; }
.chart-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 6px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.legend .l-rev { background: var(--teal); }
.legend .l-exp { background: var(--red); }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl td { padding: 7px 0; border-bottom: 1px solid var(--line); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.num { text-align: right; font-weight: 700; white-space: nowrap; }
.muted { color: var(--muted); }

.filters { display: flex; gap: 6px; overflow-x: auto; margin: 12px 0 8px; padding-bottom: 2px; }
.search { margin-bottom: 10px; }
.a-order { background: var(--card); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; }
.a-order .o-body { font-weight: 600; }
.a-order .client { margin-top: 4px; font-size: 14px; }
.a-order .client a { color: var(--teal); text-decoration: none; }
.a-order .comment { margin-top: 6px; font-size: 13px; color: var(--text2); background: var(--card2); padding: 6px 9px; border-radius: 8px; white-space: pre-line; }
.status-btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.sbtn { border: 1px solid var(--line); background: var(--card2); border-radius: 8px; padding: 6px 10px; font-size: 12.5px; font-weight: 600; }
.sbtn.current { border-color: var(--teal); color: var(--teal); }
.note-row { display: flex; gap: 6px; margin-top: 8px; }
.note-row input { padding: 7px 10px; font-size: 13px; }
.note-row button, .small-btn { border: 1px solid var(--line); background: var(--card2); border-radius: 8px; padding: 6px 10px; font-size: 13px; white-space: nowrap; }
.blocked-tag { color: var(--red); font-size: 12px; font-weight: 700; margin-left: 6px; }
.more { margin-top: 6px; }

.form { display: grid; gap: 8px; }
.form-row { display: flex; gap: 8px; }
.exp-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.exp-item:last-child { border-bottom: 0; }
.exp-item .e-main { min-width: 0; }
.exp-item .e-cat { font-weight: 700; }
.exp-item .e-note { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }
.exp-item .e-amt { font-weight: 800; color: var(--red); white-space: nowrap; }
.del { border: 0; background: transparent; color: var(--muted); font-size: 18px; padding: 0 4px; }

.prod-edit { display: grid; gap: 8px; }
.prod-edit label { font-size: 12px; color: var(--muted); display: grid; gap: 4px; }
.switch { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.switch input { width: auto; }
.log-item { font-size: 12.5px; padding: 6px 0; border-bottom: 1px solid var(--line); color: var(--text2); word-break: break-word; }
.product.soldout { opacity: .5; cursor: not-allowed; }
.p-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.p-foot .p-check { margin-top: 0; }
.p-stock { font-size: 12.5px; color: var(--green); font-weight: 600; }
.small { font-size: 12.5px; }
.file-btn { display: block; text-align: center; border: 1px dashed var(--line); border-radius: 10px; padding: 10px; color: var(--muted); font-weight: 600; cursor: pointer; }
.file-btn input { display: none; }
.perms { display: grid; gap: 6px; }
.perm { display: flex; gap: 8px; align-items: flex-start; font-size: 13.5px; }
.perm input { width: auto; margin-top: 3px; }
.staff-card { background: var(--card); border-radius: var(--r); padding: 14px; margin-top: 10px; display: grid; gap: 8px; }
.staff-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.staff-name { font-weight: 800; }
.role-tag { font-size: 12px; font-weight: 700; color: var(--teal); background: var(--teal-dim); padding: 3px 9px; border-radius: 99px; }
.role-tag.off { color: var(--muted); background: var(--card2); }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }
.token-box { font-family: ui-monospace, monospace; font-size: 12.5px; word-break: break-all; background: var(--card2); padding: 8px; border-radius: 8px; }
.items-box { font-family: ui-monospace, monospace; font-size: 12px; min-height: 80px; }
.item-row { display: flex; justify-content: space-between; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-family: ui-monospace, monospace; font-size: 12px; word-break: break-all; }
.item-row:last-child { border-bottom: 0; }
.danger { color: var(--red); }
.tbl td + td { padding-left: 10px; }
.reserve { margin-top: 6px; font-size: 12.5px; font-weight: 600; color: var(--amber); }
