/* ================================================================
   SignageOS v2 – Modern Minimal B&W Theme
   Inspired by: Banking apps, Smart Home dashboards, Course platforms
   ================================================================ */

/* ── Reset & Variables ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --black     : #000000;
  --white     : #ffffff;
  --bg        : #f5f5f5;
  --card      : #ffffff;
  --border    : #ebebeb;
  --text      : #1a1a1a;
  --text-2    : #888888;
  --text-3    : #bbbbbb;
  --hover     : #f0f0f0;
  --accent    : #000000;
  --accent-soft: #f0f0f0;
  --success   : #22c55e;
  --danger    : #ef4444;
  --warning   : #f59e0b;
  --radius    : 16px;
  --radius-sm : 10px;
  --radius-xs : 6px;
  --shadow    : 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md : 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg : 0 12px 40px rgba(0,0,0,.12);
  --sidebar-w : 72px;
  --sidebar-expanded : 240px;
  --topbar-h  : 0px;
  --font      : 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition: .2s cubic-bezier(.4,0,.2,1);
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

html { font-size: 15px; }
body {
  font-family: var(--font);
  background : var(--bg);
  color       : var(--text);
  line-height : 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ── Scrollbar ───────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-3); border-radius: 99px; }

/* ── Layout ──────────────────────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ── Sidebar (Icon-only by default, like the F. course dashboard) ── */
.sidebar {
  position: fixed;
  left: 0; top: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--black);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 0;
  z-index: 100;
  transition: width var(--transition);
  overflow: hidden;
}
.sidebar:hover {
  width: var(--sidebar-expanded);
}

.sidebar-logo {
  width: 40px; height: 40px;
  background: var(--white);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.2rem; color: var(--black);
  flex-shrink: 0;
  margin-bottom: 32px;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  padding: 0 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.5);
  transition: all var(--transition);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  position: relative;
}
.nav-item:hover {
  color: #fff;
  background: rgba(255,255,255,.08);
}
.nav-item.active {
  color: #fff;
  background: rgba(255,255,255,.12);
}
.nav-item svg {
  width: 20px; height: 20px;
  flex-shrink: 0;
  stroke-width: 1.8;
}
.nav-item-label {
  font-size: .85rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity var(--transition);
}
.sidebar:hover .nav-item-label {
  opacity: 1;
}
.nav-badge {
  position: absolute;
  top: 4px; right: 4px;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: #ef4444; color: #fff;
  font-size: .58rem; font-weight: 700;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}

.sidebar-bottom {
  width: 100%;
  padding: 0 12px;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}
.sidebar-user:hover { background: rgba(255,255,255,.08); }

.sidebar-avatar {
  width: 32px; height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, #444, #888);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .75rem; color: #fff;
  flex-shrink: 0;
}
.sidebar-user-info {
  opacity: 0;
  transition: opacity var(--transition);
  overflow: hidden;
}
.sidebar:hover .sidebar-user-info { opacity: 1; }
.sidebar-user-name {
  font-size: .8rem; font-weight: 600; color: #fff;
  white-space: nowrap;
}
.sidebar-user-role {
  font-size: .68rem; color: rgba(255,255,255,.4);
  white-space: nowrap;
}

