/* EntryWatch admin trial. Colours mirror lib/core/theme/app_colors.dart. */
:root {
  --bg: #121418;
  --surface: #1e2128;
  --surface-2: #252836;
  --outline: #3f4451;
  --text: #f0f2f8;
  --text-2: #cdd1e0;
  --muted: #9ca3af;
  --primary: #ffb800;
  --on-primary: #121418;
  --error: #ff6b68;
  --info: #42a5f5;
  /* Tokens added for the redesign (statusInside; amber at low strength). */
  --primary-text: #ffb800;
  --primary-soft: color-mix(in srgb, var(--primary) 14%, transparent);
  --success: #4caf50;
  --scrim: rgb(0 0 0 / 35%);
  --radius: 14px;
  --radius-input: 10px;
  --gap: 16px;
  --target: 48px;
  --header-h: 64px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fa;
    --surface: #ffffff;
    --surface-2: #e8ebf4;
    --outline: #cdd1e0;
    --text: #0d0f14;
    --text-2: #1a1d27;
    --muted: #626775;
    --primary: #e65100;
    --on-primary: #ffffff;
    --error: #b3261e;
    /* entryOnLight / baOkOnLight: readable small text on white. */
    --primary-text: #b34700;
    --primary-soft: color-mix(in srgb, var(--primary) 10%, transparent);
    --success: #256b29;
    --scrim: rgb(0 0 0 / 20%);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-2);
  font: 16px/1.5 Inter, Roboto, system-ui, -apple-system, 'Segoe UI', sans-serif;
}

h1, h2, h3 { color: var(--text); margin: 0 0 8px; line-height: 1.25; }
h1 { font-size: 1.05rem; margin: 0; white-space: nowrap; }
h2 { font-size: 1.1rem; }
h3 { font-size: 0.95rem; margin-top: var(--gap); }
p { margin: 0 0 12px; }
.muted { color: var(--muted); font-size: 0.9rem; }
.card-desc { color: var(--muted); font-size: 0.9rem; margin-bottom: 18px; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ── Header ─────────────────────────────────────────────────────────── */
.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 8px var(--gap);
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-h);
  padding: 10px max(16px, calc((100vw - 1280px) / 2 + 24px));
  background: var(--surface);
  border-bottom: 1px solid var(--outline);
}
.brand { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.wordmark { display: block; height: 28px; width: auto; }
.bar-divider { width: 1px; height: 28px; background: var(--outline); }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border: 1px solid var(--outline);
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.78rem;
}
.dot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.bar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Page layout ────────────────────────────────────────────────────── */
.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr) 300px;
  grid-template-areas: 'nav main panel';
  gap: 24px;
  align-items: start;
}
main { grid-area: main; display: grid; gap: var(--gap); min-width: 0; }
.steps, .panel { position: sticky; top: calc(var(--header-h) + 24px); }
.steps { grid-area: nav; }
.panel {
  grid-area: panel;
  max-height: calc(100vh - var(--header-h) - 48px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  padding: 20px;
}
.step-group { display: grid; gap: var(--gap); scroll-margin-top: calc(var(--header-h) + 16px); }

/* ── Left steps ─────────────────────────────────────────────────────── */
.steps ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.step {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 6px 10px 6px 14px;
  border-radius: 10px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 0.92rem;
}
.step:hover { background: var(--surface); }
.step[aria-current='true'] { background: var(--surface-2); color: var(--text); font-weight: 600; }
.step[aria-current='true']::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 3px;
  background: var(--primary);
}
.step-num {
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  border: 1px solid var(--outline);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}
.step.done .step-num { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-size: 0; }
.step.done .step-num::before { content: '✓'; font-size: 0.85rem; }
.step-label { flex: 1; min-width: 0; }
.step-flag { display: inline-flex; align-items: center; gap: 6px; color: var(--primary-text); font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.step-flag .dot, .required-dot { background: var(--primary); }
.steps-note { margin: 14px 10px 0; color: var(--muted); font-size: 0.8rem; display: flex; align-items: center; gap: 8px; }

/* ── Cards and fields ───────────────────────────────────────────────── */
.card {
  scroll-margin-top: calc(var(--header-h) + 16px);
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  padding: 22px;
  container-type: inline-size;
}
.card.info { border-color: var(--info); }
.card.info ol { margin: 0 0 12px; padding-left: 22px; display: grid; gap: 8px; }

.grid { display: grid; gap: 14px var(--gap); margin-bottom: 14px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.grid.crew-main { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.grid.crew-main > .field:nth-child(1) { grid-column: span 4; }
.grid.crew-main > .field:nth-child(n + 2) { grid-column: span 2; }
.grid.dates-row { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); align-items: end; }
.grid.dates-row .chip, .grid.dates-row .button { align-self: end; }
.grid > .field, .grid > .chip { margin: 0; }

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.grid > .field { margin-bottom: 0; }
.field input, .field select, .field textarea { text-transform: none; letter-spacing: normal; font-weight: 400; }

input, select, textarea {
  scroll-margin-top: calc(var(--header-h) + 40px);
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--outline);
  border-radius: var(--radius-input);
  padding: 10px 12px;
  min-height: var(--target);
  width: 100%;
}
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible,
.button:focus-visible, .step:focus-visible, .chips button:focus-visible,
.file-button:has(input:focus-visible), summary:focus-visible,
.chip:has(input:focus-visible) .chip-box, .risk-option:has(input:focus-visible) {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--primary); }
.invalid { border-color: var(--error) !important; }
.risk-group.invalid { outline: 2px solid var(--error); outline-offset: 4px; border-radius: var(--radius-input); }

