:root {
  --bg-main: #0e1525;
  --bg-main-2: #121e31;
  --bg-side: #343d52;
  --bg-side-deep: #2c3448;
  --bg-active: #080c1a;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.07);
  --line: rgba(255, 255, 255, 0.08);
  --text: #f4f6fb;
  --muted: #9aa3b8;
  --accent: #ff6600;
  --accent-hot: #f86200;
  --accent-soft: rgba(255, 102, 0, 0.18);
  --ok: #4caf82;
  --danger: #ef6b6b;
  --radius: 14px;
  --side-w: 92px;
  --font-brand: "Nunito", sans-serif;
  --font-body: "Outfit", sans-serif;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font-body);
  background: var(--bg-main);
  -webkit-font-smoothing: antialiased;
}
body.is-app {
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #ff8533; }

/* —— Sidebar (Ziggo app) —— */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: linear-gradient(180deg, var(--bg-side) 0%, var(--bg-side-deep) 100%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 1.1rem 0 1rem;
  z-index: 20;
  animation: side-in 0.45s ease both;
}

.brand-logo {
  font-family: var(--font-brand);
  font-weight: 900;
  font-size: 1.45rem;
  letter-spacing: -0.04em;
  color: var(--accent);
  text-align: center;
  padding: 0.35rem 0.4rem 1.1rem;
  line-height: 1;
  transition: transform 0.2s ease;
}
.brand-logo:hover { transform: scale(1.04); color: var(--accent); text-decoration: none; }

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.side-item-form { margin: 0; }
.side-item {
  appearance: none;
  border: 0;
  background: transparent;
  color: #dce2ef;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.28rem;
  padding: 0.85rem 0.4rem;
  cursor: pointer;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: background 0.2s ease, color 0.2s ease;
  text-decoration: none;
}
.side-item:hover {
  background: rgba(8, 12, 26, 0.35);
  color: #fff;
  text-decoration: none;
}
.side-item.active {
  background: var(--bg-active);
  color: #fff;
}
.side-item.active .side-ico { color: var(--accent); }
.side-ico {
  display: grid;
  place-items: center;
  color: inherit;
  width: 28px;
  height: 28px;
}
.side-label { opacity: 0.95; }
.side-foot { margin-top: auto; }
.side-item.logout { color: var(--muted); }
.side-item.logout:hover { color: #fff; }

.shell {
  min-width: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 12% -8%, rgba(255, 102, 0, 0.12), transparent 55%),
    radial-gradient(700px 380px at 100% 0%, rgba(80, 110, 180, 0.12), transparent 50%),
    linear-gradient(165deg, var(--bg-main-2), var(--bg-main) 55%, #0a101c);
  padding: 1.4rem 1.6rem 2.5rem;
  animation: rise 0.5s ease both;
}

body.is-auth .shell {
  display: grid;
  place-items: center;
  padding: 2rem;
}

/* —— Page head —— */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}
.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.page-title {
  margin: 0;
  font-weight: 300;
  font-size: clamp(1.8rem, 3.2vw, 2.4rem);
  letter-spacing: -0.02em;
  color: #eef2fa;
}
.account-line { margin: 0 0 1.1rem; font-size: 0.92rem; }
.muted { color: var(--muted); }

.status-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: flex-end;
}
.pill {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
  color: var(--muted);
}
.pill.ok { color: #b8f0d2; border-color: rgba(76,175,130,0.35); background: rgba(76,175,130,0.12); }
.pill.bad { color: #ffc9c9; border-color: rgba(239,107,107,0.35); background: rgba(239,107,107,0.12); }

/* —— Controls —— */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  margin: 0 0 1.35rem;
  padding: 0.85rem;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
}
.toolbar input[type="search"] {
  flex: 1 1 220px;
  min-width: 180px;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.88rem;
  user-select: none;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--text);
  border-radius: 999px;
  padding: 0.58rem 1rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.btn:hover {
  transform: translateY(-1px);
  background: rgba(255,255,255,0.08);
  text-decoration: none;
  color: #fff;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent-hot), var(--accent));
  border-color: transparent;
  color: #1a0900;
  box-shadow: 0 8px 22px rgba(255, 102, 0, 0.28);
}
.btn-primary:hover { color: #1a0900; filter: brightness(1.05); }
.btn-key {
  background: var(--accent-soft);
  border-color: rgba(255, 102, 0, 0.45);
  color: #ffd2b0;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(8, 12, 26, 0.55);
  color: var(--text);
  border-radius: 12px;
  padding: 0.72rem 0.9rem;
  font: inherit;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(255, 102, 0, 0.55);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.88rem;
  color: var(--muted);
}
.stack { display: grid; gap: 0.9rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.45rem; }

/* —— Channel grid —— */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.9rem;
}
.channel {
  position: relative;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--line);
  padding: 0.95rem;
  box-shadow: var(--shadow);
  animation: rise 0.55s ease both;
  transition: transform 0.18s ease, border-color 0.2s ease, background 0.2s ease;
}
.channel:hover {
  transform: translateY(-2px);
  background: var(--bg-card-hover);
  border-color: rgba(255, 102, 0, 0.28);
}
.channel.has-key { border-color: rgba(255, 102, 0, 0.35); }
.channel-flag {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.22rem 0.5rem;
  border-radius: 999px;
}
.flag-key { background: var(--accent-soft); color: #ffc291; }
.flag-ok { background: rgba(76,175,130,0.15); color: #9be4c2; }
.flag-free { background: rgba(120,150,220,0.15); color: #b8c8f0; }

.channel-head {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 0.8rem;
  margin-bottom: 0.85rem;
}
.logo-wrap {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(8, 12, 26, 0.65);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
}
.logo { width: 100%; height: 100%; object-fit: contain; }
.logo.placeholder {
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--accent);
}
.channel-title h3 {
  margin: 0.15rem 0;
  font-size: 1.02rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.pos, .meta { color: var(--muted); font-size: 0.78rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-all; }
.badge {
  display: inline-block;
  margin-top: 0.35rem;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}
.badge.ready { background: rgba(76,175,130,0.14); color: #a8ecc9; }
.badge.missing { background: rgba(239,107,107,0.12); color: #ffc2c2; }

.empty-state {
  grid-column: 1 / -1;
  color: var(--muted);
  padding: 2rem;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

/* —— Auth —— */
.auth-screen { width: min(420px, 100%); }
.auth-card {
  background: rgba(52, 61, 82, 0.45);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1.8rem 1.5rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  animation: rise 0.55s ease both;
}
.auth-brand {
  font-size: 2.2rem;
  padding: 0;
  margin-bottom: 0.4rem;
  text-align: left;
}
.auth-card h1 {
  margin: 0 0 0.25rem;
  font-weight: 300;
  font-size: 1.6rem;
}

/* —— Dialog / flash / toast —— */
.panel {
  background: var(--bg-side);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.2rem;
}
.settings-dialog {
  border: 0;
  border-radius: 18px;
  padding: 0;
  background: transparent;
  color: var(--text);
  max-width: min(440px, calc(100vw - 2rem));
}
.settings-dialog::backdrop {
  background: rgba(4, 8, 18, 0.72);
  backdrop-filter: blur(4px);
}
.settings-dialog .panel { margin: 0; box-shadow: var(--shadow); }
.settings-dialog h2 { margin: 0 0 0.4rem; font-weight: 500; }

.flash {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  animation: rise 0.35s ease both;
}
.flash.ok { border-color: rgba(76,175,130,0.35); background: rgba(76,175,130,0.1); }
.flash.err { border-color: rgba(239,107,107,0.4); background: rgba(239,107,107,0.12); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.4rem;
  transform: translateX(-50%);
  z-index: 50;
  background: #1a2236;
  border: 1px solid rgba(255, 102, 0, 0.4);
  color: #fff;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-weight: 600;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes side-in {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 820px) {
  body.is-app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: sticky;
    top: 0;
    height: auto;
    flex-direction: row;
    align-items: center;
    padding: 0.55rem 0.6rem;
    gap: 0.4rem;
    overflow-x: auto;
  }
  .brand-logo {
    font-size: 1.2rem;
    padding: 0 0.5rem 0 0.2rem;
  }
  .side-nav {
    flex-direction: row;
    flex: 1;
    gap: 0.15rem;
  }
  .side-item {
    flex-direction: row;
    gap: 0.35rem;
    padding: 0.55rem 0.7rem;
    border-radius: 999px;
    font-size: 0.78rem;
  }
  .side-item.active { border-radius: 999px; }
  .side-label { display: none; }
  .side-foot { margin-top: 0; }
  .shell { padding: 1rem 0.9rem 2rem; }
  .page-head { align-items: flex-start; }
  .status-pills { justify-content: flex-start; }
}