/* ── Main Content ────────────────────────────────────────────────── */
.main-content {
  grid-column: 2;
  padding: 32px 40px;
  max-width: 1400px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

.page-subtitle {
  font-size: .85rem;
  color: var(--text-2);
  margin-top: 2px;
}

.page-clock {
  font-size: .82rem;
  color: var(--text-2);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ── Cards ────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: box-shadow var(--transition);
}
.card:hover {
  box-shadow: var(--shadow-md);
}
.card-dark {
  background: var(--black);
  color: #fff;
  border-color: transparent;
}
.card-dark .text-muted { color: rgba(255,255,255,.5); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ── Stat Cards (Dashboard) ──────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: all var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card.dark {
  background: var(--black);
  color: #fff;
  border-color: transparent;
}
.stat-value {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1;
  margin-bottom: 6px;
}
.stat-label {
  font-size: .78rem;
  font-weight: 500;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.stat-card.dark .stat-label { color: rgba(255,255,255,.5); }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: .82rem;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: var(--black);
  color: #fff;
}
.btn-primary:hover { background: #222; transform: translateY(-1px); box-shadow: var(--shadow); }

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

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  padding: 8px 14px;
}
.btn-ghost:hover { background: var(--hover); color: var(--text); }

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

.btn-sm {
  padding: 6px 12px;
  font-size: .75rem;
  border-radius: var(--radius-xs);
}

.btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-xs);
  color: var(--text-2);
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
}
.btn-icon:hover { background: var(--hover); color: var(--text); }
.btn-icon svg { width: 16px; height: 16px; }
.btn-icon.btn-danger:hover { background: #fef2f2; color: var(--danger); }

.btn-group {
  display: flex;
  gap: 8px;
}

/* ── Form Controls ───────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--black);
  box-shadow: 0 0 0 3px rgba(0,0,0,.06);
}
.form-control::placeholder { color: var(--text-3); }

textarea.form-control { resize: vertical; min-height: 80px; }

.form-hint {
  font-size: .72rem;
  color: var(--text-2);
  margin-top: 4px;
}

.required { color: var(--danger); }

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 500px) { .form-row-2 { grid-template-columns: 1fr; } }

/* ── Filter Tabs (Pill style) ────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: 0;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  padding: 3px;
}
.filter-tab {
  padding: 8px 18px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--transition);
}
.filter-tab:hover { color: var(--text); }
.filter-tab.active {
  background: var(--black);
  color: #fff;
  box-shadow: var(--shadow);
}

/* ── Search ──────────────────────────────────────────────────────── */
.search-wrap {
  position: relative;
}
.search-wrap svg {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  stroke: var(--text-3);
}
.search-input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text);
  outline: none;
  transition: all var(--transition);
}
.search-input:focus {
  border-color: var(--black);
  box-shadow: 0 0 0 3px rgba(0,0,0,.06);
}
.search-input::placeholder { color: var(--text-3); }

/* ── Toolbar ─────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.toolbar-spacer { flex: 1; }

/* ── Tables ──────────────────────────────────────────────────────── */
.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th {
  text-align: left;
  padding: 14px 20px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-2);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
td {
  padding: 14px 20px;
  font-size: .85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(0,0,0,.015); }

.table-user {
  display: flex;
  align-items: center;
  gap: 12px;
}
.table-avatar {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--black);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .75rem;
  flex-shrink: 0;
}
.table-name { font-weight: 600; }
.table-sub { font-size: .72rem; color: var(--text-2); }

/* ── Badges ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: .68rem;
  font-weight: 600;
  line-height: 1.5;
}
.badge-dark   { background: var(--black); color: #fff; }
.badge-light  { background: var(--accent-soft); color: var(--text); }
.badge-success{ background: #dcfce7; color: #15803d; }
.badge-danger { background: #fef2f2; color: #dc2626; }
.badge-warning{ background: #fef3c7; color: #92400e; }
.badge-outline{
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
}

/* ── Modal ────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-backdrop.hidden { display: none; }

.modal {
  background: var(--card);
  border-radius: 20px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalSlideUp .25s ease-out;
}
.modal-lg { max-width: 640px; }
.modal-xl { max-width: 800px; }

@keyframes modalSlideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px 0;
}
.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
}
.modal-close {
  background: var(--accent-soft);
  border: none;
  width: 32px; height: 32px;
  border-radius: 10px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
  transition: all var(--transition);
}
.modal-close:hover { background: var(--hover); color: var(--text); }

.modal-body {
  padding: 20px 28px;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 28px 24px;
}

/* ── Media Grid ──────────────────────────────────────────────────── */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.media-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all var(--transition);
}
.media-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.media-card.disabled { opacity: .5; }

