/* The dashboard's look (D14-quater 3, S-18): the dark theme and tokens of the iot-gateway kit that
   dashboard/src/index.css copies (zinc chrome, emerald --signal only for progress and OK, red only for
   errors), the system font, white andes-ttm logo. No framework, no build. The burned label of the photos
   does not change: it keeps Inter (loaded below only for the canvas). */
@font-face { font-family: "Inter"; src: url("brand/fonts/inter-latin-wght-normal.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --radius: 0.625rem;
  --background: oklch(0.145 0 0);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.205 0 0);
  --primary: oklch(0.922 0 0);
  --primary-foreground: oklch(0.205 0 0);
  --secondary: oklch(0.269 0 0);
  --muted: oklch(0.269 0 0);
  --muted-foreground: oklch(0.708 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.556 0 0);
  --signal: oklch(0.765 0.177 163.223);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --code: ui-monospace, "SF Mono", Menlo, Consolas, monospace; /* only for #tags */
  color-scheme: dark;
}

* { box-sizing: border-box; }
/* 100 % and not 100dvh: in the app installed on an iPhone, 100dvh counts the status bar too and the
   page scrolled by that much (seen on an iPhone 16 Pro Max, S-18). */
html { height: 100%; }
/* no rubber-band bounce: in the installed app the whole page moved up and down although nothing
   overflowed (iPhone, S-18) */
html, body { margin: 0; background: var(--background); color: var(--foreground); overscroll-behavior: none; }
body {
  font: 400 16px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { font-weight: 600; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 18px; text-transform: uppercase; letter-spacing: 0.02em; }
h2 { font-size: 20px; }
h3 { font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; color: var(--muted-foreground); }
p { margin: 0; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ top bar */
#bar {
  position: sticky; top: 0; z-index: 5;
  background: var(--background);
  border-bottom: 1px solid var(--border);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
}
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-row img { width: 26px; height: auto; }
.bar-title { font: 600 16px/1.2 var(--font); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-count { font: 500 14px var(--font); color: var(--foreground); background: var(--input); border: 0; border-radius: 999px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
.progress { height: 6px; background: var(--muted); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.progress > i { display: block; height: 100%; background: var(--signal); transition: width .2s; }
.bar-role { font-size: 14px; color: var(--muted-foreground); }
.bar-out { flex: none; width: 40px; height: 40px; margin: -6px -8px -6px 0; display: grid; place-items: center; background: none; border: 0; border-radius: var(--radius); color: var(--muted-foreground); cursor: pointer; }
.bar-out:active { background: var(--muted); }
.crumbs { margin-top: 6px; font-size: 13px; color: var(--muted-foreground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------------------------------------------ content */
#main { flex: 1; padding: 16px 16px 24px; display: flex; flex-direction: column; gap: 16px; }
.muted { color: var(--muted-foreground); font-size: 14px; }
.tag { font: 500 15px/1.3 var(--code); background: var(--muted); border: 1px solid var(--border); border-radius: calc(var(--radius) - 4px); padding: 6px 8px; display: inline-block; word-break: break-word; align-self: flex-start; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: calc(var(--radius) + 4px); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.card.alt { background: transparent; }
.alert { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: var(--card); display: flex; flex-direction: column; gap: 6px; }
.alert b { color: var(--destructive); }
.ok { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: var(--card); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 15px; }
.kv dt { color: var(--muted-foreground); }
.kv dd { margin: 0; font-weight: 500; word-break: break-word; }

/* lists of the tree */
.list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--card); }
.list li + li { border-top: 1px solid var(--border); }
.list button, .list .row {
  width: 100%; min-height: 58px; padding: 10px 14px; border: 0; background: none; color: var(--foreground);
  font: inherit; text-align: left; display: flex; align-items: center; gap: 12px; cursor: pointer;
}
.list button:active { background: var(--muted); }
.list .grow { flex: 1; min-width: 0; }
.list .row .open { padding: 0; min-height: 0; background: none; border: 0; color: inherit; font: inherit; text-align: left; display: block; cursor: pointer; }
.list .name { font-weight: 500; display: block; overflow-wrap: anywhere; }
.list .sub { font-size: 13px; color: var(--muted-foreground); display: block; }
.list .chev { color: var(--muted-foreground); font-size: 20px; }
.mini { width: 54px; height: 4px; background: var(--muted); border-radius: 2px; overflow: hidden; flex: none; }
.mini > i { display: block; height: 100%; background: var(--signal); }
.group-title { margin: 6px 2px -8px; }
.list.plan { border-color: color-mix(in oklch, var(--signal) 45%, transparent); }
.fold { display: flex; justify-content: space-between; align-items: center; width: 100%; min-height: 48px; padding: 10px 14px; background: none; border: 1px dashed var(--border); border-radius: var(--radius); color: var(--muted-foreground); font: 500 15px var(--font); cursor: pointer; }

/* states of a slot and of an upload */
.st { font-size: 12px; font-weight: 500; border-radius: 999px; padding: 3px 9px; border: 1px solid var(--border); color: var(--muted-foreground); white-space: nowrap; }
.st.done { border-color: color-mix(in oklch, var(--signal) 45%, transparent); color: var(--signal); }
.st.done::before { content: "✓ "; }
.st.nodmg { color: var(--foreground); background: var(--muted); }
.st.err { border-color: color-mix(in oklch, var(--destructive) 45%, transparent); color: var(--destructive); }

/* ------------------------------------------------------------------ buttons */
/* outlined, never filled (user, S-18): the border and the letters carry the color */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 52px; padding: 12px 16px;
  font: 500 17px/1.2 var(--font); color: var(--foreground);
  background: transparent; border: 1.5px solid oklch(1 0 0 / 28%); border-radius: var(--radius);
  cursor: pointer; text-decoration: none;
}
.btn:active { background: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn.quiet { border-color: var(--border); color: var(--muted-foreground); }
.btn.small, .list .btn.small { width: auto; min-height: 40px; padding: 6px 12px; font-size: 14px; flex: none; background: transparent; border: 1.5px solid oklch(1 0 0 / 28%); border-radius: var(--radius); color: var(--foreground); justify-content: center; }
.btn.strong, .btn.shoot { border-color: var(--foreground); font-weight: 600; }
.btn.shoot { font-size: 19px; min-height: 62px; }

/* by meaning (user, S-18): green to go ahead, red to end or discard, gray for the rest */
.btn.go { border-color: var(--signal); color: var(--signal); font-weight: 600; }
.btn.stop { border-color: var(--destructive); color: var(--destructive); font-weight: 600; }
.btn.go:active { background: color-mix(in oklch, var(--signal) 15%, transparent); }
.btn.stop:active { background: color-mix(in oklch, var(--destructive) 15%, transparent); }
.row-btns { display: flex; gap: 10px; }
.row-btns .btn { flex: 1; }
.row-btns.work .btn { font-size: 15px; padding: 10px 6px; min-width: 0; }
#actions {
  position: sticky; bottom: 0; z-index: 5; background: var(--background);
  border-top: 1px solid var(--border);
  padding: 10px 16px calc(env(safe-area-inset-bottom) + 10px);
  display: flex; flex-direction: column; gap: 10px;
}

/* ------------------------------------------------------------------ forms */
label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: 15px; }
input[type=text], select {
  font: 400 17px var(--font); color: var(--foreground); padding: 12px; min-height: 50px;
  border: 1px solid var(--input); border-radius: calc(var(--radius) - 2px); background: transparent; width: 100%;
}
input[type=text]:focus, select:focus { outline: 3px solid color-mix(in oklch, var(--ring) 50%, transparent); border-color: var(--ring); }
select option { background: var(--card); }

/* scope switch inside a PB of the plan */
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--muted); border-radius: var(--radius); padding: 3px; gap: 3px; }
.seg button { min-height: 44px; border: 0; border-radius: calc(var(--radius) - 3px); background: transparent; color: var(--muted-foreground); font: 500 15px var(--font); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--background); color: var(--foreground); }

