:root {
  /* Legacy names used by the older screens, mapped onto the design tokens (tokens.css). */
  --bg: var(--canvas);
  --text: var(--ink);
  --muted: var(--ink-muted);
  --border: var(--line);
  --link: var(--accent-text);
  --error: var(--danger);
  --radius: var(--radius-md);
  --ok: var(--confirmed);
  --warn-bg: var(--accent-soft);
  --warn-text: var(--ink);
  --gig-offered: var(--offered);
  --gig-negotiating: var(--negotiating);
  --gig-confirmed: var(--confirmed);
  --gig-played: var(--played);
  --gig-declined: var(--declined);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

h1, h2 { line-height: 1.2; }
h1, h2 {
  font-family: var(--font-display);
  font-weight: 800;
  font-stretch: 112%;
  letter-spacing: -0.03em;
}

.brand { font-weight: 700; line-height: 0; }
.brand-logo { height: 28px; width: auto; display: inline-block; vertical-align: middle; }
.auth .brand-logo { height: 40px; }

.muted { color: var(--muted); }

.error { color: var(--error); margin: 0; font-size: 0.9rem; }

.small { font-size: 0.85rem; }

a { color: var(--link); }

h3 { margin: 28px 0 10px; font-size: 1.05rem; }
h4 { margin: 18px 0 8px; font-size: 0.95rem; }
form > h4:first-child { margin-top: 0; }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.row.wrap { flex-wrap: wrap; }
.row.wrap > * { flex: 0 0 auto; }

.ok { color: var(--ok); margin: 0; }
.warn {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--warn-bg);
  color: var(--warn-text);
}

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-head + * { margin-top: 0; }


.stack { display: flex; flex-direction: column; gap: 12px; }
.stack p { margin: 0; }

.narrow { max-width: 420px; }

.banner {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #fdf0d5;
  color: #5c3300;
}

button { font: inherit; cursor: pointer; }

button.primary,
.button.primary {
  width: 100%;
  min-height: var(--size-tap);
  padding: 10px 16px;
  border: 0;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--on-ink);
  font-weight: 600;
}
button.primary.compact,
.button.primary.compact { width: auto; padding: 8px 14px; }
button.primary:disabled { opacity: 0.6; cursor: default; }

