/* Six Nations Fall Fair Exhibits System — forest green theme, tablet-first, accessible */
:root {
  --green-900: #1b2e1a;
  --green-800: #24401f;
  --green-700: #2f5427;
  --green-600: #3c6b31;
  --green-500: #4c843e;
  --green-100: #e3edda;
  --green-50: #f2f7ec;
  --cream: #fdfcf7;
  --ink: #1d241b;
  --muted: #5a6655;
  --line: #cfd8c6;
  --red: #b3261e;
  --red-bg: #fdeceb;
  --amber: #8a5a00;
  --amber-bg: #fff4d6;
  --blue: #1757a5;
  --blue-bg: #e7f0fb;
  --gold: #8a6d00;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(27, 46, 26, .12), 0 4px 14px rgba(27, 46, 26, .07);
  --font-scale: 1;
}

* { box-sizing: border-box; }

html { font-size: calc(16px * var(--font-scale)); }
html.large-text { --font-scale: 1.25; }
html.large-text body { font-weight: 500; }
html.large-text h1, html.large-text h2, html.large-text h3 { font-weight: 800; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--green-50);
  color: var(--ink);
  line-height: 1.45;
}

/* High contrast mode */
html.high-contrast {
  --green-900: #000; --green-800: #062b00; --green-700: #0a4d00; --green-600: #0a5c00;
  --green-500: #0a6e00; --green-100: #e8ffe0; --green-50: #ffffff; --cream: #ffffff;
  --ink: #000; --muted: #222; --line: #000; --red: #a00000; --red-bg: #ffe0e0;
  --amber: #6b4500; --amber-bg: #fff0b3; --blue: #003d99; --blue-bg: #d6e8ff;
}
html.high-contrast .card, html.high-contrast table, html.high-contrast input,
html.high-contrast select, html.high-contrast textarea, html.high-contrast .btn {
  border-width: 2px;
}

/* Reduced motion */
html.reduce-motion *, html.reduce-motion *::before, html.reduce-motion *::after {
  animation-duration: 0.001s !important;
  transition-duration: 0.001s !important;
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
}

.skip-link {
  position: absolute; left: -9999px; top: 0; background: var(--green-800); color: #fff;
  padding: .6rem 1rem; z-index: 200; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 4px; }

a { color: var(--green-700); }
h1 { font-size: 1.5rem; margin: .2rem 0 .6rem; }
h2 { font-size: 1.2rem; margin: 1rem 0 .5rem; }
h3 { font-size: 1.05rem; margin: .8rem 0 .4rem; }

/* ---------- Header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 60;
  background: linear-gradient(180deg, var(--green-800), var(--green-900));
  color: #fff;
  box-shadow: var(--shadow);
}
.bunting {
  height: 10px;
  background:
    linear-gradient(135deg, transparent 8px, #c0392b 0) 0 0/20px 10px repeat-x,
    linear-gradient(45deg, transparent 8px, #e8b93c 0) 10px 0/20px 10px repeat-x,
    linear-gradient(135deg, transparent 8px, #4c843e 0) 0 0/20px 10px repeat-x;
  opacity: .9;
}
.topbar-main {
  display: flex; align-items: center; gap: .8rem; flex-wrap: wrap;
  padding: .55rem 1rem;
  max-width: 1200px; margin: 0 auto;
}
.topbar .logos { display: flex; align-items: center; gap: .6rem; }
.topbar .logos img { height: 44px; width: auto; background: #fff; border-radius: 6px; padding: 2px; }
.topbar .site-title { font-weight: 700; font-size: 1.05rem; line-height: 1.15; }
.topbar .site-sub { font-size: .8rem; opacity: .85; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: .9rem; text-align: right; }
.topbar .who .role { opacity: .8; font-size: .78rem; }

.topbar .search-wrap { position: relative; flex: 1 1 220px; max-width: 380px; }
.topbar .search-wrap input {
  width: 100%; padding: .5rem .7rem .5rem 2rem; border-radius: 999px; border: 2px solid transparent;
  font-size: .95rem;
}
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: #fff; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  max-height: 60vh; overflow: auto; z-index: 70; padding: .4rem;
}
.search-results h4 { margin: .4rem .4rem .2rem; font-size: .75rem; text-transform: uppercase; color: var(--muted); }
.search-results button {
  display: block; width: 100%; text-align: left; background: none; border: 0; padding: .5rem .6rem;
  border-radius: 6px; cursor: pointer; font-size: .95rem; min-height: 44px;
}
.search-results button:hover, .search-results button.active { background: var(--green-100); }

.topbar button.icon-btn, .topbar a.icon-btn {
  background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.35);
  border-radius: 8px; min-width: 44px; min-height: 44px; padding: .35rem .6rem; cursor: pointer;
  font-size: .9rem; text-decoration: none; display: inline-flex; align-items: center; gap: .35rem;
}
.topbar button.icon-btn:hover { background: rgba(255,255,255,.25); }

/* Collapsed slim strip */
.topbar.collapsed .topbar-main { padding: .25rem 1rem; }
.topbar.collapsed .logos img { height: 26px; }
.topbar.collapsed .site-sub, .topbar.collapsed .bunting, .topbar.collapsed .search-wrap { display: none; }
.topbar.collapsed .site-title { font-size: .9rem; }

