/* Purpose: app styles — AKGNI's component set, refreshed: large touch targets, a tile menu, and a
   theme that follows the phone (dark mode uses solid, high-contrast buttons). */
:root {
  --bg: #f3f5fa;
  --surface: #ffffff;
  --surface-2: #eef2f8;
  --ink: #0f172a;
  --ink-soft: #5b6b82;
  --line: #e1e7f0;
  --brand: #1f4788;
  --brand-ink: #ffffff;
  --brand-soft: #e7eefa;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #8a5a00;
  --warn-soft: #fff4d6;
  --ok: #157a3c;
  --ok-soft: #e2f5e9;
  --info: #1d4f91;
  --info-soft: #e5eefb;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 16px rgba(15, 23, 42, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c1118;
    --surface: #151c26;
    --surface-2: #1c2531;
    --ink: #e8edf4;
    --ink-soft: #97a6ba;
    --line: #263142;
    --brand: #3a72dd;
    --brand-ink: #ffffff;
    --brand-soft: #1b2a44;
    --danger: #ff8a7f;
    --danger-soft: #3a1d1a;
    --warn: #f2c35b;
    --warn-soft: #362d17;
    --ok: #6fd394;
    --ok-soft: #15301f;
    --info: #8db8f2;
    --info-soft: #1a2a40;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
.muted { color: var(--ink-soft); }
.center { text-align: center; }
.pad { padding: 24px 16px; }
.small { font-size: .875rem; }
.num { font-variant-numeric: tabular-nums; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { margin-right: auto; display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.05rem; color: var(--ink); text-decoration: none; padding: 4px; }
.brand img { width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0; }
.link-btn { background: none; border: 0; padding: 6px; color: var(--ink-soft); font: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; white-space: nowrap; }
.link-btn:hover { color: var(--ink); }
.install-app { color: var(--brand); }
/* small icon link in the top bar (📊 History) */
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; text-decoration: none; font-size: 1.2rem; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:focus-visible { outline: 3px solid var(--info); outline-offset: 2px; }
@media (max-width: 420px) { .topbar { gap: 4px; padding-left: 8px; padding-right: 8px; } .brand { font-size: .98rem; } .link-btn { font-size: .8rem; padding: 4px; } }

/* page */
.app { max-width: 560px; margin: 0 auto; padding: 16px 12px 32px; }
.app.wide-menu { max-width: 760px; }
@media (min-width: 600px) { .app { padding: 28px 20px 40px; } }

/* cards, forms */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.stack > * + * { margin-top: 14px; }
.card h2, .card p { margin-bottom: 0; }
.card h2 { font-size: 1.25rem; }
.field { display: grid; gap: 8px; }
.field > span { font-weight: 600; font-size: 1rem; line-height: 1.4; }
input, select, textarea {
  width: 100%; min-height: 52px; padding: 12px 14px; font: inherit; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
textarea { min-height: 100px; resize: vertical; }
.big-input { font-size: 1.6rem; font-weight: 600; letter-spacing: .02em; min-height: 62px; font-variant-numeric: tabular-nums; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 54px; padding: 0 20px;
  border-radius: 14px; border: 1.5px solid transparent; font: inherit; font-size: 1.02rem; font-weight: 700; cursor: pointer; text-decoration: none;
  background: var(--brand); color: var(--brand-ink); transition: transform .08s, filter .15s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.big { min-height: 60px; font-size: 1.1rem; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--surface-2); filter: none; }
.btn.danger { background: var(--danger); color: #fff; }
.btn:focus-visible { outline: 3px solid var(--info); outline-offset: 2px; }
.buttons:empty { display: none; }
.buttons > * + * { margin-top: 10px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

.alert { padding: 12px 14px; border-radius: 12px; font-weight: 600; line-height: 1.4; }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.info { background: var(--info-soft); color: var(--info); }

/* key/value figures */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; padding: 14px 16px; background: var(--surface-2); border-radius: 12px; }
.kv dt { color: var(--ink-soft); }
.kv dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }

.photo { max-width: 100%; max-height: 50vh; border-radius: 12px; border: 1px solid var(--line); margin: 0 auto; display: block; }

/* screens appear with a short fade, so a tap feels immediate and smooth */
.screen, .tiles-menu, .menu-title { animation: appear .16s ease-out; }
@keyframes appear { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .screen, .tiles-menu, .menu-title { animation: none; } }
a, button { touch-action: manipulation; } /* no 300 ms double-tap-zoom wait on taps */

/* flow screens: header (‹ + title), panel, hero icon, big input, big result */
.screen-head { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; min-height: 44px; }
.screen-head h1 { margin: 0; font-size: 1.3rem; font-weight: 800; line-height: 1.25; }
.screen-head .back {
  width: 44px; height: 44px; flex-shrink: 0; display: grid; place-items: center; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none;
  font-size: 1.9rem; line-height: 1; padding-bottom: 4px; box-shadow: var(--shadow);
}
.screen-head .back:hover { border-color: var(--brand); }
.screen-head .back:active { transform: scale(.96); }
.screen-lead { margin: 0 2px 12px; color: var(--ink-soft); font-weight: 600; }
.panel-card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 22px 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.panel-card p { margin: 0; }
.panel-card .lead { font-size: 1.12rem; font-weight: 700; line-height: 1.4; }
.hero-icon { width: 72px; height: 72px; margin: 0 auto; border-radius: 22px; display: grid; place-items: center; font-size: 2.3rem; background: var(--brand-soft); }
.panel-card > .hero-icon + * { text-align: center; }
.panel-card > .hero-icon ~ .lead, .panel-card > .hero-icon ~ .muted { text-align: center; }
.field.ask > span { font-size: 1.05rem; text-align: center; }
.unit-input { position: relative; display: flex; align-items: center; }
.unit-input input { font-size: 1.8rem; font-weight: 700; text-align: center; min-height: 68px; padding: 10px 84px; letter-spacing: .02em; font-variant-numeric: tabular-nums; border-radius: 16px; }
.unit-input span { position: absolute; right: 18px; color: var(--ink-soft); font-weight: 700; pointer-events: none; }
.hint { text-align: center; color: var(--ink-soft); font-size: .92rem; }
.steps { display: inline-block; font-weight: 700; color: var(--brand); }
.big-number { font-size: 2.3rem; font-weight: 800; text-align: center; line-height: 1.15; letter-spacing: -.01em; overflow-wrap: anywhere; }
.big-number.ok { color: var(--ok); }
.big-number.warn { color: var(--warn); }
.result .muted { text-align: center; }
.outcome { text-align: center; font-weight: 800; padding: 10px 12px; border-radius: 12px; }
.outcome.ok { background: var(--ok-soft); color: var(--ok); }
.outcome.offline { background: var(--warn-soft); color: var(--warn); }
.spinner { width: 36px; height: 36px; margin: 4px auto 0; border-radius: 50%; border: 4px solid var(--brand-soft); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

/* option list (Neutralization) */
.option-list { display: grid; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 14px; min-height: 68px; padding: 12px 16px; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); font-weight: 800; font-size: 1.08rem;
}
.option:hover { border-color: var(--brand); }
.option:active { transform: scale(.99); }
.option-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 1.5rem; background: var(--brand-soft); flex-shrink: 0; }
.option:nth-child(2) .option-icon { background: var(--ok-soft); }
.option:nth-child(3) .option-icon { background: var(--info-soft); }
.option .chev { margin-left: auto; color: var(--ink-soft); font-size: 1.6rem; font-weight: 400; }
.option-text { display: grid; gap: 2px; }
.option-text small { font-size: .85rem; font-weight: 600; color: var(--ink-soft); }
.option-text small.live { color: var(--ok); }
.tile-btn:nth-child(5) .tile-icon { background: var(--surface-2); }
.tiles-menu .tile-btn:nth-child(odd):last-child {
  /* the odd tile out (last of an odd number) spans the row as a compact horizontal card: icon · label + status · › */
  grid-column: 1 / -1; min-height: 0; padding: 14px 16px;
  grid-template-columns: auto 1fr auto; grid-template-rows: auto auto; align-items: center; column-gap: 14px; row-gap: 2px;
}
.tiles-menu .tile-btn:nth-child(odd):last-child .tile-icon { grid-row: 1 / 3; margin: 0; }
.tiles-menu .tile-btn:nth-child(odd):last-child .tile-label { grid-column: 2; align-self: end; }
.tiles-menu .tile-btn:nth-child(odd):last-child .tile-status { grid-column: 2; align-self: start; }
.tiles-menu .tile-btn:nth-child(odd):last-child::after {
  content: '›'; grid-column: 3; grid-row: 1 / 3; font-size: 1.8rem; color: var(--ink-soft); line-height: 1;
}

/* main menu: tiles */
.menu-title { font-size: 1.15rem; font-weight: 800; margin: 4px 2px 14px; }
.tiles-menu { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 340px) { .tiles-menu { grid-template-columns: 1fr; } }
.tile-btn {
  display: grid; align-content: start; gap: 6px; min-height: 150px; padding: 16px; text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
  transition: transform .08s, border-color .15s;
}
.tile-btn:hover { border-color: var(--brand); }
.tile-btn:active { transform: scale(.98); }
.tile-btn:focus-visible { outline: 3px solid var(--info); outline-offset: 2px; }
.tile-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 1.8rem; background: var(--brand-soft); margin-bottom: 4px; }
.tile-btn:nth-child(2) .tile-icon { background: var(--warn-soft); }
.tile-btn:nth-child(3) .tile-icon { background: var(--ok-soft); }
.tile-btn:nth-child(4) .tile-icon { background: var(--info-soft); }
.tile-label { font-weight: 800; font-size: 1.02rem; line-height: 1.25; }
.tile-status { font-size: .84rem; font-weight: 600; color: var(--ink-soft); line-height: 1.3; }
.tile-status.live { color: var(--ok); }
.tile-status.ok { color: var(--ok); }
.tile-status.warn { color: var(--warn); }

/* History */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); text-decoration: none; font-weight: 600; font-size: .9rem; }
.chip.on { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.range { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }
.range .btn { min-height: 52px; }
@media (max-width: 420px) { .range { grid-template-columns: 1fr 1fr; } .range .btn { grid-column: 1 / -1; } }
.totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 420px) { .totals { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.totals > div { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; display: grid; gap: 2px; }
.totals span { font-size: .78rem; color: var(--ink-soft); font-weight: 600; }
.totals strong { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.section-title { display: flex; align-items: center; gap: 8px; margin: 22px 2px 10px; font-size: 1.05rem; }
.section-title .count { font-size: .78rem; font-weight: 700; color: var(--ink-soft); background: var(--surface-2); padding: 2px 9px; border-radius: 999px; }
.entries { display: grid; gap: 10px; margin-bottom: 8px; }
.entry { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: grid; gap: 10px; }
.entry p { margin: 0; }
.entry .kv { padding: 10px 12px; }
.entry-head, .entry-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.entry-notes { font-size: .88rem; color: var(--ink-soft); }
.badge { font-size: .75rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--ink-soft); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.live { background: var(--info-soft); color: var(--info); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.user-row { color: var(--ink); text-decoration: none; }
.user-row:hover { border-color: var(--brand); }
.check { display: flex; align-items: center; gap: 12px; font-weight: 600; cursor: pointer; }
.check input { width: 24px; height: 24px; min-height: 0; padding: 0; flex-shrink: 0; accent-color: var(--brand); }
.photo-link { font-weight: 700; text-decoration: none; white-space: nowrap; }
.temps { display: grid; gap: 4px; font-size: .88rem; }

/* sub-menus (Neutralization) */
.menu { display: grid; gap: 10px; }
.menu .btn { justify-content: flex-start; min-height: 58px; font-size: 1.05rem; padding: 0 18px; }

/* sign-in */
.login { min-height: 80vh; display: grid; place-content: center; gap: 18px; text-align: center; padding: 24px 0; }
.login .logo { width: 72px; height: 72px; margin: 0 auto; border-radius: 18px; }
.login form { text-align: left; width: min(92vw, 400px); }
/* WhatsApp sign-in widget, in the app's colours (light and dark) */
.wa-signin { --wa-ink: var(--ink); --wa-ink-soft: var(--ink-soft); --wa-line: var(--line); --wa-accent: var(--brand); width: min(92vw, 400px); justify-self: center; }
.wa-signin .wa-primary { background: var(--brand); color: var(--brand-ink); }
.wa-signin .wa-confirm-code { background: var(--surface); color: var(--ink); }

.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  max-width: min(92vw, 480px); padding: 12px 18px; border-radius: 12px; background: var(--ink); color: var(--bg); font-weight: 600; box-shadow: var(--shadow);
}
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); padding: 20px; width: min(92vw, 520px); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }

/* install the app */
.install-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.install-card > div { display: grid; }
.install-card .btn { min-height: 44px; white-space: nowrap; }
.install-steps { margin: 0; padding-left: 1.3em; display: grid; gap: 8px; }
.install-dialog h2 { margin: 0; }

/* ⚙️ Settings: editable lists */
.settings-form .rows { display: grid; gap: 12px; }
.list-row { display: flex; align-items: center; gap: 8px; }
.list-row .field { flex: 1; min-width: 0; }
.list-row input { min-width: 0; }
.list-row .grow { flex: 1; }
.list-stack { display: grid; gap: 6px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.field-title { font-weight: 700; margin: 6px 0 0; }
button.icon-btn { border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; padding: 0; }
.icon-btn.small { width: 36px; height: 36px; font-size: 1rem; flex-shrink: 0; }
.check.small { font-size: .92rem; white-space: nowrap; }

/* 🌀 Dryer run timeline: newest at the top; day pinned on the left, symbol, dot on the line, gap between dots */
.timeline { padding: 6px 4px; }
.tl-day { display: grid; grid-template-columns: 52px 1fr; }
.tl-date { position: sticky; top: 62px; align-self: start; padding: 4px 0; color: var(--ink-soft); font-size: .8rem; font-weight: 700; line-height: 1.2; background: var(--surface); }
.tl-day ol { list-style: none; margin: 0; padding: 0; }
.tl-event, .tl-gap { display: grid; grid-template-columns: 28px 18px 1fr; align-items: start; position: relative; }
.tl-event::before, .tl-gap::before { content: ''; position: absolute; left: 36px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.tl-day:first-child .tl-event:first-child::before { top: 12px; }
.tl-day:last-child .tl-event:last-child::before { bottom: calc(100% - 12px); }
.tl-icon { grid-column: 1; text-align: center; font-size: 1rem; line-height: 24px; }
.tl-dot { grid-column: 2; justify-self: center; margin-top: 7px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--brand); position: relative; }
.tl-event.warn .tl-dot { border-color: var(--warn); background: var(--warn-soft); }
.tl-text { grid-column: 3; padding: 2px 0 2px 8px; line-height: 20px; overflow-wrap: anywhere; }
.tl-text time { margin-left: 6px; white-space: nowrap; color: var(--ink-soft); font-size: .76rem; }
.tl-text small { display: block; color: var(--ink-soft); font-size: .8rem; line-height: 1.3; }
.tl-gap span { grid-column: 3; padding: 6px 0 6px 8px; color: var(--ink-soft); font-size: .76rem; font-weight: 600; }
.tl-gap span::before { content: '↕ '; }

/* 📞 Help & Support: the option under the menu tiles, and the contacts with their Call buttons */
.tiles-menu.help-menu { margin-top: 12px; }
.help-menu .tile-btn { grid-column: 1 / -1; min-height: 0; padding: 14px 16px; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto; align-items: center; column-gap: 14px; row-gap: 2px; }
.help-menu .tile-icon { grid-row: 1 / 3; margin: 0; background: var(--ok-soft); }
.help-menu .tile-label { grid-column: 2; align-self: end; }
.help-menu .tile-status { grid-column: 2; align-self: start; }
.help-menu .tile-btn::after { content: '›'; grid-column: 3; grid-row: 1 / 3; font-size: 1.8rem; color: var(--ink-soft); line-height: 1; }
.contact-list { display: grid; gap: 10px; }
.contact { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.contact-who { display: flex; flex-direction: column; min-width: 0; flex: 1 1 160px; }
.contact-who strong { overflow-wrap: anywhere; }
.contact-who small { color: var(--ink-soft); }
.contact-calls { display: flex; flex-direction: column; gap: 6px; }
.call-btn { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 999px; background: var(--ok-soft); color: var(--ok); font-weight: 700; text-decoration: none; white-space: nowrap; }
.call-btn img { width: 30px; height: 30px; border-radius: 50%; }
.contact-group { margin: 0; padding: 10px; border: 1px solid var(--line); border-radius: 12px; }
.contact-edit { padding-top: 4px; }

/* 🛢 Tanks: the empty part in green, the water (filled) in red */
.empty-q, .kv dt.empty-q { color: var(--ok); }
.filled-q, .kv dt.filled-q { color: var(--danger); }

/* 🧪 Batch Preparation: one input per material (smaller than the single big ones), History steps */
.material .unit-input input { font-size: 1.3rem; min-height: 52px; padding: 8px 64px; }
.material > span { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.material .inch { text-align: center; min-height: 1em; }
.batch-step { margin-top: 6px; }
.batch-step summary { cursor: pointer; font-weight: 700; font-size: .92rem; }
.batch-step .temps { margin-top: 4px; }
.kv.batch-done { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } /* long step names must not squeeze the times */
.list-row .field > span { font-size: .8rem; font-weight: 600; color: var(--ink-soft); } /* small labels in Settings rows */
.vessel-q { display: grid; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.vessel-q:last-child { border-bottom: 0; padding-bottom: 0; }
