/* ============================================================
   SlimRadio "Broadcast Dark" Design System
   Phase 8e UI Redesign
   ============================================================ */

:root {
  --bg:          #080c10;
  --surface:     #0f1419;
  --surface-2:   #161d27;
  --border:      #1e2a38;
  --text:        #e8edf2;
  --text-2:      #6b7d8e;
  --text-3:      #3d4f5f;
  --accent:      #e8b84b;
  --accent-dim:  #b8882b;

  --green:   #22c55e;
  --red:     #ef4444;
  --blue:    #60a5fa;
  --orange:  #f59e0b;
  --purple:  #a78bfa;
  --grey:    #6b7d8e;

  --sidebar-width: 220px;
  --font-ui: -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Courier New", monospace;
}

/* ============================================================
   Reset & Base
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-dim);
  text-decoration: underline;
}

h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 20px 0;
  color: var(--text);
  letter-spacing: -0.3px;
}

h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 28px 0 12px 0;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

h3 {
  font-size: 13px;
  font-weight: 600;
  margin: 20px 0 8px 0;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

p {
  margin: 0 0 12px 0;
  color: var(--text);
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 28px 0;
}

code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface-2);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 3px;
  word-break: break-all;
}

strong {
  font-weight: 600;
  color: var(--text);
}

/* ============================================================
   Layout: Sidebar + Main
   ============================================================ */

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 200;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 20px 20px 16px 20px;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.5px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: color 0.15s, background 0.15s;
}

.sidebar-nav a:hover {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}

.sidebar-nav a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(232, 184, 75, 0.07);
}

.sidebar-nav a svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-nav a.active svg {
  opacity: 1;
}

.sidebar-nav .nav-section {
  padding: 16px 20px 4px 20px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-3);
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-footer .user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.sidebar-footer .user-role {
  font-size: 11px;
  color: var(--text-2);
  margin-bottom: 10px;
}

.sidebar-footer a {
  display: block;
  font-size: 12px;
  color: var(--text-2);
  padding: 3px 0;
}

.sidebar-footer a:hover {
  color: var(--text);
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 150;
}

/* Main wrapper */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Mobile header */
.mobile-header {
  display: none;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.mobile-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}

.hamburger {
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}

.hamburger:hover {
  background: var(--surface-2);
}

/* Main content */
.main-content {
  padding: 28px 32px;
  flex: 1;
  max-width: 1200px;
  width: 100%;
}

/* Mobile responsive */
@media (max-width: 767px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .sidebar-overlay {
    display: block;
  }

  .mobile-header {
    display: flex;
  }

  .main-wrapper {
    margin-left: 0;
  }

  .main-content {
    padding: 16px;
  }

  /* Prevent iOS Safari from auto-zooming on input focus (triggers when font-size < 16px) */
  .form-group input[type="text"],
  .form-group input[type="password"],
  .form-group input[type="number"],
  .form-group input[type="file"],
  .form-group select,
  .form-group textarea,
  .filter-form input[type="text"],
  .filter-form select {
    font-size: 16px;
  }
}

/* ============================================================
   Session Warning
   ============================================================ */

#session-warning {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(232, 184, 75, 0.12);
  border-top: 2px solid var(--accent);
  color: var(--accent);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

#session-warning button {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
}

/* ============================================================
   Flash Messages
   ============================================================ */

.flash-messages {
  margin-bottom: 20px;
}

.flash {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 13px;
  border-left: 4px solid;
  opacity: 1;
  transition: opacity 0.4s ease;
}

.flash.fade-out {
  opacity: 0;
}

.flash-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
  opacity: 0.6;
}

.flash-close:hover {
  opacity: 1;
}

.flash-success {
  background: rgba(34, 197, 94, 0.1);
  border-color: var(--green);
  color: #86efac;
}

.flash-success .flash-close {
  color: #86efac;
}

.flash-error {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--red);
  color: #fca5a5;
}

.flash-error .flash-close {
  color: #fca5a5;
}

.flash-warning {
  background: rgba(245, 158, 11, 0.1);
  border-color: var(--orange);
  color: #fcd34d;
}

.flash-warning .flash-close {
  color: #fcd34d;
}

.flash-info {
  background: rgba(96, 165, 250, 0.1);
  border-color: var(--blue);
  color: #93c5fd;
}

