/* YouTube Content Dashboard — Apple-inspired light theme */
:root {
  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface2: #f5f5f7;
  --surface3: #ebebed;
  --border: #d2d2d7;
  --border-light: #e8e8ed;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --faint: #86868b;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --blue: #0071e3;
  --purple: #bf5af2;
  --orange: #ff9500;
  --red: #ff3b30;
  --yellow: #ffcc00;
  --green: #34c759;
  --sidebar-w: 260px;
  --header-h: 56px;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 18px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.1);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.04);
  --ring: 0 0 0 3px rgba(0, 113, 227, 0.18);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --ease: cubic-bezier(0.25, 0.1, 0.25, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

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

.sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 8px;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px 18px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(145deg, #0071e3 0%, #5ac8fa 100%);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(0, 113, 227, 0.28);
}

.brand-mark svg { width: 20px; height: 20px; color: #fff; }

.brand h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.brand p {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
}

.nav-section {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 14px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: all 0.15s;
  font-size: 13px;
  font-weight: 500;
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.75; }

.nav-item:hover {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.nav-item.active {
  background: rgba(0, 113, 227, 0.08);
  border-color: rgba(0, 113, 227, 0.15);
  color: var(--accent);
  font-weight: 600;
}

.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px 10px 4px;
  border-top: 1px solid var(--border);
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.status-dot.offline { background: var(--red); box-shadow: 0 0 8px var(--red); }

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.topbar {
  min-height: var(--header-h);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  flex-shrink: 0;
}

.topbar-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  min-height: var(--header-h);
}

.topbar-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 24px 10px;
  flex-wrap: wrap;
  border-top: 1px solid rgba(30, 42, 58, 0.35);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-group-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  margin-right: 4px;
  white-space: nowrap;
}

.channel-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.channel-tab .tab-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.channel-tab:hover { color: var(--text); border-color: var(--border-light); }

.channel-tab.active {
  color: var(--text);
  border-color: var(--border-light);
  background: var(--surface2);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.type-tab {
  padding: 4px 11px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.15s;
}

.type-tab:hover { color: var(--text); }
.type-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.hub-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--muted);
  max-width: 220px;
  outline: none;
}

.hub-select:focus { border-color: var(--blue); color: var(--text); }

.topbar h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-wrap {
  position: relative;
}

.search-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--muted);
  pointer-events: none;
}

#globalSearch {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px 8px 34px;
  width: 260px;
  outline: none;
  font-size: 13px;
  transition: border-color 0.15s;
}

#globalSearch:focus { border-color: var(--blue); }

.content-area {
  flex: 1;
  overflow: auto;
  padding: 24px;
}

.content-area.animations-mode {
  padding: 0;
  overflow: hidden;
}

.hidden { display: none !important; }

.server-banner {
  margin: 0 0 16px;
  padding: 12px 16px;
  background: rgba(255, 149, 0, 0.12);
  border: 1px solid rgba(255, 149, 0, 0.35);
  border-radius: var(--radius-sm);
  color: #9a6700;
  font-size: 13px;
  font-weight: 500;
}

.content-area.reader-mode {
  padding-top: 8px;
}

.content-area.reader-mode .topbar-filters { display: none !important; }

.content-area.life-mode .search-wrap,
.content-area.life-mode #btnRebuild,
.content-area.prod-mode .search-wrap,
.content-area.prod-mode #btnRebuild,
.content-area.reader-mode .search-wrap,
.content-area.reader-mode #btnRebuild {
  display: none;
}

.page { display: none; }
.page.active { display: block; }

/* ─── Buttons ────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:hover { border-color: var(--border-light); background: var(--surface2); }
.btn svg { width: 14px; height: 14px; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 113, 227, 0.25);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 113, 227, 0.3);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.btn-sm { padding: 5px 10px; font-size: 11px; }

/* ─── Stats grid ─────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-card .label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.stat-card .sub {
  font-size: 12px;
  color: var(--muted);
}

.channel-stat {
  display: flex;
  align-items: center;
  gap: 10px;
}

.channel-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ─── Panels ─────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}

.panel-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-header h3 {
  font-size: 14px;
  font-weight: 600;
}

.panel-body { padding: 16px 18px; }

/* ─── Filters ────────────────────────────────────── */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.filter-chip {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-chip:hover { color: var(--text); border-color: var(--border-light); }

.filter-chip.active {
  background: rgba(74, 222, 128, 0.12);
  border-color: rgba(74, 222, 128, 0.35);
  color: var(--accent);
}

/* ─── Content table ──────────────────────────────── */
.table-wrap { overflow-x: auto; }

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

table.data-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  white-space: nowrap;
}

table.data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid rgba(30, 42, 58, 0.6);
  vertical-align: middle;
}

