/* =========================================================================
   WRC Camp Sign-In — admin platform styling
   Theme: "Alpine Dusk" — deep spruce + warm amber, snow working surface.
   ========================================================================= */
:root {
  /* Neutral slate platform chrome */
  --spruce-900: #1f2730;   /* header bar dark */
  --spruce-800: #283139;
  --spruce-700: #323c46;
  --spruce-600: #4b5763;   /* accent text / labels */
  --amber: #56657a;        /* restrained steel accent */
  --amber-bright: #6a798d;
  --snow: #f1f3f6;         /* app background */
  --paper: #ffffff;
  --ink: #1c2530;
  --ink-soft: #5b6675;
  --line: #e2e6eb;
  --line-soft: #eef1f4;

  --red: #e4231b;
  --red-soft: #fde8e7;
  --orange: #f3911d;
  --orange-soft: #fdf0dd;
  --green: #29c24a;
  --green-soft: #e6f8ea;
  --blue: #2747b0;
  --blue-soft: #eef2fc;

  --shadow: 0 14px 34px -20px rgba(20, 30, 45, 0.40);
  --radius: 12px;
  --font-display: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --font-text: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-text);
  color: var(--ink);
  background: var(--snow);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---- Header ------------------------------------------------------------- */
.topbar {
  background: var(--spruce-900);
  color: #fff;
  padding: 16px clamp(20px, 5vw, 48px);
  display: flex; align-items: center; gap: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}
