:root {
  --bg: #f2f2f5;
  --panel: #ffffff;
  --border: #ececef;
  --border-strong: #e0e0e5;
  --text: #16161d;
  --text-muted: #8b8b95;
  --text-faint: #b8b8c0;
  --accent: #16161d;
  --accent-contrast: #ffffff;
  --green: #1f8a4c;
  --green-bg: #e9f7ee;
  --red: #c8443b;
  --red-bg: #fbeae9;
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-panel: 0 1px 2px rgba(20, 20, 26, 0.04), 0 10px 30px rgba(20, 20, 26, 0.05);
  --sidebar-w: 76px;

  --dot-corporate: #3a7dd0;
  --dot-wedding: #b3679a;
  --dot-private-event: #4f9a6d;

  --loc-arizona-bg: #fdf0e2; --loc-arizona-fg: #c1701c;
  --loc-colorado-bg: #e7eefc; --loc-colorado-fg: #2f5fc7;
  --hold-bg: #fdf6df; --hold-fg: #a67c1f;

  --avatar-0: #e7ecfb; --avatar-0-fg: #3a5bc7;
  --avatar-1: #fbe9ee; --avatar-1-fg: #c04868;
  --avatar-2: #eaf7ee; --avatar-2-fg: #2f8a55;
  --avatar-3: #fdf2e2; --avatar-3-fg: #b6791c;
  --avatar-4: #f1eafb; --avatar-4-fg: #7a4fc4;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

h1, h2, h3 { margin: 0; }
h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 14px; font-weight: 700; margin-top: 28px; margin-bottom: 10px; color: var(--text); }

/* ---------- App shell: icon sidebar + topbar + content ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: #17171d;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #24242c;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  text-decoration: none;
  margin-bottom: 28px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.sidebar-nav a, .sidebar-logout button {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #83838f;
  text-decoration: none;
  border: none;
  background: none;
  cursor: pointer;
}
.sidebar-nav a:hover, .sidebar-logout button:hover { background: #232329; color: #e5e5ea; }
.sidebar-nav a.active { background: #232329; color: #ffffff; }
.sidebar-nav svg, .sidebar-logout svg { width: 20px; height: 20px; }

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-y: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 36px;
}

.header-actions { display: flex; align-items: center; gap: 10px; }

.crumb {
  font-size: 13px;
  color: var(--text-muted);
}
.crumb strong { color: var(--text); font-weight: 700; }

.content { padding: 0 36px 48px; min-width: 0; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: 999px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.btn:hover { opacity: 0.85; }
.btn-small { padding: 6px 14px; font-size: 12px; }
.btn-ghost { background: var(--panel); color: var(--text); border: 1px solid var(--border-strong); }

.link-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  font: inherit;
  font-weight: 600;
}
.link-btn-danger { color: var(--red); }
.link-btn-small {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  font-size: 12px;
  text-decoration: underline;
}

form.inline { display: inline; }

/* ---------- Pill tabs ---------- */

.pill-tabs {
  display: inline-flex;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-panel);
}
.pill-tab {
  border: none;
  background: none;
  padding: 7px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}
.pill-tab.active { background: var(--accent); color: var(--accent-contrast); }
.pill-tab .count { opacity: 0.6; font-weight: 500; margin-left: 4px; }

/* ---------- Panel / card ---------- */

.panel {
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
}

/* The table itself can be wider than the panel (lots of columns) — this
   scrolls just the table horizontally within its own rounded card instead
   of letting it spill past the viewport edge with no way to see the rest. */
.table-scroll {
  overflow-x: auto;
  overflow-y: visible;
  border-radius: var(--radius-lg);
}

/* ---------- Table ---------- */

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
}

