/* ISTOK Group: obsidian and gold, as on istokgroup.com. One dark theme: the brand is dark whatever the phone is set to. */
:root {
  --bg: #141317;           /* obsidian, the site's background */
  --surface: #1b1a1f;
  --raised: #222127;
  --text: #ededf0;
  --muted: #9d9aa4;
  --line: #2e2c33;
  --accent: #c9b37e;       /* the site's gold */
  --accent-light: #e3d3a3;
  --accent-deep: #8f7b52;
  --accent-text: #141317;
  --pay: #9fd3a8;
  --pay-bg: #1b2a1f;
  --review: #eba35c;       /* amber, apart from the gold of buttons and links */
  --review-bg: #33240f;
  --neutral-bg: #26252b;
  --error: #f19a90;
  --error-bg: #3b1c1a;
  --mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

a { color: var(--accent); }
@media (hover: hover) { a:hover { color: var(--accent-light); } }
::selection { background: var(--accent-deep); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgb(20 19 23 / 0.92);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(8px);
}

/* the logo and the app's name in the site's mono capitals */
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.brand img { display: block; height: 28px; width: auto; }
.brand span { padding-left: 12px; border-left: 1px solid var(--line); color: var(--accent); font: 500 12px/1 var(--mono);
              letter-spacing: 0.16em; text-transform: uppercase; }
.top nav { display: flex; flex-wrap: wrap; gap: 4px 18px; align-items: center; }
.top nav a { padding: 6px 0; color: var(--muted); font: 500 12px/1.4 var(--mono); letter-spacing: 0.1em; text-transform: uppercase;
             text-decoration: none; }
@media (hover: hover) { .top nav a:hover { color: var(--text); } }
.logout { padding: 0; border: 0; background: none; }
.logout button { width: auto; min-height: 0; margin: 0; padding: 6px 0; background: none; color: var(--muted);
                 font: 500 12px/1.4 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; }
@media (hover: hover) { .logout button:hover { color: var(--text); filter: none; } }

main { max-width: 680px; margin: 0 auto; padding: 24px 16px 48px; }
h1 { margin: 0 0 8px; font-size: 26px; font-weight: 650; line-height: 1.15; letter-spacing: 0.02em; text-transform: uppercase;
     overflow-wrap: anywhere; }
h2 { letter-spacing: 0.02em; text-transform: uppercase; }
h2 { margin: 32px 0 12px; font-size: 18px; }
.eyebrow { margin: 0 0 6px; color: var(--accent); font: 500 12px/1.4 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; }
.lead { margin: 0 0 20px; color: var(--muted); }
.hint { margin: 8px 0 0; color: var(--muted); font-size: 14px; }

form, .totals, .progress {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}

.field { display: block; margin-bottom: 16px; }
.field span { display: block; margin-bottom: 4px; font-weight: 600; font-size: 14px; }

input[name], textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

textarea { display: block; resize: vertical; }
.comment-field { margin: 16px 0 0; }

.comment {
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.comment .text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.drop {
  position: relative;
  display: block;
  padding: 24px 16px;
  border: 2px dashed var(--line);
  border-radius: 10px;
  text-align: center;
  cursor: pointer;
}

.drop.over { border-color: var(--accent); }
.drop strong { display: block; color: var(--accent); }
.drop span { display: block; margin-top: 4px; color: var(--muted); font-size: 14px; }
.drop input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.drop:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

.chosen { margin: 12px 0 0; padding: 0; list-style: none; font-size: 14px; color: var(--muted); }
.chosen li { padding: 2px 0; overflow-wrap: anywhere; }

button, .button {
  display: inline-block;
  min-height: 44px;
  padding: 10px 18px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--accent-light) -40%, var(--accent) 100%);  /* the gold of the site's cable trays */
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

form button { width: 100%; margin-top: 16px; }
button:disabled { opacity: 0.6; cursor: default; }
.button.quiet { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-deep); }
@media (hover: hover) { button:not(.danger):not(:disabled):hover, .button:hover { filter: brightness(1.08); } }
@media (hover: hover) { .button.quiet:hover { box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent-light); filter: none; } }

.error { padding: 12px; border-radius: 8px; background: var(--error-bg); color: var(--error); overflow-wrap: anywhere; }

.bar { height: 8px; border-radius: 4px; background: var(--neutral-bg); overflow: hidden; }
.bar div { height: 100%; background: var(--accent); transition: width 0.3s; }
.progress p:first-child { margin-top: 0; }

