:root {
  --bg: #f6f6f4;
  --bg-card: #ffffff;
  --bg-subtle: #fafaf8;
  --tag-bg: #f0f0ec;
  --border: #e8e8e4;
  --text: #16161a;
  --text-dim: #8c8c8c;
  --accent: #e4002b;
  --accent-dim: #a3001f;
  --green: #2ecc71;
  --green-text: #1a9850;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}
.hidden { display: none !important; }
a { color: var(--accent); }
img { max-width: 100%; display: block; }

/* ---------- Buttons & inputs ---------- */
.btn {
  font-size: 0.9rem;
  padding: 0.55rem 1.1rem;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  transition: opacity 0.15s ease;
}
.btn:hover { opacity: 0.85; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-small { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-block { width: 100%; }

input[type="text"], input[type="search"], input[type="email"], input[type="password"], input[type="date"], select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  font-size: 0.9rem;
  color-scheme: light;
  font-family: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
.search-input { min-width: 220px; flex: 1 1 220px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin: 1rem 0 1.25rem;
}
.date-range {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
}
.date-range label { font-size: 0.75rem; color: var(--text-dim); display: flex; align-items: center; gap: 0.35rem; }
.tz-note { font-size: 0.78rem; color: var(--text-dim); }

/* ---------- Splash page ---------- */
#splash { display: flex; flex-direction: column; min-height: 100vh; }
.splash-topbar { display: flex; justify-content: flex-end; gap: 0.6rem; padding: 1.2rem 1.5rem; }
.splash-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 1rem;
}
.splash-title {
  font-size: clamp(2.5rem, 9vw, 5rem);
  font-weight: 800;
  letter-spacing: 0.05em;
  margin: 0;
  color: var(--text);
}
.splash-title span { color: var(--accent); }
.splash-tagline { color: var(--text-dim); font-size: 1.1rem; margin: 0.75rem 0 2.5rem; }
.splash-stats { display: flex; flex-wrap: wrap; gap: 1.5rem; justify-content: center; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 2rem;
  min-width: 160px;
}
.stat-value { font-size: 2rem; font-weight: 800; color: var(--accent); min-height: 2.4rem; }
.stat-value.loading {
  width: 70%; height: 1.7rem; margin: 0.35rem auto 0; border-radius: 6px;
  background: linear-gradient(90deg, var(--tag-bg) 25%, var(--bg-subtle) 50%, var(--tag-bg) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.4s ease-in-out infinite;
}
@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.stat-label { color: var(--text-dim); font-size: 0.85rem; margin-top: 0.25rem; text-transform: uppercase; letter-spacing: 0.04em; }

/* ---------- Pending-approval screen ---------- */
#pending-screen { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 2rem 1rem; }
.pending-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 2.5rem; max-width: 420px; text-align: center;
}
.pending-card h2 { margin: 0 0 0.75rem; color: var(--text); }
.pending-card p { color: var(--text-dim); font-size: 0.92rem; line-height: 1.5; margin: 0 0 1.5rem; }
.pending-card .btn { margin: 0 0.25rem; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 1rem; overflow-y: auto;
}
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  width: 100%; max-width: 380px;
  position: relative;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
}
.modal-box.modal-wide { max-width: 460px; }
.modal-close {
  position: absolute; top: 0.75rem; right: 0.9rem;
  background: none; border: none; color: var(--text-dim);
  font-size: 1.4rem; cursor: pointer; line-height: 1;
}
.modal-tabs { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; }
.modal-tab {
  flex: 1; background: none; border: 1px solid var(--border); color: var(--text-dim);
  padding: 0.5rem; border-radius: 6px; cursor: pointer; font-weight: 600;
}
.modal-tab.active { border-color: var(--accent); color: #fff; background: var(--accent-dim); }
#auth-form, #account-form { display: flex; flex-direction: column; gap: 0.9rem; }
#auth-form label, #account-form label { font-size: 0.8rem; color: var(--text-dim); display: flex; flex-direction: column; gap: 0.3rem; }
.form-row { display: flex; gap: 0.75rem; }
.form-row > label { flex: 1; }
.checkbox-row { flex-direction: row !important; align-items: center; gap: 0.5rem !important; }
.checkbox-row input { width: auto; }
.auth-error { color: var(--accent); font-size: 0.85rem; }
.auth-info { color: var(--green-text); font-size: 0.85rem; }
.form-divider { border: none; border-top: 1px solid var(--border); margin: 0.25rem 0; }

/* ---------- Navbar ---------- */
.navbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.75rem;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky; top: 0; z-index: 50;
}
.nav-logo { font-weight: 800; letter-spacing: 0.04em; font-size: 1.1rem; color: var(--text); }
.nav-links { display: flex; gap: 0.4rem; }
.nav-link {
  background: none; border: none; color: var(--text-dim);
  padding: 0.5rem 0.9rem; border-radius: 6px; cursor: pointer; font-size: 0.9rem; font-weight: 600;
}
.nav-link.active { color: #fff; background: var(--accent-dim); }
.nav-right { display: flex; align-items: center; gap: 0.6rem; }
.user-name { color: var(--text); font-size: 0.85rem; font-weight: 600; }

main { padding: 1.25rem 1.5rem 3rem; max-width: 1400px; margin: 0 auto; }
.page-section { display: none; }
.page-section.active { display: block; }

/* ---------- Pills (network/station badges) ---------- */
.tag {
  display: inline-block; font-size: 0.68rem; font-weight: 700;
  padding: 0.2rem 0.6rem; border-radius: 999px; white-space: nowrap;
  background: var(--tag-bg); color: var(--text-dim);
}
.station-card .tag { margin-bottom: 0.4rem; }

/* ---------- Stations grid ---------- */
.stations-grid, .artists-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1rem;
}
.station-card, .artist-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.station-card-top { display: flex; gap: 0.75rem; align-items: center; }
.station-card-info { display: flex; flex-direction: column; gap: 0.4rem; min-width: 0; }
.station-logo, .logo-placeholder {
  width: 56px; height: 56px; border-radius: 8px; object-fit: cover; flex-shrink: 0;
}
.logo-placeholder {
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.95rem; color: #fff; background: var(--accent);
}
.station-name { font-weight: 700; font-size: 0.95rem; color: var(--text); }

.live-btn {
  display: flex; align-items: center; gap: 0.4rem; width: fit-content; padding: 0.25rem 0.65rem;
  border-radius: 999px; border: 1px solid var(--border); background: var(--bg-card);
  cursor: pointer; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; color: var(--green-text);
}
.live-btn:hover { background: var(--bg-subtle); }
.live-btn:disabled { cursor: default; opacity: 0.5; }
.live-btn:disabled:hover { background: var(--bg-card); }
.live-btn.playing { background: var(--accent); border-color: var(--accent); color: #fff; }
.live-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 0 0 rgba(46,204,113,0.6);
  animation: pulse 1.6s infinite;
}
.live-btn.playing .live-dot, .live-btn:disabled .live-dot { animation: none; background: rgba(255,255,255,0.6); }
.live-btn:disabled .live-dot { background: var(--text-dim); }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(46,204,113,0.6); }
  70%  { box-shadow: 0 0 0 7px rgba(46,204,113,0); }
  100% { box-shadow: 0 0 0 0 rgba(46,204,113,0); }
}
.last-played { display: flex; gap: 0.6rem; align-items: center; margin-top: 0.6rem; border-top: 1px solid var(--border); padding-top: 0.6rem; }
.last-played img, .last-played .art-placeholder {
  width: 38px; height: 38px; border-radius: 5px; object-fit: cover; flex-shrink: 0; background: var(--tag-bg);
}
.last-played .art-placeholder { display: flex; align-items: center; justify-content: center; font-size: 1.05rem; color: var(--text-dim); }
.last-played-text { font-size: 0.8rem; line-height: 1.3; min-width: 0; overflow: hidden; }
.last-played-text .lp-artist { color: var(--text-dim); }
.last-played-text .lp-title { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Artists grid ---------- */
.artist-card { text-align: center; cursor: pointer; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.artist-card:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgba(0,0,0,0.06); }
.artist-photo, .artist-placeholder {
  width: 90px; height: 90px; border-radius: 8px; object-fit: cover; margin: 0 auto 0.6rem;
}
.artist-placeholder { display: flex; align-items: center; justify-content: center; background: var(--accent-dim); font-weight: 800; font-size: 1.4rem; color: #fff; }
.artist-card-name { font-weight: 700; font-size: 0.9rem; color: var(--text); }

/* ---------- Logs page ---------- */
.logs-layout { display: flex; gap: 1.25rem; align-items: flex-start; }
.logs-sidebar {
  width: 230px; flex-shrink: 0; background: var(--bg-card);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.75rem;
}
.logs-sidebar .all-stations-item, .logs-sidebar .station-item {
  display: block; width: 100%; text-align: left; background: none; border: none;
  color: var(--text-dim); padding: 0.4rem 0.5rem; border-radius: 5px; cursor: pointer; font-size: 0.85rem;
}
.logs-sidebar .all-stations-item { font-weight: 700; color: var(--text); margin-bottom: 0.4rem; }
.logs-sidebar .station-item:hover { background: var(--bg-subtle); }
.logs-sidebar .station-item.active { background: var(--accent-dim); color: #fff; }
.network-group { margin-bottom: 0.6rem; }
.network-title { padding: 0.4rem 0.5rem 0.3rem; }
.network-title .tag { font-size: 0.66rem; }
.logs-main { flex: 1; min-width: 0; }
.logs-filter-label { font-size: 0.85rem; color: var(--text-dim); margin-bottom: 0.5rem; }

.log-groups { display: flex; flex-direction: column; gap: 1.75rem; }
.log-empty { color: var(--text-dim); padding: 2.5rem 0; text-align: center; }
.hour-heading {
  display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.55rem;
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.03em; color: var(--text-dim);
}
.hour-heading > span:first-child { text-transform: uppercase; }
.hour-line { flex: 1; height: 1px; background: var(--border); }
.hour-count { background: var(--tag-bg); color: var(--text-dim); border-radius: 999px; padding: 0.15rem 0.6rem; font-size: 0.68rem; font-weight: 700; }

.table-wrap { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-card); }
table.log-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 0.85rem; }
table.log-table th, table.log-table td { padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--border); text-align: left; overflow: hidden; }
/* Fixed column widths (same on every table/station) so every hour block lines up identically. */
table.log-table th:nth-child(1), table.log-table td:nth-child(1) { width: 8%; }
table.log-table th:nth-child(2), table.log-table td:nth-child(2) { width: 9%; }
table.log-table th:nth-child(3), table.log-table td:nth-child(3) { width: 21%; }
table.log-table th:nth-child(4), table.log-table td:nth-child(4) { width: 23%; }
table.log-table th:nth-child(5), table.log-table td:nth-child(5) { width: 13%; }
table.log-table th:nth-child(6), table.log-table td:nth-child(6) { width: 16%; }
table.log-table th:nth-child(7), table.log-table td:nth-child(7) { width: 10%; }
table.log-table th { color: var(--text-dim); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em; background: var(--bg-subtle); white-space: nowrap; }
table.log-table td.td-time, table.log-table td.td-duration { white-space: nowrap; }
table.log-table td.td-artist, table.log-table td.td-title { white-space: normal; word-break: break-word; }
table.log-table tr:last-child td { border-bottom: none; }
table.log-table tbody tr:hover { background: var(--bg-subtle); }
table.log-table .tag { white-space: normal; word-break: break-word; }
/* Station name always shows in full on one line — never wraps, never truncates. */
table.log-table td.td-station { overflow: visible; }
table.log-table td.td-station .tag { display: inline-block; white-space: nowrap; word-break: normal; }
.td-artist, .td-title { color: var(--text); }
.art-wrap { position: relative; width: 36px; height: 36px; flex-shrink: 0; display: inline-block; }
.row-art, .row-art-placeholder { width: 36px; height: 36px; border-radius: 5px; object-fit: cover; background: var(--tag-bg); display: block; }
.row-art-placeholder { display: flex; align-items: center; justify-content: center; font-size: 1rem; color: var(--text-dim); }
.preview-btn {
  position: absolute; right: -4px; bottom: -4px; width: 18px; height: 18px; border-radius: 50%;
  border: none; background: #16161a; color: #fff; font-size: 9px; line-height: 1; padding: 0;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.35);
}
.preview-btn.playing { background: var(--accent); }

