:root {
  --bg: #f7f2e9;
  --panel: #fffdf9;
  --panel-strong: #fffdf9;
  --ink: #24211d;
  --muted: #6b6359;
  --accent: #1f6870;
  --accent-strong: #18545a;
  --border: rgba(181, 157, 118, 0.36);
  --warn: #b66d12;
  --danger: #b63131;
  --shadow: 0 18px 42px rgba(188, 166, 126, 0.22);
}

body.theme-staging {
  --bg: #fff4e5;
  --panel: #fffaf2;
  --panel-strong: #fff7ec;
  --ink: #2d2116;
  --muted: #7d6547;
  --accent: #c7541f;
  --accent-strong: #913914;
  --border: rgba(199, 84, 31, 0.28);
  --warn: #b95306;
  --danger: #9f2727;
  --shadow: 0 18px 42px rgba(199, 84, 31, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(214, 193, 156, 0.18), transparent 30%),
    linear-gradient(180deg, #fbf7f0 0%, var(--bg) 100%);
  min-height: 100vh;
}

body.theme-staging {
  background:
    radial-gradient(circle at top right, rgba(255, 177, 66, 0.2), transparent 34%),
    linear-gradient(180deg, #fffaf1 0%, var(--bg) 100%);
}

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

code {
  font-family: "SFMono-Regular", monospace;
}

.brandmark {
  display: block;
  font-size: 1.85rem;
  line-height: 1.05;
  font-weight: 900;
  color: var(--ink);
}

.instance-banner {
  margin: 14px 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(199, 84, 31, 0.14);
  color: var(--accent-strong);
  border: 1px solid rgba(199, 84, 31, 0.26);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.narrow {
  max-width: 480px;
}

.login-shell {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100vh;
  padding: 28px 20px;
  border-right: 1px solid var(--border);
  background: rgba(251, 247, 239, 0.92);
}

.sidebar-nav {
  display: grid;
  gap: 8px;
  margin-top: 22px;
}

.sidebar-nav a {
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  color: #6c655b;
  font-weight: 700;
}

.sidebar-nav a.active {
  color: white;
  background: var(--accent);
  border-color: var(--accent);
}

.brand-switcher {
  margin: 8px 0 6px;
}

.sidebar-divider {
  height: 1px;
  margin: 12px 0 4px;
  background: var(--border);
}

.sidebar-section-label {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.app-main {
  min-width: 0;
}

.page {
  width: 100%;
  padding: 28px 28px 48px;
}

.stack {
  display: grid;
  gap: 14px;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.action-panel {
  margin-bottom: 20px;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.action-grid strong {
  display: block;
  margin-bottom: 6px;
  font-size: 1.8rem;
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-size: 2rem;
}

.analytics-chart-panel {
  margin-bottom: 20px;
}

.analytics-chart-heading {
  align-items: end;
}

.analytics-chart-filters {
  display: flex;
  gap: 10px;
  align-items: end;
  flex-wrap: wrap;
}

.analytics-chart-filters label {
  min-width: 220px;
}

.analytics-chart-shell {
  display: grid;
  gap: 14px;
}

.analytics-chart-frame {
  position: relative;
}

.analytics-chart {
  width: 100%;
  height: 240px;
  overflow: visible;
}

.analytics-chart-grid {
  stroke: rgba(31, 104, 112, 0.14);
  stroke-width: 1;
}

.analytics-chart-axis {
  fill: var(--muted);
  font-size: 12px;
}

.analytics-chart-area {
  fill: rgba(31, 104, 112, 0.12);
}

.analytics-chart-line {
  fill: none;
  stroke: var(--accent-strong);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.analytics-chart-dot {
  fill: var(--accent-strong);
  stroke: white;
  stroke-width: 2;
}

.analytics-chart-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.analytics-chart-label {
  position: absolute;
  display: grid;
  gap: 2px;
  transform: translateX(-50%);
  text-align: center;
  white-space: nowrap;
}

.analytics-chart-label strong {
  font-size: 0.92rem;
  line-height: 1.2;
  color: var(--text);
}

.analytics-chart-label span {
  color: var(--muted);
  font-size: 0.92rem;
}

.hero-heading,
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.section-heading {
  margin-bottom: 14px;
}

.subtle {
  color: var(--muted);
}

h1,
h2 {
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 800;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.95rem;
}

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

input,
textarea,
select {
  width: 100%;
  padding: 12px 13px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #ffffff;
}

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

.checkbox input {
  width: auto;
}

.row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  padding: 11px 16px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 700;
}

.button-secondary {
  background: #fffdf9;
  color: var(--accent-strong);
  border: 1px solid var(--accent);
}

.button-danger {
  background: var(--danger);
  color: white;
}

.flash {
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 14px;
}

.flash-success {
  background: rgba(31, 104, 112, 0.08);
  color: var(--accent-strong);
}

.flash-error {
  background: rgba(140, 47, 47, 0.12);
  color: var(--danger);
}

.filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.filters select,
.filters button,
.filters input {
  width: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  text-align: left;
}

.table th {
  color: var(--muted);
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.pill {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(31, 104, 112, 0.1);
  color: var(--accent-strong);
  font-size: 0.82rem;
}

.pill-warn {
  background: rgba(141, 93, 0, 0.12);
  color: var(--warn);
}

.block-form {
  margin-bottom: 14px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.asset-card {
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 16px;
}

.compact-text {
  max-width: 420px;
  word-break: break-all;
}

.video-picker {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px;
}

.picker-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border-radius: 10px;
}

.picker-row:hover {
  background: rgba(31, 104, 112, 0.06);
}

.picker-row input {
  width: auto;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 14px;
}

.calendar-day {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.55);
  min-height: 220px;
}

.calendar-day header {
  margin-bottom: 12px;
  font-weight: 700;
}

.calendar-card {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
  padding: 10px;
  border-radius: 12px;
  background: white;
  border: 1px solid var(--border);
}

.calendar-filled {
  border-color: rgba(31, 104, 112, 0.35);
}

.inline-form {
  display: grid;
  gap: 6px;
}

.inset-form {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.hero-panel {
  margin-bottom: 20px;
  background: #fffdf9;
}

.hero-note {
  max-width: 320px;
  display: grid;
  gap: 6px;
  padding: 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(31, 104, 112, 0.14);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.82rem;
  font-weight: 900;
}

.row-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.row-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.row-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.helper-panel {
  margin-top: 20px;
}

.token-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.token {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(31, 104, 112, 0.08);
  border: 1px solid rgba(31, 104, 112, 0.12);
}

.token-button {
  cursor: pointer;
  font: inherit;
  color: var(--accent-strong);
}

.selected-list {
  display: grid;
  gap: 10px;
}

.selected-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.82);
}

.selected-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mini-button {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fffdf9;
  color: var(--accent-strong);
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 700;
}

.mini-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.mini-button-danger {
  color: var(--danger);
}

.form-note {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
  padding: 12px 14px;
  border: 1px dashed var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.delete-panel {
  display: grid;
  gap: 18px;
}

.delete-summary {
  display: grid;
  gap: 6px;
}

.delete-summary h2 {
  margin: 0;
}

.delete-warning strong {
  display: block;
  margin-top: 8px;
}

.hero-actions,
.video-library-actions,
.empty-state-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.video-library-hero {
  margin-bottom: 20px;
}

.video-library-head {
  margin-bottom: 0;
}

.video-library-new {
  min-width: 132px;
}

.bulk-upload-errors {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 10px;
}

.bulk-upload-errors li {
  color: var(--danger);
}

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

.video-table th,
.video-table td {
  padding-top: 18px;
  padding-bottom: 18px;
}

.video-thumb-shell {
  width: 108px;
}

.video-thumb {
  width: 108px;
  height: 62px;
  object-fit: cover;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(31, 104, 112, 0.06);
}

.video-thumb-empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.video-asset {
  font-weight: 800;
  letter-spacing: 0.04em;
}

.video-title-cell {
  display: grid;
  gap: 6px;
  min-width: 220px;
}

.video-category-list {
  max-width: 220px;
  line-height: 1.45;
}

.toggle-form {
  margin: 0;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  padding: 0;
  color: var(--ink);
  cursor: pointer;
}

.switch-track {
  position: relative;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: rgba(107, 99, 89, 0.24);
  transition: background 160ms ease;
}

.switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16);
  transition: transform 160ms ease;
}

.switch.is-on .switch-track {
  background: var(--accent);
}

.switch.is-on .switch-thumb {
  transform: translateX(20px);
}

.switch-label {
  font-weight: 700;
  color: var(--muted);
}

.switch.is-on .switch-label {
  color: var(--accent-strong);
}

.video-actions {
  width: 72px;
  text-align: right;
  overflow: visible;
}

.actions-menu {
  position: relative;
  display: inline-block;
}

.actions-menu summary {
  list-style: none;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fffdf9;
  color: var(--accent-strong);
  font-size: 1.2rem;
  font-weight: 800;
}

.actions-menu summary::-webkit-details-marker {
  display: none;
}

.actions-popover {
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  min-width: 140px;
  padding: 8px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
  z-index: 10;
}

.actions-popover a {
  display: block;
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 700;
}

.actions-popover a:hover {
  background: rgba(31, 104, 112, 0.08);
}

.table-code {
  display: inline-block;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: top;
}

.empty-state {
  display: grid;
  gap: 10px;
  justify-items: start;
  padding: 18px 0 4px;
}

@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .row-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    min-height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .two-col,
  .stats-grid,
  .row,
  .row-2,
  .row-3,
  .row-4 {
    grid-template-columns: 1fr;
  }

  .hero-actions,
  .video-library-actions,
  .empty-state-actions {
    align-items: stretch;
  }

  .analytics-chart-labels {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

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

.schedule-dialog {
  width: min(480px, calc(100% - 32px));
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0;
}

.schedule-dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.dialog-shell {
  padding: 22px 22px 0;
}

.schedule-dialog .stack {
  padding: 0 22px 22px;
}

.traffic-pill {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.traffic-red {
  background: rgba(140, 47, 47, 0.14);
  color: #7d1d1d;
}

.traffic-yellow {
  background: rgba(191, 128, 0, 0.18);
  color: #7a5200;
}

.traffic-green {
  background: rgba(38, 121, 72, 0.16);
  color: #1f6a3f;
}

.month-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.month-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 12px;
}

.month-day {
  min-height: 170px;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.72);
}

.month-day-required {
  background: rgba(244, 214, 114, 0.24);
  border-color: rgba(210, 172, 53, 0.4);
}

.month-day-complete {
  background: rgba(135, 198, 126, 0.24);
  border-color: rgba(76, 142, 78, 0.35);
}

.month-day header {
  margin-bottom: 8px;
  font-weight: 700;
}

.month-day-muted {
  opacity: 0.45;
}

.month-item {
  display: grid;
  gap: 4px;
  margin-bottom: 8px;
  padding: 8px;
  border-radius: 12px;
  background: white;
  border: 1px solid var(--border);
}

.schedule-settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.weekday-pills,
.weekday-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.weekday-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-weight: 700;
}

.weekday-pill-active {
  background: rgba(244, 214, 114, 0.35);
  color: #7a5200;
  border-color: rgba(210, 172, 53, 0.45);
}

.weekday-pill-large {
  width: 44px;
  height: 44px;
}

.weekday-option {
  display: inline-flex;
  align-items: center;
  gap: 0;
}

.weekday-option input {
  display: none;
}

.weekday-option input:checked + .weekday-pill {
  background: rgba(244, 214, 114, 0.35);
  color: #7a5200;
  border-color: rgba(210, 172, 53, 0.45);
}

.import-attach-list {
  display: grid;
  gap: 14px;
}

.import-attach-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(0, 1fr) minmax(0, 1fr) auto minmax(220px, 0.9fr);
  gap: 14px;
  align-items: center;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.85);
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.import-attach-row.is-complete {
  border-color: rgba(32, 122, 72, 0.3);
  background: rgba(218, 245, 227, 0.9);
}

.import-attach-row.is-error {
  border-color: rgba(177, 53, 68, 0.35);
  background: rgba(255, 236, 238, 0.92);
}

.import-attach-meta {
  display: grid;
  gap: 8px;
}

.import-drop-shell {
  min-width: 0;
}

.import-drop-zone {
  display: grid;
  gap: 8px;
  min-height: 118px;
  align-content: center;
  justify-items: start;
  padding: 16px;
  border: 2px dashed rgba(31, 104, 112, 0.2);
  border-radius: 18px;
  background: rgba(248, 245, 239, 0.9);
  cursor: pointer;
}

.import-drop-zone.is-dragging {
  border-color: var(--accent);
  background: rgba(31, 104, 112, 0.08);
}

.import-drop-title {
  font-weight: 800;
}

.import-drop-copy,
.import-drop-file {
  color: var(--muted);
  line-height: 1.45;
  word-break: break-word;
}

.import-drop-file {
  font-weight: 700;
  color: var(--ink);
}

.import-attach-actions {
  display: grid;
  gap: 10px;
  align-content: center;
}

.import-attach-status {
  display: grid;
  gap: 10px;
}

.import-attach-progress progress {
  width: 100%;
  height: 12px;
}

.public-page {
  min-height: 100vh;
}

.public-watch {
  width: min(900px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.video-frame {
  margin-top: 24px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 14px 30px rgba(61, 44, 18, 0.06);
}

.video-frame video {
  width: 100%;
  display: block;
  border-radius: 14px;
  background: black;
}

@media (max-width: 900px) {
  .two-col,
  .stats-grid,
  .action-grid,
  .calendar-grid,
  .month-grid,
  .month-weekdays {
    grid-template-columns: 1fr;
  }

  .import-attach-row {
    grid-template-columns: 1fr;
  }

  .hero-heading,
  .section-heading {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .sidebar {
    position: static;
    min-height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .page {
    padding: 20px 16px 36px;
  }
}
