:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface-2: #f8f7f3;
  --ink: #1f2328;
  --muted: #687078;
  --line: #dedbd2;
  --line-strong: #c8c3b8;
  --black: #151515;
  --green: #668c4a;
  --green-soft: #dfead6;
  --gold: #c59a38;
  --gold-soft: #f2dfaa;
  --rose: #a83c62;
  --rose-soft: #f4d9e2;
  --blue: #426b9f;
  --blue-soft: #dce7f4;
  --teal: #347f7a;
  --teal-soft: #d9eeeb;
  --shadow: 0 18px 42px rgba(38, 35, 28, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

body:not([data-auth="signed-in"]) {
  overflow: hidden;
  background: #f7f5ef;
}

body:not([data-auth="signed-in"]) .app-shell {
  display: none;
}

body[data-auth="signed-in"] .auth-modal {
  display: none !important;
}

body[data-role="artist"] [data-internal-only] {
  display: none !important;
}

body[data-role="internal"] .artist-preview-only {
  display: none !important;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  border-right: 1px solid var(--line);
  background: #191919;
  color: #f8f7f3;
  padding: 22px 16px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px 8px;
}

.brand-logo-frame {
  display: grid;
  place-items: center;
  width: 52px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: #f8f7f3;
  padding: 6px;
}

.brand-logo {
  display: block;
  width: 100%;
  height: auto;
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
}

.brand-subtitle {
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
  text-transform: uppercase;
}

.nav-list {
  display: grid;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  padding: 10px 10px;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-weight: 800;
}

.side-summary {
  display: grid;
  gap: 10px;
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding: 18px 6px 0;
}

.summary-label {
  color: rgba(255, 255, 255, 0.54);
  font-size: 12px;
  text-transform: uppercase;
}

.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: rgba(255, 255, 255, 0.72);
}

.summary-row strong {
  color: #ffffff;
}

.workspace {
  min-width: 0;
  padding: 24px 28px 34px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.15;
}

.view-subtitle,
.drawer-subtitle {
  color: var(--muted);
  margin-top: 4px;
}

.topbar-actions,
.button-cluster {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.button-cluster {
  grid-column: 1 / -1;
  justify-content: flex-end;
}

.save-state {
  color: var(--muted);
  font-size: 12px;
  transition: color 180ms ease;
}

.role-select {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 10px;
  font-weight: 700;
}

.save-state.pulse {
  color: var(--green);
}

.auth-status {
  max-width: 220px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-hidden {
  display: none !important;
}

.icon-button,
.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  padding: 0 12px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
}

.icon-button {
  width: 36px;
  padding: 0;
  font-size: 18px;
}

.primary-button {
  border-color: var(--black);
  background: var(--black);
  color: #ffffff;
}

.secondary-button:hover,
.icon-button:hover {
  border-color: var(--black);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(126px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  display: grid;
  gap: 4px;
  min-height: 88px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 13px 14px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  font-size: 28px;
  line-height: 1;
}

.tile-open {
  border-top: 4px solid var(--green);
}

.tile-contracts {
  border-top: 4px solid var(--gold);
}

.tile-upcoming {
  border-top: 4px solid var(--blue);
}

.tile-booked {
  border-top: 4px solid var(--teal);
}

.tile-leads {
  border-top: 4px solid var(--rose);
}

.tile-value {
  border-top: 4px solid var(--black);
}

.controls-bar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) repeat(3, minmax(140px, 180px));
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.search-wrap {
  position: relative;
}

.search-wrap input,
.controls-bar select,
.lead-form input,
.lead-form select,
.lead-form textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 8px 10px;
  outline: none;
}

.search-wrap input {
  padding-left: 34px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  color: var(--muted);
  transform: translateY(-50%);
}

.view-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-bottom: 14px;
  padding-bottom: 2px;
}

.view-chip {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 0 13px;
  font-weight: 700;
  white-space: nowrap;
}

.view-chip.active,
.view-chip:hover {
  border-color: var(--black);
  color: var(--black);
}

.table-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.table-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  padding: 11px 14px;
}

.table-header span {
  color: var(--muted);
}

.table-scroll {
  overflow: auto;
  max-height: calc(100vh - 350px);
  min-height: 360px;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #111111;
  color: #ffffff;
  font-size: 11px;
  text-transform: uppercase;
}

td {
  max-width: 220px;
  color: #252525;
}

tbody tr {
  transition: background 120ms ease;
}

tbody tr:hover {
  background: #fbfaf6;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.status-open {
  background: var(--green-soft);
  color: #315720;
}