.flash-info .flash-close {
  color: #93c5fd;
}

.flash-danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--red);
  color: #fca5a5;
}

.flash-danger .flash-close {
  color: #fca5a5;
}

/* ============================================================
   Status Badges
   ============================================================ */

@keyframes pulse-recording {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* Role badges */
.badge-admin {
  background: rgba(167, 139, 250, 0.2);
  color: var(--purple);
  border: 1px solid rgba(167, 139, 250, 0.3);
}

.badge-editor {
  background: rgba(96, 165, 250, 0.2);
  color: var(--blue);
  border: 1px solid rgba(96, 165, 250, 0.3);
}

.badge-viewer {
  background: rgba(107, 125, 142, 0.2);
  color: var(--grey);
  border: 1px solid rgba(107, 125, 142, 0.3);
}

/* Recording status badges */
.badge-recording {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.3);
  animation: pulse-recording 1.5s ease-in-out infinite;
}

.badge-recorded {
  background: rgba(34, 197, 94, 0.1);
  color: #34d399;
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.badge-ready_to_upload {
  background: rgba(96, 165, 250, 0.15);
  color: var(--blue);
  border: 1px solid rgba(96, 165, 250, 0.3);
}

.badge-recording_failed {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-skipped {
  background: rgba(107, 125, 142, 0.15);
  color: var(--grey);
  border: 1px solid rgba(107, 125, 142, 0.3);
}

.badge-scheduled {
  background: rgba(61, 79, 95, 0.3);
  color: var(--text-3);
  border: 1px solid var(--border);
}

.badge-deleted {
  background: rgba(61, 79, 95, 0.15);
  color: var(--text-3);
  border: 1px solid var(--border);
}

.badge-uploaded {
  background: rgba(34, 197, 94, 0.1);
  color: #34d399;
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.badge-upload_started {
  background: rgba(251, 191, 36, 0.15);
  color: var(--amber);
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.badge-uploading {
  background: rgba(96, 165, 250, 0.15);
  color: var(--blue);
  border: 1px solid rgba(96, 165, 250, 0.3);
  animation: pulse-recording 1.5s ease-in-out infinite;
}

.badge-upload_failed {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Service state badges */
.badge-active {
  background: rgba(52, 211, 153, 0.15);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.4);
}

.badge-inactive {
  background: rgba(107, 125, 142, 0.15);
  color: var(--grey);
  border: 1px solid rgba(107, 125, 142, 0.3);
}

.badge-not-recording {
  background: rgba(107, 125, 142, 0.12);
  color: #8a9bab;
  border: 1px solid rgba(107, 125, 142, 0.25);
}

/* Activity page toolbar */
.activity-toolbar {
  border-radius: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.activity-toolbar .range-or {
  color: var(--text-2);
  font-size: 12px;
}

.activity-toolbar .date-range-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-mono);
  padding: 4px 8px;
  outline: none;
  width: 108px;
}

.activity-toolbar .date-range-input:focus {
  border-color: var(--amber);
}

.activity-toolbar .date-range-input.field-error {
  border-color: var(--red);
}

.activity-date-error {
  color: var(--red);
  font-size: 13px;
  margin: -12px 0 12px;
}

/* Activity page event labels — title case, not all-caps */
.activity-label .badge {
  text-transform: capitalize;
  letter-spacing: 0;
}

/* Badge styles for activity-only event types */
.badge-alert_raised {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.badge-alert_resolved {
  background: rgba(34, 197, 94, 0.15);
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, 0.3);
}
.badge-backup_auto,
.badge-backup_manual,
.badge-backup_prerestore {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

/* Slot enabled slide-toggle */
.slot-toggle {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}
.slot-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.slot-toggle-track {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--surface-3, #3a3f4b);
  border-radius: 10px;
  transition: background 0.2s;
  flex-shrink: 0;
}
.slot-toggle input:checked ~ .slot-toggle-track {
  background: var(--accent);
}
.slot-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.slot-toggle input:checked ~ .slot-toggle-track .slot-toggle-thumb {
  transform: translateX(16px);
}

.badge-failed {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-unknown {
  background: rgba(61, 79, 95, 0.3);
  color: var(--text-3);
  border: 1px solid var(--border);
}

/* Alert severity badges */
.badge-critical {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--orange);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* ============================================================
   Dashboard: Status Banner
   ============================================================ */

.status-banner {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 8px;
  margin-bottom: 24px;
  border: 1px solid;
}

.recording-progress-track {
  flex: 0 0 100%;
  height: 5px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 3px;
  overflow: hidden;
  margin-top: -4px;
  display: flex;
}

.recording-progress-missed {
  height: 100%;
  background: var(--accent);
  flex-shrink: 0;
  width: 0%;
}

.recording-progress-fill {
  height: 100%;
  background: var(--green);
  flex-shrink: 0;
  width: 0%;
  transition: width 1s linear;
}

.status-banner p {
  margin: 0;
  font-size: 13px;
}

.status-active {
  background: rgba(34, 197, 94, 0.08);
  border-color: rgba(34, 197, 94, 0.3);
  color: var(--green);
}

.status-active strong {
  color: var(--green);
  font-size: 15px;
}

.status-active p {
  color: var(--text-2);
  font-size: 15px;
}

.status-active p strong {
  color: #ffffff;
  font-weight: 700;
}

.status-inactive {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--red);
}

.status-inactive strong {
  color: var(--red);
}

.status-inactive p {
  color: var(--text-2);
}

.status-uploading {
  background: rgba(96, 165, 250, 0.08);
  border-color: rgba(96, 165, 250, 0.3);
  color: var(--blue);
}

.status-uploading strong {
  color: var(--blue);
  font-size: 14px;
}

.status-uploading p {
  color: var(--text-2);
  font-size: 14px;
}

/* ============================================================
   Dashboard: Alert Banners
   ============================================================ */

.alert-banner {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 18px;
  border-radius: 8px;
  margin-bottom: 16px;
  border-left: 4px solid;
}

.alert-banner p {
  margin: 4px 0 0 0;
  font-size: 13px;
}

.alert-banner a {
  font-size: 12px;
}

.alert-critical {
  background: rgba(239, 68, 68, 0.1);
  border-color: var(--red);
  color: #fca5a5;
}

.alert-critical strong {
  color: #fca5a5;
}

.alert-warning {
  background: rgba(245, 158, 11, 0.1);
  border-color: var(--orange);
  color: #fcd34d;
}

.alert-warning strong {
  color: #fcd34d;
}

/* ============================================================
   Dashboard: Stats Grid
   ============================================================ */

.stats-grid,
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 8px;
  padding: 16px 20px;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-label {
  font-size: 11px;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ============================================================
   Cards
   ============================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px;
  margin-bottom: 20px;
}

.card h2 {
  margin-top: 0;
}

/* ============================================================
   Services Grid
   ============================================================ */

.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.service-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px;
}

.service-card h2 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 14px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  font-family: var(--font-mono);
}

.service-state {
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 8px;
}

.service-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.service-warning {
  font-size: 11px;
  color: var(--text-3);
  margin: 0;
  font-style: italic;
}

.service-timestamp {
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 14px;
}

/* ============================================================
   Server Health
   ============================================================ */

.server-health {
  margin-top: 36px;
}

.server-health h2 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-2);
  margin-bottom: 16px;
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

.health-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.health-card-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.health-value {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
}

.donut-chart {
  width: 100%;
  height: auto;
  max-width: 120px;
  display: block;
}

.donut-pct {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  fill: var(--text);
}

.health-card-detail {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-2);
  text-align: center;
}