.media-thumb {
  position: relative;
  aspect-ratio: 16/10;
  background: #f0f0f0;
  overflow: hidden;
  cursor: pointer;
}
.media-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.media-thumb:hover .media-play-hint { opacity: 1; }

.media-overlay {
  position: absolute;
  top: 8px; left: 8px;
  display: flex; gap: 4px;
  flex-wrap: wrap;
}

.media-play-hint {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.3);
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity var(--transition);
}
.media-play-hint svg {
  width: 36px; height: 36px;
  stroke: #fff;
  fill: none;
}

.video-thumb, .embed-thumb {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
}
.video-thumb { background: var(--black); }
.video-thumb svg { width: 40px; height: 40px; stroke: #fff; opacity: .6; }
.embed-thumb { background: linear-gradient(135deg, #333, #666); }
.embed-thumb svg { width: 40px; height: 40px; stroke: #fff; opacity: .6; }

.media-info {
  padding: 14px 16px 8px;
}
.media-name {
  font-weight: 600;
  font-size: .85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.media-meta {
  font-size: .72rem;
  color: var(--text-2);
  margin-top: 2px;
}

.media-actions {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
  padding: 4px 10px 12px;
}

/* ── Storage Bar ─────────────────────────────────────────────────── */
.storage-bar-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
}
.storage-bar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .82rem;
  color: var(--text-2);
  margin-bottom: 10px;
}
.storage-track {
  background: var(--accent-soft);
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
}
.storage-fill {
  height: 100%;
  background: var(--black);
  border-radius: 99px;
  transition: width .6s ease;
}
.storage-fill.warn { background: var(--warning); }
.storage-fill.danger { background: var(--danger); }

/* ── Screens Table Extras ────────────────────────────────────────── */
.screen-key-code {
  font-family: 'SF Mono', 'Cascadia Code', Consolas, monospace;
  font-size: .72rem;
  background: var(--accent-soft);
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  color: var(--text-2);
}

/* ── Playlist Items ──────────────────────────────────────────────── */
.playlist-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.playlist-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  cursor: grab;
  transition: all var(--transition);
}
.playlist-item:hover { box-shadow: var(--shadow); }
.playlist-item.dragging {
  opacity: .5;
  box-shadow: var(--shadow-md);
}

.pi-handle {
  color: var(--text-3);
  cursor: grab;
}
.pi-handle svg { width: 16px; height: 16px; }

.pi-thumb {
  width: 56px; height: 40px;
  border-radius: 8px;
  overflow: hidden;
  background: #f0f0f0;
  flex-shrink: 0;
}
.pi-thumb img, .pi-thumb video {
  width: 100%; height: 100%;
  object-fit: cover;
}

.pi-info { flex: 1; min-width: 0; }
.pi-name {
  font-weight: 600;
  font-size: .82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pi-meta {
  font-size: .7rem;
  color: var(--text-2);
}

.pi-actions {
  display: flex;
  gap: 2px;
}

/* ── Orientation Cards ───────────────────────────────────────────── */
.orientation-cards {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.orient-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  min-width: 85px;
  text-align: center;
}
.orient-card:hover { border-color: var(--text-3); }
.orient-card.selected {
  border-color: var(--black);
  background: var(--accent-soft);
}
.orient-icon { font-size: 1.3rem; }
.orient-label { font-size: .72rem; font-weight: 600; }
.orient-deg { font-size: .65rem; color: var(--text-2); }

/* ── Days Chips ──────────────────────────────────────────────────── */
.days-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.day-chip { cursor: pointer; }
.day-chip input { display: none; }
.day-chip span {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--card);
  font-size: .75rem;
  font-weight: 500;
  transition: all .15s;
}
.day-chip input:checked + span {
  background: var(--black);
  color: #fff;
  border-color: var(--black);
}

/* ── Schedule Section ────────────────────────────────────────────── */
.schedule-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 14px;
}
.schedule-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 14px;
}

