/* Hafawa Lounge — Boarding pass log
   Palette: departure-board navy, pass-paper white, boarding amber, cleared teal. */
:root {
  --board: #101c33;
  --board-2: #1a2b4d;
  --paper: #f3f4f7;
  --card: #ffffff;
  --ink: #14213d;
  --muted: #6b7386;
  --line: #dbe0ea;
  --amber: #f2a93b;
  --amber-ink: #3a2a05;
  --teal: #1d9a7a;
  --red: #c8433b;
  --warn-bg: #fff4dc;
  --mono: ui-monospace, "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --ui: system-ui, -apple-system, "Segoe UI", Tahoma, "Noto Sans Arabic", sans-serif;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--ui); font-size: 15px; line-height: 1.5;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2 { margin: 0; font-weight: 700; }
h2 { font-size: 16px; }
h2 small { font-weight: 400; color: var(--muted); font-size: 12px; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }

/* Header — a departure-board strip */
.board {
  background: var(--board); color: #fff; padding: 14px 16px 16px;
  padding-top: calc(14px + env(safe-area-inset-top));
}
.board-strip {
  font-family: var(--mono); font-size: 11px; letter-spacing: .22em; color: var(--amber);
  direction: ltr; text-align: left; text-transform: uppercase; margin-bottom: 6px;
}
.board h1 { font-size: 22px; }
.board-meta { color: #b9c2d6; font-size: 13px; margin-top: 4px; }
.board-meta b { color: #fff; font-family: var(--mono); }

main { padding: 14px 14px 28px; display: grid; gap: 14px; max-width: 980px; margin: 0 auto; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 12px; padding: 12px 16px;
  font-weight: 700; background: var(--board-2); color: #fff; min-height: 46px;
  text-align: center; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn-amber { background: var(--amber); color: var(--amber-ink); }
.btn-teal { background: var(--teal); color: #fff; }
.btn-ghost { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn-small { padding: 8px 12px; min-height: 38px; font-size: 14px; }
.btn[disabled] { opacity: .5; cursor: default; }

/* Scan section */
.scan { background: var(--board); color: #fff; border-radius: var(--radius); padding: 14px; }
.scan-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.scan-actions .btn-amber { grid-column: 1 / -1; font-size: 17px; min-height: 54px; }
.scan .btn-ghost { background: rgba(255,255,255,.08); color: #fff; border-color: rgba(255,255,255,.18); }
.cam { position: relative; margin-top: 12px; border-radius: 12px; overflow: hidden; background: #000; aspect-ratio: 4 / 3; }
.cam video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-guide {
  position: absolute; inset: 18% 8%; border: 2px solid rgba(255,255,255,.75); border-radius: 10px;
  box-shadow: 0 0 0 999px rgba(0,0,0,.35); pointer-events: none;
}
.cam-guide::after {
  content: ""; position: absolute; left: 6%; right: 6%; top: 50%; height: 2px;
  background: var(--amber); opacity: .9; animation: sweep 2.2s ease-in-out infinite;
}
@keyframes sweep { 0%, 100% { transform: translateY(-38px); } 50% { transform: translateY(38px); } }
@media (prefers-reduced-motion: reduce) { .cam-guide::after { animation: none; } }
.cam-bar { position: absolute; bottom: 10px; inset-inline: 10px; display: flex; justify-content: space-between; gap: 8px; }
.chip { border: 0; border-radius: 999px; padding: 8px 14px; background: rgba(255,255,255,.92); color: var(--ink); font-weight: 700; font-size: 14px; }
.chip-red { background: var(--red); color: #fff; }
.chip.on { background: var(--amber); }
.status { margin: 12px 0 0; color: #d6dcea; font-size: 14px; min-height: 1.5em; }
.status.ok { color: #9be3c9; }
.status.err { color: #ffb4ae; }
.paste { margin-top: 10px; color: #d6dcea; font-size: 14px; }
.paste summary { cursor: pointer; }
.paste textarea {
  width: 100%; margin-top: 8px; border-radius: 10px; border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.06); color: #fff; padding: 10px; font-family: var(--mono); font-size: 12px;
}
.paste .btn { margin-top: 8px; }

/* The latest pass — rendered as a boarding stub with a tear line */
.stub {
  position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px 14px 26px; direction: ltr; text-align: left; font-family: var(--mono);
}
.stub::before {
  content: ""; position: absolute; top: 10px; bottom: 10px; left: 13px;
  border-left: 2px dashed var(--line);
}
.stub::after {
  content: ""; position: absolute; left: 6px; top: -8px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--paper); border-bottom: 1px solid var(--line);
}
.stub-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.stub-name { font-size: 18px; font-weight: 700; letter-spacing: .02em; word-break: break-word; }
.stub-class { font-size: 12px; padding: 3px 8px; border-radius: 6px; background: var(--board); color: var(--amber); white-space: nowrap; }
.stub-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px 10px; margin-top: 10px; }
.stub-grid em { display: block; font-style: normal; font-size: 15px; font-weight: 700; }
.stub-grid span { display: block; font-size: 10px; letter-spacing: .12em; color: var(--muted); }
.stub-foot { margin-top: 10px; font-size: 12px; color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; }
.stub-foot b { color: var(--ink); font-weight: 700; }
.stub .missing { color: var(--red); }

/* ETD per flight */
.etd-add { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-bottom: 10px; }
.etd-add input, .settings input, .settings select {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; min-height: 44px; width: 100%;
}
.etd-add input[type="text"] { font-family: var(--mono); text-transform: uppercase; }
.etd-list { display: grid; gap: 6px; }
.etd-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.etd-row .fl { font-family: var(--mono); font-weight: 700; direction: ltr; text-align: left; }
.etd-row .fl small { color: var(--muted); font-weight: 400; }
.etd-row input[type="time"] { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-family: var(--mono); }
.etd-row input.warn { border-color: var(--amber); background: var(--warn-bg); }
.etd-row .x { border: 0; background: transparent; color: var(--muted); font-size: 16px; padding: 4px 6px; }
.etd-empty { color: var(--muted); font-size: 14px; }

/* Log table */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; max-height: 60vh; -webkit-overflow-scrolling: touch; }
table { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; font-family: var(--mono); font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
th { position: sticky; top: 0; background: var(--board); color: #fff; font-weight: 700; font-size: 11px; letter-spacing: .08em; z-index: 1; text-align: left; }
td[contenteditable] { min-width: 3.5em; }
td[contenteditable]:focus { outline: 2px solid var(--amber); outline-offset: -2px; background: #fffaf0; }
td.name { min-width: 14em; }
td.idx { color: var(--muted); background: #fafbfd; }
td.warn { background: var(--warn-bg); }
td.f, td.bg { text-align: center; font-weight: 700; }
tr.hit td { background: #e6f6f1; }
td.del { padding: 4px; }
td.del .x { border: 0; background: transparent; color: var(--red); font-size: 16px; padding: 6px 10px; }
.empty { color: var(--muted); text-align: center; padding: 20px 8px 8px; }

/* Settings */
.settings summary { cursor: pointer; font-weight: 700; }
.settings .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.settings label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.settings label.wide { grid-column: 1 / -1; }
.settings label.check { grid-template-columns: auto 1fr; align-items: center; color: var(--ink); }
.settings .hint { grid-column: 1 / -1; font-size: 12px; color: var(--muted); margin: 0; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); z-index: 50; max-width: 92vw; text-align: center;
}
.toast.err { background: var(--red); }
.toast.ok { background: var(--teal); }

@media (min-width: 700px) {
  .scan-actions { grid-template-columns: 2fr 1fr 1fr; }
  .scan-actions .btn-amber { grid-column: auto; }
  .stub-grid { grid-template-columns: repeat(6, 1fr); }
}