/* Nav */
.mainnav { background: var(--green-700); }
.mainnav-inner { max-width: 1200px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: .2rem; padding: .3rem .6rem; }
.mainnav a, .mainnav button {
  color: #fff; text-decoration: none; padding: .55rem .8rem; border-radius: 8px; font-size: .95rem;
  background: none; border: 0; cursor: pointer; min-height: 44px; display: inline-flex; align-items: center;
}
.mainnav a:hover, .mainnav button:hover { background: rgba(255,255,255,.15); }
.mainnav a.active { background: #fff; color: var(--green-800); font-weight: 700; }
.mainnav .badge { background: #c0392b; color: #fff; border-radius: 999px; padding: 0 .45rem; font-size: .75rem; margin-left: .35rem; }

/* Admin sidebar */
.layout { display: flex; max-width: 1200px; margin: 0 auto; align-items: flex-start; }
.sidebar {
  width: 230px; flex: 0 0 230px; padding: .8rem .6rem; position: sticky; top: 118px;
  max-height: calc(100vh - 130px); overflow: auto;
}
.sidebar h4 { margin: .7rem .4rem .25rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sidebar a {
  display: flex; align-items: center; gap: .4rem; padding: .55rem .6rem; border-radius: 8px;
  color: var(--ink); text-decoration: none; min-height: 44px;
}
.sidebar a:hover { background: var(--green-100); }
.sidebar a.active { background: var(--green-700); color: #fff; font-weight: 700; }
.sidebar .badge { background: #c0392b; color: #fff; border-radius: 999px; padding: 0 .45rem; font-size: .75rem; margin-left: auto; }
.sidebar .archive-btn { background: var(--amber-bg); border: 1px solid var(--amber); }
.content { flex: 1; min-width: 0; padding: .8rem 1rem 3rem; }
@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .sidebar { position: static; width: 100%; flex: none; max-height: none; }
}

/* ---------- Components ---------- */
.card {
  background: var(--cream); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem;
}
.card h2:first-child, .card h3:first-child { margin-top: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  background: var(--green-700); color: #fff; border: 2px solid var(--green-800);
  border-radius: 8px; padding: .55rem 1rem; font-size: 1rem; cursor: pointer; min-height: 44px;
  text-decoration: none; font-weight: 600;
}
.btn:hover { background: var(--green-600); }
.btn.secondary { background: #fff; color: var(--green-800); border-color: var(--green-600); }
.btn.secondary:hover { background: var(--green-100); }
.btn.danger { background: var(--red); border-color: #7c1611; }
.btn.small { padding: .35rem .7rem; font-size: .9rem; min-height: 44px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.calm { background: #fff; color: var(--green-800); border-color: var(--green-500); }

label { display: block; font-weight: 600; margin: .6rem 0 .25rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"],
input[type="datetime-local"], select, textarea {
  width: 100%; padding: .6rem .7rem; border: 2px solid var(--line); border-radius: 8px;
  font-size: 1rem; background: #fff; color: var(--ink); min-height: 44px;
}
textarea { min-height: 90px; }
input:focus, select:focus, textarea:focus { border-color: var(--green-600); outline: 3px solid rgba(23,87,165,.35); outline-offset: 1px; }
.field-row { display: flex; gap: .7rem; flex-wrap: wrap; }
.field-row > * { flex: 1 1 180px; }
.hint { font-size: .85rem; color: var(--muted); margin-top: .2rem; }
.error-text { color: var(--red); font-weight: 600; margin: .4rem 0; }
.success-text { color: var(--green-700); font-weight: 600; margin: .4rem 0; }

table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { border: 1px solid var(--line); padding: .45rem .55rem; text-align: left; vertical-align: top; }
th { background: var(--green-100); font-size: .88rem; }
tr:nth-child(even) td { background: #fafcf6; }
.table-wrap { overflow-x: auto; border-radius: 8px; border: 1px solid var(--line); }
.table-wrap table { border: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.flag { border-radius: 8px; padding: .55rem .7rem; margin: .4rem 0; border: 1px solid; }
.flag.red { background: var(--red-bg); border-color: var(--red); color: #6d0f0b; }
.flag.amber { background: var(--amber-bg); border-color: var(--amber); color: #5c3d00; }
.flag.blue { background: var(--blue-bg); border-color: var(--blue); color: #0c3a6e; }
.flag.green { background: var(--green-100); border-color: var(--green-600); color: var(--green-900); }
html.high-contrast .flag { color: #000; }

.chip {
  display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .82rem; font-weight: 700;
  border: 1.5px solid; white-space: nowrap;
}
.chip.p1 { background: #f7e08b; border-color: #8a6d00; color: #4d3d00; }
.chip.p2 { background: #e6e9ec; border-color: #5f6b73; color: #2e363c; }
.chip.p3 { background: #f3d2ae; border-color: #8a5a2b; color: #4d2f12; }
.chip.status-not-started { background: #eee; border-color: #888; color: #333; }
.chip.status-progress { background: var(--amber-bg); border-color: var(--amber); color: #5c3d00; }
.chip.status-complete { background: var(--green-100); border-color: var(--green-600); color: var(--green-900); }
.chip.claimed { background: var(--green-100); border-color: var(--green-600); color: var(--green-900); }
.chip.unclaimed { background: #eee; border-color: #888; color: #333; }
html.high-contrast .chip { color: #000; }

.today-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .7rem; margin-bottom: 1rem; }
.today-strip .stat { background: var(--cream); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; box-shadow: var(--shadow); }
.today-strip .stat .n { font-size: 1.6rem; font-weight: 800; color: var(--green-800); }
.today-strip .stat .l { font-size: .85rem; color: var(--muted); }

.empty-state { text-align: center; padding: 1.6rem 1rem; color: var(--muted); }
.empty-state .big { font-size: 1.15rem; color: var(--ink); font-weight: 700; margin-bottom: .3rem; }

/* Login */
.login-wrap { max-width: 520px; margin: 1.2rem auto; padding: 0 1rem; }
.login-tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: .8rem; }
.login-tabs button {
  flex: 1 1 100px; padding: .7rem .4rem; border-radius: 8px; border: 2px solid var(--green-600);
  background: #fff; color: var(--green-800); font-weight: 700; cursor: pointer; min-height: 48px; font-size: 1rem;
}
.login-tabs button.active { background: var(--green-700); color: #fff; }
.pin-display {
  font-size: 1.8rem; letter-spacing: .4rem; text-align: center; padding: .6rem; border: 2px solid var(--line);
  border-radius: 8px; background: #fff; min-height: 3.2rem; margin: .5rem 0;
}
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; max-width: 320px; margin: .6rem auto; }
.pin-pad button {
  font-size: 1.5rem; padding: .8rem 0; border-radius: 10px; border: 2px solid var(--green-600);
  background: #fff; cursor: pointer; min-height: 60px; font-weight: 700; color: var(--green-900);
}
.pin-pad button:active { background: var(--green-100); }
.pin-pad button.utility { font-size: 1rem; background: var(--green-50); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 30, 18, .55); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal {
  background: #fff; border-radius: 12px; max-width: 640px; width: 100%; max-height: 90vh; overflow: auto;
  padding: 1.2rem; box-shadow: 0 10px 40px rgba(0,0,0,.3);
}
.modal h2 { margin-top: 0; }
.privacy-scroll { border: 1px solid var(--line); border-radius: 8px; padding: .8rem; max-height: 40vh; overflow: auto; background: var(--green-50); }

/* Save-all bar */
.savebar {
  position: sticky; bottom: 0; z-index: 55; background: var(--amber-bg); border-top: 2px solid var(--amber);
  padding: .55rem 1rem; display: flex; align-items: center; gap: .7rem; flex-wrap: wrap;
}
.savebar .msg { font-weight: 700; color: #5c3d00; }

/* Toasts */
#toast-root { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 150; width: min(92vw, 520px); }
.toast {
  background: var(--green-900); color: #fff; border-radius: 10px; padding: .7rem 1rem; margin-top: .5rem;
  display: flex; gap: .7rem; align-items: center; box-shadow: var(--shadow);
}
.toast button { background: #fff; color: var(--green-900); border: 0; border-radius: 6px; padding: .35rem .8rem; font-weight: 700; cursor: pointer; min-height: 40px; }

/* Signature pad */
.sig-pad { border: 2px dashed var(--green-600); border-radius: 8px; background: #fff; width: 100%; height: 180px; touch-action: none; }

/* Judging */
.judge-row { display: grid; grid-template-columns: 1fr; gap: .4rem; padding: .6rem; border: 1px solid var(--line); border-radius: 8px; margin-bottom: .5rem; background: #fff; }
.judge-row .sec-head { font-weight: 700; }
.judge-row .sec-desc { color: var(--muted); font-size: .9rem; }
.place-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
@media (max-width: 640px) { .place-grid { grid-template-columns: 1fr; } }
.place-grid label { margin-top: .2rem; }
.range-head { background: var(--green-800); color: #fff; padding: .5rem .8rem; border-radius: 8px; margin: 1rem 0 .5rem; font-weight: 700; }
.review-panel { border-top: 3px solid var(--green-700); padding-top: .8rem; margin-top: 1rem; }

/* Tags */
.tag-row { display: flex; align-items: center; gap: .7rem; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 8px; margin-bottom: .35rem; background: #fff; min-height: 48px; }
.tag-row input[type="checkbox"] { width: 26px; height: 26px; flex: 0 0 26px; }
.tag-batch-head { position: sticky; top: 118px; background: var(--cream); padding: .5rem 0; z-index: 5; border-bottom: 2px solid var(--green-600); }

/* Footer */
footer.site-footer {
  background: var(--green-900); color: #e8f0e0; padding: 1rem; margin-top: 2rem; font-size: .85rem;
}
footer.site-footer .inner { max-width: 1200px; margin: 0 auto; display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; }
footer.site-footer img { height: 36px; background: #fff; border-radius: 5px; padding: 2px; }
footer.site-footer button { color: #fff; background: none; border: 1px solid rgba(255,255,255,.4); border-radius: 6px; padding: .4rem .7rem; cursor: pointer; min-height: 40px; }

/* Sync indicator */
.sync-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .3rem; }
.sync-dot.ok { background: #2e7d32; }
.sync-dot.pending { background: #e8a33d; }
.sync-dot.offline { background: #b3261e; }

/* Voice button */
.mic-btn { flex: 0 0 auto; }

/* Print */
.print-only { display: none; }
@media print {
  .topbar, .mainnav, .sidebar, footer.site-footer, .savebar, #toast-root, .no-print { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 0; }
  .print-only { display: block; }
  .receipt-print { font-size: 11pt; }
  .sig-line { border-bottom: 1.5px solid #000; height: 3.2rem; margin-top: 2rem; }
  .dispute-banner { border: 2px solid #000; padding: .6rem; margin-top: 1rem; }
}