/* ── Toast ────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--black);
  color: #fff;
  padding: 14px 22px;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn .3s ease-out;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.error { background: var(--danger); }
.toast.success { background: #18181b; }
.toast-icon { width: 18px; height: 18px; flex-shrink: 0; }

@keyframes toastIn {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Upload ──────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--black);
  background: rgba(0,0,0,.02);
}
.drop-zone svg {
  width: 36px; height: 36px;
  margin: 0 auto 12px;
  stroke: var(--text-3);
}
.drop-zone p { color: var(--text-2); font-size: .85rem; }
.drop-zone strong { color: var(--text); }
.upload-browse-link {
  color: var(--black);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}
.small { font-size: .75rem; }
.text-muted { color: var(--text-2); }

.upload-queue { margin-top: 16px; }
.upload-queue.hidden { display: none; }
.upload-item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.upload-item-info { display: flex; justify-content: space-between; margin-bottom: 6px; }
.upload-item-name { font-weight: 600; font-size: .82rem; }
.upload-item-size { font-size: .72rem; color: var(--text-2); }
.upload-progress-bar {
  height: 4px;
  background: var(--accent-soft);
  border-radius: 99px;
  overflow: hidden;
}
.upload-progress-fill {
  height: 100%;
  background: var(--black);
  border-radius: 99px;
  transition: width .3s;
}
.upload-status { font-size: .72rem; color: var(--text-2); }
.upload-status.success { color: var(--success); }
.upload-status.error { color: var(--danger); }

/* ── Preview Modal ───────────────────────────────────────────────── */
.modal-preview {
  max-width: 900px;
  background: var(--black);
  padding: 0;
  position: relative;
}
.modal-preview .modal-close {
  position: absolute; top: 12px; right: 12px;
  z-index: 10;
}
.modal-preview img, .modal-preview video {
  width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 20px;
}
.preview-name {
  text-align: center;
  padding: 14px;
  color: rgba(255,255,255,.6);
  font-size: .82rem;
}
.preview-close { background: rgba(255,255,255,.15); color: #fff; }
.preview-close:hover { background: rgba(255,255,255,.25); }

/* ── Empty State ─────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  grid-column: 1 / -1;
}
.empty-state svg {
  width: 48px; height: 48px;
  stroke: var(--text-3);
  margin: 0 auto 16px;
}
.empty-state p {
  color: var(--text-2);
  margin-bottom: 16px;
  font-size: .9rem;
}

/* ── Loading ─────────────────────────────────────────────────────── */
.media-loading, .loading-text {
  text-align: center;
  padding: 40px;
  color: var(--text-2);
  font-size: .85rem;
  grid-column: 1 / -1;
}

/* ── Login Page ──────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--white);
}
.login-brand {
  background: var(--black);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 20px;
  padding: 40px;
}
.login-brand-logo {
  width: 80px; height: 80px;
  background: var(--white);
  border-radius: 24px;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem; font-weight: 800; color: var(--black);
}
.login-brand h1 {
  color: #fff;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -.02em;
}
.login-brand p {
  color: rgba(255,255,255,.4);
  font-size: .9rem;
  max-width: 300px;
  text-align: center;
}
.login-features {
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
  max-width: 280px;
}
.login-feature {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,.55);
  font-size: .8rem;
}
.login-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.login-form-wrap {
  width: 100%;
  max-width: 380px;
}
.login-form-wrap h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.login-form-wrap .subtitle {
  color: var(--text-2);
  font-size: .85rem;
  margin-bottom: 32px;
}
.login-form .form-group { margin-bottom: 20px; }
.login-form .btn-primary {
  width: 100%;
  justify-content: center;
  padding: 13px;
  font-size: .9rem;
  border-radius: var(--radius-sm);
}
.forgot-link {
  font-size: .78rem;
  color: var(--text-2);
  float: right;
  cursor: pointer;
}
.forgot-link:hover { color: var(--text); }

.input-password-wrap {
  position: relative;
}
.input-password-wrap .form-control { padding-right: 42px; }
.toggle-password {
  position: absolute;
  right: 8px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  cursor: pointer; color: var(--text-3);
  padding: 4px;
}
.toggle-password:hover { color: var(--text); }
.toggle-password svg { width: 18px; height: 18px; }

/* ── Profile Page ────────────────────────────────────────────────── */
.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 800px) { .profile-grid { grid-template-columns: 1fr; } }