button.secondary,
.button.secondary {
  align-self: flex-start;
  min-height: var(--size-tap);
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

a.button {
  display: inline-block;
  text-align: center;
  text-decoration: none;
}

button.primary.danger-bg { background: var(--error); }

button.danger {
  min-height: var(--size-tap);
  padding: 8px 14px;
  border: 1px solid var(--error);
  border-radius: 8px;
  background: var(--surface);
  color: var(--error);
}

.danger-text { color: var(--error) !important; }

button.link {
  border: 0;
  background: none;
  color: var(--link);
  padding: 4px 0;
}

/* ---- Auth ---- */

.auth {
  max-width: 400px;
  margin: 0 auto;
  padding: 48px 16px;
}
.auth h1 { text-align: center; margin: 0 0 24px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
}

.tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.tab {
  flex: 1;
  padding: 10px;
  border: 0;
  border-bottom: 2px solid var(--border);
  background: none;
  color: var(--muted);
}
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

form { display: flex; flex-direction: column; gap: 14px; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; font-weight: 500; }

input, select, textarea {
  font: inherit;
  font-size: 16px; /* prevents iOS zoom on focus */
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
input, select, textarea { min-height: var(--size-tap); border-color: var(--line-strong); }
#user-name {
  color: var(--text);
  text-decoration: none;
  max-width: 40vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav {
  display: flex;
  overflow-x: auto;
  gap: 4px;
  padding: 0 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  flex: 0 0 auto;
  padding: 12px 10px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.nav a.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.content { padding: 16px; max-width: 960px; margin: 0 auto; }

/* ---- Lists ---- */

.list { list-style: none; margin: 0; padding: 0; }
.list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top-width: 0;
}
.list-item:first-child { border-top-width: 1px; border-radius: var(--radius) var(--radius) 0 0; }
.list-item:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.list-item:only-child { border-radius: var(--radius); }
.list-item select { padding: 6px 8px; }
.grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.badge {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  white-space: nowrap;
}
.badge.role-leader { background: #fdf0d5; border-color: #f1d9a3; }

/* ---- Segmented controls & attendance ---- */

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
  margin-bottom: 12px;
}
.seg {
  padding: 8px 14px;
  border: 0;
  border-left: 1px solid var(--border);
  background: none;
  color: var(--text);
}
.seg:first-child { border-left: 0; }
.seg.active { background: var(--accent); color: var(--on-accent); }
.seg.att-yes.active { background: var(--ok); }
.seg.att-maybe.active { background: var(--gig-negotiating); color: var(--on-accent); }
.seg.att-no.active { background: var(--error); }
.rehearsal .segmented { margin: 4px 0 0; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--border); }
.dot.att-yes { background: var(--ok); }
.dot.att-maybe { background: var(--gig-negotiating); }
.dot.att-no { background: var(--error); }

details.attendance { font-size: 0.9rem; color: var(--muted); }
details.attendance summary { cursor: pointer; padding: 4px 0; }
details.attendance ul { list-style: none; margin: 4px 0 0; padding: 0; color: var(--text); }
details.attendance li { padding: 2px 0; }

.rehearsal { display: flex; flex-direction: column; gap: 10px; }
.notes { margin: 0; white-space: pre-wrap; }

textarea { resize: vertical; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: line-through;
}
.chip.on { color: var(--text); text-decoration: none; border-color: #c9c9d3; }
.chip:not(.on) .swatch { opacity: 0.3; }
/* On phones events are small dots; labels appear on wider screens. */
.ev { width: 8px; height: 8px; border-radius: 50%; }
.ev.reh { border-radius: 2px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 0 4px; color: var(--muted); }
.legend > span { display: inline-flex; align-items: center; gap: 5px; }

/* ---- Gigs ---- */

.segmented.scroll { display: flex; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.segmented.scroll::-webkit-scrollbar { display: none; }
.segmented.scroll .seg { flex: 0 0 auto; white-space: nowrap; }
.seg .count {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
}
.seg.active .count { background: rgba(255, 255, 255, 0.25); color: inherit; }

.back { display: inline-block; margin-bottom: 6px; text-decoration: none; }
.status-line { margin-bottom: 8px; }

.details {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 16px;
  margin: 16px 0 0;
}
.details dt { color: var(--muted); font-size: 0.9rem; }
.details dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.inline-form { margin-top: 10px; gap: 8px; }

fieldset { margin: 0; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
legend { padding: 0 4px; font-weight: 600; }
.row > .narrow-field { flex: 0 0 90px; }

ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li + li { margin-top: 2px; }

/* ---- Contacts ---- */

.search-bar { margin-bottom: 10px; }
.search-bar input { width: 100%; }

.row-link { color: var(--text); text-decoration: none; }
.row-link:hover .contact-name { text-decoration: underline; }
.contact-name { font-weight: 600; }
.badge.type-venue { background: #e8f1fb; border-color: #c8dcf3; }
.badge.type-promoter { background: #fdf0e1; border-color: #f3d9b8; }
.badge.type-agent { background: #ecebfb; border-color: #cfcbf5; }

.due { color: var(--muted); }
.due.overdue, .overdue-title { color: var(--error); }

.followup { align-items: flex-start; }
.followup input[type='checkbox'] { width: 20px; height: 20px; margin: 2px 0 0; flex: 0 0 auto; }
.followup.done .followup-note { text-decoration: line-through; color: var(--muted); }
.followup.overdue { border-left: 3px solid var(--error); }
.followup-contact { font-weight: 600; text-decoration: none; }
.followup-inputs > input[type='date'] { flex: 0 0 160px; }
details.done-list { margin-top: 12px; }
details.done-list summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; margin-bottom: 8px; }

.simple-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.9rem; }
.simple-table th { text-align: left; padding: 8px 10px; font-size: 0.8rem; color: var(--muted); border-bottom: 1px solid var(--border); }
.simple-table td { padding: 8px 10px; border-top: 1px solid var(--border); vertical-align: middle; }
.simple-table .num { text-align: right; }
.nowrap { white-space: nowrap; }

.contact-pick { display: flex; align-items: flex-end; gap: 8px; }
.contact-pick label { flex: 1; min-width: 0; }
.contact-pick button { padding: 10px 14px; }
.quick-contact { display: flex; flex-direction: column; gap: 12px; background: var(--bg); }
.quick-contact h4 { margin: 0; }
.row > .type-field { flex: 0 0 120px; }

@media (max-width: 480px) {
  .followup-inputs { flex-direction: column; }
  .followup-inputs > input[type='date'] { flex: none; }
  .simple-table th:first-child, .simple-table td:first-child { padding-right: 4px; }
}


/* ---- Venues ---- */

.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 0.9rem; font-weight: 500; }
.venue-picker { display: flex; flex-direction: column; gap: 8px; }
.venue-picker .warn { margin: 0; }
.venue-picker > button.secondary { align-self: flex-start; }
.venue-chosen {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.venue-results { list-style: none; margin: 0; padding: 0; border-radius: 8px; overflow: hidden; }
.venue-results:empty { display: none; }
.venue-results li { border: 1px solid var(--border); border-top-width: 0; background: var(--surface); }
.venue-results li:first-child { border-top-width: 1px; border-radius: 8px 8px 0 0; }
.venue-results li:last-child { border-radius: 0 0 8px 8px; }
.venue-results li:only-child { border-radius: 8px; }
.venue-results button {
  width: 100%;
  padding: 10px 12px;
  border: 0;
  background: none;
  color: var(--text);
  text-align: left;
}
.venue-results button:hover, .venue-results button:focus { background: var(--bg); }
.venue-results .empty, .venue-results .error { padding: 10px 12px; }
.venue-form .row > label { min-width: 0; }
.badge.pa-yes { background: #eaf7ef; border-color: #bfe5cc; color: var(--ok); }

/* ---- Admin ---- */

.admin-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.admin-tabs { margin: 4px 0 16px; }
.admin-tabs a.seg { text-decoration: none; }
.admin-body > a.button { margin-bottom: 12px; }
#nav-admin { color: var(--error); }
.admin-user { align-items: flex-start; }
.admin-user-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.badge.status-disabled { background: #fdecec; border-color: #f3c4c4; color: var(--error); }
.radio-row { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; padding: 4px 0; }
.radio-row input { width: 18px; height: 18px; margin: 0; flex: 0 0 auto; }
.table-scroll { overflow-x: auto; }
.merge-table th { white-space: nowrap; vertical-align: top; }
.merge-table td { min-width: 120px; overflow-wrap: anywhere; }
.merge-summary { margin: 0 0 12px; padding-left: 20px; }
.merge-summary li { margin: 4px 0; }
.audit-item { align-items: flex-start; }
.audit-item details { margin-top: 4px; }
.audit-json {
  margin: 6px 0 0;
  padding: 8px;
  max-height: 260px;
  overflow: auto;
  background: var(--bg);
  border-radius: 6px;
  font-size: 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.confirm-dialog {
  width: min(440px, calc(100vw - 32px));
  padding: 20px;
  border: 0;
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  color: var(--text);
}
.confirm-dialog::backdrop { background: rgba(20, 20, 30, 0.45); }
.confirm-dialog h3 { margin: 0 0 10px; }
.confirm-dialog p { margin: 0 0 10px; }
.dialog-actions { justify-content: flex-end; margin-top: 16px; }

/* ---- Modal ---- */

.modal {
  width: min(680px, calc(100vw - 16px));
  max-height: calc(100vh - 24px);
  padding: 0 16px 16px;
  border: 0;
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  overflow-y: auto;
}
.modal::backdrop { background: rgba(20, 20, 30, 0.5); }
.modal .gig-form { gap: 12px; }
.auth-lang { display: flex; justify-content: flex-end; margin-bottom: 8px; }
.chip.all-chip.on { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip.add-chip { color: var(--link); font-weight: 700; padding: 5px 12px; }

/* One colour per band (cycled): chip when selected, and the small tag on items. */
.band-tag {
  display: inline-block;
  margin-top: 3px;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}
.bc-0.band-tag, .band-chip.on.bc-0 { background: #e9e7fb; border-color: #cfcbf5; color: #2c2480; }
.bc-1.band-tag, .band-chip.on.bc-1 { background: #dff3e8; border-color: #b9e0c9; color: #1f6b41; }
.bc-2.band-tag, .band-chip.on.bc-2 { background: #fdebd9; border-color: #f3d0ac; color: #8a4a10; }
.bc-3.band-tag, .band-chip.on.bc-3 { background: #e0f0fa; border-color: #b7dbf0; color: #175a82; }
.bc-4.band-tag, .band-chip.on.bc-4 { background: #fbe3ee; border-color: #f0bfd6; color: #8a2358; }
.bc-5.band-tag, .band-chip.on.bc-5 { background: #ececef; border-color: #d3d3da; color: #44444e; }
.gig-card-head + .band-tag, .list-item .band-tag { margin-top: 0; }
input[type='file'] { padding: 8px; background: var(--bg); }
.shared-badge { background: #eaf7ef; border-color: #bfe5cc; color: var(--ok); }
.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.panel p { margin: 0; }
.push-right { margin-left: auto; }

/* ---- Settings & Google ---- */

.notice { margin: 0 0 12px; padding: 10px 12px; border-radius: 8px; }
.ok-bg { background: #eaf7ef; color: var(--ok); }
#user-name:hover { text-decoration: underline; }

.import-box { margin-top: 12px; display: flex; flex-direction: column; gap: 12px; }
.import-box > summary { cursor: pointer; font-weight: 600; }
.import-box form { margin-top: 10px; }
.import-box p { margin: 0; }
.import-row { align-items: flex-start; }
.import-row input[type='checkbox'] { width: 20px; height: 20px; margin: 2px 0 0; flex: 0 0 auto; }
.import-row input[type='text'] { margin-top: 6px; width: 100%; padding: 6px 10px; }

@media (min-width: 768px) {
  .ev {
    width: auto;
    height: auto;
    padding: 1px 5px;
    border-radius: 4px;
    color: #fff;
    font-size: 0.72rem;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .ev.gig-negotiating { color: var(--on-accent); }
  .ev.gig-declined .ev-label { text-decoration: line-through; }
}


@media (min-width: 768px) {
  .nav { justify-content: center; }
  .content { padding: 24px; }
}


/* Gigs: month / year filter */

/* ---- Brand link, user menu, band admin sub-navigation ---- */

a.brand { text-decoration: none; display: inline-flex; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 200px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(20, 20, 30, 0.15); padding: 4px; display: flex; flex-direction: column;
}
.menu[hidden] { display: none; }
.band-section + .band-section { margin-top: 32px; padding-top: 16px; border-top: 2px solid var(--border); }