.spark-wrap {
  position: relative;
  width: 100%;
  flex: 1;
  display: flex;
  align-items: stretch;
  gap: 4px;
  min-width: 0;
  min-height: 60px;
}

.spark-chart {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: block;
  overflow: visible;
}

.spark-scale {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-3);
  line-height: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0;
  white-space: nowrap;
}

.health-sub {
  font-size: 11px;
  color: var(--text-2);
  align-self: flex-start;
  font-family: var(--font-mono);
}

.net-rows {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
}

.net-row {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
  min-height: 0;
}

.net-row-label {
  font-size: 11px;
  flex-shrink: 0;
}

.net-spark {
  flex: 1;
  min-width: 0;
  height: 100%;
}

.net-row-value {
  font-size: 10px;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 60px;
  text-align: right;
}

/* ============================================================
   Tables
   ============================================================ */

table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

thead th {
  background: var(--surface);
  color: var(--text-2);
  padding: 9px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  border-top: 1px solid var(--border);
  white-space: nowrap;
}

thead th:first-child {
  border-left: 1px solid var(--border);
  border-radius: 6px 0 0 0;
}

thead th:last-child {
  border-right: 1px solid var(--border);
  border-radius: 0 6px 0 0;
}

tbody tr:nth-child(odd) td {
  background: var(--bg);
}

