:root {
  --ink: #17212b;
  --muted: #657080;
  --line: #d9e0e8;
  --soft: #f4f7fa;
  --panel: #ffffff;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --coral: #d85f4b;
  --amber: #b7791f;
  --blue: #2563eb;
  --shadow: 0 18px 45px rgba(28, 39, 50, .09);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #eef3f7;
}

a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card, .panel, .metric, .table-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-card {
  width: min(460px, 100%);
  padding: 26px;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px 16px;
  background: #17212b;
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--teal);
  font-weight: 800;
}

.brand span, .muted, .metric span, .meta { color: var(--muted); }
.brand span { display: block; color: #b9c3cf; font-size: 13px; }

.nav { display: grid; gap: 6px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  color: #dce5ed;
  text-decoration: none;
}
.nav a.active, .nav a:hover { background: #24313f; color: #fff; }
.sidebar-footer { margin-top: auto; color: #b9c3cf; font-size: 13px; }

.main { padding: 28px; overflow: hidden; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 30px; }
h2 { font-size: 18px; }

.eyebrow {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric { padding: 18px; }
.metric strong { display: block; margin-top: 8px; font-size: 30px; }

.panel { padding: 18px; margin-bottom: 16px; }
.panel-heading, .actions, .toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.button, .button-secondary, .button-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 700;
}
.button { background: var(--teal); color: #fff; border-color: var(--teal); }
.button:hover { background: var(--teal-dark); }
.button-secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.button-danger { background: #fff; color: var(--coral); border-color: #f3c7bf; }

form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  min-height: 40px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
textarea { resize: vertical; }

.auto-upload-submit {
  width: fit-content;
  opacity: .01;
  pointer-events: none;
  position: absolute;
}
.auto-upload-status {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.auto-upload-status[data-state="loading"] { color: var(--teal); }
.auto-upload-form.is-uploading input[type="file"] {
  opacity: .65;
  cursor: wait;
}

input:disabled,
select:disabled,
textarea:disabled {
  background: #eef2f5;
  border-color: #d6dee6;
  color: #7b8794;
  cursor: not-allowed;
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  min-height: 16px;
  height: 16px;
  padding: 0;
  margin: 0;
  accent-color: var(--teal);
}

.checkbox-label {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  color: var(--ink);
}

.option-locked {
  padding: 10px;
  border: 1px solid #d7e0ea;
  border-radius: 8px;
  background: #f3f6f9;
}

.option-locked input {
  cursor: not-allowed;
}

.option-locked small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.conditional-time.is-disabled {
  color: #8a97a6;
}

.table-card { overflow: hidden; }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 13px; }
tr:last-child td { border-bottom: 0; }

.info-list {
  display: grid;
  gap: 8px;
  margin: 18px 0 0;
}

.info-list div {
  display: grid;
  grid-template-columns: minmax(170px, 220px) minmax(0, 1fr);
  align-items: start;
  gap: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.info-list div:last-child {
  border-bottom: 1px solid var(--line);
}

.info-list dt,
.info-list dd {
  margin: 0;
}

.info-list dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
}

.info-list dd {
  color: var(--ink);
  font-weight: 650;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.access-list dd {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.client-link-row {
  grid-template-columns: 1fr;
}

.client-link-row dt {
  margin-bottom: 4px;
}

.client-link-row dd {
  align-items: stretch;
}

.access-list input {
  flex: 1 1 360px;
  min-width: 0;
}

.client-link-field {
  flex: 1 1 100%;
  min-height: 74px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.45;
  word-break: break-all;
}

.client-link-copy-zone {
  flex: 1 1 100%;
  width: 100%;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.client-link-copy-zone p {
  margin-bottom: 6px;
}

.client-link-visible {
  display: block;
  width: 100%;
  max-width: 100%;
  color: var(--blue);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.55;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-all;
  user-select: text;
}

.access-list .button-secondary {
  flex: 0 0 auto;
  white-space: normal;
  text-align: center;
}

.access-list small {
  flex-basis: 100%;
}

.access-actions {
  justify-content: flex-start;
  margin-top: 14px;
}

.planning-panel {
  overflow: hidden;
}

.calendar-legend {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.calendar-legend span {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  background: var(--teal);
}

.year-calendar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.month-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.month-card h3 {
  margin-bottom: 10px;
  font-size: 15px;
}

.weekday-row,
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.weekday-row {
  margin-bottom: 5px;
}

.weekday-row span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.calendar-day {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.calendar-day.reserved {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}

.calendar-day.reserved:hover {
  background: var(--teal-dark);
}

.calendar-day small {
  position: absolute;
  right: 2px;
  bottom: 1px;
  display: grid;
  place-items: center;
  min-width: 13px;
  height: 13px;
  border-radius: 999px;
  background: #fff;
  color: var(--teal-dark);
  font-size: 9px;
  line-height: 1;
}

.calendar-day.empty {
  visibility: hidden;
}

.inline-form {
  display: inline-flex;
  margin: 0;
}

.document-thumbnails {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 14px 0;
}

.document-thumb {
  width: 132px;
  min-height: 118px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.document-thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  background: var(--soft);
}

.document-thumb span {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #e8f5f3;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 700;
}
.badge.quote, .badge.lead { background: #fff4df; color: var(--amber); }
.badge.completed { background: #e9efff; color: var(--blue); }
.badge.cancelled, .alert { background: #fdecea; color: var(--coral); }
.success { background: #e8f5f3; color: var(--teal-dark); }
.notice { padding: 12px; border-radius: 8px; margin-bottom: 14px; }

.client-shell { max-width: 980px; margin: 0 auto; padding: 24px; }
.client-header { margin-bottom: 18px; }

.client-info-panel {
  grid-column: 1 / -1;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.client-info-panel h3 {
  margin-bottom: 10px;
  font-size: 16px;
}

.client-info-panel p {
  margin-bottom: 10px;
  color: var(--muted);
  line-height: 1.55;
}

.client-info-panel p:last-child {
  margin-bottom: 0;
}

.client-save-reminder {
  margin: 10px 0 16px;
  padding: 12px 14px;
  border: 1px solid #c8d7ea;
  border-radius: 8px;
  background: #eef6ff;
  color: #244569;
  font-weight: 700;
  line-height: 1.45;
}

.song-list {
  grid-column: 1 / -1;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.song-list-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.song-list-heading h3 {
  margin: 0;
  font-size: 16px;
}

.song-fixed {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.song-fixed legend {
  padding: 0 6px;
  color: var(--ink);
  font-weight: 800;
}

.song-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.song-fixed .song-row {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.song-summary {
  display: grid;
  gap: 10px;
}

.song-summary p {
  margin-bottom: 0;
}

.song-summary a {
  color: var(--blue);
  overflow-wrap: anywhere;
}

.roadmap {
  max-width: 980px;
  margin: 0 auto;
}

.roadmap-header {
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--ink);
}

.roadmap-header h1 {
  margin-bottom: 6px;
}

.roadmap-notes {
  margin-bottom: 0;
  white-space: pre-wrap;
}

.roadmap-documents a {
  color: var(--blue);
  font-weight: 800;
}

.roadmap-attachments {
  display: grid;
  gap: 18px;
}

.roadmap-attachment {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.roadmap-attachment h3 {
  margin-bottom: 6px;
  font-size: 16px;
}

.roadmap-attachment-image {
  display: block;
  width: 100%;
  max-height: 980px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.roadmap-attachment-pdf {
  display: block;
  width: 100%;
  height: 980px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
}

.preview-modal.active {
  display: block;
}

body.preview-open {
  overflow: hidden;
}

.preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 24, 32, .72);
}

.preview-dialog {
  position: absolute;
  inset: 24px;
  display: grid;
  grid-template-rows: auto 1fr;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .32);
  overflow: hidden;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.preview-header h2 {
  margin: 0;
  font-size: 17px;
}

.preview-close {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.preview-close:hover {
  background: #eef2f5;
}

.preview-body {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 14px;
  background: #f6f8fb;
}

.preview-image {
  max-width: 100%;
  max-height: calc(100vh - 150px);
  object-fit: contain;
  cursor: zoom-in;
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(28, 39, 50, .16);
}

.preview-image.zoomed {
  max-width: none;
  max-height: none;
  width: auto;
  height: auto;
  cursor: zoom-out;
}

.preview-frame {
  width: 100%;
  height: 100%;
  min-height: calc(100vh - 150px);
  border: 0;
  background: #fff;
}

.preview-unavailable {
  max-width: 520px;
  padding: 24px;
  text-align: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 78px 1fr; }
  .brand div:last-child, .nav span, .sidebar-footer { display: none; }
  .metrics, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .year-calendar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .app-shell { display: block; }
  .sidebar { position: sticky; top: 0; z-index: 2; flex-direction: row; padding: 10px; overflow-x: auto; }
  .brand { display: none; }
  .nav { display: flex; }
  .nav a { min-width: 44px; justify-content: center; }
  .main { padding: 18px; }
  .topbar, .panel-heading, .toolbar { align-items: stretch; flex-direction: column; }
  .year-calendar { grid-template-columns: 1fr; }
  .info-list div { grid-template-columns: 1fr; gap: 4px; }
  .access-list dd { align-items: stretch; flex-direction: column; }
  .access-actions { align-items: stretch; flex-direction: column; }
  .song-list-heading, .song-row { grid-template-columns: 1fr; }
  .preview-dialog { inset: 8px; }
  .preview-header { align-items: stretch; flex-direction: column; }
  table, thead, tbody, tr, th, td { display: block; }
  thead { display: none; }
  tr { border-bottom: 1px solid var(--line); }
  td { border-bottom: 0; }
}

@media print {
  body {
    background: #fff;
    color: #000;
  }

  .sidebar,
  .print-hidden,
  .preview-modal,
  script {
    display: none !important;
  }

  .app-shell {
    display: block;
    min-height: auto;
  }

  .main {
    padding: 0;
    overflow: visible;
  }

  .roadmap {
    max-width: none;
  }

  .panel,
  .table-card {
    break-inside: avoid;
    box-shadow: none;
    border-color: #bbb;
  }

  .panel {
    padding: 12px 0;
    margin-bottom: 12px;
    border-width: 0 0 1px;
    border-radius: 0;
  }

  .info-list div {
    grid-template-columns: 190px 1fr;
    padding: 6px 0;
  }

  a {
    color: #000;
    text-decoration: none;
  }

  .roadmap-documents a::after {
    content: " (" attr(href) ")";
    font-weight: 400;
  }

  .roadmap-attachments {
    gap: 0;
  }

  .roadmap-attachment {
    break-inside: avoid;
    page-break-inside: avoid;
    margin: 0 0 18px;
    padding: 0;
    border: 0;
  }

  .roadmap-attachment-image {
    max-height: none;
    border: 0;
    border-radius: 0;
  }

  .roadmap-attachment-pdf {
    height: 900px;
    border: 0;
  }
}
