/* Mobile first. One calm palette (light and dark), system fonts, tap targets of 44px and more.
   No inline styles anywhere: the content policy allows only this file. */

/* ---------- Tokens ---------- */
:root {
  color-scheme: light dark;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;

  --paper: #eef2f1;        /* page: soft, never pure white */
  --surface: #ffffff;      /* cards, fields */
  --sunken: #f4f7f6;       /* nested blocks, table heads */
  --ink: #14262a;
  --muted: #586a6e;
  --line: #d8e0df;
  --line-strong: #b7c5c3;

  --primary: #0e6b66;
  --primary-hover: #0a5955;
  --on-primary: #ffffff;
  --primary-soft: #dcefec;

  --ok: #1b7348;      --ok-soft: #dff2e7;
  --warn: #875600;    --warn-soft: #fbefcd;   --warn-line: #ecd596;
  --danger: #ad261d;  --danger-soft: #fbe5e2; --danger-line: #f0bdb7;

  --hero: #12383a;    --on-hero: #eef6f4;     --on-hero-muted: #a8c7c3;

  --ring: rgba(14, 107, 102, 0.3);
  --shadow: 0 1px 2px rgba(20, 38, 42, 0.04), 0 8px 24px -16px rgba(20, 38, 42, 0.22);
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23586a6e' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9.5 6 6 6-6'/%3E%3C/svg%3E");

  --r-s: 0.5rem;
  --r-m: 0.75rem;
  --r-l: 1rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1718;
    --surface: #182224;
    --sunken: #131c1e;
    --ink: #e3ebea;
    --muted: #9badae;
    --line: #283537;
    --line-strong: #3c4d4f;

    --primary: #58c7bd;
    --primary-hover: #74d5cc;
    --on-primary: #05211f;
    --primary-soft: #183b39;

    --ok: #6fd19b;      --ok-soft: #153426;
    --warn: #ebc068;    --warn-soft: #382c11;   --warn-line: #5a4718;
    --danger: #f39489;  --danger-soft: #3c1b18; --danger-line: #6a2b25;

    --hero: #1a4646;    --on-hero: #eef6f4;     --on-hero-muted: #a8c7c3;

    --ring: rgba(88, 199, 189, 0.4);
    --shadow: none;
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239badae' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9.5 6 6 6-6'/%3E%3C/svg%3E");
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
main { max-width: 35rem; margin: 0 auto; padding: 1rem 1rem 2.5rem; }
main.broad { max-width: 76rem; }
body.app main { padding-bottom: calc(6rem + env(safe-area-inset-bottom)); }

h1 { font-size: 1.5rem; line-height: 1.2; font-weight: 700; letter-spacing: -0.015em; margin: 0.4rem 0 1rem; text-wrap: balance; }
h2 { font-size: 1.05rem; line-height: 1.3; font-weight: 650; margin: 0 0 0.6rem; }
p { margin: 0.5rem 0; }
a { color: var(--primary); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
strong { font-weight: 650; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
.ico { width: 1.5rem; height: 1.5rem; flex: none; fill: none; stroke: currentColor; }

/* ---------- Menu: top strip + bottom bar + sheet on a phone ---------- */
.side {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: calc(0.7rem + env(safe-area-inset-top)) 1rem 0.3rem;
}
.brand { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--ink); font-weight: 700; text-decoration: none; letter-spacing: -0.01em; }
.brand .ico { color: var(--primary); width: 1.6rem; height: 1.6rem; }
.who { color: var(--muted); font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.menu-toggle { position: absolute; width: 1px; height: 1px; margin: -1px; opacity: 0; pointer-events: none; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 0.3rem 0.4rem calc(0.3rem + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 0.15rem;
  min-height: 3.2rem; margin: 0; padding: 0.3rem 0.15rem; border-radius: var(--r-m);
  color: var(--muted); font-size: 0.75rem; line-height: 1.2; font-weight: 600; text-decoration: none;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.tab[aria-current="page"] { color: var(--primary); }
.tab:active { background: var(--sunken); }
.tab.new .ico {
  width: 2.75rem; height: 2.75rem; padding: 0.6rem; margin-top: -1.2rem; border-radius: 50%;
  background: var(--primary); color: var(--on-primary); box-shadow: 0 0 0 0.3rem var(--surface);
}
.tab.new { color: var(--ink); }
.menu-toggle:checked ~ .tabs label.tab { color: var(--primary); }
.menu-toggle:focus-visible ~ .tabs label.tab { outline: 3px solid var(--ring); outline-offset: -3px; }

.backdrop {
  position: fixed; inset: 0; z-index: 24; margin: 0; background: rgba(8, 18, 20, 0.5);
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.menu-toggle:checked ~ .backdrop { opacity: 1; pointer-events: auto; }
.menu {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 26;
  max-height: 90vh; overflow-y: auto; overscroll-behavior: contain;
  padding: 1.25rem 1rem calc(5rem + env(safe-area-inset-bottom));
  background: var(--surface); border-radius: 1.25rem 1.25rem 0 0;
  box-shadow: 0 -16px 40px -16px rgba(0, 0, 0, 0.4);
  transform: translateY(105%); visibility: hidden;
  transition: transform 0.22s ease, visibility 0s linear 0.22s;
}
.menu-toggle:checked ~ .menu { transform: none; visibility: visible; transition: transform 0.22s ease; }
.group { margin: 0 0 0.9rem; }
.group-title { margin: 0 0 0.4rem 0.2rem; color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.links { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; }
.links a, .links button.link {
  display: flex; align-items: center; width: 100%; min-height: 2.75rem; margin: 0; padding: 0.45rem 0.8rem;
  border: none; border-radius: var(--r-m); background: var(--sunken);
  color: var(--ink); font-weight: 600; text-align: left; text-decoration: none; justify-content: flex-start;
}
.links a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
.links .inline { display: block; margin: 0; }
.links button.link { color: var(--danger); }
.account { margin-bottom: 0; }

/* ---------- Menu: side column on a wide screen ---------- */
@media (min-width: 62rem) {
  body.app { padding-left: 16rem; }
  body.app main { margin: 0; padding: 2rem 2.5rem 3rem; }
  .side {
    position: fixed; inset: 0 auto 0 0; z-index: 10; width: 16rem;
    flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 0;
    padding: 1.4rem 0.9rem 1rem; overflow-y: auto;
    background: var(--surface); border-right: 1px solid var(--line);
  }
  .brand { padding: 0 0.6rem 1.4rem; font-size: 1.05rem; }
  .who, .tabs, .backdrop, .menu-toggle { display: none; }
  .menu, .menu-toggle:checked ~ .menu {
    position: static; flex: 1; display: flex; flex-direction: column;
    max-height: none; overflow: visible; padding: 0; border-radius: 0; box-shadow: none; background: none;
    transform: none; visibility: visible; transition: none;
  }
  .group { margin-bottom: 1.2rem; }
  .group-title { margin-left: 0.6rem; font-size: 0.8rem; }
  .links { grid-template-columns: 1fr; gap: 0.1rem; }
  .links a, .links button.link { min-height: 2.3rem; padding: 0.4rem 0.6rem; border-radius: var(--r-s); background: none; font-weight: 500; }
  .links a:hover, .links button.link:hover { background: var(--sunken); }
  .links a[aria-current="page"] { background: var(--primary-soft); font-weight: 650; }
  .account { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--line); }
}

/* ---------- Forms ---------- */
label { display: block; margin: 0.75rem 0; color: var(--muted); font-size: 0.9rem; font-weight: 550; }
input, select, button, textarea, .button { font: inherit; }
input[type="text"], input[type="tel"], input[type="password"], input[type="search"], input[type="date"], select, textarea {
  display: block; width: 100%; min-height: 3rem; margin-top: 0.3rem; padding: 0.6rem 0.8rem;
  border: 1px solid var(--line-strong); border-radius: var(--r-m);
  background-color: var(--surface); color: var(--ink); font-size: 1rem; font-weight: 400;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.85; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
select {
  appearance: none; -webkit-appearance: none; padding-right: 2.4rem; text-overflow: ellipsis;
  background-image: var(--chevron); background-repeat: no-repeat; background-position: right 0.7rem center; background-size: 1.1rem;
}
textarea { min-height: 5.5rem; line-height: 1.45; }
input[type="search"] { -webkit-appearance: none; appearance: none; }
input[type="file"] { display: block; max-width: 100%; margin-top: 0.3rem; color: var(--muted); font-size: 0.9rem; }
input[type="file"]::file-selector-button {
  min-height: 2.5rem; margin-right: 0.7rem; padding: 0.35rem 0.9rem; border: 1px solid var(--line-strong); border-radius: var(--r-m);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }
.hint { display: block; margin-top: 0.3rem; color: var(--muted); font-size: 0.85rem; font-weight: 400; }

button, .button {
  display: inline-flex; align-items: center; justify-content: center; text-align: center;
  min-height: 2.9rem; margin: 0.25rem 0; padding: 0.55rem 1.15rem;
  border: 1px solid var(--line-strong); border-radius: var(--r-m);
  background: var(--surface); color: var(--ink); font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
  -webkit-tap-highlight-color: transparent;
}
button:hover, .button:hover { background: var(--sunken); }
button:active, .button:active { transform: translateY(1px); }
.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.danger { color: var(--danger); border-color: var(--danger-line); }
.danger:hover { background: var(--danger-soft); }
.wide { display: flex; width: 100%; }
button.link { min-height: 2.75rem; padding: 0.4rem 0; border: none; background: none; color: var(--primary); font-weight: 600; }
button.link:hover { background: none; text-decoration: underline; }

.row { display: flex; flex-wrap: wrap; gap: 0 0.6rem; align-items: flex-end; }
.row > * { flex: 1 1 6rem; }
.row > input { flex: 999 1 13rem; margin-top: 0.25rem; }
.row > button { flex: 1 0 auto; }
.choice { display: flex; gap: 0.7rem; align-items: center; min-height: 2.9rem; margin: 0; color: var(--ink); font-size: 1rem; font-weight: 400; cursor: pointer; }
.choice input { flex: none; width: 1.35rem; height: 1.35rem; margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 0 0.8rem; align-items: flex-end; }
.filters > label { flex: 1 1 8.5rem; }
.filters > button { margin-bottom: 0.75rem; }
main > form.filters { margin: 1rem 0; padding: 0.25rem 1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); }
.inline { display: inline; margin: 0 0 0 auto; }
details summary { padding: 0.6rem 0; color: var(--primary); font-weight: 600; cursor: pointer; }

/* ---------- Blocks ---------- */
.card {
  margin: 1rem 0; padding: 1rem 1.1rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow);
}
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.attention { background: var(--warn-soft); border-color: var(--warn-line); box-shadow: none; }
.attention .item { border-color: var(--warn-line); }
.check { border: 2px solid var(--primary); }
/* the one loud block: the money a person is holding */
.money { background: var(--hero); border-color: transparent; color: var(--on-hero); }
.money h2 { color: var(--on-hero-muted); font-weight: 550; }
.money .big { font-size: 2.1rem; }
.money a { color: var(--on-hero); font-weight: 600; }
/* a person's pockets, one per line; the cashed-out money under the card it came from */
.pocket { margin: 0.2rem 0; }
.pocket.sub { padding-left: 1.1rem; }

.item { border-top: 1px solid var(--line); padding: 0.7rem 0; }
.item:first-of-type { border-top: none; }
.item ul { margin: 0.3rem 0; padding-left: 1.2rem; }
.line { margin: 0.75rem 0; padding: 0.75rem 0.8rem; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r-m); }
.line > p { margin-top: 0; }
.payment { border-top: 1px solid var(--line); padding: 0.3rem 0; }
.payment:first-of-type { border-top: none; }
.hit { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 0.6rem 0; border-top: 1px solid var(--line); }
#customers:not(:empty), #products:not(:empty) { margin-top: 0.5rem; }

.list { list-style: none; margin: 0.25rem 0; padding: 0; }
.list li { margin: 0; padding: 0.7rem 0; border-top: 1px solid var(--line); line-height: 1.6; }
.list li:first-child { border-top: none; }
.list li > a:first-child { font-weight: 650; text-decoration: none; }
main > .list { margin: 1rem 0; padding: 0.2rem 1.1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow); }

.muted { color: var(--muted); }
.big { font-size: 1.6rem; line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; }
.warn { color: var(--warn); font-weight: 700; }
.error { color: var(--danger); font-weight: 600; }
p.error { padding: 0.7rem 0.9rem; background: var(--danger-soft); border: 1px solid var(--danger-line); border-radius: var(--r-m); }
.notice { padding: 0.7rem 0.9rem; background: var(--warn-soft); border: 1px solid var(--warn-line); border-radius: var(--r-m); }
.status {
  display: inline-block; padding: 0.05rem 0.6rem; border-radius: 999px; white-space: nowrap;
  background: var(--ok-soft); color: var(--ok); font-size: 0.8rem; font-weight: 600;
}
.status.pending { background: var(--warn-soft); color: var(--warn); }
.status.cancelled, .status.rejected { background: var(--danger-soft); color: var(--danger); }
.url { word-break: break-all; }
.pre { white-space: pre-line; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; margin: 0.5rem 0; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 0.8rem; font-weight: 600; vertical-align: bottom; }
tbody tr:last-child td { border-bottom: none; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
.num { text-align: right; white-space: nowrap; }
td button { min-height: 2.5rem; padding: 0.35rem 0.9rem; }
td form { margin: 0; }

/* Owner pages: wide tables scroll inside their own frame. */
.scroll { overflow-x: auto; margin: 0.75rem 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); }
.scroll table { min-width: 36rem; margin: 0; }
.scroll th { background: var(--sunken); white-space: nowrap; }
.scroll th:first-child, .scroll td:first-child { padding-left: 1rem; }
.scroll th:last-child, .scroll td:last-child { padding-right: 1rem; }
.scroll tbody tr:hover td { background: var(--sunken); }
.card .scroll { margin: 0.5rem -1.1rem; border-width: 1px 0; border-radius: 0; }
.card .scroll th:first-child, .card .scroll td:first-child { padding-left: 1.1rem; }
.card .scroll th:last-child, .card .scroll td:last-child { padding-right: 1.1rem; }
.card > .scroll:last-child { margin-bottom: -1rem; border-bottom: none; border-radius: 0 0 var(--r-l) var(--r-l); }

/* ---------- Owner overview ---------- */
.dash { display: grid; grid-template-columns: 1fr; gap: 0; padding-top: 0.3rem; padding-bottom: 0.3rem; }
.dash > * { margin: 0; }
.dash > h2 { padding-top: 0.9rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.9rem; font-weight: 600; }
.dash > h2:first-child { border-top: none; }
.dash > :not(h2) { padding: 0.2rem 0 0.9rem; }
.dash p { margin: 0.15rem 0; }
.cells { display: flex; flex-wrap: wrap; gap: 0.4rem 0.5rem; align-items: center; }
.cells input[type="text"] { display: inline-block; width: 9rem; margin-top: 0; }
.cells > form { margin: 0; }
p.cells > a, p.cells > strong {
  display: inline-flex; align-items: center; min-height: 2.4rem; padding: 0.3rem 0.85rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink); font-size: 0.9rem; font-weight: 600; text-decoration: none;
}
p.cells > a:hover { background: var(--sunken); }
p.cells > strong { background: var(--primary-soft); border-color: transparent; color: var(--primary); }
@media (min-width: 44rem) {
  .dash { grid-template-columns: minmax(10rem, 15rem) 1fr; column-gap: 1.5rem; }
  .dash > h2, .dash > :not(h2) { padding: 0.9rem 0; border-top: 1px solid var(--line); }
  .dash > h2:first-child, .dash > h2:first-child + * { border-top: none; }
}

/* ---------- Sign-in ---------- */
.signin { margin: 12vh auto 0; max-width: 24rem; }
.signin .brand { margin-bottom: 1.2rem; font-size: 1.1rem; }
.signin .card { padding: 1.4rem 1.3rem; }
.signin h1 { font-size: 1.35rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
@media print {
  .side { display: none; }
  body, body.app { padding: 0; background: #fff; color: #000; }
  .card, .scroll { box-shadow: none; }
}

/* Lines of a sale on the seller's page: «3 × 1 050 000 ₸ … 3 150 000 ₸»; the total drops under when it does not fit */
.lines .split { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0 0.8rem; }
.lines .split > :last-child { margin-left: auto; text-align: right; }
.lines .split > :first-child { color: var(--muted); }

/* The scan page: the queue's status line and the reads that need scanning again (kept until their own «Убрать») */
.scan-status:empty, .scan-alerts:empty { display: none; }
.scan-status { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.8rem; margin: 0.5rem 0; color: var(--muted); font-weight: 600; }
.scan-alerts { margin: 0.5rem 0; padding: 0.2rem 1.1rem; background: var(--warn-soft); border: 1px solid var(--warn-line); border-radius: var(--r-l); }
.scan-alerts li { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; color: var(--warn); }
.scan-skip { margin: -0.5rem 0 1rem; }

/* The scan page's camera (/static/scan.js): a square frame, the outline the decoder reads inside (70 % of it),
   dimmed with a note while a question waits; frame and «Стоп» only while the camera is on */
.scan-camera-buttons { display: flex; gap: 0.6rem; }
.scan-camera-buttons > button { flex: 1 1 0; }
.scan-camera #scan-stop, .scan-camera .scan-frame { display: none; }
.scan-camera.is-on #scan-stop { display: inline-flex; }
.scan-camera.is-on #scan-start { display: none; }
.scan-camera.is-on .scan-frame { display: block; }
.scan-frame { position: relative; width: 100%; max-width: 28rem; aspect-ratio: 1 / 1; margin: 0.75rem auto 0; overflow: hidden; border-radius: var(--r-l); background: #000; }
.scan-frame video { display: block; width: 100%; height: 100%; object-fit: cover; transition: opacity 0.2s; }
.scan-target { position: absolute; inset: 15%; border: 3px solid rgba(255, 255, 255, 0.9); border-radius: var(--r-m); box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.25); pointer-events: none; }
.scan-wait { display: none; position: absolute; left: 0; right: 0; bottom: 0; margin: 0; padding: 0.6rem; background: var(--warn-soft); color: var(--warn); font-weight: 600; text-align: center; }
.scan-camera.is-busy video { opacity: 0.35; }
.scan-camera.is-busy .scan-wait { display: block; }
.scan-hint { margin: 0.6rem 0 0; font-size: 0.9rem; }
.scan-problem { margin: 0.6rem 0 0; color: var(--warn); font-weight: 600; }
.scan-problem:empty { display: none; }