th, td {
  text-align: left;
  vertical-align: middle;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  font-weight: 700;
  background: #fafafb;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafafb; }

/* The container used to clip its own corners round via overflow:hidden,
   but that also clipped anything (like a tooltip) trying to escape above
   or below a row — now that it doesn't clip vertically, the table's own
   corner cells round themselves instead. */
thead tr:first-child th:first-child { border-top-left-radius: var(--radius-lg); }
thead tr:first-child th:last-child { border-top-right-radius: var(--radius-lg); }
tbody tr:last-child td:first-child { border-bottom-left-radius: var(--radius-lg); }
tbody tr:last-child td:last-child { border-bottom-right-radius: var(--radius-lg); }

.text-right { text-align: right; }
.checkbox-cell { text-align: center; }
.actions-cell { text-align: right; }
.actions-cell a { color: var(--text-muted); text-decoration: none; margin-right: 12px; font-weight: 600; }

.empty { color: var(--text-muted); padding: 28px 4px; }

/* ---------- Details icon (leftmost column) ---------- */

.details-cell { width: 1%; }
.details-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}
.details-icon-btn:hover { background: #f3f3f5; color: var(--text); }
.details-icon-btn svg { width: 17px; height: 17px; }

/* ---------- Money inputs (always show a $ prefix) ---------- */

.money-input { position: relative; display: inline-flex; align-items: center; }
.field .money-input { display: flex; width: 100%; }
.money-prefix {
  position: absolute;
  left: 7px;
  color: var(--text);
  font-weight: 600;
  font-size: inherit;
  pointer-events: none;
}
.money-input input { padding-left: 17px !important; }
.money-input-small .money-prefix { left: 6px; font-size: 12px; }
.money-input-small input { padding-left: 13px !important; }

/* ---------- Type dot badge ---------- */

.type-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 7px;
}
.type-dot-corporate { background: var(--dot-corporate); }
.type-dot-wedding { background: var(--dot-wedding); }
.type-dot-private-event { background: var(--dot-private-event); }

/* ---------- Location badge (toggle button) ---------- */

.loc-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: none;
  cursor: pointer;
}
.loc-arizona { background: var(--loc-arizona-bg); color: var(--loc-arizona-fg); }
.loc-colorado { background: var(--loc-colorado-bg); color: var(--loc-colorado-fg); }

/* ---------- Status column: Pending/Confirmed toggle + Attention/Note badges ---------- */

.status-badges { display: flex; align-items: center; gap: 4px; }

.mini-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  border: none;
  cursor: pointer;
}
.mini-badge.pending { background: var(--hold-bg); color: var(--hold-fg); cursor: default; }
.mini-badge.confirmed { background: var(--green-bg); color: var(--green); cursor: default; }
.mini-badge.attention { background: var(--red-bg); color: var(--red); cursor: default; }
.mini-badge.note { background: var(--avatar-1); color: var(--avatar-1-fg); cursor: default; }

/* A custom tooltip instead of the native title="" attribute — title
   tooltips were getting suppressed (inconsistent browser timing/behavior,
   and the table's scroll container used to clip anything escaping its
   rows vertically). This one is fully in our control and always shows. */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--panel);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  max-width: 220px;
  width: max-content;
  white-space: normal;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease;
  z-index: 100;
}
[data-tooltip]:hover::after {
  opacity: 1;
  visibility: visible;
}

/* ---------- Inline "click to edit" table cells ---------- */