tbody tr:nth-child(even) td {
  background: var(--surface);
}

tbody tr:hover td {
  background: var(--surface-2);
}

td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

td:first-child {
  border-left: 1px solid var(--border);
}

td:last-child {
  border-right: 1px solid var(--border);
}

tbody tr:last-child td:first-child {
  border-radius: 0 0 0 6px;
}

tbody tr:last-child td:last-child {
  border-radius: 0 0 6px 0;
}

.table-scroll {
  overflow-x: auto;
}

/* Mono data in tables */
td.mono,
td.ts,
td.size {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-2);
}

/* Upcoming schedule — fixed column widths so all date tables align */
table.upcoming-table {
  table-layout: fixed;
  width: 100%;
}
table.upcoming-table th:nth-child(1) { width: 110px; }  /* Time */
table.upcoming-table th:nth-child(2) { width: 190px; }  /* DJ */
table.upcoming-table th:nth-child(3) { width: 220px; }  /* Show */
table.upcoming-table th:nth-child(4) { width: 110px; }  /* Cadence */
table.upcoming-table th:nth-child(5),
table.upcoming-table td:nth-child(5) { padding-left: 105px; } /* Status — nudged right */

/* Dimmed row (non-recordable / cancelled) — dim DJ and Show text only */
tr.row-dimmed td:nth-child(2),
tr.row-dimmed td:nth-child(3) {
  color: var(--text-2);
}

/* Past row on today — dim DJ and Show text only, leave background untouched */
tr.row-past td:nth-child(2),
tr.row-past td:nth-child(3) {
  color: var(--text-2);
}

/* Currently-recording row (upcoming page) */
tr.row-current-show td {
  background: rgba(232, 184, 75, 0.15) !important;
  color: var(--accent);
  font-weight: 600;
}
tr.row-current-show td:first-child {
  border-left: 3px solid var(--accent);
  padding-left: 9px;
}

/* ============================================================
   Schedule Grid
   ============================================================ */

.grid-table {
  min-width: 700px;
  border-collapse: collapse;
}

.grid-table thead th {
  background: var(--accent);
  color: var(--bg);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 10px;
  border: 1px solid var(--accent-dim);
}

.grid-table thead th:first-child {
  background: var(--surface);
  color: var(--text-2);
  border-color: var(--border);
}

.grid-table td.time-label {
  background: var(--surface);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  width: 80px;
  border: 1px solid var(--border);
  padding: 6px 10px;
}

.grid-cell {
  border: 1px solid var(--border);
  padding: 6px 8px;
  font-size: 12px;
  min-width: 100px;
  vertical-align: top;
}

.grid-cell a {
  color: inherit;
  text-decoration: none;
  display: block;
  white-space: pre-line;
}

.grid-cell a:hover {
  text-decoration: underline;
}

.grid-empty {
  background: transparent;
}

.grid-empty-link {
  cursor: pointer;
}

.grid-empty-link:hover {
  background: rgba(232, 184, 75, 0.05);
}

.new-slot-hint {
  color: transparent;
  font-size: 16px;
  line-height: 1;
  user-select: none;
}

.grid-empty-link:hover .new-slot-hint {
  color: var(--text-3);
}

.grid-filled {
  background: var(--surface-2);
  border-left: 3px solid var(--accent) !important;
  color: var(--text);
  font-weight: 500;
}

.grid-filled:hover {
  background: rgba(232, 184, 75, 0.08);
}

.grid-vacant {
  background: var(--surface);
  color: var(--text-3);
  font-style: italic;
  padding: 0;
}

.grid-vacant a {
  display: block;
  padding: 6px 8px;
  min-height: 2em;
}

.grid-vacant:hover {
  background: var(--surface-2);
  color: var(--text-2);
}

