/* Purpose: app styles — the same design tokens and components as AKGNI Delivery Tracking. */
:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f1f4f9;
  --ink: #111827;
  --ink-soft: #64748b;
  --line: #dfe5ee;
  --brand: #1f4788;
  --brand-ink: #ffffff;
  --brand-soft: #e6edf8;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #8a5a00;
  --warn-soft: #fff4d6;
  --ok: #19703c;
  --ok-soft: #e3f4e8;
  --info: #1d4f91;
  --info-soft: #e5eefb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141c;
    --surface: #171e29;
    --surface-2: #1e2733;
    --ink: #e6ebf2;
    --ink-soft: #94a3b8;
    --line: #2a3442;
    --brand: #8fb0ea;
    --brand-ink: #0b1a33;
    --brand-soft: #1d2b44;
    --danger: #ff8a7f;
    --danger-soft: #3a1d1a;
    --warn: #f2c35b;
    --warn-soft: #3a3018;
    --ok: #6fd394;
    --ok-soft: #173323;
    --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);
}
[hidden] { display: none !important; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; }
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: app name on the left, Install app + Sign out on the right */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; padding-top: max(6px, env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { margin-right: auto; display: inline-flex; align-items: center; gap: 8px; font-weight: 800; color: var(--brand); text-decoration: none; padding: 4px; }
.brand img { width: 28px; height: 28px; flex-shrink: 0; }
@media (max-width: 420px) { .topbar { gap: 6px; } .brand { font-size: .95rem; } .link-btn { font-size: .8rem; } }
.sync-badge { font-size: .78rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.sync-badge:empty { display: none; }
.sync-badge.ok { background: var(--ok-soft); color: var(--ok); }
.sync-badge.wait { background: var(--warn-soft); color: var(--warn); }
.sync-badge.off { background: var(--surface-2); color: var(--ink-soft); }
.big-input { font-size: 1.5rem; letter-spacing: .04em; min-height: 58px; font-variant-numeric: tabular-nums; }
.link-btn { background: none; border: 0; padding: 4px; color: var(--ink-soft); font: inherit; font-size: .85rem; cursor: pointer; white-space: nowrap; }
.link-btn:hover { color: var(--ink); text-decoration: underline; }

.app { max-width: 560px; margin: 0 auto; padding: 12px 8px; }
@media (min-width: 600px) { .app { padding: 20px 16px; } }
.app.wide { max-width: 1280px; }

/* cards, forms */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.stack > * + * { margin-top: 14px; }
.field { display: grid; gap: 6px; }
.field > span { font-weight: 600; font-size: .95rem; }
.field small { color: var(--ink-soft); }
input, select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; font: inherit; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 10px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 0; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input[readonly] { background: var(--surface-2); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px;
  border-radius: 10px; border: 1.5px solid transparent; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none;
  background: var(--brand); color: var(--brand-ink);
}
.btn:disabled { opacity: .45; 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.danger { background: var(--danger); color: #fff; }
.btn.small-btn { min-height: 36px; padding: 0 12px; font-size: .9rem; }
.btn:focus-visible { outline: 3px solid var(--info); outline-offset: 2px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.alert { padding: 12px 14px; border-radius: 10px; font-weight: 600; }
.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 summary */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--ink-soft); }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

.login { min-height: 80vh; display: grid; place-content: center; gap: 18px; text-align: center; padding: 24px 0; }
.login .logo { width: 64px; height: 64px; margin: 0 auto; }

.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: 14px; padding: 12px 14px; }
.install-card > div { display: grid; }
.install-card .btn { min-height: 42px; white-space: nowrap; }
.install-steps { margin: 0; padding-left: 1.3em; display: grid; gap: 8px; }
.install-dialog h2 { margin: 0; }
.install-app { color: var(--brand); font-weight: 700; text-decoration: none; }

.login form { text-align: left; width: min(92vw, 400px); }

/* flow screens */
.card h2, .card p { margin-bottom: 0; }
.photo { max-width: 100%; max-height: 50vh; border-radius: 10px; border: 1px solid var(--line); margin: 0 auto; display: block; }
.buttons:empty { display: none; }
textarea { min-height: 96px; resize: vertical; }

/* main menu: one large button per module, as in the bot's menu */
.menu { display: grid; gap: 12px; }
.menu .btn { justify-content: flex-start; min-height: 64px; font-size: 1.1rem; padding: 0 18px; }
.menu-title { font-size: 1.15rem; font-weight: 700; margin: 4px 2px 14px; }
