/* CountMesh web app.
 *
 * The palette is the product app's, taken from `app/lib/theme/bar_theme.dart` rather than
 * re-chosen, so the web and the phone are one product. Every text/surface pair there is checked
 * against WCAG AA in the app's `theme_contrast_test.dart`; re-picking colours here would quietly
 * leave that behind.
 *
 * Dark-first on purpose: this is read in dimly lit storerooms and bars. `--primary` is reserved
 * for actions and focus. The status hues never touch an interactive element — a red button must
 * not be able to mean "out of stock".
 */
:root {
  --bg: #12141C;
  --surface: #1A1D27;
  --surface-container: #1E2230;
  --surface-high: #252A3C;
  --outline: #4A5166;
  --ink: #F2F4F8;
  --ink-dim: #B4BBCB;
  --primary: #00E5FF;
  --on-primary: #00363D;
  --error: #FF6E6E;

  /* Status signalling, from the same file and used only to report state. */
  --ok: #69F0AE;
  --warn: #FFB300;
  --bad: #FF5252;

  --radius: 14px;
  --gutter: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------------ the sign-in screen */
body.signed-out { display: flex; align-items: center; justify-content: center; min-height: 100dvh; padding: 24px var(--gutter); }
body.signed-out #app { display: none; }
body.signed-in #gate { display: none; }

#gate { width: 100%; max-width: 380px; }
.brand { text-align: center; margin-bottom: 28px; }
.brand h1 { margin: 0; font-size: 30px; font-weight: 650; letter-spacing: -0.02em; }
.brand h1 b { color: var(--primary); font-weight: 650; }
.brand p { margin: 6px 0 0; color: var(--ink-dim); font-size: 14px; }

.card { background: var(--surface); border: 1px solid var(--outline); border-radius: var(--radius); padding: 22px 20px; }
form { display: flex; flex-direction: column; gap: 16px; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-dim); }

input, select {
  font: inherit; font-size: 16px;  /* 16px minimum, or iOS zooms the page on focus */
  color: var(--ink); background: var(--surface-container);
  border: 1px solid var(--outline); border-radius: 10px; padding: 11px 13px;
}
input:focus-visible, select:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 1px;
}
input:disabled, button:disabled { opacity: .55; }

button {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 10px;
  padding: 11px 15px; min-height: 44px;
  border: 1px solid var(--outline); background: transparent; color: var(--ink);
}
button.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
button.small { min-height: 34px; padding: 5px 11px; font-size: 13px; font-weight: 500; }
button:disabled { cursor: default; }

.alert {
  margin: 0; padding: 11px 13px; border-radius: 10px;
  border: 1px solid var(--error); color: var(--error); background: rgba(255,110,110,.08); font-size: 14px;
}
.alert[hidden], [hidden] { display: none !important; }

/* ------------------------------------------------------------------ the shell */
header.top {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg); border-bottom: 1px solid var(--outline);
  padding: 10px var(--gutter) 0;
}
.top .row { display: flex; align-items: center; gap: 10px; max-width: 1100px; margin: 0 auto; }
.top .wordmark { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.top .wordmark b { color: var(--primary); font-weight: 650; }
.grow { flex: 1 1 auto; min-width: 0; }
.who { font-size: 13px; color: var(--ink-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

nav.tabs {
  display: flex; gap: 2px; max-width: 1100px; margin: 8px auto 0;
  overflow-x: auto; scrollbar-width: none;
}
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs button {
  border: none; border-bottom: 2px solid transparent; border-radius: 0;
  background: none; color: var(--ink-dim); font-weight: 500;
  padding: 9px 13px; min-height: 40px; white-space: nowrap;
}
nav.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--primary); font-weight: 600; }

main { max-width: 1100px; margin: 0 auto; padding: var(--gutter) var(--gutter) 56px; }

.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.bar input[type=search] { flex: 1 1 240px; min-width: 0; }
.count { color: var(--ink-dim); font-size: 13px; font-variant-numeric: tabular-nums; }

.note { color: var(--ink-dim); font-size: 13px; }
/* The answer to "is there anything to do?", above the history rather than inside it. */
#sessionWaiting { margin: 0 0 12px; color: var(--ink); font-weight: 500; }
.status.bad { color: var(--error); }

/* ------------------------------------------------------------------ cards and rows */
.item {
  background: var(--surface); border: 1px solid var(--outline);
  border-radius: 12px; margin-bottom: 10px; overflow: hidden;
}
.item .head { display: flex; gap: 12px; align-items: center; padding: 12px 14px; }
.item .body { border-top: 1px solid var(--outline); padding: 12px 14px; }
.title { font-weight: 600; }
.sub { color: var(--ink-dim); font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--ink-dim); }

/* The verdict, at a glance. Louder than the detail behind it, because "can this bottle be
   counted" is the question and which sides are held is the explanation. */
.chip {
  font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  border: 1px solid currentColor; white-space: nowrap;
}
.chip.ok { color: var(--ok); }
.chip.calc { color: var(--primary); }
.chip.warn { color: var(--warn); }
.chip.bad { color: var(--bad); }
.chip.quiet { color: var(--ink-dim); border-color: var(--outline); font-weight: 400; }

/* A fixed box so a tall bottle and a wide one do not make two rows different heights, and
   `contain` rather than `cover` because a label cropped square is the half somebody is reading. */
.thumb {
  width: 44px; height: 58px; flex: 0 0 auto; border-radius: 6px;
  border: 1px solid var(--outline); background: var(--surface-container);
  object-fit: contain;
}
/* Faded and inert while there is nothing behind it; a pointer once there is. */
.thumb[data-empty] { opacity: .35; }
.thumb[src] { cursor: zoom-in; }

.shots { display: flex; gap: 6px; flex-wrap: wrap; }
.shots img {
  width: 64px; height: 64px; object-fit: cover; border-radius: 6px;
  border: 1px solid var(--outline); background: var(--surface-container); cursor: zoom-in;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 7px 9px; border-bottom: 1px solid var(--outline); vertical-align: top; }
th { color: var(--ink-dim); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.scroll { overflow-x: auto; }

/* A finding from the label check. The rule carries the severity, so scanning the column shows
   where to stop without reading a word. */
.find { border-left: 2px solid var(--outline); padding: 3px 0 3px 9px; margin: 5px 0; font-size: 13px; }
.find.stop { border-color: var(--bad); }
.find.look { border-color: var(--warn); }
.find .was { color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.src { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-dim); }

dialog { border: none; border-radius: 12px; padding: 0; background: var(--surface); max-width: 95vw; }
dialog img { display: block; max-width: 92vw; max-height: 86vh; }
dialog::backdrop { background: rgba(0,0,0,.72); }

footer { max-width: 1100px; margin: 0 auto; padding: 0 var(--gutter) 28px; color: var(--ink-dim); font-size: 12px; }

@media (max-width: 560px) {
  .item .head { flex-wrap: wrap; }
  th, td { padding: 6px 7px; }
}
@media (prefers-reduced-motion: no-preference) {
  #gate { animation: rise .22s ease-out both; }
  @keyframes rise { from { opacity: 0; transform: translateY(6px); } }
}