.cell-input {
  border: 1px solid transparent;
  background: transparent;
  font: inherit;
  color: inherit;
  padding: 5px 7px;
  border-radius: var(--radius-sm);
  width: 100%;
  min-width: 90px;
}
.cell-input:hover { background: #fafafb; border-color: var(--border-strong); }
.cell-input:focus { outline: none; background: var(--panel); border-color: var(--accent); }
.cell-input.payment-sub { font-size: 12px; margin-top: 2px; }
select.cell-input { min-width: 120px; }
.type-select { min-width: 88px; width: auto; }
input[type="number"].cell-input { min-width: 70px; }
input[type="date"].cell-input { min-width: 130px; }

/* Venue — a textarea (not input) so a long name wraps onto a second line
   instead of clipping; app.js grows its height to fit as you type. */
.venue-cell { min-width: 220px; max-width: 340px; white-space: normal; }
.cell-textarea {
  resize: none;
  overflow: hidden;
  white-space: normal;
  line-height: 1.35;
  min-height: 32px;
  display: block;
}

/* ---------- Payment cells ---------- */

.payment-badge { font-size: 13px; color: var(--green); margin-right: 8px; white-space: nowrap; font-weight: 600; }
.payment-sub { color: var(--text-muted); font-weight: 500; }

/* Amount box + a click-to-expand Owed/Paid status pill, stacked. */
.pay-cell { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.pay-amount { width: 90px; }
.fee-input { width: 66px; min-width: 66px; }

.pay-status summary {
  cursor: pointer;
  list-style: none;
}
.pay-status summary::-webkit-details-marker { display: none; }
.pay-status summary::marker { content: ""; }

.status-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.status-pill.owed { background: var(--red-bg); color: var(--red); }
.status-pill.paid { background: var(--green-bg); color: var(--green); }

.musicians-cell { min-width: 150px; }
.musician-name-line { font-size: 13px; margin-bottom: 4px; white-space: nowrap; }
.musician-needed-pill { margin-bottom: 4px; }

.pay-details { margin-top: 8px; }
.pay-details .payment-sub { font-size: 12px; margin-bottom: 6px; white-space: nowrap; }

.mark-received-form { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.mark-received-form input, .mark-received-form select {
  padding: 6px 8px;
  font-size: 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--panel);
}
.mark-received-form input[type="number"] { width: 80px; }
.mark-received-form input[type="date"] { width: 130px; }

.email-links a { color: var(--text-muted); text-decoration: none; margin-right: 10px; font-size: 13px; font-weight: 600; }

/* ---------- Forms ---------- */

.form-panel { background: var(--panel); border-radius: var(--radius-lg); box-shadow: var(--shadow-panel); padding: 28px 32px; max-width: 560px; }
.email-prep { margin-top: 28px; padding-top: 24px; border-top: 1px solid var(--border); }
.email-prep .email-links a { font-size: 14px; }

/* ---------- Musicians (details page) ---------- */

.musicians-panel { max-width: 760px; margin-top: 24px; }
.musician-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.musician-row:first-of-type { padding-top: 4px; }
.musician-fields { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; flex: 1; }
.musician-fields select.cell-input { min-width: 100px; }
.musician-name-input { min-width: 140px; }
.musician-confirmed { white-space: nowrap; font-size: 13px; }
.musician-pay-cell { flex: 0 0 auto; }
.musicians-panel .btn-small { margin-top: 8px; }

/* ---------- Expenses + Net Revenue (details page) ---------- */

.expenses-panel { max-width: 480px; margin-top: 24px; }
.expense-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.expense-fields { display: flex; align-items: center; gap: 10px; flex: 1; }
.expense-desc-input { flex: 1; min-width: 120px; }
.expenses-panel .btn-small { margin-top: 8px; }

.net-revenue-summary { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.net-revenue-line {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-muted);
}
.net-revenue-total {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 13px; color: var(--text); }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-sizing: border-box;
  font-size: 14px;
  font-family: inherit;
  background: var(--panel);
  color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.field textarea { resize: vertical; }
.field input[readonly], .field textarea[readonly] { background: #fafafb; color: var(--text-muted); }

.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; }

.check-field label { font-weight: 500; display: flex; align-items: center; gap: 8px; }
.check-field input { width: auto; }

.actions { margin-top: 22px; display: flex; align-items: center; gap: 18px; }
.actions a { color: var(--text-muted); text-decoration: none; font-weight: 600; font-size: 13px; }

.hint { color: var(--text-muted); font-size: 12.5px; margin: -6px 0 16px; }
.hint code { background: #f3f3f5; padding: 1px 5px; border-radius: 4px; }

.template-form { margin-bottom: 20px; max-width: 560px; }

/* ---------- Flashes ---------- */

.flashes {
  list-style: none;
  padding: 12px 16px;
  margin: 0 0 20px;
  background: #eef2ff;
  border: 1px solid #dde4fb;
  border-radius: var(--radius-sm);
  color: #3a4ba0;
  font-size: 13px;
  font-weight: 600;
}

/* ---------- Standalone (pre-login) pages ---------- */

.standalone {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.standalone-card {
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-panel);
  padding: 36px 36px 28px;
  width: 100%;
  max-width: 360px;
}
.standalone-card h1 { font-size: 20px; margin-bottom: 8px; }
.standalone-card p { color: var(--text-muted); font-size: 13px; margin: 0 0 20px; }

/* Calendar sync status in the page header (display only). */
.sync-status { font-size: 13px; font-weight: 600; padding: 9px 14px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--panel); }
.sync-status.on { color: var(--green); }
.sync-status.off { color: var(--text-muted); }