/* ------------------------------------------------------------------ home */
.center { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 16px; padding-top: env(safe-area-inset-top); }
.home-head { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; margin-bottom: 8px; }
.home-head img { width: 168px; height: auto; }

.welcome { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; text-align: center; }
.welcome img { width: 200px; height: auto; }
.welcome .btn { max-width: 260px; }
.upcard .big { font-size: 22px; font-weight: 600; }
.por-subir { font-size: 17px; font-weight: 600; margin: 2px 0 4px; }
/* progress of the pack (S-35): the card of Inicio opens it; the total of the screens */
.avcard { width: 100%; text-align: left; color: inherit; font: inherit; cursor: pointer; }
.avcard:active { background: var(--muted); }
.av-head { display: flex; align-items: center; justify-content: space-between; }
.av-label { font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; color: var(--muted-foreground); }
.av-head .chev { color: var(--muted-foreground); font-size: 20px; line-height: 1; }
.av-total { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; }
.av-total b { font-size: 22px; font-weight: 600; }
.av-total span { color: var(--muted-foreground); font-weight: 500; }
.avcard .progress, .card .av-total + .progress { margin-top: 0; }
.foot { font-size: 12px; color: var(--muted-foreground); display: flex; justify-content: center; gap: 4px 12px; }

/* ------------------------------------------------------------------ uploading */
.uphead { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.uphead b { font-size: 20px; font-weight: 600; }
.uphead span { color: var(--muted-foreground); font-weight: 500; }
.uplist .ico { width: 20px; flex: none; text-align: center; color: var(--muted-foreground); }
.uplist .ico.i-ok { color: var(--signal); }
.uplist .ico.i-err { color: var(--destructive); }
.uplist .name { font: 500 14px/1.3 var(--code); }

/* ------------------------------------------------------------------ scanner and preview */
.scanner { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 3 / 4; }
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner .frame { position: absolute; inset: 18%; border: 3px solid var(--signal); border-radius: 12px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
.viewer { position: relative; height: 58dvh; background: #000; border-radius: var(--radius); overflow: hidden; touch-action: none; }
/* a saved photo (S-36, sketch 2): up to four buttons below, so the line under the photo stays in view */
.viewer.corta { height: 40dvh; }
.viewer img { width: 100%; height: 100%; object-fit: contain; transform-origin: 0 0; display: block; user-select: none; -webkit-user-drag: none; }

/* ------------------------------------------------------------------ overlays */
#busy { position: fixed; inset: 0; background: oklch(0.145 0 0 / 0.8); display: grid; place-items: center; z-index: 20; }
.busy-box { display: flex; flex-direction: column; align-items: center; gap: 12px; font-weight: 500; }
.spinner { width: 40px; height: 40px; border-radius: 50%; border: 4px solid var(--muted); border-top-color: var(--foreground); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 25; display: flex; align-items: flex-end; justify-content: center; }
.sheet img.keep { width: 100%; max-height: 52dvh; object-fit: contain; background: #000; border-radius: var(--radius); -webkit-touch-callout: default; }
.sheet { background: var(--card); border: 1px solid var(--border); border-bottom: 0; width: 100%; max-width: 560px; border-radius: 16px 16px 0 0; padding: 18px 16px calc(env(safe-area-inset-bottom) + 16px); display: flex; flex-direction: column; gap: 12px; }
.sheet ol { margin: 0; padding-left: 20px; }
