/* The Juraboshi panel stylesheet — one file, both services.
 *
 * Shared byte for byte by Teaplaces and Bazaar, which is the point: the two
 * panels were separate copies of the same design and had already begun to
 * drift (a focus ring here, a checkbox fix there). A service picks its palette
 * with <body data-service="teaplaces|bazaar"> and changes nothing else.
 *
 * The design is the hand-written one this replaced, with two deliberate
 * changes. The colour variables were renamed — from what they are (--amber) to
 * what they mean (--accent) — so one rule can serve an amber panel and a green
 * one. And there is no monospace any more: Sen for headings, Inter for
 * everything else, figures and labels included. Bordered cards on warm paper,
 * a floating tab bar, 44px touch targets.
 *
 * Costs and counts keep their columns through Inter's tabular digits (.num),
 * not a fixed-width face. The Inter files are cut from the official release
 * (github.com/rsms/inter, v4.1) to the three unicode ranges below, keeping
 * tnum and case.
 *
 * A card shows one status, and it is the only badge (.tag). Facts about the
 * row -- QR checked, a photo's age, a date -- are .meta: plain muted text, with
 * a dot when the fact is good news. Colour never carries a state alone; the
 * words always say it. Status text uses the --*-ink shades, which hold 4.5:1
 * on their tinted fills (the plain --ok/--warn/--no did not).
 *
 * Fonts are served from /static/fonts (OFL; licences are beside them) and the
 * icons are inlined as an SVG sprite. Both used to come from a third-party CDN,
 * which inside Telegram's webview is a round trip before the first paint: on a
 * slow connection the panel rendered in a fallback face with no icons at all.
 */

