/* ============================================================================
   6am — an instrument, not a dashboard.
   The name is the brief: this thing fires at dawn. So the panel is a warm night
   ground with a single amber accent, and the one piece of real visual invention
   is the window bar — the ±5 minute send window drawn as an actual sunrise,
   night-blue bleeding into amber, with a tick where the poll will land.
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Frank+Ruhl+Libre:wght@500;700&family=IBM+Plex+Sans+Hebrew:wght@400;450;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --ink:        #100e0c;
  --ink-2:      #191512;
  --ink-3:      #221d18;
  --line:       #322a22;
  --line-soft:  #262019;

  --text:       #f4efe7;
  --muted:      #9c9188;
  --faint:      #6b625a;

  --amber:      #f2a355;
  --amber-hot:  #ffbd7a;
  --amber-dim:  #7d5228;
  --night:      #2f4468;

  --sage:       #8fb996;
  --brick:      #dd7361;

  --r:    10px;
  --r-sm: 6px;

  --sans: 'IBM Plex Sans Hebrew', 'Segoe UI', system-ui, sans-serif;
  --serif: 'Frank Ruhl Libre', Georgia, serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  font-weight: 400;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(130% 55% at 50% -5%, rgba(242, 163, 85, .11), transparent 62%),
    radial-gradient(90% 40% at 50% -5%, rgba(47, 68, 104, .18), transparent 70%),
    var(--ink);
  background-attachment: fixed;
}

/* Grain. Keeps the large dark fields from reading as flat digital black. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: .04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.wrap {
  max-width: 660px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

/* ---------------------------------------------------------------- header -- */

.masthead {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding-bottom: 22px;
  margin-bottom: 26px;
  border-bottom: 1px solid var(--line-soft);
}
.masthead h1 {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 26px;
  letter-spacing: -.02em;
  margin: 0;
  color: var(--amber);
  direction: ltr;
}
.masthead .tag {
  font-family: var(--serif);
  font-size: 15px;
  color: var(--muted);
  font-weight: 500;
}
.masthead .spacer { flex: 1; }

.linkbtn {
  background: none;
  border: 0;
  color: var(--faint);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 2px;
  border-bottom: 1px solid transparent;
  transition: color .18s, border-color .18s;
}
.linkbtn:hover { color: var(--amber); border-bottom-color: var(--amber-dim); }

/* ----------------------------------------------------------------- cards -- */

.card {
  background: linear-gradient(180deg, var(--ink-2), var(--ink));
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 22px;
  margin-bottom: 18px;
  animation: rise .5s cubic-bezier(.2, .7, .3, 1) backwards;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
}
.card:nth-of-type(1) { animation-delay: .04s; }
.card:nth-of-type(2) { animation-delay: .10s; }
.card:nth-of-type(3) { animation-delay: .16s; }
.card:nth-of-type(4) { animation-delay: .22s; }
.card:nth-of-type(5) { animation-delay: .28s; }

.sec-num {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--amber-dim);
  letter-spacing: .12em;
  display: block;
  margin-bottom: 4px;
  direction: ltr;
  text-align: start;
}
.sec-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 19px;
  margin: 0 0 4px;
  letter-spacing: -.01em;
}
.sec-note {
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 18px;
}

/* -------------------------------------------------------------- readouts -- */

.readout {
  display: flex;
  align-items: center;
  gap: 12px;
}
.dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--faint);
  flex: none;
  position: relative;
}
.dot.live { background: var(--sage); box-shadow: 0 0 0 0 rgba(143, 185, 150, .5); animation: pulse 2.6s infinite; }
.dot.warn { background: var(--amber); }
.dot.dead { background: var(--brick); }
@keyframes pulse {
  70%  { box-shadow: 0 0 0 9px rgba(143, 185, 150, 0); }
  100% { box-shadow: 0 0 0 0 rgba(143, 185, 150, 0); }
}

.readout-main { font-weight: 600; }
.readout-sub {
  font-size: 13px;
  color: var(--muted);
  font-family: var(--mono);
  direction: ltr;
  text-align: start;
}

/* -------------------------------------------- the window bar (the hook) -- */