.grid-disabled {
  background: var(--bg);
  color: var(--text-3);
}

.grid-disabled a {
  text-decoration: line-through;
  color: var(--text-3);
}

/* Today column & current-time highlights */
th.grid-today-header {
  background: rgba(232, 184, 75, 0.18) !important;
  color: var(--accent);
}

td.grid-today {
  background-color: rgba(232, 184, 75, 0.07) !important;
}

td.grid-today.grid-filled {
  background-color: rgba(232, 184, 75, 0.12) !important;
}

.grid-table td.time-label.grid-current-time {
  color: #ffffff;
  font-weight: 700;
  font-size: 12px;
}

td.grid-current-playing {
  position: relative;
  background: rgba(232, 184, 75, 0.22) !important;
  border-left: 3px solid transparent !important;
}

td.grid-current-playing::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--red);
  animation: pulse-recording 3s ease-in-out infinite;
}

td.grid-current-playing a {
  color: var(--accent) !important;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.2px;
}

td.grid-current-idle {
  position: relative;
  border-left: 3px solid transparent !important;
}

td.grid-current-idle::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--grey);
}

/* ============================================================
   Forms
   ============================================================ */

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.form-group label code {
  text-transform: none;
  letter-spacing: 0;
}

.form-group label:has(+ input[type="checkbox"]),
.form-group label input[type="checkbox"] {
  text-transform: none;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="file"],
.form-group select,
.form-group textarea {
  width: 100%;
  max-width: 420px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus,
.form-group input[type="number"]:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(232, 184, 75, 0.2);
}

.form-group input.field-error,
.form-group input.field-error:focus,
.form-group textarea.field-error,
.form-group textarea.field-error:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

.form-group.cadence-inactive label,
.form-group.cadence-inactive input,
.form-group.cadence-inactive select,
.form-group.cadence-inactive textarea {
  opacity: 0.35;
  pointer-events: none;
}

.form-group input[type="file"] {
  color: var(--text-2);
}

.form-group input[type="file"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(232, 184, 75, 0.2);
}

.form-group textarea {
  resize: vertical;
}

.form-group input[type="checkbox"] {
  accent-color: var(--accent);
  margin-right: 8px;
  width: auto;
}

.form-group select option {
  background: var(--surface-2);
  color: var(--text);
}

.filter-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.filter-form label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-form select,
.filter-form input[type="text"] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 13px;
  padding: 5px 8px;
  outline: none;
  font-family: inherit;
}

.filter-form select:focus,
.filter-form input[type="text"]:focus {
  border-color: var(--accent);
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 16px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn:hover {
  text-decoration: none;
  opacity: 0.9;
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
}

.btn-primary:hover {
  background: var(--accent-dim);
  color: var(--bg);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
  color: var(--text);
}

.btn-danger {
  background: var(--red);
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
  color: #fff;
}

.btn-warning {
  background: var(--orange);
  color: var(--bg);
}

.btn-warning:hover {
  background: #d97706;
  color: var(--bg);
}

.btn-start {
  background: var(--green);
  color: #fff;
}

.btn-start:hover {
  background: #16a34a;
  color: #fff;
}

.btn-stop {
  background: var(--red);
  color: #fff;
}

.btn-stop:hover {
  background: #dc2626;
  color: #fff;
}

.btn-restart {
  background: var(--orange);
  color: var(--bg);
}

.btn-restart:hover {
  background: #d97706;
  color: var(--bg);
}

.btn-small {
  padding: 4px 10px;
  font-size: 11px;
}

.audit-filter-btn.active,
.btn-secondary.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

.btn[disabled],
.btn:disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

/* ============================================================
   Detail List (dl/dt/dd)
   ============================================================ */

.detail-list {
  display: grid;
  grid-template-columns: 185px 1fr;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 24px;
}

.detail-list dt {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}

.detail-list dd {
  font-size: 13px;
  color: var(--text);
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  margin: 0;
  word-break: break-word;
  display: flex;
  align-items: center;
}

.detail-list dt:last-of-type,
.detail-list dd:last-of-type {
  border-bottom: none;
}

/* ============================================================
   Error Box
   ============================================================ */

.error-box {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-left: 4px solid var(--red);
  border-radius: 6px;
  padding: 12px 16px;
  color: #fca5a5;
  font-size: 13px;
  margin-bottom: 20px;
}

.error-box strong {
  color: var(--red);
}

/* ============================================================
   Actions row
   ============================================================ */

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

/* ============================================================
   Pagination
   ============================================================ */

.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  font-size: 13px;
  color: var(--text-2);
}