@font-face { font-family: "Inter"; font-style: normal;
  font-weight: 400; font-display: swap;
  src: url("../fonts/inter-cyrillic-400-normal.woff2") format("woff2");
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}
@font-face { font-family: "Inter"; font-style: normal;
  font-weight: 400; font-display: swap;
  src: url("../fonts/inter-latin-ext-400-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face { font-family: "Inter"; font-style: normal;
  font-weight: 400; font-display: swap;
  src: url("../fonts/inter-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face { font-family: "Inter"; font-style: normal;
  font-weight: 500; font-display: swap;
  src: url("../fonts/inter-cyrillic-500-normal.woff2") format("woff2");
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}
@font-face { font-family: "Inter"; font-style: normal;
  font-weight: 500; font-display: swap;
  src: url("../fonts/inter-latin-ext-500-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face { font-family: "Inter"; font-style: normal;
  font-weight: 500; font-display: swap;
  src: url("../fonts/inter-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face { font-family: "Inter"; font-style: normal;
  font-weight: 600; font-display: swap;
  src: url("../fonts/inter-cyrillic-600-normal.woff2") format("woff2");
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}
@font-face { font-family: "Inter"; font-style: normal;
  font-weight: 600; font-display: swap;
  src: url("../fonts/inter-latin-ext-600-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face { font-family: "Inter"; font-style: normal;
  font-weight: 600; font-display: swap;
  src: url("../fonts/inter-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face { font-family: "Inter"; font-style: normal;
  font-weight: 700; font-display: swap;
  src: url("../fonts/inter-cyrillic-700-normal.woff2") format("woff2");
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116;
}
@font-face { font-family: "Inter"; font-style: normal;
  font-weight: 700; font-display: swap;
  src: url("../fonts/inter-latin-ext-700-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face { font-family: "Inter"; font-style: normal;
  font-weight: 700; font-display: swap;
  src: url("../fonts/inter-latin-700-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face { font-family: "Sen"; font-style: normal;
  font-weight: 400; font-display: swap;
  src: url("../fonts/sen-latin-ext-400-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face { font-family: "Sen"; font-style: normal;
  font-weight: 400; font-display: swap;
  src: url("../fonts/sen-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face { font-family: "Sen"; font-style: normal;
  font-weight: 700; font-display: swap;
  src: url("../fonts/sen-latin-ext-700-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face { font-family: "Sen"; font-style: normal;
  font-weight: 700; font-display: swap;
  src: url("../fonts/sen-latin-700-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face { font-family: "Sen"; font-style: normal;
  font-weight: 800; font-display: swap;
  src: url("../fonts/sen-latin-ext-800-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face { font-family: "Sen"; font-style: normal;
  font-weight: 800; font-display: swap;
  src: url("../fonts/sen-latin-800-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

/* ── Palette ────────────────────────────────────────────────────────────────
 *
 * Teaplaces is the default. Bazaar's greens are not decoration: fresh, turning
 * and gone are the three states a supplier is judged on, so the palette is the
 * domain model. Everything below this block is colour-blind — it only ever
 * names --accent, --ok, --warn and --no.
 */

:root {
  --paper: #faf7f2;
  --surface: #ffffff;
  --line: #e8e3da;
  --ink: #111215;
  --muted: #6b7280;

  --accent: #e67e22;
  --accent-soft: rgba(230, 126, 34, 0.1);
  /* The accent as text (links, the current tab, focus) and as a filled button.
     Bright orange holds only 2.9:1 with white, so text on it is ink. */
  --accent-ink: #a65e1e;
  --button: #e67e22;
  --on-button: #111215;

  --ok: #2ecc71;
  --ok-soft: rgba(46, 204, 113, 0.1);
  --ok-ink: #227c49;                          /* text on --ok-soft */
  --warn: #e67e22;                            /* Teaplaces: waiting is amber */
  --warn-soft: rgba(230, 126, 34, 0.1);
  --warn-ink: #9e591e;
  --no: #e74c3c;
  --no-soft: rgba(231, 76, 60, 0.1);
  --no-ink: #b83f33;

  --shadow-sm: 0 1px 2px rgba(17, 18, 21, 0.05);
  --radius-lg: 12px;
  --radius-md: 10px;
  --illustration-width: 250px;
  --illustration-blend: multiply;
}

body[data-service="bazaar"] {
  --paper: #f1f5ef;
  --line: #dce5d9;
  --ink: #14201a;
  --muted: #667a6f;

  /* fresh — the primary accent, and the state every product is trying to be */
  --accent: #3f8f4a;
  --accent-soft: rgba(63, 143, 74, 0.1);
  --accent-ink: #387c42;                      /* white on it: 5.1:1 */
  --button: #387c42;
  --on-button: #fff;

  --ok: #3f8f4a;
  --ok-soft: rgba(63, 143, 74, 0.1);
  --ok-ink: #36773f;
  /* turning — a photo going stale, produce near its date */
  --warn: #dd8127;
  --warn-soft: rgba(221, 129, 39, 0.12);
  --warn-ink: #935d22;
  /* gone — expired, declined, refused */
  --no: #c8394f;
  --no-soft: rgba(200, 57, 79, 0.1);
  --no-ink: #bb374b;

  --shadow-sm: 0 1px 2px rgba(20, 32, 26, 0.05);
  --illustration-width: 260px;
  --illustration-blend: normal;
}

/* ── Base ───────────────────────────────────────────────────────────────── */

* { box-sizing: border-box; }
body {
  /* Declared here, not on :root, so var(--line) resolves against the service's
     own palette on <body> -- on :root every panel got Teaplaces' line. */
  --hairline: 1px solid var(--line);
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.5 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(env(safe-area-inset-bottom, 0) + 80px); /* space for the tab bar */
  -webkit-font-smoothing: antialiased;
}
body.in-telegram header { display: none; }
body.in-telegram main { padding-top: 1rem; }
/* Type scale: page title 26, section and card title 20, minor title 16, body
   16, supporting text 14, captions 12. Nothing read often goes below 14. */
h1, h2, h3 { font-family: "Sen", "Inter", sans-serif; font-weight: 700; margin: 0 0 .5rem; }
h1 { font-size: 26px; line-height: 1.25; letter-spacing: -0.01em; color: var(--ink); }
h2 { font-size: 20px; line-height: 1.3; }
h3 { font-size: 16px; line-height: 1.4; }
/* The line above a title: where, when, for whom. Grey, because it describes;
   in Bazaar and Teaplaces the accent is also a status colour. */
.eyebrow {
  font-family: "Inter", sans-serif; font-size: 14px;
  color: var(--muted); font-weight: 500; margin-bottom: 0.25rem; display: block;
}
/* A literal someone types or copies (BOT_TOKEN, .env). Weight sets it apart. */
.code { font-family: "Inter", sans-serif; font-weight: 600; font-variant-numeric: tabular-nums; }
a { color: var(--accent-ink); text-decoration: none; transition: opacity 0.2s ease; }
a:hover { opacity: 0.8; }
/* No 300ms double-tap wait on anything that is tapped. */
a, button, input, select, textarea, label, summary { touch-action: manipulation; }
summary { cursor: pointer; }

/* Icons are an inline sprite (templates/_icons.html), sized by the text around
   them: an icon in a 20px nav label is 20px without anyone saying so. */
.ic {
  width: 1em; height: 1em; display: inline-block; vertical-align: -0.125em;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

/* ── Sticky top bar (browser) ───────────────────────────────────────────── */

header {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: var(--hairline);
  padding: 1rem 1.25rem;
  position: sticky; top: 0; z-index: 100;
}
.bar { max-width: 980px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; }
.bar .brand { font-family: "Sen", sans-serif; font-size: 22px; font-weight: 800; color: var(--ink); }

/* ── Floating tab bar (iOS / Telegram Mini App) ─────────────────────────── */

.bottom-nav {
  display: flex; justify-content: space-around; align-items: center;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(20px);
  border-top: var(--hairline);
  padding: 0.8rem 1rem calc(env(safe-area-inset-bottom, 0) + 0.8rem);
  z-index: 999;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.05);
}
.bottom-nav a, .bottom-nav summary {
  font-size: 14px; font-weight: 600; color: var(--muted);
  padding: 0.6rem 1rem; border-radius: var(--radius-lg);
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.bottom-nav .ic { width: 20px; height: 20px; }
.bottom-nav a.on, .bottom-nav details.on > summary { color: var(--accent-ink); background: var(--accent-soft); }

/* A phone has room for four tabs. A panel with more keeps its daily ones on
   the bar and folds the set-up pages into "Yana"; from 720px every tab fits. */
.bottom-nav .setup { display: none; }
.bottom-nav details { position: relative; }
.bottom-nav summary { list-style: none; }
.bottom-nav summary::-webkit-details-marker { display: none; }
.bottom-nav .more-menu {
  position: absolute; right: 0; bottom: calc(100% + 8px); min-width: 12rem;
  display: flex; flex-direction: column; padding: 6px;
  background: var(--surface); border: var(--hairline); border-radius: var(--radius-md);
  box-shadow: 0 4px 16px rgba(17, 18, 21, 0.08);
}
.bottom-nav .more-menu a { flex-direction: row; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: 8px; }
@media (min-width: 720px) {
  .bottom-nav .setup { display: flex; }
  .bottom-nav details { display: none; }
}

main { max-width: 1200px; width: 100%; margin: 0 auto; padding: 2rem 1.25rem; }
@media (max-width: 600px) { main { padding: 1rem; } }

/* ── Cards ──────────────────────────────────────────────────────────────── */

.card {
  background: var(--surface); border-radius: var(--radius-lg);
  border: var(--hairline);
  padding: 1.5rem; margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}
/* Something the owner still owes the row: a missing photo, an unanswered
   request. The edge is the only place the list shows it before you read a
   word — which is the point. */
.card.attention { border-left: 3px solid var(--warn); }
.row { display: flex; gap: 1.5rem; flex-wrap: wrap; align-items: center; }
.grow { flex: 1 1 auto; }
/* A card's status column: beside the title on a wide screen, under it and
   aligned with it on a phone, where the row wraps anyway. */
.side { text-align: right; }
@media (max-width: 600px) { .side { text-align: left; flex-basis: 100%; } }
.muted { color: var(--muted); }
/* Costs, counts, quantities, phone numbers. The face is named, not inherited, so
   a figure in a heading is Inter rather than Sen; tabular digits line it up. */
.num { font-family: "Inter", sans-serif; font-variant-numeric: tabular-nums; }
/* What the card costs: findable at a glance, still smaller than the title. */
.total { font-size: 18px; font-weight: 600; }

/* Something went wrong and the page says so: role="alert" in the markup. */
.error { color: var(--no-ink); font-weight: 500; }

/* A supporting fact, not a status: QR checked, a photo's age, a date. */
.meta { font-size: 14px; line-height: 1.5; color: var(--muted); }
.meta.ok::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok); margin-right: 6px; vertical-align: 1px;
}

/* The delivery code written on the crates: read from arm's length. Its
   alphabet drops 0/O and 1/I/L, so it needs no fixed-width face. */
.code-big {
  font-family: "Inter", sans-serif; font-variant-numeric: tabular-nums;
  font-size: 44px; font-weight: 600; letter-spacing: .04em; line-height: 1.1;
  color: var(--ink); margin: 0 0 .4rem;
}

/* ── Tables ─────────────────────────────────────────────────────────────── */

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.8rem 0.5rem; border-bottom: var(--hairline); }
th { font-size: 12px; color: var(--muted); font-weight: 500; }
/* A figure never breaks at its thousands space ("11 / 000,00"): the table
   scrolls inside .scroll instead of squeezing its columns. */
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ── Status tags ────────────────────────────────────────────────────────── */

.tag {
  display: inline-block; border-radius: 4px;
  padding: 4px 8px; font-size: 12px; line-height: 1.3; font-weight: 600;
  background: var(--paper); color: var(--muted);
}
/* Two vocabularies, one set of colours: Teaplaces answers yes/no/waiting,
   Bazaar grades produce fresh/turning/gone. They are the same three states. */
.tag.yes,  .tag.fresh   { background: var(--ok-soft);   color: var(--ok-ink); }
.tag.open, .tag.stale   { background: var(--warn-soft); color: var(--warn-ink); }
.tag.no,   .tag.expired { background: var(--no-soft);   color: var(--no-ink); }

/* ── Buttons ────────────────────────────────────────────────────────────── */

button, .btn {
  font: 600 15px "Inter", sans-serif; border-radius: var(--radius-md); cursor: pointer;
  border: none; background: var(--button); color: var(--on-button);
  padding: 0.8rem 1.2rem; min-height: 44px;   /* iOS touch target */
  transition: transform 0.1s ease;
}
button:active { transform: scale(0.97); }
/* Sent, waiting for the server: base.html disables it so a second tap is not a
   second order. */
button:disabled { opacity: 0.6; cursor: progress; transform: none; }
button.ghost, .btn.ghost { background: var(--paper); color: var(--ink); border: var(--hairline); }
button.danger { background: var(--no-soft); color: var(--no-ink); }

/* ── Inputs ─────────────────────────────────────────────────────────────── */

/* 16px, not less: iOS zooms the whole Mini App into any smaller field. */
input, select, textarea {
  font: 16px "Inter", sans-serif; padding: 0.8rem 1rem;
  border: var(--hairline); border-radius: var(--radius-md); background: var(--paper);
  color: var(--ink); min-height: 44px; transition: border-color 0.2s;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent-ink); }
/* A checkbox is not a text field and must not inherit the 44px row height. */
input[type="checkbox"] { min-height: 0; }
form.inline { display: flex; gap: 0.8rem; flex-wrap: wrap; align-items: flex-end; }
/* A field with its name above it. A placeholder is an example, never the only
   label: once a value is typed or prefilled, the name has to stay visible. */
.field {
  display: inline-flex; flex-direction: column; gap: 4px;
  font-size: 14px; font-weight: 500; color: var(--ink);
}
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.empty { color: var(--muted); padding: 2rem 1rem; text-align: center; }
/* The heading in an empty state is the invitation, not the aside. */
.empty h2 { color: var(--ink); }

/* The 4:3 box is held before the art arrives, so the text below never jumps. */
.illustration {
  width: 100%; max-width: var(--illustration-width); margin: 0 auto 1.5rem; display: block;
  aspect-ratio: 4 / 3; height: auto; object-fit: contain;
  border-radius: var(--radius-lg); mix-blend-mode: var(--illustration-blend);
}

/* ── Top loading bar ────────────────────────────────────────────────────── */

/* Scaled, not resized: a transform runs on the compositor, a width change
   re-lays-out the bar every frame. */
.top-loader {
  position: fixed; top: 0; left: 0; height: 3px; width: 100%;
  background: var(--accent); transform-origin: left; transform: scaleX(0);
  z-index: 10000; opacity: 0;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
  pointer-events: none;
}
.top-loader.loading {
  opacity: 1; transform: scaleX(0.7);
  animation: loader-pulse 1.8s infinite ease-in-out;
}
@keyframes loader-pulse {
  0% { transform: scaleX(0.25); }
  50% { transform: scaleX(0.75); }
  100% { transform: scaleX(0.9); }
}

/* ── Everyone gets a focus ring and a way out of the animation ──────────── */

:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