.brand-logo { height: 40px; width: auto; flex: none; display: block; object-fit: contain; }
.brand-text h1 {
  font-family: var(--font-display); font-weight: 600;
  font-size: clamp(18px, 2vw, 22px); margin: 0; letter-spacing: -0.2px;
}
.brand-text p { margin: 2px 0 0; color: #aeb7c2; font-size: 13px; }
.topbar .spacer { flex: 1; }
.topbar .hint { color: #99a2ad; font-size: 12px; text-align: right; max-width: 230px; line-height: 1.4; }

/* ---- Layout ------------------------------------------------------------- */
.wrap { padding: clamp(20px, 4vw, 40px); max-width: 1320px; margin: 0 auto; }
.panel {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: clamp(18px, 2.5vw, 26px);
}

.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: stretch; }
@media (max-width: 760px) { .controls { grid-template-columns: 1fr; } }

.step-label {
  font-family: var(--font-display); font-weight: 700; font-size: 12px;
  letter-spacing: 1.5px; text-transform: uppercase; color: var(--spruce-600);
  display: flex; align-items: center; gap: 8px; margin: 0 0 9px;
}
.step-label .n {
  width: 19px; height: 19px; border-radius: 50%; background: var(--spruce-700);
  color: var(--snow); font-size: 11px; display: grid; place-items: center;
}

/* ---- Dropzones ---------------------------------------------------------- */
.drop {
  border: 2px dashed var(--line); border-radius: 12px; background: #fbfcfd;
  padding: 20px; text-align: center; cursor: pointer; transition: all .18s ease;
  display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 132px;
  justify-content: center;
}
.drop:hover { border-color: var(--spruce-600); background: #f4f6f9; }
.drop:focus-visible { outline: 2px solid var(--spruce-600); outline-offset: 2px; }
.drop.dragging { border-color: var(--spruce-600); background: var(--blue-soft); transform: translateY(-2px); }
.drop.loaded { border-style: solid; border-color: var(--green); background: var(--green-soft); cursor: default; }
.drop input[type=file] { display: none; }
.drop-empty, .drop-done { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.drop .ico { font-size: 24px; line-height: 1; color: var(--spruce-600); }
.drop .big { font-weight: 600; font-size: 15px; }
.drop .sub { font-size: 12.5px; color: var(--ink-soft); }
.drop .check {
  width: 38px; height: 38px; border-radius: 50%; background: var(--green); color: #fff;
  display: grid; place-items: center; font-size: 21px; font-weight: 700;
}
.drop .remove {
  margin-top: 4px; font-family: var(--font-text); font-size: 12.5px; font-weight: 600;
  color: #9a3a32; background: #fff; border: 1px solid #e8c9c5; border-radius: 8px;
  padding: 5px 12px; cursor: pointer; transition: all .15s;
}
.drop .remove:hover { background: #fdeceb; border-color: #d98b83; }

/* ---- Week + generate ---------------------------------------------------- */
.runbar {
  margin-top: 18px; display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap;
}
.field { display: flex; flex-direction: column; gap: 7px; }
.field label {
  font-family: var(--font-display); font-weight: 700; font-size: 12px;
  letter-spacing: 1.2px; text-transform: uppercase; color: var(--spruce-600);
}
select {
  font-family: var(--font-text); font-size: 15px; padding: 11px 14px; min-width: 230px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink);
  appearance: none; background-image:
    linear-gradient(45deg, transparent 50%, var(--spruce-600) 50%),
    linear-gradient(135deg, var(--spruce-600) 50%, transparent 50%);
  background-position: right 16px center, right 11px center;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; cursor: pointer;
}
select:focus { outline: none; border-color: var(--spruce-600); box-shadow: 0 0 0 3px rgba(30,82,64,0.14); }

.btn {
  font-family: var(--font-display); font-weight: 700; font-size: 15px;
  padding: 12px 22px; border-radius: 11px; border: none; cursor: pointer;
  transition: transform .12s ease, box-shadow .18s ease, background .18s; letter-spacing: .2px;
}
.btn-primary {
  background: linear-gradient(160deg, var(--spruce-600), var(--spruce-800));
  color: var(--snow); box-shadow: 0 10px 22px -10px rgba(15,44,32,0.7);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-amber { background: var(--spruce-700); color: #fff; }
.btn-amber:hover { transform: translateY(-2px); box-shadow: 0 10px 22px -12px rgba(31,39,48,0.7); }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--spruce-700); }
.btn-ghost:hover { border-color: var(--spruce-600); background: #f4f8f4; }

/* ---- Summary + warnings ------------------------------------------------- */
.summary { margin-top: 22px; display: none; }
.summary.show { display: block; animation: rise .4s ease both; }
.stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: 11px;
  padding: 12px 16px; min-width: 92px; display: flex; flex-direction: column; gap: 2px;
}
.stat .num { font-family: var(--font-display); font-weight: 800; font-size: 22px; line-height: 1; }
.stat .lbl { font-size: 11.5px; letter-spacing: .6px; text-transform: uppercase; color: var(--ink-soft); }
.stat.red .num { color: var(--red); } .stat.orange .num { color: var(--orange); } .stat.green .num { color: #1c9c39; }

.notes { display: flex; flex-direction: column; gap: 8px; }
.note {
  border-radius: 10px; padding: 11px 14px; font-size: 13.5px; display: flex; gap: 9px; align-items: flex-start;
}
.note.info { background: var(--blue-soft); color: #1c2f74; border: 1px solid #d3ddf6; }
.note.warn { background: #fff6e6; color: #7a5410; border: 1px solid #f3e0b5; }
.note .ic { flex: none; }
.note ul { margin: 4px 0 0; padding-left: 18px; } .note li { margin: 2px 0; }

.toolbar {
  margin-top: 22px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding-top: 18px; border-top: 1px dashed var(--line);
}
.toolbar .grp { display: flex; gap: 8px; }
.toolbar .lbl { font-size: 12px; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-soft); margin-right: 2px; }

/* ---- Sheets preview ----------------------------------------------------- */
.sheets { margin-top: 26px; display: flex; flex-direction: column; gap: 30px; }
.sheet { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.sheet-scroll { overflow-x: auto; }

/* Per-group colour tokens */
.sheet.red    { --bar: #d4261e; --soft: #fce4e2; --tab: #f9d6d3; }
.sheet.orange { --bar: #e88a1c; --soft: #fdecdd; --tab: #fbe2c9; }
.sheet.green  { --bar: #25a549; --soft: #e4f6e8; --tab: #d4f0db; }

/* Masthead */
.sheet-mast { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 3px solid var(--bar); }
.sheet-mast .chip { width: 46px; height: 46px; border-radius: 10px; background: var(--bar); flex: none; display: grid; place-items: center; }
.sheet-mast .chip img { width: 34px; height: 34px; object-fit: contain; }
.sheet-mast .mh { display: flex; flex-direction: column; gap: 1px; }
.sheet-mast h2 { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 20px; letter-spacing: -.3px; color: var(--ink); }
.sheet-mast .sub { font-size: 12px; color: var(--ink-soft); }
.sheet-mast .right { margin-left: auto; text-align: right; }
.sheet-mast .wk { font-family: var(--font-display); font-weight: 700; font-size: 12px; letter-spacing: .6px; text-transform: uppercase; color: var(--spruce-700); }
.sheet-mast .all { font-size: 11.5px; font-weight: 600; color: #ce241c; margin-top: 2px; }

table.grid { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 12.5px; }
table.grid th, table.grid td { border: 1px solid #d4d9df; padding: 5px 6px; vertical-align: middle; }
table.grid thead th.zone { color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 11px; letter-spacing: .8px; text-transform: uppercase; text-align: center; padding: 6px; }
th.zone.child { background: #212a34; } th.zone.in { background: var(--bar); } th.zone.out { background: #4a5663; }
table.grid thead th.sub { background: #4a5663; color: #fff; font-family: var(--font-display); font-weight: 600; font-size: 10.5px; letter-spacing: .2px; text-align: center; padding: 7px 5px; }
table.grid thead th.sub.l { text-align: left; }

table.grid col.c-no { width: 32px; } table.grid col.c-name { width: 16%; }
table.grid col.c-age { width: 42px; } table.grid col.c-type { width: 78px; }
table.grid col.c-med { width: 15%; }
table.grid col.c-in { width: 34px; } table.grid col.c-out { width: 6.6%; }

td.no { text-align: center; font-weight: 700; color: var(--ink-soft); background: var(--tab); }
td.name { font-weight: 600; }
td.age { text-align: center; }
td.type { text-align: center; }
.pill { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .3px; padding: 2px 8px; border-radius: 999px; }
.pill.combo, .pill.both { background: #f08a24; color: #fff; }
.pill.wrc { background: #fff; color: #212a34; border: 1px solid #4a5663; }
td.med { font-size: 10.5px; color: #ce241c; line-height: 1.18; }
td.day { padding: 0; }
td.day.booked { background: var(--soft); }
td.day.closed { background: #eceef1; background-image: linear-gradient(135deg, transparent 45%, #c8ced4 46%, #c8ced4 54%, transparent 55%); }

tr.has-allergy td.no { box-shadow: inset 4px 0 0 #ce241c; }

tfoot td { border: 1px solid #d4d9df; }
tfoot .tot-label { text-align: right; font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--ink); padding-right: 12px; background: var(--blue-soft); }
tfoot td.tot { background: #212a34; color: #fff; text-align: center; font-family: var(--font-display); font-weight: 700; font-size: 14px; }
tfoot td.tot-end { background: var(--blue-soft); }

.empty-hint { color: var(--ink-soft); font-size: 13px; text-align: center; padding: 40px 0; }

/* ---- Move-between-groups control (screen only; never in the PDF) -------- */
table.grid col.c-move { width: 72px; }
table.grid th.move-h { background: #212a34; color: #fff; font-family: var(--font-display); font-weight: 600; font-size: 9.5px; letter-spacing: .5px; text-transform: uppercase; }
td.move { text-align: center; padding: 2px; }
td.move .mv {
  display: inline-flex; gap: 2px;
}
td.move button {
  width: 18px; height: 18px; border-radius: 5px; border: 1px solid transparent;
  font-family: var(--font-text); font-size: 10px; font-weight: 700; cursor: pointer;
  color: #fff; opacity: .35; transition: opacity .12s, transform .12s; padding: 0;
}
td.move button:hover { opacity: 1; transform: scale(1.12); }
td.move button.active { opacity: 1; box-shadow: 0 0 0 1.5px rgba(0,0,0,.25) inset; }
td.move button.r { background: var(--red); } td.move button.o { background: var(--orange); } td.move button.g { background: var(--green); }
.moves-note {
  font-size: 12.5px; color: var(--ink-soft); margin: 2px 0 0; display: flex; align-items: center; gap: 10px;
}
.moves-note button {
  font-family: var(--font-text); font-size: 12px; font-weight: 600; color: var(--spruce-700);
  background: #fff; border: 1px solid var(--line); border-radius: 7px; padding: 4px 10px; cursor: pointer;
}
.moves-note button:hover { border-color: var(--spruce-600); }

@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.sheet { animation: rise .45s ease both; }
.sheet:nth-child(2) { animation-delay: .07s; }
.sheet:nth-child(3) { animation-delay: .14s; }

footer.foot { text-align: center; color: var(--ink-soft); font-size: 12.5px; padding: 30px 0 10px; }

/* ---- Print: one landscape page per sheet -------------------------------- */
@media print {
  @page { size: A4 landscape; margin: 9mm; }
  body { background: #fff; }
  .topbar, .wrap > .panel, .toolbar, .summary, .foot, .no-print { display: none !important; }
  .wrap { padding: 0; max-width: none; }
  .sheets { margin: 0; gap: 0; display: block; }
  .sheet { box-shadow: none; border: none; border-radius: 0; page-break-after: always; animation: none; }
  .sheet:last-child { page-break-after: auto; }
  table.grid { font-size: 9pt; }
  table.grid thead th { font-size: 7.5pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .sheet-title, tfoot td.tot, td.label, thead th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* When printing a single colour, hide the others. */
  body[data-print="red"] .sheet:not(.red),
  body[data-print="orange"] .sheet:not(.orange),
  body[data-print="green"] .sheet:not(.green) { display: none !important; }
}

/* ---- Automatic generation (local bridge) -------------------------------- */
.auto-panel { margin-bottom: 18px; border-left: 4px solid var(--line); transition: border-color .2s; }
.auto-panel[data-state="online"] , .auto-panel[data-state="done"]     { border-left-color: var(--green); }
.auto-panel[data-state="working"], .auto-panel[data-state="checking"] { border-left-color: var(--orange); }
.auto-panel[data-state="offline"]                                     { border-left-color: var(--line); }
.auto-panel[data-state="error"]                                       { border-left-color: var(--red); }

.auto-head { display: flex; align-items: flex-start; gap: 12px; }
.auto-dot {
  width: 12px; height: 12px; border-radius: 50%; margin-top: 4px; flex: none;
  background: var(--ink-soft); box-shadow: 0 0 0 4px var(--line-soft);
}
.auto-panel[data-state="online"] .auto-dot, .auto-panel[data-state="done"] .auto-dot {
  background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); animation: autopulse 2.2s infinite;
}
.auto-panel[data-state="working"] .auto-dot, .auto-panel[data-state="checking"] .auto-dot {
  background: var(--orange); box-shadow: 0 0 0 4px var(--orange-soft); animation: autopulse 1s infinite;
}
.auto-panel[data-state="error"] .auto-dot { background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
@keyframes autopulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

.auto-text { display: flex; flex-direction: column; gap: 2px; }
.auto-text strong { font-family: var(--font-display); font-size: 16px; letter-spacing: -.1px; }
.auto-sub { font-size: 13px; color: var(--ink-soft); max-width: 70ch; }
.auto-run { margin-top: 16px; display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.auto-run .field select { min-width: 200px; }
.auto-status { font-size: 13px; color: var(--ink-soft); align-self: center; }
.auto-panel[data-state="offline"] .auto-run, .auto-panel[data-state="checking"] .auto-run { opacity: .5; }
