:root {
  --bg: #0b0f17;
  --bg-2: #111726;
  --surface: #161d2e;
  --surface-2: #1d2640;
  --border: #25304b;
  --text: #e6ebf5;
  --muted: #93a0bd;
  --primary: #5b8cff;
  --primary-2: #3f6fe6;
  --accent: #18c29c;
  --danger: #ff5d6c;
  --warn: #ffb547;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --hero-glow: #1a2540;
}

/* ── Light theme (colors from the proposal design) ── */
:root[data-theme="light"] {
  --bg: #f4f7fb;
  --bg-2: #e9eef8;
  --surface: #ffffff;
  --surface-2: #eef3fb;
  --border: rgba(16,32,51,.12);
  --text: #102033;
  --muted: #52647f;
  --primary: #2563eb;
  --primary-2: #7c3aed;
  --accent: #16a34a;
  --danger: #dc2626;
  --warn: #d97706;
  --shadow: 0 18px 50px rgba(16,32,51,.12);
  --hero-glow: #cfe0ff;
}
:root[data-theme="light"] body { color-scheme: light; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, var(--hero-glow) 0, transparent 60%), var(--bg);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden; /* never let a wide child eat the side gutters */
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

.container { width: 100%; max-width: 1140px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 460px; }

/* ── Top nav ── */
.nav {
  position: sticky; top: 0; z-index: 30;
  background: var(--nav-bg, rgba(11,15,23,.82));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
:root[data-theme="light"] { --nav-bg: rgba(244,247,251,.85); }

/* Light-theme contrast fixes for tinted alerts/badges */
:root[data-theme="light"] .alert--error { color: #b42318; }
:root[data-theme="light"] .alert--ok    { color: #0f7a4f; }
:root[data-theme="light"] .alert--info   { color: #1e4fd0; }
:root[data-theme="light"] .alert--warn   { color: #9a6700; }
:root[data-theme="light"] .badge--active { color: #0f7a4f; }
:root[data-theme="light"] .badge--pending { color: #9a6700; }
:root[data-theme="light"] .badge--expired,
:root[data-theme="light"] .badge--fail   { color: #b42318; }
.nav__inner { display: flex; align-items: center; gap: 14px; min-height: 62px; flex-wrap: wrap; padding-block: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; color: var(--text); flex: none; }
.brand:hover { text-decoration: none; }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.nav__links { display: flex; gap: 6px; margin-inline-start: auto; align-items: center; flex-wrap: wrap; }
.lang-switch { display: inline-flex; gap: 2px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.lang-switch a { padding: 6px 9px; font-size: 12px; font-weight: 700; color: var(--muted); }
.lang-switch a:hover { background: var(--surface); text-decoration: none; }
.lang-switch a.active { background: var(--surface-2); color: var(--text); }
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 15px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text); line-height: 1;
}
.theme-toggle:hover { border-color: var(--primary); }
.nav__links a { color: var(--muted); padding: 8px 12px; border-radius: 9px; font-size: 14px; font-weight: 600; }
.nav__links a:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.nav__links a.active { color: var(--text); background: var(--surface-2); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 10px;
  padding: 11px 18px; font-size: 14px; font-weight: 700; cursor: pointer;
  background: var(--surface-2); color: var(--text); transition: .15s;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn--primary { background: linear-gradient(180deg, var(--primary), var(--primary-2)); color: #fff; }
.btn--accent { background: linear-gradient(180deg, #1ad3a8, #12a888); color: #04231c; }
.btn--ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn--danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn--danger:hover { background: rgba(255,93,108,.12); }
.btn--sm { padding: 7px 12px; font-size: 13px; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }

/* ── Cards / surfaces ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card + .card { margin-top: 18px; }
.section { padding-block: 32px; } /* vertical only — must not clobber .container's side gutter */
h1,h2,h3 { line-height: 1.2; }
h1 { font-size: 30px; margin: 0 0 6px; }
h2 { font-size: 22px; margin: 0 0 14px; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* ── Forms ── */
.field { margin-bottom: 15px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.input, select, textarea {
  width: 100%; padding: 11px 13px; border-radius: 10px;
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  font-size: 14px; font-family: inherit;
}
.input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91,140,255,.18); }
textarea { min-height: 84px; resize: vertical; }

/* ── Alerts ── */
.alert { padding: 12px 15px; border-radius: 10px; font-size: 14px; margin-bottom: 16px; border: 1px solid transparent; }
.alert--error { background: rgba(255,93,108,.10); border-color: rgba(255,93,108,.4); color: #ffb1b9; }
.alert--ok { background: rgba(24,194,156,.10); border-color: rgba(24,194,156,.4); color: #8ff0d8; }
.alert--info { background: rgba(91,140,255,.10); border-color: rgba(91,140,255,.4); color: #bcd0ff; }
.alert--warn { background: rgba(255,181,71,.10); border-color: rgba(255,181,71,.4); color: #ffd9a1; }

/* ── Badges ── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge--active { background: rgba(24,194,156,.16); color: #6fe9cf; }
.badge--pending { background: rgba(255,181,71,.16); color: #ffce8a; }
.badge--expired, .badge--fail { background: rgba(255,93,108,.16); color: #ffb1b9; }
.badge--off { background: var(--surface-2); color: var(--muted); }

/* ── Grids ── */
.grid { display: grid; gap: 18px; }
.grid--plans { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid--channels { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.form-grid { grid-template-columns: 1fr 1fr; gap: 0 16px; }

/* ── Pricing ── */
.plan { display: flex; flex-direction: column; }
.plan.is-featured { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary), var(--shadow); }
.plan .price { font-size: 34px; font-weight: 800; margin: 6px 0; }
.plan .price small { font-size: 14px; color: var(--muted); font-weight: 600; }
.plan ul { list-style: none; padding: 0; margin: 14px 0; }
.plan li { padding: 6px 0; color: var(--muted); font-size: 14px; border-bottom: 1px dashed var(--border); }
.plan li::before { content: "✓"; color: var(--accent); font-weight: 800; margin-inline-end: 8px; }
.plan .btn { margin-top: auto; }

/* ── Tables ── */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: start; padding: 11px 12px; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.table tr:hover td { background: var(--bg-2); }
.table-wrap { overflow-x: auto; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--bg-2); padding: 2px 7px; border-radius: 6px; overflow-wrap: anywhere; }

/* ── Player / dashboard ── */
.dash { display: grid; grid-template-columns: 280px 1fr; gap: 22px; align-items: start; }
.channel-list { display: flex; flex-direction: column; gap: 8px; }
.channel-item {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px;
  border: 1px solid var(--border); border-radius: 11px; cursor: pointer; background: var(--surface);
  transition: .15s; width: 100%; text-align: start; color: var(--text); font: inherit;
}
.channel-item:hover { border-color: var(--primary); }
.channel-item.active { background: var(--surface-2); border-color: var(--primary); }
.channel-item .live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 8px var(--danger); flex: none; }
.channel-item .meta { overflow: hidden; }
.channel-item .meta b { display: block; font-size: 14px; }
.channel-item .meta span { font-size: 12px; color: var(--muted); }
.player-wrap { background: #000; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.player-wrap video { width: 100%; aspect-ratio: 16/9; background: #000; display: block; }
.player-bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--surface); flex-wrap: wrap; }
.player-bar .title { font-weight: 700; }
.player-status { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.player-status .live-dot { width: 9px; height: 9px; border-radius: 50%; background: #555; }
.player-status.is-live .live-dot { background: var(--danger); box-shadow: 0 0 8px var(--danger); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

/* Player controls */
.player-ctl { display: flex; align-items: center; gap: 6px; }
.player-quality select {
  width: auto; padding: 6px 8px; font-size: 13px; border-radius: 8px;
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
}
.ctl-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 32px; padding: 0 8px; font-size: 14px; font-weight: 700;
  border-radius: 8px; cursor: pointer; color: var(--text);
  background: var(--bg-2); border: 1px solid var(--border);
}
.ctl-btn:hover { border-color: var(--primary); }
.ctl-btn.on { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Theater mode — hide the channel rail, let the player take the width */
body.theater .dash { grid-template-columns: 1fr; }
body.theater .dash > aside { display: none; }
body.theater .player-wrap { max-height: 82vh; }
body.theater .player-wrap video { max-height: 74vh; }

/* ── Hero (landing) ── */
.hero { padding: 70px 0 40px; text-align: center; }
.hero h1 { font-size: 46px; max-width: 760px; margin: 0 auto 14px; letter-spacing: -.5px; }
.hero p { font-size: 18px; color: var(--muted); max-width: 600px; margin: 0 auto 26px; }
.hero .cta { display: flex; gap: 12px; justify-content: center; }
.kicker { display: inline-block; color: var(--accent); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: 12px; margin-bottom: 14px; }

/* Pure-CSS bar chart */
.chart { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 8px; }
.chart__col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.chart__bar { width: 70%; border-radius: 5px 5px 0 0; min-height: 2px; transition: height .3s; }
.chart__x { font-size: 10px; color: var(--muted); margin-top: 6px; white-space: nowrap; }

.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.spacer { flex: 1; }
hr.sep { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.footer { color: var(--muted); font-size: 13px; padding: 30px 0; text-align: center; border-top: 1px solid var(--border); margin-top: 40px; }

/* ── RTL refinements ── */
[dir="rtl"] .player-status,
[dir="rtl"] .channel-item { text-align: right; }
[dir="rtl"] .chart { direction: ltr; } /* keep time axis left→right */
[dir="rtl"] .mono, [dir="rtl"] code { direction: ltr; unicode-bidi: embed; display: inline-block; }

@media (max-width: 820px) {
  .dash { grid-template-columns: 1fr; }
  .hero h1 { font-size: 36px; }
}

/* Plans: one card per row on phones / large phones */
@media (max-width: 640px) {
  .grid--plans { grid-template-columns: 1fr; }
  .plan.is-featured { order: -1; } /* surface the popular plan first */
}

/* ── Phones ── */
@media (max-width: 560px) {
  .container { padding: 0 50px; }
  .section { padding-block: 22px; }
  .card { padding: 18px; }

  /* Nav stacks: brand on first line, links scroll horizontally below it */
  .nav__inner { gap: 8px; padding-block: 8px; }
  .nav__links {
    margin-left: 0; width: 100%; flex-wrap: nowrap;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    gap: 4px; padding-bottom: 2px; scrollbar-width: none;
  }
  .nav__links::-webkit-scrollbar { display: none; }
  .nav__links a { padding: 7px 10px; font-size: 13px; white-space: nowrap; }
  .nav__links form { flex: none; }

  h1 { font-size: 24px; }
  h2 { font-size: 19px; }
  .hero { padding: 40px 0 24px; }
  .hero h1 { font-size: 28px; }
  .hero p { font-size: 16px; }
  .hero .cta { flex-direction: column; }
  .hero .cta .btn { width: 100%; }

  /* Any 2-col form collapses to one column */
  .form-grid { grid-template-columns: 1fr; }

  /* Pricing/feature cards already single-column via auto-fit */
  .plan .price { font-size: 28px; }

  /* Action rows in tables wrap under content instead of overflowing */
  .table th, .table td { padding: 9px 8px; }

  .player-bar { padding: 10px 12px; }
}
