* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #101418;
  --panel: #1a2027;
  --panel2: #222a33;
  --border: #2e3944;
  --text: #e8edf2;
  --muted: #8b98a5;
  --accent: #6ee7a0;
  --accent-dim: #2c5240;
  --danger: #f87171;
  --radius: 10px;
}

html, body { height: 100%; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

.hidden { display: none !important; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; line-height: 1.45; }
a { color: var(--accent); }

/* ---------- auth ---------- */
#auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 24px;
}
.logo { font-size: 34px; font-weight: 800; letter-spacing: 3px; }
.logo span { color: var(--accent); }
.auth-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.auth-card h2 { font-size: 18px; }
.auth-error { color: var(--danger); font-size: 13px; min-height: 16px; }
.auth-switch { font-size: 13px; color: var(--muted); text-align: center; }
.auth-switch button { color: var(--accent); text-decoration: underline; }

/* ---------- layout ---------- */
header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 800; letter-spacing: 2px; font-size: 17px; white-space: nowrap; }
.brand .accent { color: var(--accent); }
.brand .brand-short { display: none; }
nav { display: flex; gap: 4px; flex: 1; }
nav button {
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 600;
}
nav button .ico { margin-right: 4px; }
nav button:hover { background: var(--panel2); color: var(--text); }
nav button.active { background: var(--accent-dim); color: var(--accent); }
.userbox { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; position: relative; }
#who { color: var(--text); font-weight: 700; padding: 5px 8px; border-radius: 8px; }
#who:hover { background: var(--panel2); }
#logout:hover { color: var(--danger); }

#member-pop {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 260px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  z-index: 30;
}
#member-pop h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 6px;
}
.member-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.member-row:last-child { border-bottom: none; }
.member-row .grow { flex: 1; }
.member-row .muted { font-size: 12px; }

main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 80px; }

.btn {
  background: var(--accent);
  color: #0c1a12;
  font-weight: 700;
  padding: 9px 16px;
  border-radius: 8px;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.1); }
