:root {
  --bg: #0b0f16;
  --bg-elev: #141a24;
  --bg-hover: #1c2432;
  --line: #2a3446;
  --text: #f1f5fb;
  --muted: #8b97ab;
  --accent: #38bdf8;
  --ok: #34d399;
  --err: #fb7185;
  --radius: 14px;
  --shadow: 0 10px 32px rgba(0, 0, 0, 0.32);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --top: max(0.7rem, env(safe-area-inset-top));
  --bot: max(0.55rem, env(safe-area-inset-bottom));
  --pad: max(0.9rem, env(safe-area-inset-left));
}

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

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

body {
  background:
    radial-gradient(800px 380px at 8% -12%, rgba(56, 189, 248, 0.16), transparent 55%),
    radial-gradient(640px 320px at 110% 0%, rgba(244, 63, 94, 0.1), transparent 50%),
    var(--bg);
  padding-bottom: calc(4.6rem + var(--bot));
}

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

h1 {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0 0 0.7rem;
}
h2 {
  font-size: 0.95rem;
  margin: 0 0 0.7rem;
  letter-spacing: -0.02em;
}

.eyebrow {
  margin: 0 0 0.2rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.page-head h1 { margin: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: var(--top) var(--pad) 0.65rem;
  background: rgba(11, 15, 22, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text);
  font-weight: 800;
  letter-spacing: -0.03em;
  min-height: 44px;
}
.brand:hover { text-decoration: none; color: var(--text); }

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f43f5e;
  box-shadow: 0 0 0 4px rgba(244, 63, 94, 0.2);
}

.nav-desktop {
  display: none;
  gap: 0.2rem;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
}
.nav-desktop a {
  color: var(--muted);
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  font-weight: 600;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
}
.nav-desktop a:hover,
.nav-desktop a.is-on {
  color: var(--text);
  background: var(--bg-hover);
  text-decoration: none;
}

.logout { margin-left: auto; }
.logout button { min-height: 40px; }

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.1rem var(--pad) 1.5rem;
}

.nav-mobile {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  /* Özet · Kanallar · Rehber · Ayarlar */
  background: rgba(14, 18, 26, 0.96);
  border-top: 1px solid var(--line);
  padding: 0.25rem 0.2rem var(--bot);
  backdrop-filter: blur(14px);
}
.nav-mobile a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  min-height: 52px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-decoration: none;
}
.nav-mobile a span { font-size: 1.05rem; line-height: 1; }
.nav-mobile a.is-on { color: var(--accent); }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.65rem;
  margin: 0.4rem 0 1rem;
}
.kpi {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 0.85rem;
}
.kpi span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.kpi strong {
  display: block;
  margin-top: 0.2rem;
  font-size: 1.02rem;
  font-weight: 700;
  word-break: break-word;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin: 0.75rem 0 1rem;
}
.sticky-actions {
  position: sticky;
  bottom: calc(4.4rem + var(--bot));
  z-index: 15;
  background: rgba(11, 15, 22, 0.94);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.55rem;
  backdrop-filter: blur(10px);
}

.muted { color: var(--muted); font-size: 0.92rem; }
.err { color: var(--err); }
.ok { color: var(--ok); }
.hint { color: var(--muted); font-size: 0.85rem; margin-top: 1.2rem; }
.st-pasif { color: var(--muted); }
.st-aktif { color: var(--ok); font-weight: 650; }
.st-hata { color: var(--err); font-weight: 650; }
.st-kapali { color: #9ca3af; }

button, .btn {
  appearance: none;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--bg-hover);
  color: var(--text);
  padding: 0.62rem 0.95rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  touch-action: manipulation;
}
button:hover, .btn:hover {
  background: #263044;
  text-decoration: none;
}

.btn-primary,
form[action$="/apply"] > button,
form[action$="/login"] button {
  background: linear-gradient(180deg, #38bdf8, #0ea5e9);
  border-color: transparent;
  color: #042033;
}
.btn-primary:hover,
form[action$="/apply"] > button:hover,
form[action$="/login"] button:hover { filter: brightness(1.06); }

.btn-danger {
  background: transparent;
  border-color: #7f1d1d;
  color: #fda4af;
}
.btn-danger:hover { background: #3f1219; }

.banner {
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #10161f;
}
.banner.err { border-color: rgba(251, 113, 133, 0.4); }
.banner.ok { border-color: rgba(52, 211, 153, 0.35); }

.infobox {
  margin: 0.75rem 0 1rem;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(56, 189, 248, 0.28);
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.1), rgba(14, 18, 24, 0.35));
}
.infobox.warn {
  border-color: rgba(251, 191, 36, 0.35);
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.1), rgba(14, 18, 24, 0.35));
}
.infobox .infobox-title {
  margin: 0 0 0.4rem;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}
.infobox.warn .infobox-title { color: var(--warn); }
.infobox p {
  margin: 0 0 0.55rem;
  color: #c9d4e3;
  font-size: 0.92rem;
  line-height: 1.5;
}
.infobox p:last-child { margin-bottom: 0; }
.infobox ul {
  margin: 0.35rem 0 0;
  padding-left: 1.15rem;
  color: #c9d4e3;
  font-size: 0.92rem;
}
.infobox li { margin: 0.25rem 0; }
.infobox strong { color: var(--text); }
.infobox code {
  font-family: var(--mono);
  font-size: 0.84em;
  color: #e2e8f0;
  word-break: break-all;
}