table.data-table tr:hover td { background: rgba(255, 255, 255, 0.02); }
table.data-table tr { cursor: pointer; }

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

.badge-short { background: rgba(74, 222, 128, 0.12); color: #86efac; }
.badge-video { background: rgba(56, 189, 248, 0.12); color: #7dd3fc; }
.badge-talk { background: rgba(167, 139, 250, 0.12); color: #c4b5fd; }
.badge-playlist { background: rgba(251, 146, 60, 0.12); color: #fdba74; }

.stage-badge { border: 1px solid currentColor; background: transparent; }

.title-cell {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.path-cell {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Pipeline kanban ────────────────────────────── */
.pipeline-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  align-items: start;
}

.pipeline-col {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 200px;
  display: flex;
  flex-direction: column;
}

.pipeline-col-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  border-radius: var(--radius) var(--radius) 0 0;
}

.pipeline-col-header .count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  background: var(--surface);
  padding: 2px 8px;
  border-radius: 10px;
}

.pipeline-col-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 70vh;
  overflow-y: auto;
  min-height: 120px;
  transition: background 0.15s, border-color 0.15s;
  border-radius: 0 0 var(--radius) var(--radius);
}

.pipeline-col-body.drag-over {
  background: rgba(56, 189, 248, 0.06);
  outline: 2px dashed rgba(56, 189, 248, 0.35);
  outline-offset: -4px;
}

.pipeline-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: grab;
  transition: border-color 0.15s, transform 0.1s, opacity 0.15s;
  user-select: none;
}

.pipeline-card:active { cursor: grabbing; }

.pipeline-card.dragging {
  opacity: 0.45;
  transform: rotate(2deg);
  border-color: var(--blue);
}

.pipeline-card .pc-drag-hint {
  font-size: 9px;
  color: var(--faint);
  font-family: var(--mono);
  margin-top: 6px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pipeline-card:hover {
  border-color: var(--blue);
  transform: translateY(-1px);
}

.pipeline-card .pc-title {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pipeline-card .pc-meta {
  font-size: 10px;
  color: var(--muted);
  font-family: var(--mono);
}

.pipeline-card .pc-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}

.pipeline-read-btn {
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border-light);
  background: #fff;
  color: var(--accent);
  cursor: pointer;
}

.pipeline-read-btn:hover {
  background: rgba(0, 113, 227, 0.08);
  border-color: var(--accent);
}

.row-actions {
  white-space: nowrap;
}

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

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

.month-label {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
  min-width: 160px;
}

.schedule-layout {
  display: grid;
  grid-template-columns: minmax(260px, 300px) 1fr;
  gap: 16px;
  align-items: start;
}

.schedule-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 14px;
}

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

.field-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 14px 0 6px;
}

.schedule-notes {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  min-height: 72px;
  outline: none;
}

.schedule-notes:focus { border-color: var(--blue); }

.goal-targets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.goal-target {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.goal-target label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 6px;
}

.goal-target .gt-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.goal-target input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 18px;
  font-weight: 700;
  font-family: var(--mono);
  outline: none;
}

.goal-target input:focus { border-color: var(--blue); }

.goal-progress { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }

.goal-progress-row .gpr-head {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  margin-bottom: 4px;
}

.goal-progress-row .gpr-label { font-weight: 600; }
.goal-progress-row .gpr-stats { color: var(--muted); font-family: var(--mono); font-size: 10px; }

.goal-progress-row .gpr-bar {
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
}

.goal-progress-row .gpr-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

.schedule-cal-header {
  flex-wrap: wrap;
  gap: 10px;
}

.paint-toolbar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.paint-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.paint-btn .pb-dot { width: 8px; height: 8px; border-radius: 50%; }

.paint-btn:hover { color: var(--text); border-color: var(--border-light); }

