/* Táborové účto — design tokens.
 * A field tool: used on phones, in tents, on bad light and bad internet.
 * No webfonts (offline-first), system stack + tabular numerals for money.
 * Both themes are derived from the same tokens; components below never
 * hardcode a color. */

:root {
  --bg: #eef1ea;            /* paper with a green cast */
  --card: #ffffff;
  --field: #ffffff;
  --ink: #20281f;
  --muted: #5c675c;
  --line: #dce2d7;
  --accent: #2e7d32;        /* brand pine green — buttons, marks */
  --accent-ink: #ffffff;
  --accent-soft: #e5efe2;
  --link: #256729;
  --bar: #1d4520;           /* topbar: deep pine */
  --bar-ink: #eff5ec;
  --error: #b3261e;
  --warn-bg: #fdf3d1;  --warn-line: #ecd98f; --warn-ink: #6d5600;
  --ok-bg: #ddeddb;    --ok-ink: #1d5e20;
  --info-bg: #e1eefb;  --info-ink: #114a8b;
  --ocr-bg: #e8f2fd;   --ocr-line: #8fbfe8;
  --shadow: 0 1px 2px rgba(28, 42, 26, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151a14;
    --card: #1e241d;
    --field: #171c16;
    --ink: #e4e9e0;
    --muted: #9caa97;
    --line: #333d30;
    --accent: #2e7d32;
    --accent-ink: #ffffff;
    --accent-soft: #24371f;
    --link: #8ecf90;
    --bar: #14290f;
    --bar-ink: #dce7d6;
    --error: #ef7b70;
    --warn-bg: #37311a; --warn-line: #57511f; --warn-ink: #eece7b;
    --ok-bg: #1e3a20;   --ok-ink: #a4d8a6;
    --info-bg: #1a3049; --info-ink: #a3cbf0;
    --ocr-bg: #1c2f42;  --ocr-line: #3c6ea5;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
}

a { color: var(--link); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-color-scheme: dark) {
  :focus-visible { outline-color: var(--link); }
}

/* ---- chrome ------------------------------------------------------------ */

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .3rem 1rem;
  padding: .55rem .9rem;
  background: var(--bar);
  color: var(--bar-ink);
}
.topbar a, .topbar .linklike { color: inherit; text-decoration: none; }
.topbar nav {
  display: flex; align-items: center; gap: .1rem; flex-wrap: wrap;
}
.topbar nav a, .topbar .linklike {
  padding: .3rem .6rem;
  border-radius: 99px;
  opacity: .85;
}
.topbar nav a:hover, .topbar .linklike:hover {
  opacity: 1;
  background: rgba(255, 255, 255, .12);
}
.topbar nav a.active {
  opacity: 1;
  background: rgba(255, 255, 255, .16);
  font-weight: 600;
}
.brand { font-weight: 700; font-size: 1.05rem; letter-spacing: .01em; }

main { max-width: 60rem; margin: 1.2rem auto; padding: 0 1rem; }

h1 { font-size: 1.45rem; margin: .2rem 0 1rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  overflow-x: auto;   /* wide tables scroll inside the card, not the page */
}

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "Cascadia Mono", monospace; font-size: .85em; }
.error { color: var(--error); font-weight: 600; }
.inactive { opacity: .5; }

/* ---- tables ------------------------------------------------------------ */

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .5rem; border-bottom: 1px solid var(--line); }
th {
  color: var(--muted);
  font-weight: 600;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }

/* money reads like a receipt: right-aligned, digits in columns */
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.neg { color: var(--error); }

/* ---- forms ------------------------------------------------------------- */

form.row { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; }
form.inline { display: inline; }
form.stack { display: flex; flex-direction: column; gap: .8rem; align-items: stretch; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; }

input, select, button, textarea {
  font: inherit;
  color: var(--ink);
  padding: .45rem .6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}
input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
input:focus-visible, select:focus-visible {
  outline-offset: 0;
  border-color: var(--accent);
}

button, .button {
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid transparent;
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
  padding: .5rem 1rem;
  border-radius: 8px;
}
button:hover, .button:hover { filter: brightness(1.08); }
button:active, .button:active { transform: translateY(1px); }
button.small { padding: .25rem .6rem; font-size: .85rem; }

button.secondary, .button.secondary, .secondary-link {
  background: var(--card);
  color: var(--ink);
  border-color: var(--line);
}
button.secondary:hover, .button.secondary:hover, .secondary-link:hover {
  border-color: var(--accent);
  filter: none;
}
.secondary-link { font-size: .9rem; }

button.danger {
  background: transparent;
  color: var(--error);
  border-color: color-mix(in srgb, var(--error) 45%, transparent);
}
button.danger:hover {
  background: color-mix(in srgb, var(--error) 10%, transparent);
  filter: none;
}

button.linklike {
  background: none; border: none; padding: 0; font-weight: 400; cursor: pointer;
  color: var(--link);
}

.joined { display: flex; gap: .3rem; }
.joined input { flex: 1; min-width: 6rem; }

[hidden] { display: none !important; }

/* ---- layout bits ------------------------------------------------------- */

.page-head { display: flex; align-items: center; justify-content: space-between;
             gap: .5rem 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.spacer { flex: 1; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
         gap: 1rem; margin-bottom: 1rem; }
.tile { display: flex; flex-direction: column; gap: .2rem; margin-bottom: 0; }
.tile-label { color: var(--muted); font-size: .8rem; text-transform: uppercase;
              letter-spacing: .05em; }
.tile-value { font-size: 1.35rem; font-weight: 700;
              font-variant-numeric: tabular-nums; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
               align-items: start; }
@media (max-width: 50rem) { .detail-grid { grid-template-columns: 1fr; } }

dl.props { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1rem; margin: 0; }
dl.props dt { color: var(--muted); }
dl.props dd { margin: 0; }

.actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; align-items: center; }