.guide-steps {
  display: grid;
  gap: 0.85rem;
  margin: 1rem 0 1.5rem;
}
.guide-step {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.05rem;
  box-shadow: var(--shadow);
}
.guide-step .step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 800;
  margin-right: 0.45rem;
}
.guide-step h2 {
  display: inline;
  font-size: 1.02rem;
  margin: 0;
}
.guide-step p { margin: 0.55rem 0 0; color: #c9d4e3; font-size: 0.93rem; }
.guide-step ul { margin: 0.5rem 0 0; padding-left: 1.15rem; color: #c9d4e3; font-size: 0.92rem; }
.guide-step li { margin: 0.3rem 0; }
.guide-table {
  width: 100%;
  margin-top: 0.7rem;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.guide-table th, .guide-table td {
  text-align: left;
  padding: 0.55rem 0.45rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.guide-table th { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
th, td {
  text-align: left;
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: #10161f;
}
tr:last-child td { border-bottom: 0; }
.row-actions { white-space: nowrap; }
.row-actions form { display: inline; margin-left: 0.3rem; }

.mono-wrap {
  font-family: var(--mono);
  font-size: 0.8rem;
  word-break: break-all;
}

label {
  display: block;
  margin: 0.75rem 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}
label.check {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
  min-height: 44px;
}
input[type="text"],
input[type="password"],
input[type="url"],
select {
  display: block;
  width: 100%;
  max-width: none;
  margin-top: 0.35rem;
  padding: 0.7rem 0.8rem;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: #0c1016;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  min-height: 46px;
}
input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
}
input:focus, select:focus, button:focus {
  outline: 2px solid rgba(56, 189, 248, 0.45);
  outline-offset: 1px;
}

.form-stack { max-width: 40rem; }
.form-section {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1rem 0.85rem;
  margin: 0 0 0.85rem;
  box-shadow: var(--shadow);
}

pre.log {
  background: #07090d;
  color: #c9d4e3;
  padding: 0.9rem;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.4;
  max-height: 65vh;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;
}
.flash {
  white-space: pre-wrap;
  background: #0c1016;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  overflow-x: auto;
}

body.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  padding-bottom: 1.25rem;
}
.login-card {
  width: min(24rem, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1.5rem 1.25rem 1.3rem;
}
.login-card h1 { margin-bottom: 0.2rem; }
.login-card .sub { color: var(--muted); margin: 0 0 1.1rem; }
.login-card input, .login-card button { width: 100%; }
.login-card button { margin-top: 0.35rem; }

.channel-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.85rem;
}
.channel-card, .list-card, .empty-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
}
.channel-card {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  border-top: 3px solid #6b7280;
}
.channel-card.is-aktif, .list-card.is-aktif { border-top-color: var(--ok); }
.channel-card.is-hata, .list-card.is-hata { border-top-color: var(--err); }
.list-card { border-top: 3px solid var(--line); margin: 0 0 0.7rem; }

.channel-card-head, .list-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.6rem;
}
.channel-platform {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.channel-card h2 { margin: 0.15rem 0 0; font-size: 1.12rem; }

.status-pill {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  background: #1a2030;
  border: 1px solid var(--line);
  text-align: center;
}
.status-pill.st-aktif { color: var(--ok); border-color: rgba(52, 211, 153, 0.35); background: rgba(52, 211, 153, 0.1); }
.status-pill.st-hata { color: var(--err); border-color: rgba(251, 113, 133, 0.35); background: rgba(251, 113, 133, 0.1); }
.status-pill.st-pasif,
.status-pill.st-kapali { color: #9ca3af; }

.channel-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem 0.7rem;
  margin: 0;
}
.channel-stats .span-2 { grid-column: 1 / -1; }
.channel-stats dt {
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
}
.channel-stats dd {
  margin: 0.12rem 0 0;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  word-break: break-word;
}

.channel-card-foot {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-top: auto;
}
.channel-card-foot .btn, .channel-card-foot button { flex: 1 1 8rem; }

.mobile-list { display: block; }
.desktop-only { display: none; }

.kv {
  display: grid;
  gap: 0.55rem;
  margin: 0 0 0.8rem;
}
.kv div {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.45rem;
}
.kv dt { color: var(--muted); font-size: 0.82rem; }
.kv dd { margin: 0; font-weight: 650; text-align: right; word-break: break-word; }

.copy-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
  margin: 0.65rem 0;
}
.copy-row code {
  display: block;
  margin-top: 0.2rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  word-break: break-all;
}

.copy-field {
  display: flex;
  gap: 0.4rem;
  align-items: stretch;
  margin-top: 0.35rem;
  flex-wrap: wrap;
}
.copy-field input {
  flex: 1 1 12rem;
  min-width: 0;
  margin-top: 0;
}
.copy-field .btn {
  flex: 0 0 auto;
}

.empty-card { text-align: left; }

@media (min-width: 820px) {
  body { padding-bottom: 1.5rem; }
  .nav-mobile { display: none; }
  .topbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.75rem;
  }
  .brand { justify-self: start; }
  .nav-desktop {
    display: flex;
    flex: initial;
    justify-content: center;
    justify-self: center;
  }
  .logout {
    margin-left: 0;
    justify-self: end;
  }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .channel-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
  .mobile-list { display: none; }
  .desktop-only { display: block; }
  .sticky-actions {
    position: static;
    background: transparent;
    border: 0;
    padding: 0;
    backdrop-filter: none;
  }
  .wrap { padding: 1.5rem 1.25rem 2.5rem; }
}