.btn.secondary { background: var(--panel2); color: var(--text); border: 1px solid var(--border); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.icon-btn { color: var(--muted); padding: 4px 6px; border-radius: 6px; font-size: 14px; }
.icon-btn:hover { color: var(--danger); background: var(--panel2); }

.quick-add { display: flex; gap: 8px; margin-bottom: 18px; }
.quick-add input { flex: 1; }

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

/* ---------- tasks ---------- */
.task {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 8px;
}
.st-btn {
  font-size: 16px;
  width: 34px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel2);
  flex-shrink: 0;
}
.st-btn:hover { border-color: var(--accent); }
.st-btn.doing { border-color: #fbbf24; background: #4a3a1e; }
.st-btn.done { border-color: var(--accent-dim); }
.task.doing { border-left: 3px solid #fbbf24; }
.task .title { flex: 1; }
.task.done .title { text-decoration: line-through; color: var(--muted); }
.task select { font-size: 13px; padding: 4px 6px; color: var(--muted); max-width: 140px; }
.task .icon-btn { opacity: 0; }
.task:hover .icon-btn { opacity: 1; }

/* ---------- task categories ---------- */
.cat-head {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin: 18px 0 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.cat-head .line { flex: 1; height: 1px; background: var(--border); }
.task .cat-tag {
  font-size: 12px;
  color: var(--muted);
  background: var(--panel2);
  border-radius: 999px;
  padding: 2px 8px;
  white-space: nowrap;
}

/* ---------- dashboard ---------- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
}
.stat:hover { border-color: var(--accent); }
.stat .num { font-size: 26px; font-weight: 800; color: var(--accent); }
.stat .lbl { font-size: 13px; color: var(--muted); }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 800px) { .dash-grid { grid-template-columns: 1fr; } }

.dash-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.dash-card > h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.dash-card > h3 .grow { flex: 1; }

.feed-entry {
  display: flex;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  align-items: baseline;
}
.feed-entry:last-child { border-bottom: none; }
.feed-entry.clickable { cursor: pointer; }
.feed-entry.clickable:hover .what { color: var(--accent); }
.feed-entry .when { color: var(--muted); font-size: 12px; white-space: nowrap; width: 84px; }
.feed-entry .what { flex: 1; }
.feed-entry b { color: var(--accent); font-weight: 600; }

.cal-event {
  display: flex;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
  font-size: 14px;
  overflow: hidden;
}
.cal-event:last-child { border-bottom: none; }
.cal-when {
  color: var(--accent);
  font-weight: 700;
  font-size: 12.5px;
  white-space: nowrap;
  min-width: 52px;
  flex-shrink: 0;
}
.cal-title {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-sub {
  color: var(--muted);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-left: auto;
  max-width: 45%;
  flex-shrink: 0;
}
.cal-more {
  display: block;
  width: 100%;
  text-align: center;
  padding: 6px 0 2px;
  font-size: 12.5px;
  border-radius: 6px;
}
.cal-more:hover { color: var(--accent); }
.cal-setup { display: flex; flex-direction: column; gap: 10px; }
.cal-setup input { width: 100%; }

/* ---------- gigs ---------- */
.gig {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.gig-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  cursor: pointer;
}
.gig-row:hover { color: var(--accent); }
.gig-row .name { font-weight: 700; }
.gig-row .sub { font-size: 13px; }
.gig-row select { font-size: 13px; padding: 4px 6px; }
.gig-row .cal-when { font-size: 13px; width: 84px; }
.gig-details { padding: 0 16px 14px; border-top: 1px solid var(--border); padding-top: 14px; }
.gig-details .field-grid { margin-bottom: 10px; }

/* ---------- due dates ---------- */
.task input.due { font-size: 12.5px; padding: 4px 6px; color: var(--muted); width: 135px; }
.task input.due.overdue { color: var(--danger); border-color: var(--danger); }
.overdue-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--danger);
  background: #4a1e1e;
  border-radius: 999px;
  padding: 2px 8px;
  margin-left: 6px;
  vertical-align: middle;
}

/* ---------- dashboard reminders ---------- */
.dash-card.reminders { border-color: #6b5b2a; margin-bottom: 18px; }
.dash-card.reminders h3 { color: #fbbf24; }

/* ---------- venue map ---------- */
#venue-map {
  height: 380px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
  z-index: 1;
}
#venue-map .empty { padding-top: 160px; }

/* ---------- press kit ---------- */
.epk-card { border-color: var(--accent-dim); }
.epk-row { margin-top: 8px; }

/* ---------- notes ---------- */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  align-items: start; /* resizing one note must not stretch its row-mates */
}
.note {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.note input { background: none; border: none; font-weight: 700; font-size: 15px; padding: 0; }
.note textarea { background: none; border: none; padding: 0; min-height: 90px; font-size: 14px; }
.note .foot { display: flex; justify-content: space-between; align-items: center; }

/* ---------- contacts ---------- */
.filters { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.chip {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.chip.active { background: var(--accent-dim); color: var(--accent); border-color: var(--accent-dim); }
.filters input { margin-left: auto; width: 200px; }

.map-btn {
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}
.map-btn:hover { border-color: var(--accent); }
.map-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0c1a12;
}

.contact-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 8px;
  cursor: pointer;
}
.contact-row:hover { border-color: var(--accent); }
.contact-row .name { font-weight: 700; }
.contact-row .sub { color: var(--muted); font-size: 13px; }
.contact-row .grow { flex: 1; }
.contact-row .meta { text-align: right; font-size: 13px; color: var(--muted); white-space: nowrap; }
.contact-row.overdue .meta .ago { color: #fbbf24; }

.badge {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge.new { background: #3b2f4f; color: #c4b5fd; }
.badge.contacted { background: #1e3a5f; color: #93c5fd; }
.badge.waiting { background: #4a3a1e; color: #fbbf24; }
.badge.replied { background: #1e4a3a; color: #6ee7a0; }
.badge.booked { background: var(--accent); color: #0c1a12; }
.badge.declined { background: #4a1e1e; color: #f87171; }
.badge.followup { background: #4a2e1e; color: #fdba74; }

/* ---------- drawer ---------- */
#drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 20;
}
#drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(640px, 100vw);
  background: var(--panel);
  border-left: 1px solid var(--border);
  z-index: 21;
  overflow-y: auto;
  padding: 20px 24px 60px;
}
#drawer h2 { font-size: 20px; margin-bottom: 2px; }
.drawer-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.drawer-head .grow { flex: 1; }
.drawer-close { font-size: 22px; color: var(--muted); }
.drawer-close:hover { color: var(--text); }

.status-picker { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 18px; }
.status-picker .badge { cursor: pointer; opacity: 0.35; border: none; }
.status-picker .badge.selected { opacity: 1; outline: 2px solid rgba(255, 255, 255, 0.25); }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.field-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.field-grid label.wide { grid-column: 1 / -1; }

.section { margin-top: 22px; }
.section > h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section > h3 .line { flex: 1; height: 1px; background: var(--border); }

.draft-box { display: flex; flex-direction: column; gap: 8px; }
.draft-box .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.draft-box textarea { min-height: 220px; font-size: 14px; }
.save-state { font-size: 12px; color: var(--muted); margin-left: auto; }

.log-entry { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.log-entry .when { color: var(--muted); white-space: nowrap; width: 90px; }
.log-entry .what {
  flex: 1;
  white-space: pre-wrap;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: pointer;
}
.log-entry .what.expanded { -webkit-line-clamp: unset; }
.log-entry .who { color: var(--muted); }

#reply-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  padding: 12px;
  background: var(--panel2);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
}
#reply-box.hidden { display: none; }
#reply-box .row { display: flex; gap: 8px; flex-wrap: wrap; }
.log-add { display: flex; gap: 8px; margin-top: 10px; }
.log-add input { flex: 1; font-size: 13px; }

/* ---------- templates ---------- */
.template {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.template .row { display: flex; gap: 8px; align-items: center; }
.template .row input:first-child { font-weight: 700; flex: 1; }
.template textarea { min-height: 140px; font-size: 14px; }
.hint { font-size: 12px; color: var(--muted); }
.hint code { background: var(--panel2); padding: 1px 5px; border-radius: 4px; }

/* ---------- toast ---------- */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--accent);
  color: #0c1a12;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 999px;
  transition: transform 0.25s, opacity 0.25s;
  opacity: 0;
  pointer-events: none;
  z-index: 50;
}
#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

@media (max-width: 640px) {
  header { gap: 8px; padding: 8px 12px; justify-content: space-between; }
  .brand .brand-full { display: none; }
  .brand .brand-short { display: inline; }
  /* tabs become a fixed bottom bar, always reachable with a thumb */
  nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    flex: none;
    background: var(--panel);
    border-top: 1px solid var(--border);
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    z-index: 15;
  }
  nav button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 5px 2px;
    font-size: 10.5px;
    border-radius: 8px;
  }
  nav button .ico { font-size: 19px; margin: 0; }
  main { padding: 16px 12px 96px; }
  .field-grid { grid-template-columns: 1fr; }
  .filters input { width: 100%; margin-left: 0; }
  .map-btn { width: 100%; }
  .quick-add { flex-wrap: wrap; }
  .quick-add input, .quick-add select { flex: 1 1 45%; min-width: 0; max-width: none !important; }
  .quick-add input:first-child { flex: 1 1 100%; }
  .task { flex-wrap: wrap; row-gap: 6px; }
  .task .title { flex: 1 1 calc(100% - 60px); }
  .task .icon-btn { opacity: 1; }
  .task select, .task input.due { flex: 1 1 30%; max-width: none; width: auto; }
  .contact-row { flex-wrap: wrap; row-gap: 6px; }
  .contact-row .meta { text-align: left; width: 100%; display: flex; gap: 12px; }
  .gig-row { flex-wrap: wrap; row-gap: 6px; }
  .gig-row .grow { flex: 1 1 calc(100% - 110px); }
  #drawer { padding: 14px 14px 60px; }
  .drawer-head { flex-wrap: wrap; }
  .log-entry { flex-wrap: wrap; }
  .log-entry .when { width: auto; }
  #venue-map { height: 280px; }
  #toast { bottom: 100px; }
}
