/* Reset & base */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', Arial, sans-serif; background: #f4f6f9; color: #333; }
a { text-decoration: none; color: inherit; }

/* Layout */
#page-wrapper { display: flex; min-height: 100vh; }
#sidebar-wrapper {
  width: 240px;
  min-height: 100vh;
  background: #30426a;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width 0.3s ease;
  overflow: hidden;
}
#sidebar-wrapper.collapsed { width: 54px; }
#content-wrapper {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s ease;
  min-height: 100vh;
}
#content-wrapper.expanded { margin-left: 54px; }

/* Sidebar header */
.sidebar-brand {
  padding: 16px 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  background: #2d3e63;
  min-height: 64px;
}
.sidebar-brand .brand-icon {
  font-size: 22px;
  color: #e99d1a;
  min-width: 30px;
  text-align: center;
  flex-shrink: 0;
}
.sidebar-brand .brand-text {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-brand .brand-text span { display: block; font-size: 11px; font-weight: 400; color: #aab8d0; }
.sidebar-brand .brand-logo {
  max-width: 100%;
  max-height: 150px;
  height: auto;
  width: auto;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 6px;
}
/* Collapsed sidebar: shrink the logo to the rail width */
#sidebar-wrapper.collapsed .sidebar-brand { padding: 8px 4px; }
#sidebar-wrapper.collapsed .sidebar-brand .brand-logo { max-height: 40px; padding: 2px; }

/* Sidebar nav */
ul.sidebar-nav { list-style: none; flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 0; }
ul.sidebar-nav::-webkit-scrollbar { width: 4px; }
ul.sidebar-nav::-webkit-scrollbar-thumb { background: #4a5e8a; border-radius: 2px; }

ul.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: #c0cfe8;
  font-size: 13px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
}
ul.sidebar-nav li a:hover { background: #2d3e63; color: #fff; }
ul.sidebar-nav li a.active {
  background: #2d3e63;
  color: #fff;
  border-left: 3px solid #e99d1a;
}
ul.sidebar-nav li a .nav-icon {
  font-size: 15px;
  min-width: 20px;
  text-align: center;
  flex-shrink: 0;
}
ul.sidebar-nav li a .nav-label { overflow: hidden; }

.sidebar-divider { height: 1px; background: #3d5180; margin: 6px 0; }

/* Header */
.page-header {
  background: #fff;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e0e6ef;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.page-header .toggle-btn {
  background: none;
  border: none;
  font-size: 18px;
  color: #555;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.page-header .toggle-btn:hover { background: #f0f4fa; color: #30426a; }
.page-header .page-title { font-size: 16px; font-weight: 600; color: #30426a; margin-left: 12px; }
.page-header .header-right { display: flex; align-items: center; gap: 12px; }
.header-badge {
  background: #30426a;
  color: #fff;
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 11px;
}

/* Main content area */
.page-content { padding: 24px; flex: 1; }

#global-banner:empty { display: none; }
.global-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 24px 0;
  padding: 10px 14px;
  background: #fdf1e3;
  border: 1px solid #e6a14e;
  border-left: 4px solid #e6a14e;
  border-radius: 6px;
  color: #8a5a17;
  font-size: 13px;
}
.global-alert code { background: #f6e6cf; padding: 1px 5px; border-radius: 3px; }

.health-card { margin-bottom: 20px; }
.health-meta { font-size: 11px; color: #8a97b3; font-weight: 400; }
.health-stale { color: #9a6520; margin-left: 6px; }
.health-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.health-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 14px;
  border: 1px solid transparent;
}
.health-chip.ok      { background: #e8f6ee; color: #1f8a4c; border-color: #b6e2c6; }
.health-chip.bad     { background: #fdeaea; color: #c0392b; border-color: #f1b9b3; }
.health-chip.unknown { background: #eef1f6; color: #7a8aa8; border-color: #dde3ee; }
.global-alert button {
  margin-left: auto;
  background: none;
  border: none;
  color: #8a5a17;
  cursor: pointer;
  font-size: 14px;
}

/* Cards */
.card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  margin-bottom: 20px;
  overflow: hidden;
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid #eef2f8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.card-header h3 { font-size: 14px; font-weight: 600; color: #30426a; display: flex; align-items: center; gap: 8px; }
.card-header h3 i { color: #e99d1a; }
.card-body { padding: 16px 20px; }

/* Stat cards */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.stat-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-card .stat-icon {
  width: 48px; height: 48px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-card .stat-icon.blue { background: #e8eef9; color: #30426a; }
.stat-card .stat-icon.orange { background: #fdf3e0; color: #e99d1a; }
.stat-card .stat-icon.green { background: #e3f5ea; color: #2eaa5a; }
.stat-card .stat-icon.purple { background: #f0ebfa; color: #7c4dbd; }
.stat-card .stat-icon.teal { background: #e2f5f5; color: #1a9ba1; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; color: #1a2740; line-height: 1; }
.stat-card .stat-label { font-size: 11px; color: #778; margin-top: 2px; text-transform: uppercase; letter-spacing: 0.5px; }

/* ── Analytics ───────────────────────────────────────────────────────────── */
.an-period-btn {
  padding: 4px 12px;
  border: 1px solid #d0d8e8;
  border-radius: 4px;
  background: #fff;
  color: #30426a;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}
.an-period-btn:hover  { background: #f0f4fa; }
.an-period-btn.active { background: #30426a; color: #fff; border-color: #30426a; }

.an-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
@media (max-width: 900px) { .an-grid-2 { grid-template-columns: 1fr; } }

.an-hbar-wrap {
  height: 300px;
  position: relative;
}

.an-heatmap {
  display: grid;
  grid-template-columns: 28px repeat(7, 1fr);
  gap: 2px;
  overflow-x: auto;
}
.an-hm-label {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 18px;
  font-size: 10px;
  color: #778;
}
.an-hm-cell {
  height: 18px;
  border-radius: 2px;
  cursor: default;
  transition: opacity 0.12s;
}
.an-hm-cell:hover { opacity: 0.65; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  background: #f7f9fc;
  color: #30426a;
  font-weight: 600;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 2px solid #e0e6ef;
  white-space: nowrap;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.data-table td { padding: 9px 14px; border-bottom: 1px solid #f0f3f8; vertical-align: middle; }
.data-table tbody tr:hover { background: #f8fafd; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .text-muted { color: #99a; font-size: 12px; }
.data-table .badge {
  display: inline-block;
  background: #e8eef9;
  color: #30426a;
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
}
.data-table .badge.orange { background: #fdf3e0; color: #c07800; }
.data-table .badge.green { background: #e3f5ea; color: #1a7a3a; }
.data-table .badge.red { background: #fceaea; color: #c02020; }
.data-table .badge.gray { background: #eee; color: #666; }

/* Row action buttons */
.row-actions-cell {
  width: 1%;
  white-space: nowrap;
  text-align: right;
  vertical-align: middle;
}
.row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 5px;
  background: transparent;
  font-family: inherit;
  line-height: 1;
  cursor: pointer;
  color: #99a;
  transition: color 0.15s, background 0.15s;
}
.action-btn i { font-size: 13px; pointer-events: none; }

.action-btn.action-play,
.action-btn.action-run { color: #c07800; }
.action-btn.action-play:hover,
.action-btn.action-run:hover { color: #e99d1a; background: #fdf3e0; }

.action-btn.action-edit,
.action-btn.action-merge,
.action-btn.action-muted { color: #99a; }
.action-btn.action-edit:hover,
.action-btn.action-merge:hover,
.action-btn.action-muted:hover { color: #30426a; background: #e8eef9; }

.action-btn.action-delete { color: #c88; }
.action-btn.action-delete:hover { color: #c02020; background: #fceaea; }

.action-btn.shuffle-on { color: #e99d1a; background: #fdf3e0; }

/* Now Playing device rows */
.np-card-header {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #e99d1a;
  margin-bottom: 4px;
}
.np-device-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid #eef0f4;
  flex-wrap: wrap;
}
.np-device-row:first-of-type { border-top: none; padding-top: 0; }

/* Group-aware Now Playing: a parent row with indented member sub-rows */
.np-group {
  border-top: 1px solid #eef0f4;
  padding: 8px 0;
}
.np-group:first-of-type { border-top: none; }
.np-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #30426a;
  padding: 4px 0;
}
.np-group-header .fa-layer-group { color: #7c4dbd; }
.np-group-count { font-size: 11px; font-weight: 600; color: #7c4dbd; background: #f0e9fa; border-radius: 10px; padding: 1px 8px; }
.np-group-track { font-size: 12px; font-weight: 400; color: #8a97b3; margin-left: 4px; }
.np-group-members {
  margin-left: 14px;
  padding-left: 12px;
  border-left: 2px solid #ece6f7;
}
.np-group-members .np-device-row:first-of-type { border-top: none; padding-top: 8px; }

/* Full-width volume slider under each Now Playing device */
.np-volume {
  flex-basis: 100%;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}
.np-volume-icon { color: #9aa; font-size: 13px; flex: 0 0 auto; }
.np-volume-val { flex: 0 0 auto; min-width: 24px; text-align: right; font-size: 12px; color: #9aa; font-variant-numeric: tabular-nums; }
.np-volume-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 5px;
  border-radius: 4px;
  background: #e0e5ee;
  outline: none;
  cursor: pointer;
}
.np-volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #e99d1a;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.np-volume-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #e99d1a;
  cursor: pointer;
  border: 2px solid #fff;
}

/* Device group editor */
.group-dev-list {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid #e3e8f0;
  border-radius: 8px;
  padding: 6px;
}
.group-dev-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.group-dev-option:hover { background: #f4f6fb; }
.group-dev-option input { width: 16px; height: 16px; }
.np-device-main {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  flex: 1;
  min-width: 0;
}
.np-device-icon {
  font-size: 22px;
  color: #e99d1a;
  flex-shrink: 0;
  margin-top: 2px;
}
.np-device-meta { min-width: 0; flex: 1; }
.np-track { font-size: 16px; font-weight: 700; color: #1a2740; word-break: break-word; }
.np-artist { font-size: 13px; color: #30426a; margin-top: 2px; }
.np-album { font-size: 12px; color: #778; margin-top: 1px; word-break: break-word; }
.np-device-label { font-size: 11px; color: #9aa; margin-top: 4px; }
.np-device-paused { opacity: 0.85; }
.np-paused-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #b8860b;
  background: #fff8e6;
  border: 1px solid #f0d78c;
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 6px;
  vertical-align: middle;
}
.np-sleep-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  color: #5b4b9a;
  background: #f0ecfa;
  border: 1px solid #d6cbef;
  border-radius: 4px;
  padding: 1px 6px;
  margin-left: 6px;
  vertical-align: middle;
}
.rt-phrase-box {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 10px 12px;
  background: #f0ecfa;
  border: 1px solid #d6cbef;
  border-radius: 6px;
}
.rt-phrase-box code { flex: 1; font-size: 13px; color: #30426a; }
.sleep-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sleep-opt { width: 100%; }
.np-controls { flex-shrink: 0; }

/* Search bar */
.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.search-bar input {
  flex: 1;
  max-width: 320px;
  padding: 8px 12px 8px 34px;
  border: 1px solid #d0d8e8;
  border-radius: 6px;
  font-size: 13px;
  color: #333;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 10px center;
  outline: none;
  transition: border-color 0.15s;
}
.search-bar input:focus { border-color: #30426a; }
.search-bar .result-count { font-size: 12px; color: #99a; }

/* Pagination */
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid #f0f3f8;
  background: #fafbfd;
  font-size: 12px;
  color: #667;
}
.pagination-bar .page-btns { display: flex; gap: 4px; }
.page-btn {
  padding: 4px 10px;
  border: 1px solid #d0d8e8;
  border-radius: 4px;
  background: #fff;
  color: #30426a;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}
.page-btn:hover { background: #30426a; color: #fff; border-color: #30426a; }
.page-btn.active { background: #30426a; color: #fff; border-color: #30426a; font-weight: 600; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Status badge */
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
}
.status-dot::before {
  content: '';
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
}
.status-dot.scanning::before { background: #e99d1a; }
.status-dot.queued::before { background: #aaa; }
.status-dot.done::before { background: #2eaa5a; }
.status-dot.error::before { background: #e44; }

/* Folder card */
.folder-card {
  border: 1px solid #e0e6ef;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 12px;
  background: #fff;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.folder-card .folder-icon { font-size: 24px; color: #e99d1a; margin-top: 2px; }
.folder-card .folder-info { flex: 1; }
.folder-card .folder-path { font-size: 13px; color: #333; font-weight: 600; word-break: break-all; }
.folder-card .folder-meta { font-size: 12px; color: #667; margin-top: 4px; display: flex; gap: 16px; flex-wrap: wrap; }
.folder-card .folder-meta span { display: flex; align-items: center; gap: 4px; }
.folder-card .folder-label { font-size: 11px; color: #30426a; background: #e8eef9; border-radius: 10px; padding: 2px 8px; display: inline-block; margin-bottom: 4px; font-weight: 600; }

/* Settings form */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.setting-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.setting-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: #778; font-weight: 600; }
.setting-value { font-size: 13px; color: #222; background: #f7f9fc; border-radius: 4px; padding: 6px 10px; border: 1px solid #e8edf5; }

/* Device cards */
.device-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.device-card {
  border: 1px solid #e0e6ef;
  border-radius: 8px;
  padding: 16px;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}
.device-card .device-icon { font-size: 32px; color: #30426a; }
.device-card .device-name { font-size: 13px; font-weight: 600; color: #1a2740; }
.device-card .device-type { font-size: 11px; color: #667; }

/* Loading spinner */
.spinner-wrap { display: flex; justify-content: center; align-items: center; padding: 60px; }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid #e0e6ef;
  border-top-color: #30426a;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; color: #aab; }
.empty-state i { font-size: 48px; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 14px; }

/* Responsive — mobile only (desktop unchanged above 768px) */
@media (max-width: 768px) {
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }

  #page-wrapper {
    max-width: 100vw;
    overflow-x: hidden;
  }

  /* Off-canvas sidebar */
  #sidebar-wrapper {
    width: 240px;
    transform: translateX(-100%);
    transition: transform 0.28s ease;
    box-shadow: none;
  }
  #sidebar-wrapper.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35);
  }
  #sidebar-wrapper.collapsed {
    width: 240px;
    transform: translateX(-100%);
  }
  #sidebar-wrapper.collapsed.mobile-open {
    transform: translateX(0);
  }

  #content-wrapper,
  #content-wrapper.expanded {
    margin-left: 0;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  body.sidebar-open::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(10, 16, 28, 0.45);
    z-index: 99;
  }

  .page-header {
    padding: 8px 12px;
    height: auto;
    min-height: 52px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .page-header .page-title {
    margin-left: 4px;
    font-size: 15px;
    max-width: calc(100vw - 120px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .page-header .header-right {
    gap: 8px;
    max-width: 100%;
  }
  #now-playing-bar {
    max-width: min(220px, 55vw) !important;
    font-size: 11px !important;
    padding: 3px 10px !important;
  }
  .header-badge { display: none; }

  .page-content {
    padding: 12px;
    max-width: 100%;
    overflow-x: hidden;
  }

  .page-desc {
    font-size: 12px;
    padding: 8px 10px;
    word-break: break-word;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .stat-card { padding: 14px; }

  .card { margin-bottom: 14px; max-width: 100%; }
  .card-header {
    padding: 12px 14px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .card-header h3 { font-size: 13px; }
  .card-body { padding: 12px 14px; }

  .search-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    margin-bottom: 10px;
  }
  .search-bar input {
    max-width: none;
    width: 100%;
  }

  .data-table {
    font-size: 12px;
  }
  .data-table th,
  .data-table td {
    padding: 8px 10px;
    white-space: normal;
    word-break: break-word;
  }
  .data-table th {
    font-size: 10px;
  }

  /* Hide low-priority columns on small screens */
  .playlists-table th:nth-child(1),
  .playlists-table td:nth-child(1),
  .playlists-table th:nth-child(3),
  .playlists-table td:nth-child(3),
  .playlists-table th:nth-child(4),
  .playlists-table td:nth-child(4),
  .artists-table th:nth-child(2),
  .artists-table td:nth-child(2),
  .albums-table th:nth-child(3),
  .albums-table td:nth-child(3),
  .songs-table th:nth-child(1),
  .songs-table td:nth-child(1),
  .songs-table th:nth-child(5),
  .songs-table td:nth-child(5),
  .songs-table th:nth-child(6),
  .songs-table td:nth-child(6),
  .songs-table th:nth-child(7),
  .songs-table td:nth-child(7),
  .automation-table th:nth-child(4),
  .automation-table td:nth-child(4),
  .automation-table th:nth-child(5),
  .automation-table td:nth-child(5),
  .np-table th:nth-child(4),
  .np-table td:nth-child(4) {
    display: none;
  }

  .source-path {
    max-width: none;
    white-space: normal;
  }

  .pagination-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 12px;
  }
  .pagination-bar .page-btns {
    flex-wrap: wrap;
    justify-content: center;
  }

  .device-list li {
    flex-wrap: wrap;
    padding: 10px 12px;
  }
  .device-list .device-last-seen {
    width: 100%;
    margin-left: 30px !important;
  }
  .device-list .edit-row {
    flex-wrap: wrap;
    width: 100%;
  }
  .device-list .edit-row input { max-width: none; }

  .settings-input.wide,
  .settings-input { max-width: 100%; min-width: 0; }
  .settings-row { flex-direction: column; align-items: stretch; }
  .settings-row label { min-width: 0 !important; }

  .folder-card {
    flex-direction: column;
    padding: 12px 14px;
  }
  .folder-card .folder-meta { gap: 8px; }

  .modal-box {
    width: calc(100vw - 24px);
    padding: 18px 16px;
  }

  .an-grid-2 { grid-template-columns: 1fr; }
  .an-period-btn { padding: 6px 10px; }

  .row-actions { gap: 8px; }
  .action-btn { width: 32px; height: 32px; }
  .action-btn i { font-size: 14px; }
  .np-device-row { flex-direction: column; align-items: stretch; }
  .np-controls { justify-content: flex-end; }
}

@media (max-width: 480px) {
  .page-header .page-title { max-width: calc(100vw - 96px); }
  #now-playing-bar { display: none !important; }
}

/* Clickable row */
.clickable { cursor: pointer; }
.clickable:hover td { color: #30426a; }

/* Back link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #667;
  margin-bottom: 12px;
  cursor: pointer;
  padding: 4px 0;
}
.back-link:hover { color: #30426a; }

/* Page description */
.page-desc {
  background: #f0f5ff;
  border-left: 3px solid #30426a;
  padding: 10px 14px;
  font-size: 13px;
  color: #445;
  border-radius: 0 4px 4px 0;
  margin-bottom: 16px;
}

/* Device list */
.device-list { list-style: none; }
.device-list li {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid #f0f3f8;
  gap: 10px;
}
.device-list li:last-child { border-bottom: none; }
.device-list li:hover { background: #f8fafd; }
.device-list .device-name-text { flex: 1; font-size: 13px; color: #222; min-width: 0; }
.device-list .row-actions { margin-left: auto; flex-shrink: 0; }
.device-list .edit-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}
.device-list .edit-row input {
  flex: 1;
  max-width: 220px;
  padding: 5px 8px;
  border: 1px solid #30426a;
  border-radius: 4px;
  font-size: 13px;
  outline: none;
}
.device-list .save-btn {
  padding: 5px 12px;
  background: #30426a;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}
.device-list .cancel-btn {
  padding: 5px 10px;
  background: none;
  color: #667;
  border: 1px solid #d0d8e8;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}
.device-list .device-icon-col { color: #e99d1a; width: 22px; text-align: center; }

/* Settings form */
.settings-section { margin-bottom: 24px; }
.settings-section h4 {
  font-size: 13px;
  font-weight: 700;
  color: #30426a;
  margin-bottom: 4px;
  padding-bottom: 6px;
  border-bottom: 1px solid #e0e6ef;
}
.settings-section p.hint {
  font-size: 12px;
  color: #778;
  margin: 4px 0 10px;
  line-height: 1.5;
}
.settings-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.settings-row label { font-size: 13px; color: #333; }
.settings-input {
  padding: 6px 10px;
  border: 1px solid #d0d8e8;
  border-radius: 5px;
  font-size: 13px;
  color: #333;
  outline: none;
  transition: border-color 0.15s;
}
.settings-input:focus { border-color: #30426a; }
.settings-input.wide { min-width: 280px; }
.settings-input.narrow { width: 80px; }

.settings-footer-card { margin-top: 16px; }
.settings-footer-body h4 {
  font-size: 13px;
  font-weight: 700;
  color: #30426a;
  margin-bottom: 10px;
}
.donate-card, .donate-compact { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 10px; }
.donate-methods { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 24px; }
.donate-compact { margin-bottom: 8px; align-items: flex-start; }
.donate-compact .legal-mini { flex: 1 1 100%; margin-top: 4px; }
.venmo-block { flex-shrink: 0; text-align: center; }
.venmo-qr { display: block; border-radius: 8px; background: #fff; box-shadow: 0 1px 6px rgba(0,0,0,0.08); }
.venmo-compact .venmo-qr { box-shadow: none; }
.venmo-caption { margin: 6px 0 0; }
.paypal-hosted-wrap { min-height: 40px; min-width: 140px; }
.donate-methods .paypal-hosted-wrap { flex: 0 0 auto; }
.legal-mini { font-size: 11px; color: #889; }
.legal-text, .legal-body .hint { font-size: 12px; color: #667; line-height: 1.55; margin: 0; }
.legal-text a { color: #30426a; }
.legal-list {
  margin: 12px 0 0;
  padding-left: 20px;
  font-size: 12px;
  color: #667;
  line-height: 1.55;
}
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(20, 28, 45, 0.45);
  display: flex; align-items: center; justify-content: center;
}
.modal-box {
  background: #fff; border-radius: 10px; padding: 22px 24px;
  width: 360px; max-width: calc(100vw - 32px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}
.modal-box .save-btn, .modal-box .cancel-btn {
  padding: 7px 16px; border-radius: 6px; border: 1px solid transparent;
  font-size: 13px; cursor: pointer;
}
.modal-box .save-btn { background: #30426a; color: #fff; }
.modal-box .save-btn:disabled { opacity: 0.6; cursor: default; }
.modal-box .cancel-btn { background: #eef1f6; color: #444; }
.btn-sm {
  padding: 5px 12px;
  border-radius: 5px;
  font-size: 12px;
  cursor: pointer;
  border: 1px solid;
  transition: all 0.15s;
}
.btn-primary { background: #30426a; color: #fff; border-color: #30426a; }
.btn-primary:hover { background: #243354; }
.btn-default { background: #fff; color: #444; border-color: #d0d8e8; }
.btn-default:hover { background: #f0f4fa; }
.btn-danger { background: #fff; color: #c02; border-color: #e88; }
.btn-danger:hover { background: #fceaea; }

/* Toggle switch */
.toggle-wrap { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.toggle-label { font-size: 13px; color: #333; }
.toggle {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #ccc;
  border-radius: 20px;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle input:checked + .toggle-slider { background: #30426a; }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* Radio group */
.radio-group { display: flex; gap: 16px; flex-wrap: wrap; }
.radio-option { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; color: #333; }
.radio-option input { accent-color: #30426a; }

/* IP display */
.ip-display {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #f7f9fc;
  border: 1px solid #e0e6ef;
  border-radius: 5px;
  padding: 6px 12px;
  font-size: 13px;
  color: #333;
  font-family: monospace;
}

/* Playlist table source col */
.source-path {
  font-size: 11px;
  color: #778;
  font-family: monospace;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Automation */
.auto-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
}
@media (max-width: 768px) {
  .auto-form-grid { grid-template-columns: 1fr; }
}
.auto-field label {
  display: block;
  font-size: 12px;
  color: #667;
  margin-bottom: 4px;
}
.auto-field .settings-input { width: 100%; }
.auto-pl-wrap { position: relative; }
.auto-pl-results {
  position: absolute;
  left: 0; right: 0;
  top: 100%;
  z-index: 50;
  background: #fff;
  border: 1px solid #d8dfea;
  border-radius: 0 0 6px 6px;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.auto-pl-results:empty { display: none; }
.auto-pl-item {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid #f0f3f8;
}
.auto-pl-item:hover { background: #f4f7fc; }
.auto-pl-item small { color: #889; margin-left: 6px; }
.auto-day-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.auto-day-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid #d0d8e8;
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
}
.auto-day-chip input { accent-color: #30426a; }
.auto-day-chip.checked { background: #e8eef9; border-color: #30426a; }
.auto-list-meta { font-size: 11px; color: #889; margin-top: 2px; }
.auto-status-ok { color: #2eaa5a; }
.auto-status-err { color: #c02020; }