/* ---- badges & chips ---------------------------------------------------- */

.badge { font-size: .78rem; font-weight: 600; padding: .1rem .55rem;
         border-radius: 99px; white-space: nowrap; vertical-align: middle; }
.badge.draft { background: var(--warn-bg); color: var(--warn-ink); }
.badge.confirmed { background: var(--ok-bg); color: var(--ok-ink); }
.badge.processing { background: var(--info-bg); color: var(--info-ink); }

.chip { --chip: #888; font-size: .82rem; padding: .1rem .55rem;
        border-radius: 99px; white-space: nowrap;
        background: color-mix(in srgb, var(--chip) 18%, var(--card));
        color: color-mix(in srgb, var(--chip) 60%, var(--ink)); }
.chip-delete { color: inherit; margin-left: .2rem; }
.aliases { display: flex; gap: .3rem; flex-wrap: wrap; }

.notice { background: var(--warn-bg); border: 1px solid var(--warn-line);
          color: var(--warn-ink); padding: .5rem .8rem; border-radius: 8px; }
.hint { margin: 0 0 .8rem; font-size: .88rem; }

.progress { height: .5rem; background: var(--line); border-radius: 99px;
            overflow: hidden; margin: .2rem 0; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 99px; }
.progress-bar.over { background: var(--error); }

/* ---- receipt form & OCR ------------------------------------------------ */

.from-ocr { background: var(--ocr-bg); border-color: var(--ocr-line); }
.ocr-hint .swatch { display: inline-block; width: .9em; height: .9em;
                    background: var(--ocr-bg); border: 1px solid var(--ocr-line);
                    border-radius: 3px; vertical-align: -.1em; }

.photo-pane img { max-width: 100%; border-radius: 8px; }
.pdf-embed { width: 100%; height: 28rem; border: 1px solid var(--line); border-radius: 8px; }

.ocr-panel { margin-top: .8rem; }
.ocr-panel summary { cursor: pointer; color: var(--muted); }
.ocr-panel pre { max-height: 20rem; overflow: auto; font-size: .78rem;
                 background: var(--bg); padding: .6rem; border-radius: 8px; }

.items-editor input, .items-editor select { padding: .3rem .4rem; font-size: .9rem; }
.items-editor td { padding: .2rem .25rem; }
.items-editor .num-input { width: 6rem; text-align: right; }
.items-editor .qty-input { width: 4.5rem; text-align: right; }

/* ---- crop UI (crop.js) -------------------------------------------------- */

.crop-wrap { margin-top: .5rem; }
.crop-stage { position: relative; display: inline-block; max-width: 100%;
              overflow: hidden; border-radius: 8px; }
.crop-stage img { max-width: 100%; max-height: 26rem; display: block;
                  user-select: none; -webkit-user-drag: none; }
.crop-box { position: absolute; border: 2px solid var(--accent);
            box-shadow: 0 0 0 9999px rgba(0, 0, 0, .45); cursor: move;
            touch-action: none; }
.crop-handle { position: absolute; width: 22px; height: 22px;
               background: var(--accent); border: 2px solid #fff;
               border-radius: 50%; }
.crop-handle.nw { left: -11px; top: -11px; cursor: nwse-resize; }
.crop-handle.ne { right: -11px; top: -11px; cursor: nesw-resize; }
.crop-handle.sw { left: -11px; bottom: -11px; cursor: nesw-resize; }
.crop-handle.se { right: -11px; bottom: -11px; cursor: nwse-resize; }

/* ---- cash form (segmented control) -------------------------------------- */

.segmented { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .5rem; }
.segmented label { flex-direction: row; }
.segmented input[type="radio"] {
  position: absolute; opacity: 0; width: 0; height: 0;
}
.segmented span {
  display: inline-block; padding: .4rem .8rem; border-radius: 99px;
  border: 1px solid var(--line); background: var(--field); cursor: pointer;
  font-size: .92rem; user-select: none;
}
.segmented span:hover { border-color: var(--accent); }
.segmented input:checked + span {
  background: var(--accent); border-color: var(--accent);
  color: var(--accent-ink); font-weight: 600;
}
.segmented input:focus-visible + span {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---- reports & products ------------------------------------------------- */

.chart-wrap { position: relative; height: 16rem; }
.chart-table { margin-top: .8rem; }
.rate-input { width: 5.5rem; text-align: right; }

.assign-form { display: flex; gap: .3rem; flex-wrap: wrap; }
.assign-form input, .assign-form select { padding: .3rem .4rem; font-size: .9rem; }
.assign-form input[name="pattern"] { width: 11rem;
    font-family: ui-monospace, "Cascadia Mono", monospace; }
.assign-form input[name="product_name"] { width: 9rem; }

.outbox-banner { margin-bottom: 1rem; }

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

.login-card { max-width: 24rem; margin: 3rem auto; text-align: center; }
.login-card .button, .login-card button { width: 100%; margin-top: .8rem; }
.dev-login { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px dashed var(--line); }
.dev-login label { text-align: left; margin-bottom: .5rem; }

/* ---- small screens ------------------------------------------------------ */

@media (max-width: 40rem) {
  main { margin-top: .6rem; }
  .card { padding: .8rem; }
  th, td { padding: .4rem .3rem; font-size: .92rem; }
  h1 { font-size: 1.25rem; }
  .topbar { padding: .45rem .6rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
