/* Minimal, readable styling. No frameworks. */

:root{
  --bg:#0b0c10;
  --panel:#12141a;
  --panel2:#0f1116;
  --text:#e8e8ea;
  --muted:#a8abb6;
  --border:#2a2f3a;
  --accent:#5fd7ff;
  --danger:#ff5f87;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family:var(--sans);
  background:linear-gradient(180deg, #0b0c10 0%, #07080b 100%);
  color:var(--text);
}

.topbar{
  position:sticky;
  top:0;
  z-index:10;
  display:flex;
  gap:16px;
  align-items:center;
  justify-content:space-between;
  padding:14px 16px;
  background:rgba(11,12,16,.85);
  backdrop-filter: blur(10px);
  border-bottom:1px solid var(--border);
}

.brand .title{font-size:18px; font-weight:700; letter-spacing:.3px}
.brand .subtitle{font-size:12px; color:var(--muted)}

.controls{
  display:flex;
  gap:12px;
  align-items:end;
  flex-wrap:wrap;
}

.field{display:flex; flex-direction:column; gap:6px; font-size:12px; color:var(--muted)}
.field select,.field input,.field textarea{
  font:inherit;
  color:var(--text);
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:10px;
  padding:10px 12px;
  min-width:180px;
  outline:none;
}
.field textarea{min-width:min(560px, 70vw); resize:vertical}

.btn{
  border:1px solid var(--border);
  background:linear-gradient(180deg, #1b2230 0%, #121826 100%);
  color:var(--text);
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
  box-shadow:var(--shadow);
}
.btn:hover{border-color:#3a4252}
.btn:active{transform: translateY(1px)}
.btn--ghost{background:transparent; box-shadow:none}

.segmented{
  display:flex;
  border:1px solid var(--border);
  border-radius:12px;
  overflow:hidden;
  background:var(--panel2);
}
.segmented__btn{
  border:0;
  background:transparent;
  color:var(--muted);
  padding:10px 12px;
  cursor:pointer;
}
.segmented__btn.is-active{
  color:var(--text);
  background:#182033;
}

.content{padding:16px}
.panel{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  overflow:hidden;
}
.panel.is-hidden{display:none}

.table-wrap{
  width:100%;
  overflow:auto;
  max-height: calc(100vh - 120px);
}

table{
  border-collapse:separate;
  border-spacing:0;
  width:max-content;
  min-width:100%;
  font-size:12px;
}
thead th{
  position:sticky;
  top:0;
  z-index:3;
  background:rgba(18,20,26,.98);
  backdrop-filter: blur(8px);
  border-bottom:1px solid var(--border);
}
th, td{
  padding:8px 10px;
  border-right:1px solid var(--border);
  border-bottom:1px solid var(--border);
  white-space:nowrap;
}
tbody tr:hover td{background:#141a28}

th.sticky-col, td.sticky-col{
  position:sticky;
  left:0;
  z-index:2;
  background:rgba(18,20,26,.98);
  border-right:1px solid var(--border);
}
thead th.sticky-col{z-index:4}

.badge{
  font-family:var(--mono);
  font-size:11px;
  padding:2px 8px;
  border:1px solid var(--border);
  border-radius:999px;
  color:var(--muted);
}

.concert{
  padding:16px;
}
.concert h2{margin:0 0 6px 0}
.concert .meta{color:var(--muted); font-size:13px; margin-bottom:12px}
.concert ol{
  margin:0;
  padding-left:20px;
  columns:2;
  column-gap:32px;
}
@media (max-width: 900px){
  .concert ol{columns:1}
}

dialog::backdrop{background:rgba(0,0,0,.55)}
.dialog{
  width:min(820px, 92vw);
  background:var(--panel);
  color:var(--text);
  border:1px solid var(--border);
  border-radius:16px;
  box-shadow:var(--shadow);
  padding:0;
}
.dialog__header{padding:16px 16px 0 16px}
.dialog__header h2{margin:0 0 6px 0}
.dialog__header p{margin:0; color:var(--muted)}
.dialog__body{padding:16px}
.dialog__footer{
  padding:0 16px 16px 16px;
  display:flex;
  justify-content:flex-end;
  gap:10px;
}
.hint{color:var(--muted); font-size:12px}


/* Vertical concert headers (Excel-like) */
th.concert-header{
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  text-align: left;
  vertical-align: bottom;
  height: 220px;
  min-width: 34px;
  padding: 8px 6px;
}
th.concert-header .hdr{
  font-weight: 700;
  letter-spacing: .2px;
}

/* --- Tighter spreadsheet columns --- */
table td{
  min-width: 26px;
  text-align: center;
}

/* --- Improve header separation from first row --- */
thead th{
  padding-bottom: 14px;
  border-bottom: 2px solid var(--border);
}

/* --- Narrow vertical headers --- */
th.concert-header{
  min-width: 26px;
  height: 200px;
  padding: 6px 4px;
}


/* ===============================
   FINAL OVERRIDES (force layout)
   =============================== */

/* Make all concert columns narrower */
table td:not(.sticky-col),
table th.concert-header {
  width: 24px;
  min-width: 24px;
  max-width: 24px;
  padding-left: 4px;
  padding-right: 4px;
  text-align: center;
}

/* Ensure header row has its own space */
thead tr {
  height: 230px;
}

/* Prevent header from visually covering first data row */
thead th {
  padding-bottom: 18px;
  box-shadow: inset 0 -1px 0 var(--border);
}

/* Extra separation between header and body */
tbody tr:first-child td {
  padding-top: 10px;
}

/* Slightly tighter number rendering */
tbody td {
  font-size: 12px;
}


/* ===============================
   Song column sizing (fix)
   =============================== */

/* Song column: size to content, but cap it */
th.sticky-col,
td.sticky-col {
  width: auto !important;
  min-width: 180px;
  max-width: 320px;
  white-space: nowrap;
}

/* Ensure concert columns stay narrow */
table td:not(.sticky-col),
table th.concert-header {
  width: 24px !important;
  min-width: 24px !important;
  max-width: 24px !important;
}


/* ===============================
   Table sizing: do NOT stretch song column
   =============================== */

/* Let the table be only as wide as its content.
   (Previously min-width:100% caused the song column to expand when there are few concerts.) */
table{
  width: max-content !important;
  min-width: 0 !important;
}

/* Keep the scroll container full width so it still looks nice */
.table-wrap{
  width: 100%;
}

/* Song column: shrink to content (but with a small safety min) */
th.sticky-col,
td.sticky-col{
  min-width: 140px !important;
  max-width: 260px !important;
  width: max-content !important;
}


/* ===============================
   Gridline fixes (missing borders)
   =============================== */

/* Draw an outer border so the last column/row always has a visible line */
table{
  outline: 1px solid var(--border);
  outline-offset: -1px;
}

/* Ensure last column keeps its right border (some browsers can drop it with max-content) */
table tr > *:last-child{
  border-right: 1px solid var(--border) !important;
}

/* Ensure a crisp line between header and first body row */
thead th{
  border-bottom: 1px solid var(--border) !important;
  box-shadow: none !important; /* avoid weird gaps */
}
tbody tr:first-child td{
  border-top: 1px solid var(--border) !important;
}


/* Ensure visible right edge after last column (header too) */
.table-wrap{
  padding-right: 2px; /* prevents last border from being clipped */
}

table{
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

thead tr th:last-child{
  border-right: 1px solid var(--border) !important;
}

/* Edit button disabled state */
button:disabled{
  opacity: .45;
  cursor: not-allowed;
}

/* ===============================
   Dashboard
   =============================== */
.dashboard{ padding: 16px; }
.grid{ display:grid; grid-template-columns:repeat(12,1fr); gap:12px; }
.card{
  background: rgba(15,17,22,.65);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
}
.card h3{ margin:0 0 10px 0; font-size:14px; }
.kpi{ display:flex; flex-direction:column; gap:6px; }
.kpi .value{ font-size:28px; font-weight:800; letter-spacing:.2px; }
.kpi .label{ color: var(--muted); font-size:12px; }
.span-3{ grid-column: span 3; }
.span-6{ grid-column: span 6; }
.span-12{ grid-column: span 12; }
@media (max-width: 1100px){ .span-3,.span-6{ grid-column: span 12; } }
.donut-wrap{ display:flex; gap:14px; align-items:center; }
.legend{ display:flex; flex-direction:column; gap:6px; font-size:12px; color: var(--muted); }
.legend .item{ display:flex; justify-content:space-between; gap:10px; }
.legend .name{ color: var(--text); }
.table-mini{ width:100%; border-collapse:separate; border-spacing:0; font-size:12px; }
.table-mini td,.table-mini th{ padding:8px 10px; border-bottom:1px solid var(--border); }
.table-mini th{ text-align:left; color: var(--muted); font-weight:600; }
.small{ color: var(--muted); font-size:12px; margin-top:6px; }
textarea.codebox{
  width:100%;
  font-family: var(--mono);
  font-size: 11px;
  background:#0f1116;
  color: var(--text);
  border:1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}


/* ===============================
   Dashboard v2 layout tweaks
   =============================== */
.kpi-row{
  display:flex;
  gap:12px;
  flex-wrap:wrap;
}
.kpi-chip{
  flex: 1 1 180px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(15,17,22,.35);
}
.kpi-chip .value{ font-size: 22px; font-weight: 800; line-height: 1.1; }
.kpi-chip .label{ color: var(--muted); font-size: 11px; margin-top: 2px; }

/* Donut legend: show all items but keep card tidy */
.legend{
  max-height: 180px;
  overflow:auto;
  padding-right: 6px;
}

/* Tables: make headers compact and size columns to content */
.table-mini{
  width: max-content;
  min-width: 100%;
  table-layout: auto;
}
.table-mini th, .table-mini td{
  padding: 6px 10px;
  line-height: 1.15;
  vertical-align: top;
}
.table-mini th{
  padding-top: 4px;
  padding-bottom: 4px;
}
.table-mini td{
  white-space: nowrap;
}
.table-mini td.wrap{
  white-space: normal;
}


/* ===============================
   Dashboard table polish (v6)
   =============================== */
.table-scroll{
  overflow:auto;
  max-width: 100%;
  border-radius: 12px;
}

.table-mini{
  width: max-content;          /* shrink to content */
  min-width: 100%;             /* but at least fill the card */
  table-layout: auto;
}

.table-mini th{
  padding: 4px 10px;
  line-height: 1.05;
  font-size: 11px;
}

.table-mini td{
  padding: 6px 10px;
  line-height: 1.15;
  font-size: 12px;
}

/* Song column: keep on one line so width follows longest title */
.table-mini td.song,
.table-mini th.song{
  white-space: nowrap;
}

/* Allow long "missing songs" lists to wrap */
.table-mini td.missing{
  white-space: normal;
  max-width: 520px;
}

/* ===============================
   Song list (replaces table)
   =============================== */
.song-list{
  display:flex;
  flex-direction:column;
  gap:6px;
  margin-top: 8px;
}
.song-item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(15,17,22,.35);
}
.song-title{
  font-size: 13px;
  line-height: 1.15;
  white-space: nowrap;
  overflow:hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 64px);
}
.song-count{
  min-width: 44px;
  text-align:center;
  font-weight: 800;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(15,17,22,.55);
}

/* Make table headers extra compact */
.table-mini th{
  padding: 3px 10px !important;
  line-height: 1.0 !important;
}


/* ===============================
   Album coverage table (v9)
   =============================== */
.album-table-wrap{
  overflow-x: auto;
  max-width: 100%;
  border-radius: 12px;
}

table.album-table{
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: auto;
  font-size: 12px;
}

table.album-table th,
table.album-table td{
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

table.album-table th{
  padding-top: 3px;
  padding-bottom: 3px;
  line-height: 1.0;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

table.album-table td.num{
  white-space: nowrap;
  text-align: right;
}

table.album-table td.album{
  white-space: nowrap;
  font-weight: 600;
}

table.album-table td.missing{
  white-space: normal;
  min-width: 320px;
  max-width: 720px;
}

table.album-table thead tr{ height: auto; }

/* ===============================
   Album coverage table tweaks (v10)
   =============================== */
.album-table-wrap{
  overflow-x: auto;
  max-width: 100%;
}

table.album-table{
  width: 100%;
  table-layout: fixed; /* respect column widths */
}

table.album-table th,
table.album-table td{
  overflow: hidden;
  text-overflow: ellipsis;
}

table.album-table td.album{
  text-align: left;
}

table.album-table td.missing{
  text-align: left;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  word-break: normal;
  overflow-wrap: anywhere; /* prevent awkward vertical stacking */
  line-height: 1.25;
}

/* ===============================
   Album coverage table (v11)
   =============================== */
table.album-table col.missing-col { width: 60% !important; }
table.album-table col.album-col { width: 140px !important; }
table.album-table col.num-col { width: 64px !important; }

/* ===============================
   Album coverage sizing (v13)
   =============================== */
table.album-table{
  table-layout: fixed;
  width: 100%;
}
table.album-table col.album-col { width: 200px; }
table.album-table col.num-col { width: 70px; }
table.album-table col.pct-col { width: 80px; }
table.album-table col.missing-col { width: auto; }

table.album-table th, table.album-table td{
  overflow: visible;
  text-overflow: clip;
}
table.album-table td.album{
  white-space: nowrap;
}
table.album-table td.num{
  white-space: nowrap;
  text-align: right;
}
table.album-table td.missing{
  white-space: normal;
  overflow-wrap: anywhere;
}

/* ===============================
   Wider album column (v14)
   =============================== */
table.album-table col.album-col { width: 260px; }
table.album-table col.pct-col { width: 90px; }

/* ===============================
   Album coverage table sizing (v15)
   =============================== */
table.album-table col.album-col { width: 320px; }
table.album-table col.num-col { width: 72px; }
table.album-table col.pct-col { width: 90px; }
table.album-table td.album { white-space: nowrap; }
table.album-table th { white-space: nowrap; }
table.album-table td.missing { overflow-wrap: normal; word-break: normal; }

/* ===============================
   Layout: let dashboard use the available width (v16)
   =============================== */
.container, .app, .main, .content{
  max-width: none !important;
  width: 100% !important;
}

.dashboard{
  width: 100%;
}

/* Album table: use more of the horizontal space */
table.album-table col.album-col { width: 360px; }
table.album-table col.num-col { width: 84px; }
table.album-table col.pct-col { width: 110px; }
table.album-table col.missing-col { width: auto; }

/* Missing songs: keep words intact and wrap by commas/spaces */
table.album-table td.missing{
  overflow-wrap: normal;
  word-break: keep-all;
  hyphens: none;
  line-height: 1.25;
}

/* Reduce visual heaviness a bit */
table.album-table th, table.album-table td{
  border-bottom: 1px solid rgba(255,255,255,0.10);
}

/* ===============================
   Album coverage: readable widths (v18)
   =============================== */
.album-table-wrap{
  overflow-x: auto;
  max-width: 100%;
}

table.album-table{
  width: 100%;
  min-width: 980px;          /* ensure the missing-songs column has room */
  table-layout: fixed;       /* stable column sizing */
}

table.album-table th{
  white-space: nowrap;
}

table.album-table td.album{
  white-space: nowrap;
}

table.album-table td.num{
  white-space: nowrap;
  text-align: right;
}

table.album-table td.missing{
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  line-height: 1.25;
}

/* ===============================
   Album coverage table overrides (v19)
   Fix: previous rules used !important and hid colgroup.
   =============================== */
.album-table-wrap{ overflow-x:auto; max-width:100%; }

table.album-table{ 
  width:100%;
  min-width: 1100px; /* give missing-songs room */
  table-layout: fixed !important; /* override older auto !important */
}

table.album-table colgroup{ display: table-column-group !important; }

table.album-table th{ white-space: nowrap; }

table.album-table td.album{ white-space: nowrap; }

table.album-table td.num{ white-space: nowrap; text-align:right; }

table.album-table td.missing{
  white-space: normal;
  overflow-wrap: normal;   /* don't split words */
  word-break: normal;
  hyphens: none;
  line-height: 1.25;
}

/* ===============================
   Album coverage column widths (v20)
   =============================== */
table.album-table{
  table-layout: fixed !important;
}

/* Force colgroup to be honored */
table.album-table colgroup{
  display: table-column-group !important;
}

/* Wider Album and % columns */
table.album-table col.album-col{ width: 190px !important; }
table.album-table col.num-col{ width: 72px !important; }
table.album-table col.pct-col{ width: 90px !important; }
table.album-table col.missing-col{ width: auto !important; }

/* Never clip album/% text */
table.album-table td.album,
table.album-table td.num,
table.album-table th{
  overflow: visible !important;
  text-overflow: clip !important;
  white-space: nowrap !important;
}

/* ===============================
   Album coverage authoritative CSS (v21)
   =============================== */
.album-table-wrap{ overflow-x:auto; max-width:100%; }
table.album-table{
  width: 100% !important;
  min-width: 1100px !important;
  table-layout: fixed !important;
}
table.album-table colgroup{ display: table-column-group !important; }
table.album-table col.album-col{ width: 210px !important; }
table.album-table col.num-col{ width: 78px !important; }
table.album-table col.pct-col{ width: 96px !important; }
table.album-table col.missing-col{ width: auto !important; }

table.album-table th{
  white-space: nowrap !important;
  overflow: visible !important;
  text-overflow: clip !important;
}
table.album-table td.album{
  white-space: nowrap !important;
  overflow: visible !important;
  text-overflow: clip !important;
}
table.album-table td.num{
  white-space: nowrap !important;
  text-align: right !important;
  overflow: visible !important;
  text-overflow: clip !important;
}
table.album-table td.missing{
  white-space: normal !important;
  overflow-wrap: normal !important;
  word-break: normal !important;
  line-height: 1.25;
}

/* ===============================
   Album coverage: handle long album names (v22)
   =============================== */
table.album-table col.album-col{ width: 260px !important; } /* a bit wider default */

/* Album cells: allow 2-line wrap and avoid bleeding into numeric columns */
table.album-table td.album, table.album-table th.album-h{
  white-space: normal !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  max-width: 260px;
  line-height: 1.15;
}

/* Keep numeric columns strict */
table.album-table td.num{ white-space: nowrap !important; overflow: hidden !important; }

/* Keep missing column readable and wrapping */
table.album-table td.missing{ white-space: normal !important; }

/* Import dialog helpers */
.grid-2{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.actions-row{display:flex;align-items:center;gap:10px}
.candidates{display:grid;gap:8px;border:1px solid rgba(255,255,255,.12);border-radius:10px;padding:10px;max-height:260px;overflow:auto}
.candidate{display:flex;gap:10px;align-items:flex-start;padding:8px;border-radius:10px;background:rgba(255,255,255,.04)}
.candidate input{margin-top:4px}
.candidate__main{display:grid;gap:2px}
.candidate__title{font-weight:600}
.candidate__meta{opacity:.8;font-size:12px}
.preview{border:1px solid rgba(255,255,255,.12);border-radius:10px;padding:10px;max-height:220px;overflow:auto}
.preview h3{margin:0 0 8px 0;font-size:14px}
.preview ol{margin:0;padding-left:20px}

/* Import: song selection with checkboxes */
.import-song-info{margin:10px 0;font-size:13px;opacity:.85}
.import-as{margin:10px 0 6px 0;padding:10px;border:1px solid rgba(255,255,255,.12);border-radius:10px;background:rgba(255,255,255,.02)}
.import-as__detected{font-size:13px;opacity:.85;margin-bottom:8px}
.import-as__row{display:grid;grid-template-columns:18px 1fr minmax(120px,240px);gap:10px;align-items:center;margin:6px 0}
.import-as__select,.import-as__input{width:100%}
.import-as__remember{display:flex;gap:10px;align-items:center;margin-top:8px;font-size:13px;opacity:.9}
.import-song-list{display:grid;gap:6px;border:1px solid rgba(255,255,255,.12);border-radius:10px;padding:10px;max-height:260px;overflow:auto}
.import-song{display:grid;grid-template-columns:18px 42px 1fr;gap:10px;align-items:center;padding:6px 8px;border-radius:8px;background:rgba(255,255,255,.03)}
.import-song input{margin:0}
.import-song__num{opacity:.85;font-variant-numeric:tabular-nums}
.import-song__title{word-break:break-word}
