:root {
  --bg: #f3f5f8; --card: #ffffff; --text: #18212b; --muted: #5d6b7a; --line: #dfe4ea;
  --accent: #1f5f8b; --accent-ink: #ffffff; --soft: #e6f0f7;
  --ok: #1b7a46; --ok-bg: #e3f4ea; --warn: #9a5a00; --warn-bg: #fdf1dc; --bad: #b3261e; --bad-bg: #fbe5e3;
  --radius: 12px; --tab-h: 62px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11161c; --card: #1a2129; --text: #e7edf3; --muted: #9aa8b6; --line: #2c3540;
    --accent: #5ca8dc; --accent-ink: #0b1620; --soft: #1f3445;
    --ok: #6fd39b; --ok-bg: #173325; --warn: #f0b860; --warn-bg: #3a2c12; --bad: #ff8a80; --bad-bg: #3d1a18;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
}
a { color: var(--accent); }
h1 { font-size: 1.3rem; margin: 0 0 .3rem; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
p { margin: .3rem 0 .7rem; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.center { text-align: center; }

/* header & navigation */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--accent); color: var(--accent-ink);
}
.brand { color: inherit; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.badge { font-size: .65rem; letter-spacing: .08em; border: 1px solid currentColor; border-radius: 4px; padding: 1px 4px; vertical-align: 2px; }
.topnav { display: none; gap: 4px; flex: 1; }
.topnav a { color: inherit; text-decoration: none; padding: 6px 12px; border-radius: 8px; opacity: .85; }
.topnav a.on, .topnav a:hover { background: rgba(255,255,255,.18); opacity: 1; }
.lang { margin-left: auto; }
.lang button { background: transparent; color: inherit; border: 1px solid currentColor; border-radius: 8px; padding: 4px 10px; font-weight: 600; cursor: pointer; }
.demo-note { background: var(--soft); color: var(--muted); font-size: .8rem; text-align: center; padding: 5px 16px; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; background: var(--card);
  border-top: 1px solid var(--line); height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: .72rem; color: var(--muted); text-decoration: none; gap: 2px; min-width: 0; }
.tabbar a span { font-size: 1.25rem; line-height: 1; }
.tabbar a.on { color: var(--accent); font-weight: 600; }
@media (min-width: 820px) {
  .topnav { display: flex; }
  .tabbar { display: none; }
  body { padding-bottom: 24px; }
  .lang { margin-left: 0; }
}

main { max-width: 860px; margin: 0 auto; padding: 12px 16px 24px; }
.back { display: inline-block; margin: 2px 0 8px; text-decoration: none; font-weight: 600; }

/* cards, lists */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 12px; }
details.card > summary { cursor: pointer; font-weight: 600; }
details.card[open] > summary { margin-bottom: 10px; }
.list { list-style: none; margin: 0 0 12px; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list.flat { border: 0; border-radius: 0; background: transparent; }
.list li + li { border-top: 1px solid var(--line); }
.row { display: flex; gap: 12px; align-items: center; padding: 12px 14px; color: inherit; text-decoration: none; }
a.row:hover { background: var(--soft); }
.list.flat .row { padding: 10px 0; }
.row .main { flex: 1; min-width: 0; }
.row .t { font-weight: 600; overflow-wrap: anywhere; }
.row .s { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .side { text-align: right; flex-shrink: 0; }
.amt { font-weight: 700; white-space: nowrap; }
.empty { padding: 20px 16px; color: var(--muted); text-align: center; }
.pill { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 99px; margin-top: 3px; background: var(--soft); color: var(--muted); }
.pill.new { background: var(--ok-bg); color: var(--ok); }
.pill.done, .pill.ignored { background: var(--soft); color: var(--muted); }
.pill.skip { background: var(--warn-bg); color: var(--warn); }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 16px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .9rem; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; font: inherit; font-size: .88rem; cursor: pointer; padding: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
label { display: block; font-size: .88rem; color: var(--muted); margin: 0 0 10px; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; font: inherit; font-size: 16px; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
input[type=file] { padding: 8px; }
label.check { display: flex; gap: 10px; align-items: flex-start; color: var(--text); }
label.check input { width: 20px; min-height: 20px; height: 20px; margin: 2px 0 0; flex-shrink: 0; }
.inline { display: flex; gap: 8px; margin: 0 0 10px; flex-wrap: wrap; }
.inline input { margin: 0; flex: 1; min-width: 160px; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 560px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.seg { display: flex; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 4px; margin: 0 0 12px; overflow-x: auto; }
.seg a { flex: 1; text-align: center; padding: 8px 6px; border-radius: 8px; text-decoration: none; color: var(--muted); white-space: nowrap; font-weight: 600; font-size: .9rem; }
.seg a.on { background: var(--accent); color: var(--accent-ink); }
.flash { border-radius: 10px; padding: 12px 14px; margin: 0 0 12px; font-weight: 600; }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }

/* payment page */
.payhead { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.payhead > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.big { font-size: 1.4rem; font-weight: 800; white-space: nowrap; }
.filter { margin: 8px 0 10px; }
.items { display: grid; grid-template-columns: 1fr; gap: 6px; }
@media (min-width: 820px) { .items { grid-template-columns: 1fr 1fr; } }
.item { display: grid; grid-template-columns: 1fr auto 84px; gap: 8px; align-items: center; padding: 8px; border-radius: 10px; border: 1px solid var(--line); }
.item.picked { background: var(--soft); border-color: var(--accent); }
.iname { font-weight: 600; min-width: 0; overflow-wrap: break-word; hyphens: auto; }   /* break only a word longer than the line */
.hints { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chip { font: inherit; font-size: .75rem; font-weight: 500; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--muted); cursor: pointer; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.qty { display: flex; align-items: center; }
.qty input { width: 46px; text-align: center; margin: 0; padding: 8px 2px; border-radius: 0; -moz-appearance: textfield; }
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.step { width: 40px; height: 44px; font-size: 1.2rem; font-weight: 700; border: 1px solid var(--line); background: var(--card); color: var(--accent); cursor: pointer; }
.step:first-child { border-radius: 10px 0 0 10px; }
.step:last-child { border-radius: 0 10px 10px 0; }
.price { margin: 0; text-align: right; }
@media (max-width: 480px) {      /* phones: name and quantity on one line, the price box below - names stay whole */
  .item { grid-template-columns: minmax(0, 1fr) auto; row-gap: 6px; }
  .item .price { grid-column: 1 / -1; }
}
.sticky { position: sticky; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 8px); background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; box-shadow: 0 6px 24px rgba(0,0,0,.12); margin-bottom: 8px; }
@media (min-width: 820px) { .sticky { bottom: 12px; } }
.status { font-weight: 600; margin-bottom: 8px; font-size: .92rem; }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.preview { font-size: .88rem; margin-bottom: 8px; max-height: 30vh; overflow: auto; }
.preview div { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }

/* tables, KPIs, bars */
.scroll { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; margin: 8px 0; }
.tbl th, .tbl td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.tbl .r { text-align: right; white-space: nowrap; }
.tbl tfoot td, .tbl tfoot th { border-bottom: 0; }
.tbl tr.neg td { color: var(--bad); }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpis div { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.kpis span { display: block; color: var(--muted); font-size: .8rem; }
.kpis b { font-size: 1.05rem; }
.bar { margin: 0 0 10px; }
.bar .lbl { display: flex; justify-content: space-between; gap: 8px; font-size: .9rem; margin-bottom: 3px; }
.track { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.track div { height: 100%; background: var(--accent); border-radius: 99px; }