#logs-load-more { margin-top: 1.25rem; }

/* ---------- Artist inline detail (expands under the clicked card) ---------- */
.artist-card.active { border-color: var(--accent); box-shadow: 0 2px 10px rgba(0,0,0,0.06); }
.artist-detail-row {
  grid-column: 1 / -1;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; position: relative; text-align: left;
}
.artist-detail-close { position: absolute; top: 1rem; right: 1.25rem; background: none; border: none; color: var(--text-dim); font-size: 1.6rem; cursor: pointer; line-height: 1; }
.artist-detail-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.25rem; }
.artist-detail-img, .artist-detail-placeholder { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.artist-detail-placeholder { display: flex; align-items: center; justify-content: center; background: var(--accent-dim); font-weight: 800; font-size: 1.2rem; color: #fff; }
.artist-detail-name { color: var(--text); margin: 0; }

/* ---------- Audio bar ---------- */
.audio-bar {
  position: fixed; bottom: 0; left: 0; right: 0; background: var(--bg-card);
  border-top: 1px solid var(--border); padding: 0.6rem 1.25rem;
  display: flex; align-items: center; z-index: 60;
  box-shadow: 0 -2px 14px rgba(0,0,0,0.06);
}
.audio-bar-info { display: flex; align-items: center; gap: 0.75rem; max-width: 480px; width: 100%; }
.audio-bar-logo { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; flex-shrink: 0; font-size: 0.8rem; }
.audio-bar-playstop {
  width: 32px; height: 32px; border-radius: 50%; border: none; background: var(--accent); color: #fff;
  font-size: 0.7rem; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.audio-bar-text { min-width: 0; flex: 1; overflow: hidden; }
.audio-bar-station { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em; color: var(--text-dim); text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.audio-bar-track { font-size: 0.85rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.audio-bar-volume { width: 100px; flex-shrink: 0; accent-color: var(--accent); cursor: pointer; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .logs-layout { flex-direction: column; }
  .logs-sidebar { width: 100%; }
  .navbar { padding: 0.75rem 1rem; }
  main { padding: 1rem 1rem 3rem; }
  .form-row { flex-direction: column; }
  table.log-table th, table.log-table td { padding: 0.4rem 0.35rem; font-size: 0.78rem; }
  .art-wrap, .row-art, .row-art-placeholder { width: 26px; height: 26px; }
  .preview-btn { width: 14px; height: 14px; font-size: 7px; }
}
