:root {
  --bg: #f5f2ea;
  --surface: #ffffff;
  --surface-2: #faf8f3;
  --ink: #15171c;
  --muted: #6d7180;
  --line: #e8e3d7;
  --blue: #1d3b8f;
  --blue-soft: #e8edfb;
  --gold: #f6c343;
  --gold-soft: #fdf3d4;
  --green: #12805c;
  --green-soft: #e3f4ec;
  --red: #c2410c;
  --red-soft: #fdebe1;
  --violet: #6d28d9;
  --violet-soft: #efe8fd;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(21, 23, 28, 0.04), 0 8px 24px -12px rgba(21, 23, 28, 0.12);
  font-family: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body { background: var(--bg); min-height: 100vh; font-size: 15px; line-height: 1.45; }
a { color: inherit; text-decoration: none; }
h1, h2 { margin: 0; letter-spacing: -0.02em; }
h1 { font-size: clamp(26px, 4vw, 34px); font-weight: 800; }
h2 { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
b { font-weight: 700; }
button, input { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; flex: none; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.grow { flex: 1; min-width: 0; }
.pos { color: var(--green); font-weight: 600; }
.neg { color: var(--red); font-weight: 600; }
.empty { color: var(--muted); padding: 18px 0 6px; margin: 0; }

/* ---------- buttons & inputs ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 20px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 700; cursor: pointer; white-space: nowrap; user-select: none;
  transition: transform .12s ease, background .15s ease, opacity .15s ease;
}
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--blue); color: #fff; box-shadow: 0 6px 16px -8px rgba(29, 59, 143, .7); }
.btn.primary:hover:not(:disabled) { background: #17307a; }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.ghost:hover:not(:disabled) { background: var(--surface); }
.btn.sm { height: 38px; padding: 0 14px; font-size: 14px; }
.btn.big { height: 64px; font-size: 19px; border-radius: 16px; }
.btn.wide { width: 100%; }

.link { background: none; border: 0; padding: 6px 4px; cursor: pointer; color: var(--muted); font-weight: 600; }
.link:hover { color: var(--ink); }

input {
  height: 46px; width: 100%; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input:focus { border-color: var(--blue); background: var(--surface); box-shadow: 0 0 0 4px var(--blue-soft); }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }

.row { display: flex; gap: 10px; align-items: center; }
.row > input { flex: 1; min-width: 0; }
.stack { display: grid; gap: 14px; }

/* ---------- login ---------- */

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(380px, 100%); background: var(--surface); border-radius: 24px; padding: 32px 28px;
  box-shadow: var(--shadow); display: grid; gap: 16px; position: relative; overflow: hidden;
}
.login-card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 6px;
  background: repeating-linear-gradient(90deg, var(--blue) 0 22px, var(--surface) 22px 30px, var(--gold) 30px 52px, var(--surface) 52px 60px);
}
.login-card p { margin: -10px 0 6px; }

/* ---------- shell ---------- */

.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; letter-spacing: -0.02em; }
.brand.big { font-size: 26px; }
.mark { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--blue); color: var(--gold); }
.brand.big .mark { width: 44px; height: 44px; border-radius: 13px; }

.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px; padding: 12px max(16px, calc((100vw - 1240px) / 2));
  background: rgba(245, 242, 234, .88); backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.top nav { display: flex; gap: 4px; background: var(--surface); padding: 4px; border-radius: 12px; border: 1px solid var(--line); }