.profile-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.profile-card-title {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── AI Generate ─────────────────────────────────────────────────── */
.ai-gen-quota {
  display: flex; align-items: center; gap: 4px;
  padding: 10px 16px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  font-size: .8rem; font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
}
.ai-mode-cards { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.ai-mode-card {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .15s;
  min-width: 80px;
  text-align: center;
}
.ai-mode-card:hover { border-color: var(--text-3); }
.ai-mode-card.selected { border-color: var(--black); background: var(--accent-soft); }
.ai-mode-icon { font-size: 1.4rem; }
.ai-mode-label { font-size: .72rem; font-weight: 600; }
.ai-mode-ratio { font-size: .65rem; color: var(--text-2); }

/* ── AI Theme Cards ──────────────────────────────────────────────── */
.ai-theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.ai-theme-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .15s;
  text-align: center;
}
.ai-theme-card:hover { border-color: var(--text-3); background: var(--hover); }
.ai-theme-card.selected { border-color: var(--black); background: var(--accent-soft); }
.ai-theme-icon { font-size: 1.6rem; }
.ai-theme-label { font-size: .75rem; font-weight: 600; }

/* ── AI Quick Prompts ───────────────────────────────────────────── */
.ai-prompts-section { margin-top: 12px; }
.ai-prompts-label {
  font-size: .75rem;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 8px;
}
.ai-prompt-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ai-prompt-chip {
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  background: var(--card);
  color: var(--text);
  white-space: nowrap;
}
.ai-prompt-chip:hover {
  border-color: var(--black);
  background: var(--accent-soft);
}

/* ── AI Reference Image Upload ──────────────────────────────────── */
.ai-ref-upload {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  position: relative;
}
.ai-ref-upload:hover { border-color: var(--text-3); background: rgba(0,0,0,.02); }
.ai-ref-upload.has-image { border-style: solid; border-color: var(--success); }
.ai-ref-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}
.ai-ref-preview img {
  width: 60px; height: 60px;
  object-fit: cover;
  border-radius: 8px;
}
.ai-ref-preview-info { flex: 1; min-width: 0; }
.ai-ref-preview-name {
  font-weight: 600;
  font-size: .82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ai-ref-preview-size { font-size: .72rem; color: var(--text-2); }
.ai-ref-remove {
  background: var(--danger);
  color: #fff;
  border: none;
  width: 24px; height: 24px;
  border-radius: 50%;
  font-size: .8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── AI Step Indicators ─────────────────────────────────────────── */
.ai-step-label {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ai-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--black);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
}

.ai-preview-area {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px; background: var(--bg);
}
.ai-preview-area.hidden { display: none; }
.ai-preview-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px; font-size: .82rem; font-weight: 600; color: var(--text-2);
}
.ai-preview-img {
  display: flex; justify-content: center;
  background: var(--black); border-radius: 10px;
  overflow: hidden; max-height: 400px;
}
.ai-preview-img img { max-width: 100%; max-height: 400px; object-fit: contain; }
.ai-generating {
  display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 40px 20px;
}
.ai-generating.hidden { display: none; }
.ai-generating p { font-size: .85rem; color: var(--text-2); }
.ai-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border); border-top-color: var(--black);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Playlists Split ─────────────────────────────────────────────── */
.playlists-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  align-items: start;
}
@media (max-width: 800px) {
  .playlists-layout { grid-template-columns: 1fr; }
}