.paint-btn.active {
  color: var(--text);
  border-color: currentColor;
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 0 0 1px currentColor;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.preset-btn {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

.preset-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
  border-style: solid;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 4px;
}

.cal-weekdays span {
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  padding: 4px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-day {
  min-height: 72px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cal-day:hover { border-color: var(--border-light); background: var(--surface); }

.cal-day.other-month {
  opacity: 0.35;
  pointer-events: none;
}

.cal-day.today {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.2);
}

.cal-day.selected {
  border-color: var(--accent);
  background: rgba(74, 222, 128, 0.06);
}

.cal-day .cd-num {
  font-size: 12px;
  font-weight: 700;
  font-family: var(--mono);
  color: var(--text);
}

.cal-day.today .cd-num { color: var(--blue); }

.cal-day .cd-phases {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: auto;
}

.cal-phase-dot {
  font-size: 8px;
  font-weight: 700;
  font-family: var(--mono);
  padding: 2px 4px;
  border-radius: 3px;
  letter-spacing: 0.02em;
  line-height: 1;
}

.muted-count {
  color: var(--muted);
  font-weight: 400;
  font-size: 12px;
}

.assigned-list { display: flex; flex-direction: column; gap: 8px; }

.assigned-row {
  display: grid;
  grid-template-columns: 1fr repeat(4, 88px) auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.assigned-row .ar-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assigned-row .ar-path {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.assigned-row input[type="date"] {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 6px;
  font-size: 10px;
  font-family: var(--mono);
  color-scheme: dark;
}

.assigned-empty {
  text-align: center;
  padding: 28px;
  color: var(--muted);
  font-size: 13px;
}

.day-popover {
  position: fixed;
  z-index: 250;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  min-width: 220px;
  box-shadow: var(--shadow);
}

.day-popover h4 {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
}

.day-popover .dp-phases {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.day-popover .dp-phase {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  cursor: pointer;
}

.day-popover .dp-phase input { accent-color: var(--accent); }

@media (max-width: 1000px) {
  .schedule-layout { grid-template-columns: 1fr; }
  .assigned-row { grid-template-columns: 1fr; gap: 6px; }
  .cal-day { min-height: 56px; }
}

/* ─── Detail drawer ──────────────────────────────── */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(480px, 100vw);
  height: 100vh;
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  z-index: 301;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.drawer.open { transform: translateX(0); }

.drawer-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.drawer-header h3 {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
  flex: 1;
}

.drawer-close {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  color: var(--muted);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.drawer-close:hover { color: var(--text); }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.drawer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

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

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

.field-group select,
.field-group input[type="text"],
.field-group input[type="date"] {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  outline: none;
}

.field-group select:focus,
.field-group input:focus { border-color: var(--blue); }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(30, 42, 58, 0.5);
}

.toggle-row span { font-size: 13px; }

.toggle {
  position: relative;
  width: 42px;
  height: 24px;
  background: var(--surface3);
  border-radius: 12px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s;
}

.toggle.on { background: rgba(74, 222, 128, 0.3); border-color: var(--accent); }

.toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: var(--muted);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.toggle.on::after {
  transform: translateX(18px);
  background: var(--accent);
}

.drawer-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
}

.drawer-footer .btn { flex: 1; }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 13px;
  z-index: 400;
  box-shadow: var(--shadow);
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.25s;
  pointer-events: none;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: rgba(74, 222, 128, 0.4); }
.toast.error { border-color: rgba(248, 113, 113, 0.4); color: #fca5a5; }

/* ─── Animations embed ───────────────────────────── */
#page-animations.active {
  display: flex;
  flex-direction: column;
  height: 100%;
  margin: 0;
  padding: 0;
}

#page-animations .animations-frame {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: none;
  border-radius: 0;
}

/* ─── Pair indicator ─────────────────────────────── */
.pair-links {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  padding: 12px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.pair-links .pl-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.pair-link {
  font-size: 12px;
  font-family: var(--mono);
  color: var(--blue);
  cursor: pointer;
}

.pair-link:hover { text-decoration: underline; }

/* ─── Responsive ─────────────────────────────────── */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .phase-dates { grid-template-columns: 1fr 1fr; }
}

.empty-state {
  text-align: center;
  padding: 48px;
  color: var(--muted);
}

.empty-state .icon { font-size: 36px; opacity: 0.3; margin-bottom: 12px; }

/* ─── Todos workspace ─────────────────────────────── */
.todos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

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

.todos-kanban {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.todo-column {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.96), rgba(13, 17, 25, 0.94));
  overflow: hidden;
}

.todo-column-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(30, 42, 58, 0.7);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.todo-column-head .count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(74, 222, 128, 0.1);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
}

.todo-column-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  min-height: 140px;
}

.todo-card {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(42, 58, 82, 0.85);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.todo-empty {
  min-height: 92px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--surface2);
}

/* ═══════════════════════════════════════════════════
   Light theme polish · Headless UI inputs · Motion
   ═══════════════════════════════════════════════════ */

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

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.97); }
  to { opacity: 1; transform: scale(1); }
}

.page.active {
  animation: fadeInUp 0.4s var(--ease) both;
}

.stat-card,
.panel,
.prod-goal-card,
.prod-task-item,
.prod-habit-card {
  animation: fadeInUp 0.45s var(--ease) both;
}

.stats-grid .stat-card:nth-child(2) { animation-delay: 0.04s; }
.stats-grid .stat-card:nth-child(3) { animation-delay: 0.08s; }
.stats-grid .stat-card:nth-child(4) { animation-delay: 0.12s; }

/* Headless UI–style form controls */
.ui-input,
input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="submit"]):not([type="button"]),
select,
textarea {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), transform 0.15s var(--ease);
}

.ui-input::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--faint);
}

.ui-input:hover,
input:not([type="checkbox"]):hover,
select:hover,
textarea:hover {
  border-color: #b0b0b5;
}

