/* Specification section 14: large touch targets, visible focus, contrast, and
   no reliance on colour alone. Designed for a phone held one-handed at a
   counter, then scaled up rather than down. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #16191d;
  --muted: #5c6470;
  --line: #d8dce2;
  --accent: #1d4ed8;
  --accent-ink: #ffffff;
  --selected: #15803d;
  --danger: #b91c1c;
  --warn-bg: #fef3c7;
  --warn-line: #d97706;
  --error-bg: #fee2e2;
  --radius: 12px;
  --tap: 60px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c;
    --surface: #1c2027;
    --ink: #f2f4f7;
    --muted: #a3acb9;
    --line: #333a44;
    --accent: #60a5fa;
    --accent-ink: #0b1220;
    --selected: #4ade80;
    --danger: #f87171;
    --warn-bg: #422b06;
    --warn-line: #f59e0b;
    --error-bg: #451a1a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 0 96px;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden; /* never scroll sideways on a phone */
}

h1 { font-size: 1.25rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 .5rem; }
h3 { font-size: .95rem; margin: 1.25rem 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ chrome */

.mode-banner {
  background: var(--warn-bg);
  border-bottom: 2px solid var(--warn-line);
  padding: .55rem 1rem;
  font-size: .9rem;
  text-align: center;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.alert {
  margin: 1rem;
  padding: .85rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
}
.alert-warning { background: var(--warn-bg); border-color: var(--warn-line); }
.alert-error { background: var(--error-bg); border-color: var(--danger); }

/* ------------------------------------------------------------------ login */

.login-shell {
  min-height: 80vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: min(420px, 100%);
}

label {
  display: block;
  margin: 1rem 0 .35rem;
  font-weight: 600;
  font-size: .9rem;
}

.input, .select, .textarea, input[type="email"], input[type="password"], input[type="search"] {
  width: 100%;
  min-height: 48px;
  padding: .7rem .8rem;
  font-size: 16px; /* 16px stops iOS zooming on focus */
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.textarea { min-height: 64px; resize: vertical; }

/* ----------------------------------------------------------------- buttons */

.btn {
  min-height: 48px;
  padding: .7rem 1.1rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn-quiet { background: transparent; }
.btn-block { width: 100%; margin-top: 1.25rem; }

/* -------------------------------------------------------------------- grid */

.send-shell { padding: 1rem; }
.controls { margin-bottom: 1.25rem; }

.grid-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .5rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--tap), 1fr));
  gap: .5rem;
}

.box {
  position: relative;
  min-height: var(--tap);
  padding: .4rem .2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: var(--surface);
  color: var(--ink);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  font: inherit;
  cursor: pointer;
  transition: transform .06s ease;
}
.box:active { transform: scale(.96); }

.box-number { font-size: 1.15rem; font-weight: 700; }

/* Selection is signalled three ways at once - border, fill and a tick - so it
   survives colour blindness and bright sunlight (sections 7 and 14). */
.box.is-selected {
  border-color: var(--selected);
  border-width: 3px;
  background: color-mix(in srgb, var(--selected) 16%, var(--surface));
}
.box-tick {
  font-size: .8rem;
  font-weight: 800;
  color: var(--selected);
  min-height: 1em;
}

.box.is-unavailable {
  opacity: .55;
  cursor: not-allowed;
  border-style: dashed;
}
.box-why { font-size: .6rem; color: var(--muted); text-align: center; line-height: 1.1; }

.box-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: .6rem;
  color: var(--muted);
}

.box.is-dimmed { opacity: .25; }

/* -------------------------------------------------------------- action bar */

.action-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem 1rem calc(.75rem + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgb(0 0 0 / .08);
  z-index: 10;
}
.count { font-weight: 600; }

/* ----------------------------------------------------------------- dialogs */

.dialog {
  width: min(560px, 94vw);
  max-height: 88vh;
  overflow-y: auto;
  border: none;
  border-radius: var(--radius);
  padding: 1.25rem;
  background: var(--surface);
  color: var(--ink);
}
.dialog::backdrop { background: rgb(0 0 0 / .55); }

.dialog-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: .6rem;
  justify-content: flex-end;
  padding-top: 1rem;
  margin-top: 1rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.summary { display: grid; gap: .4rem; margin: 0 0 1rem; }
.summary > div { display: flex; justify-content: space-between; gap: 1rem; }
.summary dt { color: var(--muted); margin: 0; }
.summary dd { margin: 0; font-weight: 700; }

.msg-list, .skip-list, .status-list { list-style: none; margin: 0; padding: 0; }
.msg-list li {
  padding: .6rem .75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: .5rem;
}
.msg-to { font-size: .85rem; color: var(--muted); margin-bottom: .25rem; }
.msg-body { font-size: .95rem; overflow-wrap: anywhere; }

.skip-list li { padding: .35rem 0; font-size: .9rem; color: var(--muted); }

.status-list li {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  padding: .45rem 0;
  border-bottom: 1px solid var(--line);
  font-size: .9rem;
}

.pill {
  font-size: .75rem;
  padding: .15rem .5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  white-space: nowrap;
}
.pill-delivered { border-color: var(--selected); color: var(--selected); }
.pill-failed, .pill-undelivered { border-color: var(--danger); color: var(--danger); }
.pill-skipped { color: var(--muted); }

.ack { display: flex; align-items: center; gap: .5rem; margin-top: .6rem; font-weight: 600; }
.ack input { width: 22px; height: 22px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: .7rem 1.1rem;
  border-radius: 999px;
  z-index: 30;
  max-width: 92vw;
  text-align: center;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem; border-bottom: 1px solid var(--line); }
.table-wrap { overflow-x: auto; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