.pagination a {
  color: var(--accent);
}

/* ============================================================
   Logs Page
   ============================================================ */

.log-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
  border-bottom: none;
  font-size: 13px;
}

.log-toolbar label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.log-toolbar select,
.log-toolbar input[type="checkbox"] {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 13px;
  padding: 4px 8px;
  outline: none;
  font-family: inherit;
}

.log-output {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-2);
  max-height: 600px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

.log-count {
  font-size: 14px;
  color: var(--text-3);
  padding: 8px 0 4px 0;
}

.log-ts   { color: #6b7e99; }
.log-host { color: #4a5a6e; }
.log-proc { color: #7a8fa8; }
.log-msg  { color: #c8d4e0; }
.log-error { color: #f87171; font-weight: 600; }
.log-warn  { color: var(--amber); }

/* ============================================================
   Text utility classes
   ============================================================ */

.text-critical {
  color: var(--red);
  font-weight: 600;
}

.text-warning {
  color: var(--orange);
  font-weight: 600;
}

.text-muted {
  color: var(--text-2);
}

.text-mono {
  font-family: var(--font-mono);
}

/* ============================================================
   Upcoming: override labels
   ============================================================ */

.label-cancelled {
  color: var(--red);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.label-substitute {
  color: var(--orange);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ============================================================
   Login Page
   ============================================================ */

body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
}

.login-box {
  background: var(--surface);
  padding: 36px 40px;
  border-radius: 10px;
  width: 100%;
  max-width: 380px;
  border: 1px solid var(--border);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.login-logo {
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}

.login-subtitle {
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 28px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.login-box .btn-primary {
  width: 100%;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
}

.login-box .form-group input[type="text"],
.login-box .form-group input[type="password"] {
  max-width: 100%;
}

/* ============================================================
   Back links
   ============================================================ */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 20px;
}

.back-link:hover {
  color: var(--text);
}

/* ============================================================
   Disk usage
   ============================================================ */

.disk-section {
  margin-bottom: 24px;
}

.free-space {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-2);
}

/* ============================================================
   Disk Usage: Collapsible Rows
   ============================================================ */

/* Caret header cell — narrow, no padding needed */
.disk-caret-th {
  width: 28px;
  padding: 0 !important;
}

/* Summary rows are clickable */
.disk-summary-row {
  cursor: pointer;
}

.disk-summary-row:hover td {
  background: rgba(232, 184, 75, 0.06) !important;
}

/* Caret cell */
.disk-caret {
  width: 28px;
  text-align: center;
  font-size: 10px;
  color: var(--text-3);
  user-select: none;
  transition: color 0.15s;
  padding: 9px 4px !important;
}

.disk-summary-row:hover .disk-caret {
  color: var(--accent);
}

/* Rotate caret when expanded — use CSS content swap */
.disk-summary-row.expanded .disk-caret {
  color: var(--accent-dim);
}

/* Detail row attaches visually to its summary row — direct child only, not inner table cells */
.disk-detail-row > td {
  border-top: none !important;
  padding: 0 0 8px 0 !important;
  background: var(--bg) !important;
}

/* Outer disk usage summary table — explicit width so fixed layout enforces column widths */
.disk-outer-table {
  table-layout: fixed;
  width: 738px;
}

/* Status and Files column widths; total 28+490+96+80+44 = 738px matches table width exactly */
/* Use > thead > tr > th to avoid affecting nested inner tables */
.disk-outer-table > thead > tr > th:nth-child(2) { width: 490px; }
.disk-outer-table > thead > tr > th:nth-child(3) { width: 96px; }

/* Nested file table */
.disk-detail-table {
  table-layout: fixed;
  width: calc(100% - 28px);
  margin-left: 28px;
  font-size: 12px;
  border-collapse: collapse;
}

.disk-detail-table thead th {
  font-size: 10px;
  padding: 5px 10px;
  color: var(--text-3);
  background: var(--bg) !important;
  border-top: none !important;
  border-left: none !important;
  border-right: none !important;
}

.disk-detail-table thead th:first-child {
  border-left: none !important;
  border-radius: 0 !important;
}

.disk-detail-table thead th:last-child {
  border-right: none !important;
  border-radius: 0 !important;
}

.disk-detail-table tbody tr:nth-child(odd) td {
  background: var(--bg);
}

.disk-detail-table tbody tr:nth-child(even) td {
  background: var(--surface);
}

.disk-detail-table td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12px;
}

.disk-detail-table td:first-child {
  border-left: none !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


.disk-detail-table td:last-child {
  border-right: none !important;
}

.disk-detail-table tbody tr:last-child td:first-child,
.disk-detail-table tbody tr:last-child td:last-child {
  border-radius: 0 !important;
}

/* Deleted file row */
.disk-file-deleted {
  opacity: 0.45;
  text-decoration: line-through;
}

.disk-file-deleted td {
  text-decoration: line-through;
}

/* "Deleted" badge for orphan files */
.badge-deleted-file {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-family: var(--font-mono);
  white-space: nowrap;
  background: rgba(107, 125, 142, 0.15);
  color: var(--grey);
  border: 1px solid rgba(107, 125, 142, 0.3);
  margin-left: 6px;
  vertical-align: middle;
}

/* Fixed-width Size (MB) column — shared between outer summary table and inner detail table */
.disk-col-size {
  width: 80px;
  white-space: nowrap;
  text-align: right;
  box-sizing: border-box;
}

/* Actions column — same fixed width in both outer and inner tables for alignment */
.disk-col-actions {
  width: 44px;
  text-align: center;
  box-sizing: border-box;
}

/* Kebab (⋮) actions button for orphan file rows */
.disk-actions-wrap {
  position: relative;
  display: inline-block;
}

.disk-actions-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: 4px;
  padding: 1px 9px 3px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  font-family: var(--font-ui);
  transition: background 0.15s, color 0.15s;
}

.disk-actions-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.disk-actions-menu {
  position: absolute;
  top: calc(100% + 3px);
  right: 0;
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 200px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.disk-actions-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 14px;
  font-size: 12px;
  font-family: var(--font-ui);
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.1s;
  box-sizing: border-box;
}

.disk-actions-item + .disk-actions-item {
  border-top: 1px solid var(--border);
}

.disk-actions-item:hover {
  background: var(--surface-2);
}

.disk-actions-item-danger {
  color: var(--red) !important;
}

.disk-actions-item-danger:hover {
  background: rgba(239, 68, 68, 0.1) !important;
}

.disk-actions-item-muted {
  color: var(--text-3) !important;
  cursor: default;
  font-style: italic;
}

/* Assign form — lives inside the actions dropdown */
.assign-orphan-form {
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
}

.assign-orphan-form select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
  padding: 3px 6px;
  outline: none;
  font-family: inherit;
  box-sizing: border-box;
}

.assign-orphan-form select:focus {
  border-color: var(--accent);
}

.assign-status.success {
  color: var(--green);
}

.assign-status.error {
  color: var(--red);
}

/* ============================================================
   404 / Error pages
   ============================================================ */

.error-page {
  padding: 60px 0;
  text-align: center;
}

.error-page h1 {
  font-size: 32px;
  color: var(--text-3);
  margin-bottom: 12px;
}

.error-page p {
  color: var(--text-2);
}

/* ============================================================
   Tab bar (Activity page and similar two-tab layouts)
   ============================================================ */

.tab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.tab {
  display: inline-block;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  border-radius: 6px 6px 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  margin-bottom: -1px;
  transition: color 0.15s, background 0.15s;
}

.tab:hover {
  color: var(--text-1);
  background: var(--surface-2);
}

.tab-active {
  color: var(--text-1);
  background: var(--surface-1);
  border-color: var(--border);
  border-bottom-color: var(--surface-1);
}

/* ============================================================
   Activity page event badges
   ============================================================ */

.badge-alert_raised {
  background: rgba(245, 158, 11, 0.15);
  color: var(--orange);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-alert_resolved {
  background: rgba(34, 197, 94, 0.1);
  color: #34d399;
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.badge-backup_auto,
.badge-backup_manual,
.badge-backup_prerestore {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.3);
}