.ui-input:focus,
input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring), 0 1px 2px rgba(0, 0, 0, 0.04);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  border-radius: 4px;
  cursor: pointer;
}

input[type="date"],
input[type="number"] {
  font-variant-numeric: tabular-nums;
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.field-group { margin-bottom: 16px; }
.field-group label.field-label { margin-bottom: 6px; }

/* Light surface overrides */
.sidebar {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(20px);
  border-right: 1px solid var(--border-light);
  box-shadow: 1px 0 0 rgba(0, 0, 0, 0.03);
}

.panel,
.stat-card,
.drawer {
  box-shadow: var(--shadow-card);
  border-color: var(--border-light);
}

.stat-card {
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

table.data-table td {
  border-bottom: 1px solid var(--border-light);
}

table.data-table tr:hover td {
  background: rgba(0, 113, 227, 0.03);
}

.filter-chip.active {
  background: rgba(0, 113, 227, 0.08);
  border-color: rgba(0, 113, 227, 0.25);
  color: var(--accent);
}

.badge-short { background: rgba(52, 199, 89, 0.12); color: #248a3d; }
.badge-video { background: rgba(0, 113, 227, 0.1); color: #0071e3; }
.badge-talk { background: rgba(191, 90, 242, 0.1); color: #9b4dca; }
.badge-playlist { background: rgba(255, 149, 0, 0.12); color: #c93400; }

.pipeline-col {
  background: var(--surface2);
  border-color: var(--border-light);
  box-shadow: var(--shadow-card);
}

.pipeline-card {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), border-color 0.2s;
}

.pipeline-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--border);
}

.drawer-backdrop.open {
  background: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(4px);
}

.drawer {
  background: #fff;
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.12);
}

.toggle.on {
  background: rgba(0, 113, 227, 0.2);
  border-color: var(--accent);
}

.toggle.on::after {
  background: var(--accent);
}

.toast {
  background: #fff;
  box-shadow: var(--shadow-lg);
  border-color: var(--border-light);
}

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

.todo-column {
  background: var(--surface);
  border-color: var(--border-light);
  box-shadow: var(--shadow-card);
}

.todo-card {
  border-color: var(--border-light);
  background: var(--surface2);
  box-shadow: none;
}

.todo-column-head .count {
  background: rgba(0, 113, 227, 0.1);
  color: var(--accent);
}

.status-dot {
  box-shadow: 0 0 6px rgba(52, 199, 89, 0.5);
}

.status-dot.offline {
  box-shadow: 0 0 6px rgba(255, 59, 48, 0.5);
}

.btn {
  transition: all 0.2s var(--ease);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-ghost:hover {
  background: var(--surface2);
  transform: none;
}

.btn-icon {
  padding: 8px;
  min-width: 36px;
}

.mobile-menu-btn { display: none; }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(2px);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease);
}

.sidebar-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* Responsive */
@media (max-width: 1024px) {
  .overview-panels {
    grid-template-columns: 1fr !important;
  }
}

.overview-panels {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
}

.prod-report-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

@media (max-width: 900px) {
  .prod-report-bottom {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 1024px) {
  #page-overview > div[style*="grid-template-columns: 1fr 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 900px) {
  .mobile-menu-btn { display: inline-flex; }

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

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 200;
    width: min(var(--sidebar-w), 88vw);
    transform: translateX(-100%);
    transition: transform 0.35s var(--ease);
    box-shadow: var(--shadow-lg);
  }

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

  .sidebar-backdrop { display: block; }

  .content-area { padding: 16px; }

  .topbar-row { padding: 0 16px; }

  .topbar-filters { padding: 0 16px 10px; }

  #globalSearch { width: 100%; max-width: 200px; }

  .search-wrap { flex: 1; max-width: 220px; }

  .pipeline-board {
    grid-template-columns: 1fr;
  }

  .schedule-layout {
    grid-template-columns: 1fr !important;
  }

  .drawer {
    width: 100% !important;
    max-width: 100%;
  }

  .phase-dates { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  .topbar-actions { gap: 6px; }

  #globalSearch { max-width: 140px; font-size: 12px; }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .stat-card .value { font-size: 22px; }

  .drawer-footer {
    flex-wrap: wrap;
  }

  .drawer-footer .btn {
    flex: 1 1 calc(50% - 5px);
    min-width: 0;
  }
}

/* Login page */
body.login-page {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top, rgba(0, 113, 227, 0.08), transparent 42%),
    var(--bg);
}

.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.login-brand h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-brand p {
  color: var(--muted);
  font-size: 14px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.login-field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--text);
  background: var(--bg);
}

.login-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.login-error {
  color: var(--red);
  font-size: 13px;
}

.login-submit {
  width: 100%;
  justify-content: center;
  margin-top: 4px;
}