fieldset { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
legend {
  padding: 0;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Risk category: three large segmented buttons (radio group). */
.risk-group { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.risk-option {
  position: relative;
  display: grid;
  align-content: center;
  gap: 2px;
  min-height: 72px;
  padding: 12px 14px;
  border: 1px solid var(--outline);
  border-radius: var(--radius-input);
  background: var(--bg);
  color: var(--text-2);
  text-align: center;
  cursor: pointer;
}
.risk-option:hover { border-color: var(--muted); }
.risk-title { color: var(--text); font-weight: 700; font-size: 1.05rem; }
.risk-sub { color: var(--muted); font-size: 0.85rem; }
.risk-option:has(input:checked) { border: 2px solid var(--primary); padding: 11px 13px; background: var(--primary-soft); }
.risk-option:has(input:checked) .risk-sub { color: var(--text-2); }
.risk-option:has(input:checked)::after {
  content: '✓';
  position: absolute;
  top: 6px;
  right: 10px;
  color: var(--primary-text);
  font-weight: 700;
}

/* Toggle chips (checkboxes underneath). */
.toggles { display: flex; gap: 10px; flex-wrap: wrap; }
.chip { display: inline-flex; margin: 0; cursor: pointer; }
.chip-box {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--outline);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-2);
  font-size: 0.95rem;
}
.chip:hover .chip-box { border-color: var(--muted); }
.chip:has(input:checked) .chip-box { border-color: var(--primary); background: var(--primary-soft); color: var(--text); font-weight: 600; }
.chip:has(input:checked) .chip-box::before { content: '✓'; color: var(--primary-text); font-weight: 700; }
.chip:has(input:disabled) { cursor: default; }

/* Checkbox rows in the checklist. */
label.check {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--text-2);
  font-size: 1rem;
  min-height: 44px;
  margin: 0;
  cursor: pointer;
}
input[type='checkbox'] { width: 22px; height: 22px; min-height: 0; accent-color: var(--primary); flex: none; }

/* ── Buttons ────────────────────────────────────────────────────────── */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  border: 2px solid var(--primary);
  position: relative;
}
.button.primary { background: var(--primary); color: var(--on-primary); }
.button.secondary { background: transparent; color: var(--primary-text); }
.bar .button.secondary { border-color: var(--outline); color: var(--text-2); }
.bar .button.secondary:hover { border-color: var(--muted); }
.button.danger { border-color: var(--error); color: var(--error); background: transparent; }
.button:disabled { opacity: 0.45; cursor: not-allowed; }
.button.small { min-height: 44px; padding: 0 14px; font-size: 0.9rem; }

/* ── Days ───────────────────────────────────────────────────────────── */
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 12px 0 0; }
.chips li {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 0 4px 0 14px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
}
.chips button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.3rem;
  width: 40px;
  height: 40px;
  cursor: pointer;
  border-radius: 50%;
}
.chips button:hover { color: var(--error); }