.playlist-sidebar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.playlist-sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.playlist-sidebar-title {
  font-size: .85rem;
  font-weight: 600;
}

.playlist-list {
  max-height: 500px;
  overflow-y: auto;
}
.playlist-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
}
.playlist-list-item:last-child { border-bottom: none; }
.playlist-list-item:hover { background: var(--hover); }
.playlist-list-item.active { background: var(--accent-soft); }

.pl-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--black);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.pl-icon svg { width: 16px; height: 16px; stroke: #fff; }

.pl-info { flex: 1; min-width: 0; }
.pl-name { font-weight: 600; font-size: .82rem; }
.pl-count { font-size: .7rem; color: var(--text-2); }

.playlist-detail {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  min-height: 300px;
}
.playlist-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.playlist-detail-title {
  font-size: 1.1rem;
  font-weight: 700;
}

/* ── Responsive Tables ───────────────────────────────────────────── */
/* Horizontal scroll wrapper for all screen sizes below 900px */
@media (max-width: 900px) {
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table-wrap table {
    min-width: 700px;
  }
}

/* Card-based layout for narrow mobile */
@media (max-width: 640px) {
  .table-wrap {
    overflow-x: visible;
    border: none;
    background: transparent;
  }
  .table-wrap table,
  .table-wrap thead,
  .table-wrap tbody,
  .table-wrap th,
  .table-wrap td,
  .table-wrap tr {
    display: block;
  }
  .table-wrap thead {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
  }
  .table-wrap tbody tr {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .table-wrap tbody tr:hover td {
    background: transparent;
  }
  .table-wrap td {
    padding: 0;
    border: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: .82rem;
  }
  .table-wrap td::before {
    content: attr(data-label);
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-2);
    flex-shrink: 0;
    min-width: 90px;
  }
  .table-wrap td:last-child {
    border-top: 1px solid var(--border);
    padding-top: 10px;
    margin-top: 4px;
    justify-content: flex-end;
  }
  .table-wrap td:last-child::before { display: none; }

  /* Ensure action buttons wrap nicely */
  .table-wrap td:last-child {
    text-align: right;
  }
  .table-wrap td .screen-key-code {
    font-size: .65rem;
    word-break: break-all;
  }
}

/* ── Mobile Topbar (hidden on desktop) ───────────────────────────── */
.mobile-topbar {
  display: none;
  position: fixed; top: 0; left: 0; right: 0;
  height: 56px; z-index: 99;
  background: var(--black); color: #fff;
  align-items: center; gap: 12px;
  padding: 0 16px;
}
.mobile-hamburger {
  background: none; border: none; cursor: pointer; padding: 4px;
  display: flex; align-items: center; justify-content: center;
}
.mobile-hamburger svg { width: 24px; height: 24px; stroke: #fff; }
.mobile-topbar-title { flex: 1; font-size: .9rem; font-weight: 600; }
.mobile-topbar-avatar {
  width: 32px; height: 32px; border-radius: 10px;
  background: linear-gradient(135deg, #444, #888);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .72rem; color: #fff;
  text-decoration: none; flex-shrink: 0;
}

/* Sidebar overlay (mobile only) */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 99;
  opacity: 0; transition: opacity .25s;
}
.sidebar-overlay.open { display: block; opacity: 1; }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  html { overflow-x: hidden; }
  body { overflow-x: hidden; }

  .mobile-topbar { display: flex; }

  .app-layout { grid-template-columns: 1fr; }

  /* Sidebar: slide-out from left */
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-expanded) !important;
    height: 100vh;
    flex-direction: column;
    align-items: flex-start;
    padding: 24px 0;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    overflow-y: auto;
    overflow-x: hidden;
    border-radius: 0;
  }
  .sidebar:hover { width: var(--sidebar-expanded) !important; }
  .sidebar.open { transform: translateX(0); }

  /* Show labels always on mobile sidebar */
  .sidebar .nav-item-label { opacity: 1; }
  .sidebar .sidebar-user-info { opacity: 1; }

  /* Sidebar bottom visible */
  .sidebar-bottom { display: flex !important; }

  /* Logout item styling */
  .nav-item-logout { color: rgba(255,255,255,.5) !important; }
  .nav-item-logout:hover { color: #ef4444 !important; }

  .main-content {
    grid-column: 1;
    padding: 72px 16px 24px;
    max-width: 100vw;
    overflow-x: hidden;
    word-wrap: break-word;
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .page-title { font-size: 1.2rem; }
  .page-subtitle { font-size: .78rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .media-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .login-page { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .playlists-layout { grid-template-columns: 1fr; }

  /* Toolbar stacking */
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .toolbar .search-wrap { width: 100% !important; }
  .toolbar .filter-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .toolbar .btn-group {
    flex-wrap: wrap;
  }
  .toolbar .btn-group .btn {
    flex: 1;
    min-width: 0;
    justify-content: center;
    font-size: .75rem;
    padding: 8px 10px;
  }

  /* Bottom mobile nav */
  .mobile-bottom-nav {
    display: flex !important;
  }
  .main-content {
    padding-bottom: 80px !important;
  }

  /* Modals full-width on mobile */
  .modal-backdrop .modal {
    max-width: calc(100vw - 24px) !important;
    max-height: calc(100vh - 80px);
    margin: 12px;
    overflow-y: auto;
  }
  .modal-body { max-height: calc(100vh - 200px); overflow-y: auto; }

  /* Tables */
  .table-wrap { max-width: 100vw; }
}

/* ── Media Pick Grid (Add to Playlist modal) ────────────────────── */
.media-pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  max-height: 420px;
  overflow-y: auto;
  padding: 4px;
}
.pick-item {
  position: relative;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  overflow: hidden;
  cursor: pointer;
  transition: all .15s;
  background: var(--bg);
}
.pick-item:hover {
  border-color: var(--text-2);
}
.pick-item.picked {
  border-color: var(--black);
  box-shadow: 0 0 0 2px var(--black);
}
.pick-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}
.pick-item p {
  padding: 6px 8px;
  font-size: .7rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}
.pick-check {
  position: absolute;
  top: 6px; right: 6px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--black);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(.7);
  transition: all .15s;
}
.pick-item.picked .pick-check {
  opacity: 1;
  transform: scale(1);
}
.video-thumb-sm {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--black);
  color: #fff;
}
.video-thumb-sm svg {
  width: 32px;
  height: 32px;
  stroke: #fff;
}