.top nav a { padding: 8px 16px; border-radius: 9px; font-weight: 600; color: var(--muted); transition: background .15s, color .15s; }
.top nav a:hover { color: var(--ink); }
.top nav a.active { background: var(--ink); color: #fff; }
.top-right { margin-left: auto; display: flex; gap: 8px; }

.view { max-width: 1240px; margin: 0 auto; padding: 24px 16px 64px; display: grid; gap: 18px; }
.view.enter { animation: rise .25s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-head { display: flex; align-items: flex-end; gap: 16px; }
.page-head p { margin: 2px 0 0; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 700; color: var(--blue); margin: 0 0 4px !important; }
.section-title { margin: 6px 0 0; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 600; width: fit-content; margin-bottom: -8px; }
.back:hover { color: var(--ink); }

.card { background: var(--surface); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); min-width: 0; }
.card.narrow { max-width: 440px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.card-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }

/* ---------- stats ---------- */

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stats.two { grid-template-columns: repeat(2, 1fr); }
.stats.five { grid-template-columns: 1.5fr repeat(4, 1fr); }
.stat {
  background: var(--surface); border-radius: var(--radius); padding: 16px 20px; box-shadow: var(--shadow);
  display: grid; gap: 4px; align-content: start; min-width: 0;
}
.stat-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.stat-value { font-size: 24px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat-sub { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stat.accent { background: var(--blue); color: #fff; }
.stat.accent .stat-label, .stat.accent .stat-sub { color: rgba(255, 255, 255, .72); }
.stat.accent .stat-value { color: var(--gold); }
.stat.warn { background: var(--red-soft); }
.stat.warn .stat-value { color: var(--red); }
.stats.five .stat-value { font-size: 20px; }
.stats.five .stat:first-child .stat-value { font-size: 26px; }

/* ---------- rows (shops / couriers) ---------- */

.rows { display: grid; gap: 6px; }
.rows.grid { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.rows.grid .row-card { background: var(--surface); box-shadow: var(--shadow); }
.row-card {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 14px;
  transition: background .15s ease, transform .15s ease;
}
.row-card:hover { background: var(--surface-2); }
.rows.grid .row-card:hover { transform: translateY(-2px); }
.row-card.archived { opacity: .55; }
.row-main { display: grid; flex: 1; min-width: 0; }
.row-main b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 16px; }
.row-side { display: grid; justify-items: end; gap: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.avatar {
  width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex: none;
  background: var(--gold-soft); color: #8a5d00; font-weight: 800;
}
.avatar.shop { background: var(--violet-soft); color: var(--violet); }
.avatar.lg { width: 60px; height: 60px; border-radius: 18px; font-size: 21px; }
.badge { display: inline-flex; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; background: var(--line); color: var(--muted); vertical-align: middle; }
.badge.warn { background: var(--red-soft); color: var(--red); }
.add-form { flex-wrap: wrap; margin-top: 10px; }
.add-form input { flex: 1 1 200px; }

.entity-head { align-items: center; flex-wrap: wrap; }
.head-actions { display: flex; gap: 8px; }

/* ---------- tabs ---------- */

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs a {
  padding: 12px 20px; border-radius: 14px; font-weight: 700; color: var(--muted);
  background: var(--surface); border: 1px solid var(--line); transition: all .15s ease;
}
.tabs a:hover { color: var(--ink); }
.tabs a.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.tab-hint { margin: 0 0 16px; }

.entity-head .avatar.lg { width: 52px; height: 52px; font-size: 19px; border-radius: 16px; }
.entity-head h1 { font-size: 28px; }
.stats.two .stat, .stats.five .stat { padding: 12px 18px; }
.stats.two .stat-value, .stats.five .stat-value { font-size: 20px; }
.stats.five .stat:first-child .stat-value { font-size: 22px; }

.pay-layout { display: grid; grid-template-columns: minmax(320px, 440px) 1fr; gap: 28px; align-items: start; }
.pay-info { display: grid; gap: 12px; }

/* ---------- calculator ---------- */

.calc { display: grid; grid-template-columns: minmax(320px, 440px) 1fr; gap: 22px; align-items: stretch; }
.calc.single { grid-template-columns: 1fr; max-width: 440px; }
.pad { display: grid; gap: 12px; align-content: start; }
.display {
  background: var(--ink); color: #fff; border-radius: 16px; padding: 14px 20px 16px;
  display: grid; gap: 2px; text-align: right;
}
.display-label { font-size: 12px; font-weight: 600; color: rgba(255, 255, 255, .55); text-align: left; text-transform: uppercase; letter-spacing: .08em; }
.display-value { font-size: 44px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.1; min-height: 48px; }
.display-value .ghost { color: rgba(255, 255, 255, .25); }
.display.pop { animation: pop .25s ease; }
@keyframes pop { 0% { background: var(--green); } 100% { background: var(--ink); } }

.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.quick button {
  height: 44px; min-width: 72px; padding: 0 14px; border-radius: 12px; cursor: pointer;
  border: 1.5px solid var(--blue); background: var(--blue-soft); color: var(--blue);
  font-weight: 800; font-size: 16px; font-variant-numeric: tabular-nums; transition: transform .1s ease;
}
.quick button:active { transform: scale(.94); }

.keys { display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 68px; gap: 8px; }
.keys button {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 14px; cursor: pointer;
  font-size: 26px; font-weight: 700; display: grid; place-items: center; user-select: none;
  transition: transform .08s ease, background .12s ease;
  box-shadow: 0 2px 0 var(--line);
}
.keys button:hover { background: #fff; }
.keys button:active, .keys button.hit { transform: translateY(2px); box-shadow: none; background: var(--line); }
.keys .k-fn { background: var(--surface); color: var(--muted); font-size: 22px; }
.keys .k-fn svg { width: 26px; height: 26px; }
.keys .k-enter { grid-row: span 2; background: var(--green); border-color: var(--green); color: #fff; font-size: 34px; box-shadow: 0 2px 0 #0b5e43; }
.keys .k-enter:hover { background: #0f7352; }
.keys .k-enter:active, .keys .k-enter.hit { background: #0b5e43; }
.keys .k-zero { grid-column: span 2; }
.calc.single .k-enter { font-size: 24px; }

.tape {
  display: grid; grid-template-rows: auto 1fr auto auto; gap: 12px; min-height: 420px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 16px; padding: 16px;
}
.tape-head { display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.tape-list { list-style: none; margin: 0; padding: 0; overflow: auto; max-height: 380px; display: grid; align-content: start; gap: 4px; }
.tape-list li {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--surface);
  border-radius: 10px; font-variant-numeric: tabular-nums;
}
.tape-list li.fresh { animation: flash .5s ease; }
@keyframes flash { from { background: var(--green-soft); } to { background: var(--surface); } }
.tape-list li b { margin-left: auto; font-size: 18px; }
.tape-list .tape-empty { background: none; color: var(--muted); justify-content: center; padding: 30px 0; animation: none; }
.tape-n { color: var(--muted); font-size: 13px; min-width: 22px; }
.tape-tag { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--violet-soft); color: var(--violet); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.tape-x { width: 34px; height: 34px; border-radius: 9px; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer; }
.tape-x:hover { background: var(--red-soft); color: var(--red); }
.tape-total { display: flex; justify-content: space-between; align-items: baseline; padding-top: 12px; border-top: 1px dashed var(--line); }
.tape-count { color: var(--muted); font-weight: 600; }
.tape-sum { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

.shop-pick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.shop-pick button {
  height: 52px; padding: 0 22px; border-radius: 14px; cursor: pointer; font-weight: 700; font-size: 16px;
  border: 1.5px solid var(--line); background: var(--surface); transition: all .12s ease;
}
.shop-pick button:hover { border-color: var(--violet); }
.shop-pick button.on { background: var(--violet); border-color: var(--violet); color: #fff; }

/* ---------- courier settle ---------- */

.settle { display: grid; grid-template-columns: 1fr minmax(320px, 440px); gap: 28px; align-items: start; }
.settle-left { display: grid; gap: 14px; }
.settle-left .tab-hint { margin: 0; }
.settle-right { display: grid; gap: 12px; }
.token-group { display: grid; gap: 8px; }
.token-shop { font-weight: 700; color: var(--violet); font-size: 14px; }
.tokens { display: flex; flex-wrap: wrap; gap: 8px; }
.token {
  height: 52px; min-width: 84px; padding: 0 14px; border-radius: 13px; cursor: pointer;
  border: 1.5px solid var(--green); background: var(--green-soft); color: var(--green);
  font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums; transition: all .12s ease;
}
.token:active { transform: scale(.95); }
.token.back { border-color: var(--red); background: var(--red-soft); color: var(--red); text-decoration: line-through; }
.token-actions { display: flex; gap: 8px; }
.summary { margin: 6px 0 0; display: grid; gap: 7px; padding: 16px; background: var(--surface-2); border-radius: 14px; }
.summary div { display: flex; justify-content: space-between; gap: 12px; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.summary .due { padding-top: 8px; border-top: 1px solid var(--line); }
.summary .due dt { color: var(--ink); font-weight: 700; }
.summary .due dd { font-size: 20px; font-weight: 800; }

/* ---------- activity ---------- */

.acts { list-style: none; margin: 8px 0 0; padding: 0; }
.act { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.act:first-child { border-top: 0; }
.act-body { flex: 1; min-width: 0; }
.act-body a:hover b { color: var(--blue); }
.act-amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.act-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.act-icon.in { background: var(--violet-soft); color: var(--violet); }
.act-icon.back { background: var(--line); color: var(--muted); }
.act-icon.pay { background: var(--red-soft); color: var(--red); }
.act-icon.give { background: var(--gold-soft); color: #9a6b00; }
.act-icon.settle { background: var(--green-soft); color: var(--green); }
.act.cancelled .act-icon { filter: grayscale(1); opacity: .5; }
.act.cancelled .act-name, .act.cancelled .act-body > .act-line:first-child, .act.cancelled .act-sum { text-decoration: line-through; text-decoration-thickness: 2px; opacity: .55; }
.act.cancelled .act-sum * { color: var(--muted); }
.act-cancelled { color: var(--red); font-weight: 700; text-decoration: none; }
.undo {
  height: 32px; min-width: 32px; padding: 0 7px; border-radius: 9px; border: 1px solid transparent; background: transparent;
  color: var(--muted); display: grid; place-items: center; cursor: pointer; font-size: 12px; font-weight: 700; white-space: nowrap;
}
.undo svg { width: 16px; height: 16px; }
.undo:hover { border-color: var(--line); color: var(--ink); }
.undo.armed { background: var(--red); color: #fff; }
.undo-spacer { width: 32px; flex: none; }

/* ---------- toast ---------- */

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; z-index: 50;
  max-width: calc(100vw - 32px); box-shadow: 0 12px 30px -10px rgba(0,0,0,.4); transition: all .22s ease;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.error { background: var(--red); }

/* ---------- responsive ---------- */

@media (max-height: 900px) and (min-width: 641px) {
  .keys { grid-auto-rows: 58px; }
  .display-value { font-size: 38px; min-height: 42px; }
  .view { padding-top: 16px; gap: 14px; }
}

@media (max-width: 1000px) {
  .pay-layout { grid-template-columns: 1fr; }
  .stats, .stats.five { grid-template-columns: repeat(2, 1fr); }
  .stats.five .stat:first-child { grid-column: span 2; }
  .grid-2, .calc, .settle { grid-template-columns: 1fr; }
  .tape { min-height: 0; }
}

@media (max-width: 640px) {
  .top { flex-wrap: wrap; gap: 10px 12px; padding: 10px 16px; }
  .top nav { order: 3; width: 100%; }
  .top nav a { flex: 1; text-align: center; padding: 8px 4px; font-size: 14px; }
  .view { padding-top: 18px; gap: 14px; }
  .stat { padding: 14px 16px; }
  .stat-value { font-size: 20px; }
  .card { padding: 16px; }
  .row { flex-wrap: wrap; }
  .row > input { flex: 1 1 100%; }
  .row > .btn { flex: 1; }
  .rows.grid { grid-template-columns: 1fr; }
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1; }
  .tabs a { flex: 1; text-align: center; padding: 10px 8px; font-size: 14px; }
  .keys { grid-auto-rows: 60px; }
  .display-value { font-size: 36px; }
}
.summary .due:first-child { border-top: 0; padding-top: 0; }

.held { display: grid; gap: 12px; margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--line); }
.held-title { font-weight: 700; }

/* ---------- action tiles on shop / courier page ---------- */

.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.action {
  --tile: var(--blue); --tile-2: #2f56c4;
  display: flex; align-items: center; gap: 16px; padding: 20px 22px; color: #fff;
  background: linear-gradient(135deg, var(--tile-2), var(--tile));
  border-radius: var(--radius); border: 0;
  box-shadow: 0 10px 22px -10px var(--tile), inset 0 1px 0 rgba(255, 255, 255, .22);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.action.tile-in { --tile: #5b21b6; --tile-2: #8b5cf6; }
.action.tile-back { --tile: #c2410c; --tile-2: #f97316; }
.action.tile-pay { --tile: #047857; --tile-2: #10b981; }
.action.tile-give { --tile: #1d3b8f; --tile-2: #3b6cf0; }
.action.tile-settle { --tile: #047857; --tile-2: #10b981; }
.action:hover { transform: translateY(-2px); filter: brightness(1.06); }
.action:active { transform: scale(.97); filter: brightness(.95); }
.action .act-icon { width: 52px; height: 52px; border-radius: 15px; background: rgba(255, 255, 255, .2); color: #fff; }
.action .act-icon svg { width: 26px; height: 26px; }
.action .muted { color: rgba(255, 255, 255, .85); }
.action-text { display: grid; gap: 2px; }
.action-text b { font-size: 18px; }

/* ---------- full-screen calculator ---------- */

body.fs-mode .top { display: none; }
body.fs-mode .view { animation: none !important; transform: none; }
body.fs-mode { overflow: hidden; }
.fs {
  position: fixed; inset: 0; z-index: 20; background: var(--bg);
  display: flex; flex-direction: column; gap: 12px; padding: 12px 16px 16px;
}
.fs-extra[hidden] { display: none; }
.fs-bar { display: flex; align-items: center; gap: 16px; }
.fs-close {
  display: inline-flex; align-items: center; gap: 6px; height: 52px; padding: 0 20px 0 14px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line); font-weight: 700; font-size: 16px;
}
.fs-close:hover { border-color: var(--ink); }
.fs-close svg { width: 22px; height: 22px; }
.fs-title { display: grid; line-height: 1.2; }
.fs-title span { font-size: 13px; font-weight: 700; color: var(--blue); text-transform: uppercase; letter-spacing: .08em; }
.fs-title b { font-size: 24px; letter-spacing: -0.02em; }
.fs-extra .shop-pick { margin: 0; }
.fs-extra .held { margin: 0; padding: 12px 16px; border: 0; background: var(--surface); border-radius: 16px; max-height: 26vh; overflow: auto; }
.fs-extra .token { height: 44px; min-width: 76px; }
.fs-body { flex: 1 1 0; min-height: 0; background: var(--surface); border-radius: 20px; padding: 18px; box-shadow: var(--shadow); }
.fs-body > .empty { padding: 30px; text-align: center; }

.fs .calc-host { height: 100%; min-height: 0; }
.fs .calc { height: 100%; grid-template-columns: minmax(380px, 46%) 1fr; }
.fs .calc.single { max-width: none; grid-template-columns: 1fr; }
.fs .pad { grid-template-rows: auto auto 1fr; height: 100%; min-height: 0; }
.fs .calc.single .pad, .fs .pad:not(:has(.quick)) { grid-template-rows: auto 1fr; }
.fs .keys { grid-template-rows: repeat(4, minmax(56px, 1fr)); grid-auto-rows: unset; min-height: 0; }
.fs .keys button { font-size: 34px; }
.fs .keys .k-enter { font-size: 44px; }
.fs .calc.single .k-enter { font-size: 30px; }
.fs .display { padding: 16px 24px 18px; }
.fs .display-value { font-size: 56px; min-height: 62px; }
.fs .quick button { height: 52px; min-width: 88px; font-size: 18px; }
.fs .tape { height: 100%; min-height: 0; }
.fs .tape-list { max-height: none; min-height: 0; }
.fs .tape-list li { padding: 10px 12px; }
.fs .tape-list li b { font-size: 22px; }
.fs .tape-sum { font-size: 32px; }

.fs .pay-layout, .fs .settle { height: 100%; min-height: 0; grid-template-columns: minmax(380px, 46%) 1fr; align-items: stretch; }
.fs .settle { grid-template-columns: 1fr minmax(380px, 42%); }
.fs .settle-left { overflow: auto; min-height: 0; align-content: start; padding-right: 4px; }
.fs .settle-right { grid-template-rows: 1fr auto; min-height: 0; }
.fs .pay-info { align-content: start; }
.fs .pay-info .summary { font-size: 17px; }

@media (max-height: 900px) and (min-width: 641px) {
  .fs .display-value { font-size: 46px; min-height: 52px; }
  .fs .keys { grid-template-rows: repeat(4, minmax(52px, 1fr)); }
}

@media (max-width: 1000px) {
  .actions { grid-template-columns: 1fr; }
  body.fs-mode { overflow: auto; }
  .fs { position: static; min-height: 100vh; }
  .fs-body { flex: none; }
  .fs .calc, .fs .pay-layout, .fs .settle { height: auto; grid-template-columns: 1fr; }
  .fs .keys { grid-template-rows: none; grid-auto-rows: 64px; }
  .fs .tape { height: auto; }
  .fs .tape-list { max-height: 50vh; }
}

/* ================= monoblock (touch kiosk) ================= */

html { touch-action: manipulation; }
body { user-select: none; -webkit-user-select: none; overscroll-behavior: none; }
input { user-select: text; -webkit-user-select: text; }
button, a { -webkit-touch-callout: none; }

.icon-btn {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted); transition: all .12s ease;
}
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn:active { transform: scale(.94); background: var(--line); }
.clock { display: grid; justify-items: end; line-height: 1.1; margin-right: 6px; }
.clock b { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.clock span { font-size: 13px; color: var(--muted); font-weight: 600; }

.top nav a { display: inline-flex; align-items: center; gap: 8px; }
.top nav a svg { width: 22px; height: 22px; }

.back-btn { padding: 0 18px 0 12px; }
.back-btn svg { width: 22px; height: 22px; }
.list-head { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.list-head .add-form { flex: 1; margin: 0; min-width: 320px; }
.card.fill { display: flex; flex-direction: column; min-height: 0; }
.card.fill .card-head { margin-bottom: 10px; }
.scroll { overflow: auto; min-height: 0; overscroll-behavior: contain; }

/* thick, draggable scrollbars for fingers */
.scroll::-webkit-scrollbar, .tape-list::-webkit-scrollbar, .fs-extra .held::-webkit-scrollbar, .settle-left::-webkit-scrollbar { width: 12px; }
.scroll::-webkit-scrollbar-thumb, .tape-list::-webkit-scrollbar-thumb, .fs-extra .held::-webkit-scrollbar-thumb, .settle-left::-webkit-scrollbar-thumb {
  background: var(--line); border-radius: 8px; border: 3px solid var(--surface);
}

.undo { height: 48px; min-width: 48px; border-radius: 12px; border-color: var(--line); }
.undo svg { width: 20px; height: 20px; }
.undo.armed { padding: 0 14px; font-size: 14px; }
.undo-spacer { width: 48px; }

@media (min-width: 1001px) {
  body { font-size: 17px; }
  h2 { font-size: 20px; }
  .small { font-size: 14px; }

  .top { height: 80px; padding: 0 24px; gap: 28px; }
  .top nav { padding: 5px; border-radius: 16px; gap: 6px; }
  .top nav a { padding: 0 24px; height: 54px; border-radius: 12px; font-size: 18px; font-weight: 700; }
  .brand { font-size: 22px; }
  .mark { width: 44px; height: 44px; border-radius: 13px; }
  .top-right { align-items: center; gap: 10px; }

  /* the app is exactly one screen; long lists scroll inside their panel */
  body:not(.fs-mode) { height: 100vh; overflow: hidden; }
  .view {
    max-width: none; height: calc(100vh - 80px); padding: 18px 24px 20px;
    display: flex; flex-direction: column; gap: 16px; overflow: auto;
  }
  .view > * { flex: none; }
  .view > .card.fill, .view > .board, .view > .fill-plain { flex: 1 1 0; min-height: 260px; }
  .board { display: grid; grid-template-columns: 1fr 1fr 1.25fr; gap: 16px; min-height: 0; }
  .board > .card { height: 100%; }

  .btn { height: 56px; padding: 0 24px; font-size: 17px; border-radius: 14px; }
  .btn.sm { height: 48px; padding: 0 18px; font-size: 16px; }
  input { height: 56px; font-size: 18px; border-radius: 14px; }
  .card { padding: 20px 22px; }

  .stats { gap: 16px; }
  .stat { padding: 18px 22px; }
  .stat-label { font-size: 15px; }
  .stat-value { font-size: 30px; }
  .stat-sub { font-size: 14px; }
  .stats.two .stat-value, .stats.five .stat-value { font-size: 26px; }
  .stats.five .stat:first-child .stat-value { font-size: 28px; }

  .row-card { padding: 14px 16px; min-height: 76px; border-radius: 16px; }
  .row-card:active { background: var(--line); transform: scale(.99); }
  .row-main b { font-size: 18px; }
  .row-side b { font-size: 17px; }
  .avatar { width: 52px; height: 52px; font-size: 18px; }
  .entity-head .avatar.lg { width: 60px; height: 60px; font-size: 21px; }
  .entity-head h1 { font-size: 30px; }
  .rows.grid { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; }

  .act { padding: 12px 0; gap: 14px; }
  .act-icon { width: 44px; height: 44px; border-radius: 12px; }
  .act-icon svg { width: 22px; height: 22px; }
  .act-amount { font-size: 18px; }

  .action { padding: 22px 26px; min-height: 104px; }
  .action .act-icon { width: 60px; height: 60px; }
  .action-text b { font-size: 21px; }

  .token { height: 64px; min-width: 104px; font-size: 20px; border-radius: 15px; }
  .fs-extra .token { height: 56px; min-width: 96px; font-size: 19px; }
  .token-actions .btn { height: 52px; }
  .summary { font-size: 18px; padding: 18px 20px; }
  .summary .due dd { font-size: 24px; }
  .fs-close { height: 60px; font-size: 18px; padding: 0 24px 0 16px; }
  .fs-title b { font-size: 28px; }
  .tape-x { width: 48px; height: 48px; border-radius: 12px; }
  .tape-x svg { width: 22px; height: 22px; }
    .tape-tag { font-size: 14px; padding: 4px 10px; }
  .tape-head { font-size: 18px; }
  .tape-head .link { font-size: 16px; padding: 10px 6px; }
  .tape-count { font-size: 17px; }

  #toast { font-size: 19px; padding: 16px 26px; border-radius: 16px; bottom: 32px; }
  .login-card { width: 460px; padding: 40px 36px; gap: 18px; }
  .card.narrow { max-width: 520px; }
}

/* short monoblock screens (1366×768, or 125% scaling) */
@media (min-width: 1001px) and (max-height: 820px) {
  .top { height: 68px; }
  .top nav a { height: 48px; }
  .view { height: calc(100vh - 68px); padding: 14px 20px 16px; gap: 12px; }
  .stat { padding: 12px 18px; }
  .stat-value { font-size: 24px; }
  .action { min-height: 84px; padding: 14px 20px; }
}

.act-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-name a:hover { color: var(--blue); }
.act-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-amount { display: grid; justify-items: end; gap: 2px; }
.row-main span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 1001px) { .board { grid-template-columns: 1fr 1fr 1.35fr; } }

/* courier's orders as one swipeable strip above the cancel calculator */
.strip { display: flex; align-items: center; gap: 14px; background: var(--surface); border-radius: 16px; padding: 10px 14px; }
.strip-title { display: grid; line-height: 1.15; flex: none; }
.strip-title b { font-size: 20px; }
.strip-row { display: flex; gap: 8px; overflow-x: auto; flex: 1; padding: 2px 0 6px; overscroll-behavior: contain; }
.strip-row::-webkit-scrollbar { height: 10px; }
.strip-row::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
.token.chip-token { flex: none; height: 60px; min-width: 92px; display: grid; place-content: center; gap: 1px; line-height: 1.1; padding: 0 12px; }
.token.chip-token small { font-size: 11px; font-weight: 700; opacity: .75; max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }

@media (min-width: 1001px) {
  #toast { top: 18px; bottom: auto; transform: translate(-50%, -16px); }
  #toast.show { transform: translate(-50%, 0); }
  .stat-value { white-space: nowrap; }
  .action-text { min-width: 0; }
  .action-text span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* 1024–1280 wide monoblocks (1024×768, 1280×800/1024) */
@media (min-width: 1001px) and (max-width: 1280px) {
  .top { gap: 12px; padding: 0 14px; }
  .top .brand > span:last-child { display: none; }
  .top nav { gap: 2px; }
  .top nav a { padding: 0 16px; font-size: 17px; gap: 7px; }
  .top-right { gap: 8px; }
  .clock { margin-right: 2px; }
  .clock b { font-size: 21px; }
  .icon-btn { width: 50px; height: 50px; }

  .view { padding-left: 16px; padding-right: 16px; }
  .stats { gap: 12px; }
  .stat { padding-left: 16px; padding-right: 16px; }
  .stats .stat-value { font-size: 24px; }
  .stats.five { grid-template-columns: 1.3fr repeat(4, 1fr); }
  .stats.five .stat-value { font-size: 19px; }
  .stats.five .stat:first-child .stat-value { font-size: 22px; }

  /* home: shops over couriers on the left, activity on the right */
  .board { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 12px; }
  .board > .card:nth-child(1) { grid-column: 1; grid-row: 1; }
  .board > .card:nth-child(2) { grid-column: 1; grid-row: 2; }
  .board > .card:nth-child(3) { grid-column: 2; grid-row: 1 / span 2; }
  .board .card { padding: 14px 16px; }
  .board .card-head { margin-bottom: 4px; }
  .board .row-card { min-height: 64px; padding: 8px 10px; }

  .actions { gap: 12px; }
  .action { gap: 12px; padding: 14px 16px; }
  .action .act-icon { width: 52px; height: 52px; }
  .action-text b { font-size: 19px; }
  .rows.grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

  .fs .calc, .fs .pay-layout { grid-template-columns: minmax(340px, 47%) 1fr; gap: 18px; }
  .fs .settle { grid-template-columns: 1fr minmax(340px, 45%); gap: 18px; }
  .fs-body { padding: 14px; }
}
@media (min-width: 1001px) {
  body.fs-mode #toast { left: auto; right: 16px; max-width: 46vw; transform: translateY(-16px); }
  body.fs-mode #toast.show { transform: translateY(0); }
}

/* ---------- history calendar ---------- */

.hist { display: grid; gap: 16px; }
.hist-side { display: flex; flex-direction: column; gap: 14px; }
.hist > .card.fill { min-height: 420px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cal-head b { font-size: 18px; }
.cal-nav {
  width: 48px; height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; color: var(--ink);
}
.cal-nav svg { width: 22px; height: 22px; }
.cal-nav.fwd svg { transform: scaleX(-1); }
.cal-nav:disabled { opacity: .35; cursor: default; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 10px; }
.cal-wd { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); padding: 2px 0 4px; }
.cal-day {
  height: 42px; border-radius: 11px; display: grid; place-items: center; align-content: center; gap: 0;
  font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; border: 2px solid transparent;
}
.cal-day i { font-style: normal; font-size: 11px; font-weight: 800; min-height: 12px; color: var(--blue); }
.cal-day.has { background: var(--blue-soft); }
.cal-day.today { border-color: var(--blue); }
.cal-day.future { color: var(--muted); opacity: .5; pointer-events: none; }
.cal-day.sel { background: var(--blue); color: #fff; }
.cal-day.sel i { color: var(--gold); }
.cal-day:active { transform: scale(.94); }
.cal-hint { margin: 0; }
.hist-day { border-top: 1px solid var(--line); padding-top: 10px; flex: 1 1 0; min-height: 0; overflow: auto; }
.hist-day .card-head { margin-bottom: 8px; }
.day-sum { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 8px; }
.day-sum li { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.day-sum .grow { display: grid; line-height: 1.25; min-width: 0; }
.day-sum .grow b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-sum .num { font-variant-numeric: tabular-nums; white-space: nowrap; }

@media (min-width: 1001px) {
  .view > .hist { flex: 1 1 0; min-height: 0; grid-template-columns: 360px 1fr; }
  .hist > .card { height: 100%; min-height: 0; }
  .hist-side { overflow: hidden; }
}

/* ---------- delivery fee ---------- */

.fee-row { margin-top: 12px; align-items: end; }
.fee-input { display: grid; gap: 4px; flex: 0 1 260px; }
.fee-input span { font-size: 13px; font-weight: 600; color: var(--muted); }
.seg { display: flex; flex: 1; gap: 6px; padding: 5px; background: var(--bg); border-radius: 14px; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: grid; place-items: center; height: 46px; padding: 0 12px; border-radius: 10px;
  font-weight: 700; color: var(--muted); cursor: pointer; text-align: center;
}
.seg input:checked + span { background: var(--blue); color: #fff; box-shadow: 0 6px 14px -8px rgba(29, 59, 143, .8); }
.fee-help { margin: 10px 0 0; }
.fee-stat { text-align: left; font: inherit; color: inherit; border: 2px dashed var(--line); cursor: pointer; display: grid; }
.fee-stat:active { transform: scale(.98); }

/* ---------- history filter ---------- */

.hist-filter { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.seg-btns { display: flex; gap: 4px; padding: 4px; background: var(--bg); border-radius: 14px; flex: none; }
.seg-btns button {
  height: 44px; padding: 0 16px; border: 0; border-radius: 10px; background: transparent;
  font-weight: 700; color: var(--muted); cursor: pointer;
}
.seg-btns button.on { background: var(--blue); color: #fff; box-shadow: 0 6px 14px -8px rgba(29, 59, 143, .8); }
select.who {
  flex: 1; min-width: 0; height: 52px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); font: inherit; font-weight: 700; color: var(--ink);
}
.sum-title { display: grid; line-height: 1.2; min-width: 0; }
.sum-title .small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-sum .sum-note { border-top: 1px dashed var(--line); padding-top: 8px; }