/* ── Teams, crew, custom items, equipment ───────────────────────────── */
.inline-add { margin-top: 4px; display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.inline-add .field { flex: 1 1 200px; margin: 0; }
.team-row { display: flex; gap: 12px; align-items: end; margin-bottom: 12px; }
.team-row .field { flex: 1; margin: 0; }
.row, .crew-row {
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  background: var(--bg);
}
.row-head, .crew-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.row-head strong { color: var(--text); }
.row.custom { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: end; }
.row.custom .grid { margin: 0; }
.crew-head { justify-content: flex-start; }
.crew-head .button { margin-left: auto; }
.crew-index {
  display: grid;
  place-items: center;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 0.8rem;
  font-weight: 700;
}
.crew-name { color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.role-pill {
  flex: none;
  padding: 2px 10px;
  border: 1px solid var(--outline);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}
.role-pill.topman { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-text); }
.crew-flags { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crew-more { margin-top: 12px; }
.crew-more summary {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 4px;
  color: var(--primary-text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}
.crew-more .grid { margin: 8px 0 0; }

/* ── Checklist ──────────────────────────────────────────────────────── */
.category { margin-bottom: 12px; }
.category h3 { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; min-height: 44px; color: var(--text-2); cursor: pointer; }
.item input { margin-top: 2px; }
.item.locked { color: var(--muted); cursor: default; }
.tag { font-size: 0.75rem; color: var(--muted); border: 1px solid var(--outline); border-radius: 999px; padding: 0 8px; margin-left: 6px; white-space: nowrap; }
/* Kept external so the offline page can use a strict style-src policy. */
label.checklist-option { display: inline-flex; font-weight: 400; font-size: 0.9rem; min-height: 44px; }

/* ── Right panel ────────────────────────────────────────────────────── */
.panel h2 { margin-bottom: 14px; }
.progress { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.progress span { height: 8px; border-radius: 4px; background: var(--outline); }
.progress span.on { background: var(--primary); }
.progress-text { margin: 8px 0 16px; color: var(--text); font-weight: 600; font-size: 0.9rem; }
.needed { margin-bottom: 4px; }
.needed h3 { margin: 0 0 6px; }
.needed ul { margin: 0 0 8px; padding-left: 18px; }
.needed li { margin-bottom: 4px; font-size: 0.9rem; }
.needed li::marker { color: var(--error); }
.needed a { color: var(--text-2); text-underline-offset: 3px; }
.needed-done { color: var(--success); font-size: 0.9rem; font-weight: 600; }
.needed-done::before { content: '✓ '; }
.panel-label {
  margin: 20px 0 10px;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.phone {
  width: 220px;
  margin: 0 auto;
  padding: 8px;
  border: 2px solid var(--outline);
  border-radius: 28px;
  background: var(--bg);
}
.phone-notch { width: 56px; height: 6px; margin: 0 auto 8px; border-radius: 3px; background: var(--outline); }
.phone-screen { padding: 10px; border-radius: 18px; background: var(--bg); }
.phone-card {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 2px solid var(--primary);
  border-radius: 4px;
  background: var(--surface);
}
.phone-card p { margin: 0; }
.pc-head { display: flex; align-items: center; gap: 6px; color: var(--primary-text); font-weight: 700; font-size: 0.9rem; }
.pc-title { color: var(--text); font-weight: 700; font-size: 0.95rem; overflow-wrap: anywhere; }
.pc-title.empty { color: var(--muted); font-weight: 400; }
.pc-sub { color: var(--text-2); font-size: 0.8rem; overflow-wrap: anywhere; }
.pc-button {
  justify-self: stretch;
  margin-top: 4px;
  padding: 7px 0;
  border-radius: 999px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
}
.panel-caption { margin: 12px 0 14px; color: var(--muted); font-size: 0.85rem; }
.panel .button { width: 100%; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 20;
  max-width: min(90vw, 560px);
  padding: 12px 18px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  box-shadow: 0 8px 24px var(--scrim);
}

/* ── Responsive ─────────────────────────────────────────────────────── */
@container (max-width: 560px) {
  .risk-group { grid-template-columns: 1fr; }
  .risk-option { min-height: 56px; }
  .grid.crew-main { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.crew-main > .field:nth-child(n) { grid-column: span 1; }
  .grid.crew-main > .field:nth-child(1) { grid-column: 1 / -1; }
  .row.custom { grid-template-columns: 1fr; }
}

@media (max-width: 1099px) {
  .layout {
    grid-template-columns: 220px minmax(0, 1fr);
    grid-template-areas: 'nav main' 'nav panel';
  }
  .panel { position: static; max-height: none; }
}

@media (max-width: 799px) {
  .bar { position: static; }
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'nav' 'main' 'panel'; padding: 0 12px 24px; gap: 16px; }
  .steps {
    top: 0;
    z-index: 9;
    margin: 0 -12px;
    padding: 8px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--outline);
    overflow-x: auto;
  }
  .steps ol { display: flex; gap: 6px; width: max-content; }
  .step { white-space: nowrap; padding: 6px 12px 6px 8px; border: 1px solid var(--outline); border-radius: 999px; }
  .step[aria-current='true']::before { top: auto; bottom: 3px; left: 14px; right: 14px; width: auto; height: 3px; }
  .steps-note { display: none; }
  .card { padding: 18px; }
  .card, .step-group { scroll-margin-top: 72px; }
  .risk-group { grid-template-columns: 1fr; }
  .brand { width: 100%; }
  .pill { white-space: normal; }
  .bar-actions { width: 100%; flex-wrap: nowrap; }
  .bar-actions .button { flex: 1 1 auto; padding: 0 10px; font-size: 0.9rem; white-space: nowrap; }
  .team-row { flex-wrap: wrap; }
}