@media (max-width: 640px) {
  .media-pick-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 8px;
    max-height: 320px;
  }
}

/* ── Mobile Bottom Nav (hidden on desktop) ───────────────────────── */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  background: var(--black);
  z-index: 98;
  align-items: stretch;
  justify-content: space-around;
  padding: 0 4px;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -2px 12px rgba(0,0,0,.15);
}
.mob-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  color: rgba(255,255,255,.4);
  text-decoration: none;
  font-size: .58rem;
  font-weight: 600;
  transition: color .15s;
  position: relative;
  padding: 6px 0;
}
.mob-nav-item:hover,
.mob-nav-item.active { color: #fff; }
.mob-nav-item svg { width: 22px; height: 22px; flex-shrink: 0; }
.mob-nav-item .mob-badge {
  position: absolute; top: 4px; right: calc(50% - 18px);
  min-width: 14px; height: 14px; padding: 0 3px;
  background: #ef4444; color: #fff; font-size: .5rem; font-weight: 700;
  border-radius: 7px; display: flex; align-items: center; justify-content: center;
}
/* AI nav special glow */
.mob-nav-item.ai-item svg { stroke: #a78bfa; }
.mob-nav-item.ai-item.active svg { stroke: #c4b5fd; }

/* ── Utilities ───────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.gap-1 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