.status-under-contract,
.outcome-pending {
  background: var(--gold-soft);
  color: #6c4f0f;
}

.status-closed,
.status-muted {
  background: #ece9e2;
  color: #68645d;
}

.outcome-booked {
  background: var(--teal-soft);
  color: #1e5f5b;
}

.outcome-not-booked {
  background: var(--rose-soft);
  color: #85304d;
}

.lane-grid,
.payment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.lane {
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
}

.lane-title {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.mini-card,
.timeline-item,
.payment-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.02);
}

.mini-card:hover {
  border-color: var(--black);
}

.mini-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.mini-meta,
.mini-action {
  color: var(--muted);
  margin-top: 6px;
}

.mini-action {
  color: var(--ink);
  font-weight: 700;
}

.money-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid var(--line);
  padding-top: 8px;
  margin-top: 8px;
}

.payment-track-title {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.timeline {
  display: grid;
  gap: 10px;
  max-width: 900px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 14px;
}

.date-block {
  display: grid;
  place-items: center;
  align-self: stretch;
  border-radius: 6px;
  background: var(--black);
  color: #ffffff;
  min-height: 72px;
}

.date-block span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  text-transform: uppercase;
}

.date-block strong {
  font-size: 26px;
  line-height: 1;
}

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  justify-content: flex-end;
  background: rgba(0, 0, 0, 0.34);
}

.drawer.open {
  display: flex;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(247, 245, 239, 0.98)),
    var(--bg);
  padding: 28px;
}

.auth-modal.open {
  display: grid;
}

.auth-panel {
  width: min(390px, 100%);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 22px 54px rgba(38, 35, 28, 0.12);
}

.login-panel {
  display: grid;
  gap: 8px;
  padding: 28px 28px 24px;
}

.login-brand {
  display: grid;
  justify-items: center;
  padding: 6px 0 2px;
}

.login-logo {
  display: block;
  width: min(180px, 76vw);
  height: auto;
}

.login-title {
  margin: 8px 0 2px;
  font-size: 18px;
  text-align: center;
}

.auth-form {
  display: grid;
  gap: 14px;
  padding: 0;
}

.auth-message {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.auth-message.error {
  color: var(--rose);
}

.auth-message.success {
  color: var(--green);
}

.login-actions {
  display: grid;
  gap: 8px;
}

.login-actions .primary-button,
.login-actions .secondary-button {
  width: 100%;
}

.drawer-panel {
  width: min(760px, 100vw);
  height: 100vh;
  overflow: auto;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.drawer-header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  padding: 20px 22px;
}

.lead-form {
  display: grid;
  gap: 18px;
  padding: 20px 22px 28px;
}

.form-section {
  display: grid;
  gap: 12px;
}

.form-section h3 {
  font-size: 13px;
  text-transform: uppercase;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

label input,
label select,
label textarea {
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  text-transform: none;
}

.invoice-status-select {
  --invoice-status-color: #dfe3e6;
  background-image:
    radial-gradient(circle at 18px center, var(--invoice-status-color) 0 9px, transparent 10px),
    linear-gradient(to right, color-mix(in srgb, var(--invoice-status-color) 28%, #ffffff), #ffffff 64%);
  background-repeat: no-repeat;
  padding-left: 38px;
}

.invoice-status-select.has-status-color {
  border-color: color-mix(in srgb, var(--invoice-status-color) 70%, #8f948c);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--invoice-status-color) 48%, transparent);
}

.assignment-status-list {
  display: grid;
  gap: 8px;
}

.assignment-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 10px;
}

.assignment-row div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.assignment-row strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assignment-row span,
.assignment-empty {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.assignment-empty {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 12px;
}

.wide-label {
  display: grid;
}

textarea {
  resize: vertical;
}

.drawer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: block;
    padding: 12px;
  }

  .brand-block {
    padding: 0;
    margin-bottom: 10px;
  }

  .nav-list {
    display: flex;
    overflow-x: auto;
  }

  .nav-item {
    width: auto;
    min-width: 126px;
  }

  .side-summary {
    display: none;
  }

  .workspace {
    padding: 18px;
  }

  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .controls-bar {
    grid-template-columns: 1fr 1fr;
  }

  .search-wrap,
  .button-cluster {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  .topbar {
    flex-direction: column;
  }

  .metric-grid,
  .controls-bar,
  .field-grid,
  .assignment-row {
    grid-template-columns: 1fr;
  }

  .button-cluster {
    justify-content: stretch;
  }

  .button-cluster button {
    flex: 1;
  }

  .auth-status {
    max-width: 100%;
  }

  .table-scroll {
    max-height: 520px;
  }
}
