:root {
  /* Brand colors, sampled directly from the logo file. */
  --brand-red: #ec1946;
  --brand-blue: #2d3b97;

  --bg: #f7f7f5;
  --panel: #ffffff;
  --text: #0a0a0a;           /* always black in light mode, per brand request */
  --muted: #5a5a5a;
  --border: #e0ddd6;
  --accent: var(--brand-blue);
  --accent-text: #ffffff;
  --highlight: var(--brand-red);
  --highlight-text: #ffffff;
  --error: #b3261e;
  --success: #1e7a34;

  /* The nav bar is intentionally NOT theme-switched -- it stays light so the
     logo's actual brand colors (red/blue) render correctly. Inverting a
     colorful logo for dark mode would turn the red/blue into wrong colors. */
  --nav-bg: #ffffff;
  --nav-border: #e0ddd6;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17140f;
    --panel: #221e17;
    --text: #f0ece3;         /* stays light in dark mode -- black text on a dark
                                 background would be unreadable */
    --muted: #a89f8f;
    --border: #3a342a;
    --accent: #6f86e0;        /* lighter blue for contrast on a dark background */
    --accent-text: #0a0a0a;
    --highlight: #ff5d7a;     /* lighter red for contrast on a dark background */
    --highlight-text: #0a0a0a;
    --error: #ff8a80;
    --success: #6fcf8a;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

h1 { font-size: 1.5rem; margin-bottom: 12px; }
h2 { font-size: 1.15rem; margin-top: 28px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topnav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 20px;
  background: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
}

.brand { font-weight: 600; display: flex; align-items: center; gap: 12px; }
.brand-logo { height: 70px; width: auto; display: block; }
.brand-name {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  border-left: 2px solid var(--nav-border);
  padding-left: 12px;
}
.brand-title {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: linear-gradient(100deg, var(--brand-red), var(--brand-blue));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-subtitle {
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav-links { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.nav-links a { color: var(--brand-blue); }
.nav-links a:hover { color: var(--brand-red); }
.whoami { color: #5a5a5a; font-size: 0.78rem; font-style: italic; white-space: nowrap; }

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--nav-border);
  border-radius: 6px;
  font-size: 1.3rem;
  line-height: 1;
  padding: 4px 10px;
  cursor: pointer;
  color: var(--brand-blue);
}

.nav-dropdown { position: relative; }
.nav-dropdown-toggle {
  background: none;
  border: none;
  font: inherit;
  color: var(--brand-blue);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav-dropdown-toggle:hover { color: var(--brand-red); }
.nav-dropdown-toggle::after { content: "\25BE"; font-size: 0.7em; }
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 160px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  padding: 6px;
  flex-direction: column;
  z-index: 20;
}
.nav-dropdown-menu a { padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
.nav-dropdown-menu a:hover { background: var(--bg); text-decoration: none; }
.nav-menu-group { padding: 8px 10px 2px; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); border-top: 1px solid var(--border); margin-top: 4px; }
.nav-dropdown.open .nav-dropdown-menu { display: flex; }

.session-widget-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 20px;
  background: #fff7e0;
  border-bottom: 1px solid var(--nav-border);
  flex-wrap: wrap;
}
.session-widget-bar.session-widget-paused { background: #f0f0f0; }
.session-widget-label { font-size: 0.85rem; }
.session-widget-label strong { color: var(--brand-red); }
.session-inline-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.session-inline-form input[type="text"] {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}
.session-widget-actions { display: flex; gap: 6px; }
.session-widget-actions button {
  font-size: 0.78rem;
  padding: 3px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}
.session-widget-actions button:hover { border-color: var(--brand-blue); color: var(--brand-blue); }
.session-widget-actions button.session-stop-btn:hover { border-color: var(--brand-red); color: var(--brand-red); }

@media (max-width: 800px) {
  .nav-toggle { display: inline-block; }
  .nav-links {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .topnav.nav-open .nav-links { display: flex; }
  .nav-dropdown { width: 100%; }
  .nav-dropdown-menu {
    position: static;
    box-shadow: none;
    border: none;
    padding: 0 0 0 14px;
    width: 100%;
  }
  .nav-dropdown.open .nav-dropdown-menu { display: flex; }
}

.login-page { position: relative; }

.login-bg-video {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -2;
}

.login-bg-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: -1;
}

.login-box {
  position: relative;
  max-width: 340px;
  margin: 10vh auto 0;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}

form.stacked-form, form.login-box form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

form.contact-form { max-width: 420px; }

.endorsement-tag-list {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
}
.endorsement-tag-list legend { padding: 0 6px; color: var(--muted); font-size: 0.85rem; }
.checkbox-label { flex-direction: row !important; align-items: center; gap: 6px; font-weight: normal; }

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9rem;
  color: var(--muted);
}

input, select, button {
  font-size: 1rem;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
}

button {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  cursor: pointer;
  padding: 9px 16px;
}

button:hover { opacity: 0.9; }

.link-button {
  background: none;
  color: var(--accent);
  border: none;
  padding: 0;
  font-size: 0.9rem;
  text-decoration: underline;
  cursor: pointer;
}
.link-button:hover { opacity: 1; color: var(--highlight); }

.error { color: var(--error); }
.success { color: var(--success); }
.muted { color: var(--muted); font-size: 0.9rem; }

.summary-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.stat {
  display: flex;
  flex-direction: column;
  padding: 12px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: 3px solid var(--brand-blue);
  border-radius: 8px;
  min-width: 130px;
}

.stat-value { font-size: 1.4rem; font-weight: 600; }
.stat-label { font-size: 0.8rem; color: var(--muted); }

.search-form { display: flex; gap: 8px; margin-bottom: 16px; }
.search-form input { flex: 1; }

.locations-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.chip {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  font-size: 0.85rem;
}

.report-links { display: flex; flex-wrap: wrap; gap: 16px; }
.report-card {
  display: block;
  width: 220px;
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: 3px solid var(--brand-red);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
}
.report-card:hover { border-top-color: var(--brand-blue); }
.report-card h2 { margin: 0 0 6px; font-size: 1.05rem; }
.report-card p { margin: 0; font-size: 0.85rem; color: var(--muted); }

.preset-links { display: flex; gap: 6px; margin: 8px 0 16px; flex-wrap: wrap; }
.preset-links a {
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
  text-decoration: none;
}
.preset-links a.active { background: var(--brand-blue); color: #fff; border-color: var(--brand-blue); }

.bulk-actions-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 10px 14px;
  margin-bottom: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.bulk-actions-bar .bulk-form { gap: 6px; }
#bulk-selected-count { font-size: 0.85rem; }

.aging-export-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

#cam-preview {
  width: 100%;
  max-width: 420px;
  border-radius: 8px;
  background: #000;
  display: block;
  margin-bottom: 14px;
}
.attendance-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.attendance-btn {
  padding: 10px 16px;
  font-size: 1rem;
  background: var(--brand-blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
.attendance-btn:hover { opacity: 0.9; }
.attendance-btn:disabled { opacity: 0.5; cursor: default; }

.help-layout { display: flex; gap: 28px; align-items: flex-start; }
.help-sidebar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 160px;
  position: sticky;
  top: 16px;
}
.help-sidebar a {
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.9rem;
  text-decoration: none;
}
.help-sidebar a.active { background: var(--brand-blue); color: #fff; }
.help-content { flex: 1; min-width: 0; }
.help-content h2 { margin-top: 24px; }
@media (max-width: 700px) {
  .help-layout { flex-direction: column; }
  .help-sidebar { flex-direction: row; flex-wrap: wrap; position: static; }
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.photo-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.photo-card img { width: 100%; display: block; aspect-ratio: 4 / 3; object-fit: cover; }
.photo-select {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  width: 18px;
  height: 18px;
}
.photo-caption form { margin-top: 4px; }
.photo-missing {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.85rem;
}
.photo-caption { padding: 8px 10px; font-size: 0.85rem; margin: 0; }
.event-thumb { width: 60px; height: 45px; object-fit: cover; border-radius: 4px; display: block; }

.stamp-link {
  display: flex;
  align-items: center;
  gap: 6px;
  color: inherit;
}
.stamp-link:hover { text-decoration: none; }
.stamp-link .event-thumb { width: 40px; height: 30px; }
.stamp-link span { text-decoration: underline; }
.stamp-link:hover span { color: var(--brand-red); }

.dev-changelog-entry {
  padding: 14px 18px;
  margin-bottom: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand-red);
  border-radius: 8px;
}
.dev-changelog-entry h2 { margin: 0 0 4px; font-size: 1.05rem; }
.dev-changelog-summary { white-space: pre-line; margin-top: 8px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin-top: 8px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
th { color: var(--muted); font-weight: 500; }

.foil-tag {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--brand-blue);
  color: #ffffff;
}

.treatment-tag {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--brand-red);
  color: var(--brand-red);
}

th a { color: var(--muted); }
th a:hover { color: var(--brand-red); }

.qty-form, .inline-form, .transfer-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.qty-form > *, .inline-form > *, .transfer-form > * { flex-shrink: 0; }
.qty-form input[type="number"] { width: 64px; }
.transfer-form { min-width: 340px; }
.transfer-form input[name="destination"] { width: 160px; }
.transfer-form input[name="quantity"] { width: 56px; }
.transfer-form input[name="new_listing_price"] { width: 100px; }

.qty-form.flash-ok input, .sell-form.flash-ok button, .transfer-form.flash-ok input {
  outline: 2px solid var(--success);
}
.qty-form.flash-err input, .sell-form.flash-err button, .transfer-form.flash-err input {
  outline: 2px solid var(--error);
}

.toast-stack {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 320px;
}
.toast {
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 4px solid var(--success);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  font-size: 0.9rem;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.toast-in { opacity: 1; transform: translateY(0); }
.toast.toast-out { opacity: 0; transform: translateY(8px); }

.sell-actions { display: flex; flex-direction: column; gap: 4px; min-width: 200px; }
.sell-buttons { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.sell-buttons input[type="number"] { width: 60px; flex-shrink: 0; }
.sell-form button { padding: 6px 10px; font-size: 0.85rem; background: var(--highlight); color: var(--highlight-text); flex-shrink: 0; }
.sell-form button:disabled, .sell-form input:disabled { opacity: 0.35; cursor: not-allowed; }

.sale-details { font-size: 0.85rem; color: var(--muted); }
.sale-details summary { cursor: pointer; color: var(--accent); }
.sale-details input, .sale-details select {
  display: block;
  margin-top: 4px;
  font-size: 0.85rem;
  padding: 5px 8px;
  width: 200px;
}

/* Transfer column: hidden by default (not a daily action), revealed by the
   "Show transfer options" toggle -- see app.js. */
.transfer-col { display: none; }
table.show-transfer .transfer-col { display: table-cell; }

.schedule-table th, .schedule-table td { white-space: nowrap; }
.schedule-table input[type="text"] { width: 130px; }
.schedule-table-wrap {
  max-height: 70vh;
  overflow-y: auto;
}
.schedule-table tr:first-child th {
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 5;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}
.schedule-table td:first-child, .schedule-table th:first-child {
  position: sticky;
  left: 0;
  background: var(--panel);
  z-index: 4;
}
.schedule-table th:first-child { z-index: 6; }
.schedule-table .schedule-group-row td { position: static; }
.schedule-group-row td {
  background: var(--panel);
  color: var(--muted);
  padding-top: 12px;
  border-bottom: 1px solid var(--border);
}
.roster-remove { font-size: 0.75rem; color: var(--muted); background: none; padding: 0; margin-left: 4px; }
.roster-remove:hover { color: var(--brand-red); }

.result-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 20px;
}

.calc-grid { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.calc-grid .result-box { flex: 1; min-width: 300px; }
.calc-grid label { margin-bottom: 12px; }
.calc-grid input[type="number"] { width: 100%; box-sizing: border-box; }
.calc-grid table td { padding: 6px 10px; vertical-align: top; }
.calc-grid table td:last-child { text-align: right; font-family: monospace; font-size: 1rem; white-space: nowrap; }

.quick-sale-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
.quick-sale-tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.quick-sale-name { font-weight: bold; }
.quick-sale-category { font-size: 0.78rem; }
.quick-sale-price { font-size: 1.2rem; }
.quick-sale-qty { font-size: 0.85rem; }
.quick-sale-form .sell-buttons { justify-content: center; }
.quick-sale-form input[type="number"] { width: 52px; }
.quick-sale-button {
  padding: 14px 10px;
  font-size: 1.05rem;
  font-weight: bold;
  background: var(--highlight);
  color: var(--highlight-text);
  border-radius: 8px;
  width: 100%;
}
.calc-grid .formula { font-size: 0.78rem; font-weight: normal; margin-top: 2px; }

.merch-photo { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; display: block; }
.merch-photo-add { color: var(--accent); font-size: 0.8rem; cursor: pointer; white-space: nowrap; }
.merch-photo-add:hover { text-decoration: underline; }
.quick-sale-photo { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; margin: 0 auto; }

.quick-action-buttons { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.quick-action-link {
  display: inline-block;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  font-weight: bold;
}
.quick-action-link:hover { background: var(--bg); text-decoration: none; }

.photo-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  cursor: zoom-out;
}
.photo-overlay img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 8px;
  background: #fff;
}
img.zoomable { cursor: zoom-in; }
