/* RAX donor PWA - phone first, big buttons (RAN Design Spec: touch density, light working theme).
   Brand colors come from /donor/api/config (white label) through setColors() in lib/ui.js. */
:root {
  --bar-bg: #000; --bar-fg: #fff;
  --btn-bg: #000; --btn-fg: #fff;
  --bg: #fff; --fg: #111; --muted: #666; --line: #ccc; --warn: #b00020;
  --ok: #1e4620; --ok-bg: #e6f4ea; --selected: #f5b400;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--fg);
  font: 19px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
input, textarea { -webkit-user-select: text; user-select: text; }

/* Top bar */
#bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: .8em; padding: .55em .9em;
  padding-top: calc(.55em + env(safe-area-inset-top)); background: var(--bar-bg); color: var(--bar-fg); }
#bar-title { font-weight: 700; }
#bar-screen { flex: 1; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#bar-menu { flex: none; min-height: 0; padding: .1em .5em; background: transparent; color: var(--bar-fg);
  border: 2px solid var(--bar-fg); font-weight: 700; line-height: 1.2; }
#bar-help { flex: none; width: 1.9em; height: 1.9em; min-height: 0; padding: 0; border-radius: 50%;
  border: 2px solid var(--bar-fg); background: transparent; color: var(--bar-fg); font-weight: 700; line-height: 1; }
#update { display: flex; align-items: center; gap: .7em; justify-content: space-between; padding: .5em .9em;
  background: #fff3cd; color: #6b5200; font-size: .9em; }
#update[hidden] { display: none; }
#update button { min-height: 0; padding: .35em .9em; font-size: .95em; }
.help-steps { padding-left: 1.2em; margin: .2em 0; }
.help-steps li { margin: .3em 0; }
#badge { font-size: .75em; font-weight: 600; padding: .2em .7em; border-radius: 999px; background: var(--warn); color: #fff; }

/* One centered column, blocks stacked with space-4 gaps */
#screen { padding: 1em 1em calc(1em + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto;
  display: flex; flex-direction: column; gap: .9em; }
h1 { font-size: 1.4em; margin: .2em 0; }
h2 { font-size: 1.1em; margin: .6em 0 0; }
p { margin: .3em 0; }
.muted { color: var(--muted); }
.warn { color: var(--warn); font-weight: 600; }
.center { text-align: center; }
.logo { width: 40%; max-width: 180px; margin: 0 auto; display: block; border-radius: 22%; }

/* Buttons: primary black, secondary grey, at least 3em tall */
button { font: inherit; border: 0; border-radius: 8px; padding: .8em 1.2em; min-height: 3em;
  background: var(--btn-bg); color: var(--btn-fg); cursor: pointer; }
button:disabled { background: #aaa; color: #fff; }
button.secondary { background: #e8e8e8; color: #111; }
button.big { font-size: 1.15em; }
.row { display: flex; gap: .7em; flex-wrap: wrap; }
.row > button { flex: 1; }
.stack { display: flex; flex-direction: column; gap: .7em; }

/* Form fields: label above, 2px border, error text below in warn */
.field { display: flex; flex-direction: column; gap: .25em; }
.field label { font-weight: 600; }
.field .hint { font-size: .85em; color: var(--muted); }
.field .err { font-size: .85em; color: var(--warn); font-weight: 600; }
input, textarea, select { font: inherit; width: 100%; padding: .6em .7em; border: 2px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--fg); }
textarea { min-height: 4.5em; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--btn-bg); }
.field.bad input, .field.bad textarea { border-color: var(--warn); }
.pair { display: flex; gap: .7em; align-items: flex-end; }   /* inputs line up even when one field has a hint */
.pair > .field { flex: 1; min-width: 0; }

/* Yes/no choice cards (forklift, reefer …): whole card is the target, gold outline + check when on */
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: .6em; }
.choice { display: flex; gap: .6em; align-items: center; padding: .7em; border: 2px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--fg); width: 100%; min-height: 3em; text-align: left; }
.choice .box { width: 1.3em; height: 1.3em; border: 2px solid #111; border-radius: 4px; flex: none;
  display: flex; align-items: center; justify-content: center; font-weight: 700; }
.choice.selected { outline: 4px solid var(--selected); }
.choice.selected .box::after { content: "\2713"; }

/* Review table: label left in muted, value right */
.review { width: 100%; border-collapse: collapse; table-layout: fixed; }
.review td { padding: .45em .3em; border-bottom: 1px solid var(--line); vertical-align: top; }
.review td:first-child { color: var(--muted); width: 42%; }
.review td:last-child { text-align: right; overflow-wrap: anywhere; }   /* long emails / addresses wrap */

/* Offer cards on the main screen, with a status pill */
.offer { border: 2px solid var(--line); border-radius: 8px; padding: .7em .8em; display: flex; flex-direction: column; gap: .2em; }
.offer .top { display: flex; justify-content: space-between; align-items: center; gap: .5em; }
.offer .top b { font-size: 1.05em; }
.pill { font-size: .75em; font-weight: 600; padding: .15em .7em; border-radius: 999px; white-space: nowrap; }
.pill.open { background: #e8e8e8; color: #111; }
.pill.accepted { background: var(--ok-bg); color: var(--ok); }
.pill.declined, .pill.expired { background: #fdecea; color: #7a1c1c; }
.msg-ok { background: var(--ok-bg); color: var(--ok); padding: .7em .9em; border-radius: 8px; }

/* Sign-in: the code waiting for Telegram */
.wait { display: flex; align-items: center; gap: .6em; color: var(--muted); }
.spinner { width: 1.2em; height: 1.2em; border: 3px solid var(--line); border-top-color: var(--btn-bg);
  border-radius: 50%; animation: spin 1s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.dev { border: 2px dashed var(--warn); border-radius: 8px; padding: .7em; display: flex; flex-direction: column; gap: .5em; }

/* Modal */
#modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center;
  justify-content: center; padding: 1em; z-index: 10; }
#modal[hidden] { display: none; }
#modal-box { background: #fff; color: #111; border-radius: 10px; padding: 1.1em; width: 100%; max-width: 480px;
  display: flex; flex-direction: column; gap: .9em; white-space: pre-line; }
#modal-box h2 { margin: 0; font-size: 1.25em; }