.total-main { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.total-main strong { font-size: 34px; line-height: 1.1; font-variant-numeric: tabular-nums; }

.row { display: flex; justify-content: space-between; gap: 12px; }
.row span:last-child { flex: none; font-variant-numeric: tabular-nums; }
.totals .row { padding: 3px 0; font-size: 15px; }
.totals .head { font-weight: 700; }
.group { padding: 8px 0; border-top: 1px solid var(--line); }
.group .row:not(.head) { color: var(--muted); }
.totals .warn { padding-top: 8px; border-top: 1px solid var(--line); color: var(--review); font-weight: 600; }
.totals .muted { color: var(--muted); }

.card {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 96px;
  border-radius: 6px;
  background: var(--neutral-bg);
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
  overflow: hidden;
}

.thumb img { width: 100%; height: 100%; object-fit: cover; }
.body { min-width: 0; }
.file { margin: 0 0 4px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.line { padding: 8px 0; border-top: 1px solid var(--line); }
.line:first-of-type { border-top: 0; padding-top: 2px; }
.title { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.amount { font-weight: 600; }
.meta { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.reason { margin: 2px 0 0; font-size: 13px; overflow-wrap: anywhere; }
.note { margin: 6px 0 0; color: var(--muted); font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }

.badge { display: inline-block; padding: 0 6px; border-radius: 4px; background: var(--neutral-bg); font-weight: 600; }
.pay .badge { background: var(--pay-bg); color: var(--pay); }
.review .badge { background: var(--review-bg); color: var(--review); }
.review .reason { color: var(--review); }
.deduct .amount { text-decoration: line-through; color: var(--muted); }
.skip .title { color: var(--muted); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }

.table { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
tfoot th { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.comment-cell { display: block; min-width: 200px; max-width: 320px; color: var(--muted); font-size: 13px; white-space: normal; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- admin */
body.wide main { max-width: 1060px; }
.top nav a[aria-current='page'] { color: var(--accent); }
.count { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 11px; background: var(--review-bg); color: var(--review);
         font-size: 13px; font-weight: 600; text-align: center; }
.flash { margin: 0 0 16px; padding: 10px 12px; border-radius: 8px; background: var(--pay-bg); color: var(--pay); overflow-wrap: anywhere; }
.flash.error { background: var(--error-bg); color: var(--error); }
.summary { margin: 0 0 12px; color: var(--muted); font-size: 14px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin: 0 0 24px; }
.tile { display: block; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
        color: var(--text); text-decoration: none; }
@media (hover: hover) { a.tile:hover { border-color: var(--accent); } }
.tile span { display: block; color: var(--muted); font-size: 14px; }
.tile strong { display: block; margin: 4px 0 2px; font-size: 28px; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile small { color: var(--muted); font-size: 13px; }
.tile.warn strong { color: var(--review); }
.columns { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 24px; }
.columns h2 { margin-top: 0; }
@media (min-width: 880px) { .columns { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); } }

.filters { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: flex-end; margin: 0 0 12px; }
.filters label { flex: 1 1 200px; }
.filters span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 13px; }
.filters button { width: auto; margin: 0; }
select { width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
         color: var(--text); font: inherit; }

.card.big { grid-template-columns: 120px minmax(0, 1fr); align-items: start; }
.card.big .thumb { width: 120px; height: 160px; }
.card.big .decide { grid-column: 1 / -1; }
@media (min-width: 880px) {
  .card.big { grid-template-columns: 150px minmax(0, 1fr) 280px; }
  .card.big .thumb { width: 150px; height: 200px; }
  .card.big .decide { grid-column: auto; }
}
.decide { padding: 0; border: 0; background: none; }
.line .decide { margin-top: 8px; }
.decide-fields { display: grid; gap: 8px; }
.decide-fields span { display: block; margin-bottom: 2px; color: var(--muted); font-size: 13px; }
.decide-buttons { display: flex; gap: 8px; margin-top: 8px; }
.decide-buttons button { flex: 1; width: auto; margin: 0; }
button.danger { background: var(--error-bg); color: var(--error); }
.decision { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; margin-top: 4px; color: var(--muted); font-size: 13px; }
.decision span { min-width: 0; overflow-wrap: anywhere; }
.inline { display: inline; padding: 0; border: 0; background: none; }
.inline button, button.link { width: auto; min-height: 0; margin: 0; padding: 0; background: none; color: var(--accent);
                              font-weight: 400; text-decoration: underline; }
.rejected .badge { background: var(--error-bg); color: var(--error); }
.badge.paid { background: var(--neutral-bg); color: var(--text); }

.state { display: inline-block; padding: 0 6px; border-radius: 4px; background: var(--neutral-bg); font-size: 13px; font-weight: 600; }
.state.review, .state.reading { background: var(--review-bg); color: var(--review); }
.state.unpaid { background: var(--pay-bg); color: var(--pay); }
.state.failed { background: var(--error-bg); color: var(--error); }

.person { margin-bottom: 12px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.person-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.person-head .who { flex: 1 1 200px; min-width: 0; }
.person-head .who .meta { display: block; }
.person-head .sum { font-size: 20px; font-variant-numeric: tabular-nums; }
.person-head form { padding: 0; border: 0; background: none; }
.person-head button { width: auto; margin: 0; }
.person details { margin-top: 8px; }
details summary { color: var(--accent); cursor: pointer; }
.plain { margin: 8px 0 0; padding: 0; list-style: none; }
.plain li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
.plain li span:first-child { min-width: 0; overflow-wrap: anywhere; }

.fields { margin-top: 8px; font-size: 13px; }
.fields dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px 12px; margin: 8px 0 0; }
.fields dt { color: var(--muted); }
.fields dd { margin: 0; overflow-wrap: anywhere; }
.totals > .group:first-child { padding-top: 0; border-top: 0; }
.fresh td { background: var(--pay-bg); }
.new { display: inline-block; padding: 0 6px; border-radius: 4px; background: var(--accent); color: var(--accent-text); font-size: 12px; font-weight: 600; }
.viewer.loading .frame { width: min(80vw, 400px); aspect-ratio: 3 / 4; border-radius: 6px; background: var(--neutral-bg); }
.viewer { max-width: 96vw; max-height: 96vh; max-height: 96dvh; padding: 8px; border: 0; border-radius: 10px; background: var(--surface); color: var(--text); }
.viewer::backdrop { background: rgba(0, 0, 0, 0.8); }
.viewer img { display: block; max-width: calc(96vw - 16px); max-height: calc(96vh - 64px); max-height: calc(96dvh - 64px); margin: 0 auto; object-fit: contain; }
.viewer p { margin: 8px 0 0; color: var(--muted); font-size: 13px; text-align: center; }

/* the employee form: three numbered steps, who sends first; extra parts open when needed */
fieldset.step { min-width: 0; margin: 0 0 24px; padding: 0; border: 0; }
fieldset.step + fieldset.step { margin-top: 28px; }
fieldset.step legend { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; padding: 0; font-size: 18px; font-weight: 700; }
fieldset.step .num { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%;
                     background: var(--accent); color: var(--accent-text); font-size: 15px; }
fieldset.step details.extra:first-of-type { margin-top: 0; }
.field span em { font-style: normal; font-weight: 400; color: var(--muted); }
.badge-scan { margin-bottom: 16px; }
.badge-scan .scan { position: relative; display: flex; justify-content: center; width: 100%; font-size: 17px; }
#badge-status { min-height: calc(3em + 16px); padding: 8px 12px; border-radius: 8px; }
#badge-status.ok-text { background: var(--pay-bg); color: var(--pay); font-weight: 600; }
.badge-scan .scan input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; opacity: 0; cursor: pointer; }
.error-text { color: var(--error); }
details.extra { margin-top: 16px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px; }
details.extra summary { font-weight: 600; cursor: pointer; }
details.extra[open] summary { margin-bottom: 12px; }
details.extra .hint:first-of-type { margin: 0 0 12px; }
.drop.small { padding: 16px; }
.pair { display: grid; gap: 0 12px; }
@media (min-width: 560px) { .pair { grid-template-columns: 1fr 1fr; } }
.check { display: flex; gap: 10px; align-items: center; min-height: 44px; margin: -10px 0 6px; }
.check input { flex: none; width: 22px; height: 22px; min-height: 22px; margin: 0; padding: 0; }
.companions input { margin-bottom: 8px; }
.companions .link { margin-top: 0; }
[hidden] { display: none !important; }  /* buttons and messages hidden by the script, whatever their own display */

/* the staff pages: how to reach the employee, the trip, the list of employees */
a.tg { white-space: nowrap; }
.who-line { margin: 0 0 16px; color: var(--muted); }
.trip { margin-bottom: 16px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.trip dl { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 0; }
.trip dt { color: var(--muted); }
.trip dd { margin: 0; overflow-wrap: anywhere; }
.trip .note { font-size: 14px; }
.import { margin-bottom: 20px; }
.import .check { margin: 12px 0 0; }
#name-status { min-height: 1.5em; margin: -8px 0 8px; } /* kept in the page and its line kept: a live region that appears is often not read out */
.tabeli { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin: 0 0 24px; }
.tabeli p { flex: 1 1 320px; margin: 0; }
.badge-id { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; color: var(--muted); }

/* photos taken one by one in the form, and the live badge scanner */
.uploads { margin-top: 4px; }
.uploads .camera { margin-bottom: 12px; }
.camera { position: relative; display: inline-flex; align-items: center; width: auto; }
.camera input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; opacity: 0; cursor: pointer; }
.camera:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.chosen li { display: flex; gap: 10px; align-items: center; padding: 4px 0; }
.chosen li img { flex: none; width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); }
.chosen li span { flex: 1; min-width: 0; min-height: 44px; display: flex; flex-direction: column; justify-content: center; }
.chosen li img { background: var(--neutral-bg); }
.chosen li .link { flex: none; }
dialog.scanner { width: min(480px, calc(100vw - 32px)); padding: 16px; border: 1px solid var(--line); border-radius: 12px;
                 background: var(--surface); color: var(--text); }
dialog.scanner::backdrop { background: rgb(0 0 0 / 0.6); }
dialog.scanner video { display: block; width: 100%; max-height: calc(100vh - 180px); max-height: calc(100dvh - 180px); aspect-ratio: 4 / 3;
                       object-fit: cover; border-radius: 8px; background: #000; }
#scanner-status { min-height: 3em; }
dialog.scanner .actions { justify-content: space-between; margin-top: 12px; }
dialog.scanner .actions .button { flex: 1 1 auto; justify-content: center; width: auto; margin: 0; text-align: center; }
.badge-scan .scan:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.chosen li small { display: block; font-size: 13px; }
.chosen li small.warn { color: var(--review); }
.chosen li small.muted { color: var(--muted); }

/* one receipt of several on a photo: its own crop as the thumbnail, its outline in the viewer, the others listed */
.thumb.part { position: relative; height: auto !important; max-height: 260px; }
.thumb.part img { position: absolute; top: 0; left: 0; max-width: none; height: auto; object-fit: fill; }
.viewer .frame { position: relative; width: fit-content; margin: 0 auto; }
.viewer .mark { position: absolute; border: 3px solid var(--review); border-radius: 6px; box-shadow: 0 0 0 100vmax rgb(0 0 0 / 0.5); pointer-events: none; }
.on-photo { margin-top: 8px; padding: 8px 12px; border-radius: 8px; background: var(--neutral-bg); font-size: 13px; }
.on-photo p { margin: 0; font-weight: 600; }
.on-photo ul { margin: 6px 0 0; padding: 0; list-style: none; color: var(--muted); }
.on-photo li { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
.status-pay { color: var(--pay); }
.status-review { color: var(--review); }
.on-photo-sum { margin: 0 0 6px; font-size: 14px; font-weight: 600; }
.num-chip { display: inline-block; padding: 0 6px; border-radius: 4px; background: var(--neutral-bg); color: var(--muted); font-size: 13px; }
.card.found { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.person-head .who .waiting { display: block; margin-top: 4px; color: var(--review); font-size: 13px; }

/* two receipts a check paired, compared inside the card, with the decision about the pair */
.compare { grid-column: 1 / -1; margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.compare summary { font-weight: 600; }
.compare-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin-top: 12px; }
.compare-grid figure { margin: 0; min-width: 0; }
/* the card's own thumbnail rules are narrower (.card.big .thumb): the photos of a pair take their column */
.card .compare .thumb, .card.big .compare .thumb { display: block; width: 100%; height: 240px; background: var(--neutral-bg); }
.card .compare .thumb:not(.part) img { object-fit: contain; }
.card .compare .thumb.part { height: auto; max-height: 300px; }
.compare .compare-pdf { display: flex; align-items: center; justify-content: center; height: 120px; border-radius: 8px; background: var(--neutral-bg); }
.compare figcaption { margin-top: 6px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.compare figcaption strong { color: var(--text); }
.compare-table { width: 100%; margin-top: 12px; border-collapse: collapse; font-size: 14px; table-layout: fixed; }
.compare-table th, .compare-table td { padding: 5px 6px; border-top: 1px solid var(--line); text-align: left; vertical-align: top;
                                       white-space: normal; overflow-wrap: anywhere; }
.compare-table thead th { border-top: 0; color: var(--muted); font-size: 12px; font-weight: 600; }
.compare-table tbody th { width: 30%; color: var(--muted); font-weight: 400; }
.compare-table tr.same td { color: var(--pay); }
.compare-table tr.apart td { color: var(--error); font-weight: 600; }
.compare-hint { margin: 10px 0 0; font-weight: 600; }
.compare-hint.apart { color: var(--review); }
.pair-buttons { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin-top: 12px; }
.pair-buttons form { margin: 0; padding: 0; border: 0; background: none; }
.pair-buttons button { width: 100%; height: 100%; margin: 0; }
@media (max-width: 520px) { .pair-buttons { grid-template-columns: 1fr; } }

/* a claim in a window over the page */
.peek { width: min(900px, 96vw); max-height: 92vh; max-height: 92dvh; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); }
.peek::backdrop { background: rgb(0 0 0 / 0.6); }
.peek .peek-close { position: sticky; top: 8px; float: right; width: 40px; min-height: 40px; margin: 8px; padding: 0; border-radius: 50%;
                    background: var(--neutral-bg); color: var(--text); font-size: 22px; line-height: 1; }
.peek-body { padding: 16px; }
.peek-head .peek-sum { margin: 4px 0; font-weight: 600; }
.peek-file { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.peek-photo .frame { position: relative; width: fit-content; max-width: 100%; margin: 8px auto; overflow: hidden; border-radius: 6px; }
.peek-photo img { display: block; max-width: 100%; max-height: 60vh; max-height: 60dvh; }
.peek .outline { position: absolute; border: 3px solid var(--review); border-radius: 6px; pointer-events: none; }
.peek .outline.only { box-shadow: 0 0 0 100vmax rgb(0 0 0 / 0.45); }
.peek-lines { margin: 8px 0 0; padding: 0; list-style: none; }
.peek-lines li { padding: 8px 0; border-top: 1px solid var(--line); }
.peek-lines li.picked { padding: 8px; border-radius: 6px; background: var(--neutral-bg); }

/* the browser's own file button, in the theme */
input[type='file']::file-selector-button { margin-right: 12px; padding: 8px 14px; border: 1px solid var(--accent-deep); border-radius: 6px;
                                          background: transparent; color: var(--accent); font: inherit; cursor: pointer; }

/* RU / EN: on every page, beside the logo */
.lang { display: flex; gap: 2px; margin-left: auto; font-family: var(--mono); font-size: 12px; letter-spacing: .08em; }
.lang a { padding: 4px 6px; border-radius: 4px; color: var(--muted); text-decoration: none; }
@media (hover: hover) { .lang a:hover { color: var(--accent-light); } }
.lang a[aria-current] { color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-deep); }

/* the confirmation page: what the employee has to send again */
.reading { min-height: 4.5em; margin: 16px 0; }  /* the status changes in place: the button below it does not jump */
.reading .warn { padding: 14px 16px; border: 1px solid var(--review); border-radius: 8px; display: grid; grid-template-columns: minmax(0, 1fr);
                 gap: 8px; overflow-wrap: anywhere; }
.reading .warn ul { padding-left: 20px; }
.reading .warn p, .reading .warn ul { margin: 0; }

/* the access page: a switched-off account greyed out */
tr.off td { color: var(--muted); }
.again { margin-top: 12px; padding: 0; border: 0; background: none; }
.warn-line { border-left: 3px solid var(--review); padding: 4px 0 4px 12px; max-width: 70ch; }

/* ---------------------------------------------------------------- phones: nothing wider than the screen, nothing that jumps */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:not(:disabled):active, .button:active { filter: brightness(0.92); }
@media (max-width: 719px), (max-height: 520px) {
  /* the header stays at the top of the page: on a phone a stuck band of two or three rows eats the screen,
     and a stuck header jumps when the keyboard opens */
  .top { position: static; backdrop-filter: none; background: var(--bg); }
  main { padding: 20px 16px 40px; }
}
/* a finger needs a bigger target than a mouse: padding that grows the target, not the layout */
@media (pointer: coarse) {
  .lang a { padding: 13px 10px; margin: -9px 0; }
  .pick, .pick-all { min-height: 44px; padding-right: 12px; }
  .pick input, .pick-all input { width: 24px; height: 24px; min-height: 24px; }
  .plain li > span > a:first-child, a.spot { display: inline-block; padding: 10px 0; margin: -10px 0; }
  .top nav a, .logout button { padding: 10px 0; }
  details summary { padding: 10px 0; margin: -10px 0; }
  details.extra[open] summary { margin-bottom: 2px; }
  button.link, .inline button { padding: 10px 0; margin: -10px 0; }
}
@media (max-width: 640px) {
  /* a table becomes a stack of cards: each row a card, each cell a line with the column's name on the left */
  .table.cards { overflow: visible; background: none; border: 0; border-radius: 0; }
  .table.cards table, .table.cards tbody, .table.cards tfoot, .table.cards tr { display: block; width: 100%; }
  .table.cards thead { display: none; }
  .table.cards tr { margin-bottom: 8px; padding: 4px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
  .table.cards tr.fresh { background: var(--pay-bg); }
  .table.cards .fresh td { background: none; }
  .table.cards td, .table.cards tfoot th { display: flow-root; position: relative; padding: 8px 0; border-bottom: 1px solid var(--line);
                                           white-space: normal; text-align: right; overflow-wrap: anywhere; }
  .table.cards td::before, .table.cards tfoot th::before { content: attr(data-label); float: left; width: 40%; margin-right: 8px;
                                                           color: var(--muted); font-size: 13px; font-weight: 400; text-align: left; }
  .table.cards a.tg { white-space: normal; }
  /* the number opens the claim: on a phone the whole first line of the card is its target */
  .table.cards td:first-child > a:first-child::after { content: ''; position: absolute; inset: 0; }
  .table.cards td:last-child, .table.cards tfoot th:last-child { border-bottom: 0; }
  .table.cards td[data-label=''] { padding-left: 0; text-align: left; }
  .table.cards td[data-label='']::before { content: none; }
  .table.cards tfoot th[colspan] { padding-left: 0; text-align: left; font-weight: 700; }
  .table.cards tfoot th:empty { display: none; }
  .table.cards .comment-cell { min-width: 0; max-width: none; margin-top: 2px; }
  .table.cards .inline { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
  .table.cards .inline .sep { display: none; }
  .table.cards .inline button { margin: 0; padding: 10px 0; min-height: 44px; }
}
@media (max-width: 560px) {
  /* a receipt's card: the photo beside the first lines, then the text, the comparison and the buttons the full width */
  .card, .card.big { display: block; }
  .card > .thumb, .card.big > .thumb { float: left; width: 84px; height: 112px; margin: 0 12px 6px 0; }
  .card > .thumb.part { height: auto !important; max-height: 180px; }
  .card .compare, .card > .decide, .card .line + .line, .card .on-photo { clear: both; }
  .card::after { content: ''; display: block; clear: both; }
  .compare { padding: 10px; }
  .compare-grid { gap: 8px; }
  .card .compare .thumb, .card.big .compare .thumb { height: 180px; }
}

/* the new data the lists offer instead of reloading under a finger: fixed, so nothing on the page moves */
.fresh-data { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 10; width: auto; margin: 0;
              transform: translateX(-50%); box-shadow: 0 6px 24px rgb(0 0 0 / 0.5); white-space: nowrap; }
/* an open window holds the page behind it still: no scrolling through to the list on a phone */
html { scrollbar-gutter: stable; }
html:has(dialog[open]) { overflow: hidden; }
dialog { overscroll-behavior: contain; }
body:has(.fresh-data) main { padding-bottom: 96px; }
@media (max-width: 480px) {
  /* the comparison of two receipts: each row a caption, then the two values under the two photos */
  .compare-table, .compare-table tbody { display: block; }
  .compare-table thead { display: none; }
  .compare-table tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 8px; padding: 6px 0;
                      border-top: 1px solid var(--line); }
  .compare-table th, .compare-table td { padding: 0; border-top: 0; border-bottom: 0; overflow-wrap: break-word; }
  .compare-table tbody th { grid-column: 1 / -1; width: auto; font-size: 12px; }
}
@media (max-width: 380px) {
  /* the smallest phones: less padding around the form, so the fields keep room for their hints */
  #claim { padding: 12px; }
  details.extra { padding: 10px 12px; }
}
@media (max-width: 359px) {
  .brand { gap: 8px; }
  .brand img { height: 22px; }
  .brand span { padding-left: 8px; letter-spacing: 0.08em; }
  .top nav { gap: 4px 14px; }
}
@media (max-width: 640px) {
  /* a message after a button: at the bottom of the screen, whatever part of the page the button sent the reader to */
  .flash { position: fixed; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); z-index: 11; margin: 0;
           box-shadow: 0 6px 24px rgb(0 0 0 / 0.55); }
}
