:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef5f2;
  --ink: #202428;
  --muted: #66717c;
  --line: #d8dee4;
  --primary: #176c5f;
  --primary-ink: #ffffff;
  --secondary: #244c7a;
  --danger: #b83a3a;
  --warning: #9a6a11;
  --radius: 8px;
  --shadow: 0 8px 30px rgba(28, 36, 45, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
}

a {
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(220px, auto) 1fr auto;
  gap: 24px;
  align-items: center;
  min-height: 72px;
  padding: 12px clamp(16px, 4vw, 44px);
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--primary-ink);
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
  white-space: nowrap;
}

.brand small {
  color: var(--muted);
}

.nav-links {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.nav-links a,
.text-link {
  color: var(--secondary);
  text-decoration: none;
  font-weight: 700;
}

.nav-links a {
  padding: 8px 10px;
  border-radius: 8px;
}

.nav-links a:hover {
  background: #eef3f7;
}

.logout {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.page {
  width: min(1380px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.page-narrow {
  width: min(760px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(23, 108, 95, 0.12), rgba(36, 76, 122, 0.08)),
    var(--bg);
}

.login-card {
  width: min(440px, 100%);
  padding: 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-brand {
  margin-bottom: 24px;
}

.dashboard-head {
  display: grid;
  grid-template-columns: 1fr minmax(320px, 520px);
  gap: 28px;
  align-items: end;
  padding: 30px 0 24px;
}

.dashboard-head h1,
.watch-layout h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4.25rem);
  line-height: 1;
  letter-spacing: 0;
}

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

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

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

.stats div {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.stats dt {
  color: var(--muted);
  font-size: 0.8rem;
}

.stats dd {
  margin: 4px 0 0;
  font-size: 1.4rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.section {
  padding: 34px 0;
  border-top: 1px solid var(--line);
}

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

h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

.stream-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
}

.stream-card,
.surface,
.empty-state {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stream-card {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.card-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-title p {
  margin: 4px 0 0;
  color: var(--muted);
}

.card-actions,
.inline-actions,
.assignment-form,
.row-actions {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.timer-form,
.schedule-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.schedule-form {
  grid-template-columns: minmax(170px, 1fr) minmax(130px, 0.65fr) auto;
}

.management-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(360px, 1.2fr);
  gap: 16px;
  align-items: start;
}

.surface,
.empty-state {
  padding: 18px;
}

.form-stack {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

label span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #c9d1d9;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus {
  outline: 3px solid rgba(23, 108, 95, 0.18);
  border-color: var(--primary);
}

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

.check-row input {
  width: 18px;
  min-height: 18px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.button-primary {
  background: var(--primary);
  color: var(--primary-ink);
}

.button-secondary {
  background: var(--secondary);
  color: #fff;
}

.button-muted {
  background: #eef3f7;
  color: #203449;
  border-color: #d3dce5;
}

.button-danger {
  background: #fff2f2;
  color: var(--danger);
  border-color: #f0c6c6;
}

.button:hover {
  filter: brightness(0.96);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #eef3f7;
  color: #203449;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: capitalize;
}

.status-active,
.status-completed {
  background: #e5f5ee;
  color: #116044;
}

.status-recording,
.status-running,
.status-starting {
  background: #fff4d8;
  color: var(--warning);
}

.status-failed,
.status-cancelled,
.status-stopped,
.status-paused {
  background: #fff0f0;
  color: var(--danger);
}

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

.manager-row {
  border-top: 1px solid var(--line);
  padding: 10px 0 0;
}

.manager-row summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  font-weight: 800;
}

.manager-row summary small {
  color: var(--muted);
  font-weight: 700;
}

.manager-row form {
  margin-top: 12px;
}

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

.assignment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

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

tr:last-child td {
  border-bottom: 0;
}

.actions-col {
  width: 220px;
}

.flash-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}

.flash {
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 700;
}

.flash-success {
  background: #e8f6ef;
  color: #116044;
  border-color: #bfe5d3;
}

.flash-error {
  background: #fff0f0;
  color: #9f2b2b;
  border-color: #f0c6c6;
}

.watch-layout {
  display: grid;
  gap: 18px;
}

.player {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #111;
  border-radius: var(--radius);
}

.settings-section {
  padding-bottom: 80px;
}

@media (max-width: 920px) {
  .topbar,
  .dashboard-head,
  .management-grid {
    grid-template-columns: 1fr;
  }

  .nav-links {
    justify-content: flex-start;
  }

  .logout {
    justify-content: space-between;
  }

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

  .schedule-form,
  .timer-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .page {
    width: min(100% - 20px, 1380px);
  }

  .topbar {
    padding: 10px;
  }

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

  .brand strong,
  .brand small {
    white-space: normal;
  }

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

  .button {
    width: 100%;
  }
}