.window {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
}
.window-label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .04em;
  margin-bottom: 10px;
}
.window-when {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 14px;
}
.window-when .t {
  font-family: var(--mono);
  color: var(--amber);
  direction: ltr;
  display: inline-block;
  font-weight: 500;
}
/* Timelines read left-to-right even in an RTL page. */
.bar {
  direction: ltr;
  position: relative;
  height: 8px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--night) 0%, #6b4a52 42%, var(--amber) 78%, var(--amber-hot) 100%);
  opacity: .85;
}
.bar .tick {
  position: absolute;
  top: -5px;
  left: var(--pos, 50%);
  width: 2px;
  height: 18px;
  background: var(--text);
  border-radius: 2px;
  box-shadow: 0 0 10px rgba(255, 255, 255, .55);
  transform: translateX(-1px);
  transition: left .7s cubic-bezier(.2, .7, .3, 1);
}
.bar .tick.est {
  background: rgba(244, 239, 231, .45);
  box-shadow: none;
  width: 1px;
}
.bar-ends {
  direction: ltr;
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--faint);
  margin-top: 7px;
}

/* ---------------------------------------------------------------- fields -- */

label.field { display: block; margin-bottom: 16px; }
label.field > span.lbl {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type=text], input[type=password], input[type=search], input[type=tel], input[type=number], input[type=time] {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
  transition: border-color .18s, box-shadow .18s;
}
input[type=time], input[type=tel], input[type=number] {
  font-family: var(--mono);
  direction: ltr;
  text-align: center;
}
input:focus {
  outline: none;
  border-color: var(--amber-dim);
  box-shadow: 0 0 0 3px rgba(242, 163, 85, .10);
}
input::placeholder { color: var(--faint); }
input:disabled { opacity: .4; }

.err {
  color: var(--brick);
  font-size: 12.5px;
  margin-top: 5px;
  min-height: 0;
}

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

button.btn {
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  border-radius: var(--r-sm);
  padding: 11px 20px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .18s, border-color .18s, color .18s, transform .1s;
}
button.btn:active { transform: translateY(1px); }
button.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn.primary {
  background: var(--amber);
  color: #1a1006;
  border-color: var(--amber);
}
.btn.primary:hover:not(:disabled) { background: var(--amber-hot); border-color: var(--amber-hot); }

.btn.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}
.btn.ghost:hover:not(:disabled) { border-color: var(--amber-dim); color: var(--amber); }

.btn.danger { background: transparent; color: var(--brick); border-color: rgba(221, 115, 97, .35); }
.btn.danger:hover:not(:disabled) { background: rgba(221, 115, 97, .10); }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------ 7-day grid -- */

.days { border-top: 1px solid var(--line-soft); }
.day {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--line-soft);
  border-inline-start: 2px solid transparent;
  transition: border-color .2s, background .2s, opacity .2s;
}
.day.on {
  border-inline-start-color: var(--amber);
  background: linear-gradient(to left, rgba(242, 163, 85, .05), transparent 55%);
}
.day:not(.on) { opacity: .48; }
.day .name { font-weight: 600; }
.day input[type=time] { width: 108px; padding: 7px 8px; }

.toggle {
  --w: 40px;
  width: var(--w); height: 22px;
  border-radius: 99px;
  background: var(--ink-3);
  border: 1px solid var(--line);
  position: relative;
  cursor: pointer;
  padding: 0;
  flex: none;
  transition: background .2s, border-color .2s;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; right: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--faint);
  transition: transform .22s cubic-bezier(.3, .8, .3, 1), background .2s;
}
.toggle[aria-checked=true] { background: rgba(242, 163, 85, .18); border-color: var(--amber-dim); }
.toggle[aria-checked=true]::after { background: var(--amber); transform: translateX(calc(-1 * (var(--w) - 22px))); }

.hint {
  font-size: 12.5px;
  color: var(--amber);
  background: rgba(242, 163, 85, .07);
  border-inline-start: 2px solid var(--amber-dim);
  padding: 7px 11px;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  margin-top: 10px;
}

/* --------------------------------------------------------- group picker -- */

.combo { position: relative; }
.combo-list {
  margin-top: 8px;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--ink);
}
.combo-list:empty { display: none; }
.g-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--line-soft);
  transition: background .12s;
}
.g-row:last-child { border-bottom: 0; }
.g-row:hover { background: var(--ink-3); }
.g-row .g-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-row .g-count { font-family: var(--mono); font-size: 11.5px; color: var(--faint); flex: none; }

.badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 99px;
  border: 1px solid var(--amber-dim);
  color: var(--amber);
  flex: none;
  white-space: nowrap;
}

.chosen {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--amber-dim);
  border-radius: var(--r-sm);
  background: rgba(242, 163, 85, .06);
}
.chosen .g-name { flex: 1; font-weight: 600; }

/* -------------------------------------------------------------- options -- */

.opt-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.opt-row .idx {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--faint);
  width: 18px;
  flex: none;
  text-align: center;
}
.icon-btn {
  background: none;
  border: 1px solid var(--line);
  color: var(--faint);
  border-radius: var(--r-sm);
  width: 34px; height: 34px;
  flex: none;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: color .16s, border-color .16s;
}
.icon-btn:hover:not(:disabled) { color: var(--brick); border-color: rgba(221, 115, 97, .4); }
.icon-btn:disabled { opacity: .3; cursor: not-allowed; }

.check {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 14px;
  padding: 4px 0;
}
.check input { accent-color: var(--amber); width: 16px; height: 16px; }

/* -------------------------------------------------------------- pairing -- */

.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.tab {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  padding: 9px 14px;
  cursor: pointer;
  margin-bottom: -1px;
  transition: color .18s, border-color .18s;
}
.tab.active { color: var(--amber); border-bottom-color: var(--amber); }

.qr-stage { text-align: center; padding: 8px 0 4px; }
.qr-stage img {
  width: 236px; height: 236px;
  border-radius: var(--r-sm);
  background: #fff;
  padding: 12px;
  box-shadow: 0 0 44px rgba(242, 163, 85, .16);
}
.qr-meta { font-family: var(--sans); font-size: 12.5px; color: var(--faint); margin-top: 12px; }
.qr-meta #qr-count { font-family: var(--mono); }

.code-out {
  font-family: var(--mono);
  font-size: 30px;
  letter-spacing: .16em;
  color: var(--amber);
  text-align: center;
  padding: 22px 0 8px;
  direction: ltr;
}

ol.steps { margin: 16px 0 0; padding-inline-start: 20px; color: var(--muted); font-size: 13px; line-height: 1.9; }
ol.steps b { color: var(--text); font-weight: 600; }

/* -------------------------------------------------------------- history -- */

.hist { list-style: none; margin: 0; padding: 0; }
.hist li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13.5px;
}
.hist li:last-child { border-bottom: 0; }
.hist .h-mark { flex: none; font-size: 12px; }
.hist .h-mark.ok { color: var(--sage); }
.hist .h-mark.no { color: var(--brick); }
.hist .h-when { font-family: var(--mono); font-size: 12px; color: var(--faint); flex: none; direction: ltr; }
.hist .h-what { flex: 1; color: var(--muted); }
.empty { color: var(--faint); font-size: 13px; padding: 6px 0; }

/* ---------------------------------------------------------------- toast -- */

#toast {
  position: fixed;
  bottom: 22px;
  inset-inline-start: 22px;
  background: var(--ink-3);
  border: 1px solid var(--line);
  border-inline-start: 3px solid var(--amber);
  border-radius: var(--r-sm);
  padding: 12px 18px;
  font-size: 14px;
  z-index: 200;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  max-width: min(420px, calc(100vw - 44px));
  box-shadow: 0 10px 34px rgba(0, 0, 0, .5);
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.bad { border-inline-start-color: var(--brick); }
#toast.good { border-inline-start-color: var(--sage); }

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

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card { width: 100%; max-width: 340px; text-align: center; }
.login-card h1 {
  font-family: var(--mono);
  font-size: 40px;
  color: var(--amber);
  margin: 0 0 6px;
  direction: ltr;
  font-weight: 500;
}
.login-card p { color: var(--muted); font-size: 13.5px; margin: 0 0 26px; font-family: var(--serif); }

[hidden] { display: none !important; }

.spin {
  display: inline-block;
  width: 13px; height: 13px;
  border: 2px solid var(--line);
  border-top-color: var(--amber);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 520px) {
  .wrap { padding: 26px 14px 60px; }
  .card { padding: 18px 15px; }
  .day { grid-template-columns: auto 1fr auto; gap: 10px; padding: 10px 6px; }
  .masthead h1 { font-size: 22px; }
}

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