@font-face {
  font-family: "InterLocal";
  src: url("/fonts/Inter-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "InterLocal";
  src: url("/fonts/Inter-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "InterLocal";
  src: url("/fonts/Inter-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #08090b;
  --surface: #0e1013;
  --surface-2: #121418;
  --border: #20242a;
  --border-strong: #2c3138;
  --text: #e7e9eb;
  --muted: #8b939b;
  --soft: #6f777f;
  --accent: #93a89c;
  --danger: #b26b64;
  --ok: #8aa79a;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "InterLocal", Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 26px 18px 18px;
  border-right: 1px solid var(--border);
  background: #0a0b0d;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
}

.brand strong {
  display: block;
  font-size: 13px;
  letter-spacing: 0.14em;
  font-weight: 600;
}

.brand span {
  display: block;
  font-size: 11px;
  color: var(--soft);
  letter-spacing: 0.08em;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  display: grid;
  place-items: center;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--surface);
}

.brand-mark.small { width: 34px; height: 34px; border-radius: 9px; font-size: 11px; }

#nav { display: grid; gap: 6px; }

.nav-item {
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  transition: background 120ms ease, color 120ms ease;
}

.nav-item:hover { color: var(--text); background: var(--surface); }
.nav-item.active { color: var(--text); background: var(--surface-2); box-shadow: inset 2px 0 0 var(--accent); }

.sidebar-foot { margin-top: auto; display: grid; gap: 14px; padding: 0 8px; }
.identity { display: grid; gap: 2px; }
.identity span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }
.identity strong { font-size: 13px; font-weight: 500; }

.main { padding: 28px clamp(20px, 4vw, 48px) 60px; max-width: 1500px; width: 100%; }

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 30px;
}

.eyebrow { font-size: 10px; letter-spacing: 0.18em; color: var(--soft); text-transform: uppercase; }
h1 { margin: 5px 0 0; font-size: 28px; line-height: 1.15; font-weight: 600; letter-spacing: -0.02em; }
h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.top-actions { display: flex; align-items: center; gap: 10px; }

.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: grid;
  gap: 8px;
}
.card span { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.card strong { font-size: 21px; font-weight: 600; letter-spacing: -0.02em; }
.card small { color: var(--soft); font-size: 12px; }

.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }

.kv { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 11px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: 12px; }
.kv dd { margin: 0; text-align: right; color: var(--text); font-size: 13px; overflow-wrap: anywhere; }

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.pill.ok { color: var(--ok); border-color: #32483f; }
.pill.bad { color: var(--danger); border-color: #4c302e; }

.btn {
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 14px;
  transition: border-color 120ms ease, background 120ms ease;
}
.btn:hover { border-color: #3a4149; background: #171a1f; }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.danger { color: var(--danger); border-color: #4a302e; background: transparent; }
.btn.ghost:hover, .btn.danger:hover { background: #15171b; color: var(--text); }

.button-row { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 18px; }
.form-row { display: flex; gap: 9px; margin-top: 18px; }

input, textarea {
  width: 100%;
  background: #0b0c0e;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}
input:focus, textarea:focus { border-color: #3a4149; }
textarea { min-height: 390px; resize: vertical; line-height: 1.6; font-family: "InterLocal", Inter, ui-sans-serif, sans-serif; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--soft); font-size: 10px; text-transform: uppercase; letter-spacing: 0.09em; font-weight: 500; }
td { font-size: 12.5px; color: var(--muted); }
td strong { color: var(--text); font-weight: 500; }
tr:last-child td { border-bottom: 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11.5px; color: #b9c0c6; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-actions .btn { padding: 5px 8px; font-size: 11px; }

.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.stat-row div { border: 1px solid var(--border); border-radius: 10px; padding: 13px; display: grid; gap: 5px; }
.stat-row span { color: var(--muted); font-size: 11px; }
.stat-row strong { font-size: 20px; font-weight: 600; }

.empty { color: var(--muted); padding: 22px 0; }
.muted { color: var(--muted); }
.texts-layout { grid-template-columns: minmax(240px, 0.7fr) minmax(0, 1.3fr); }
.category-list { display: grid; gap: 5px; }
.category-group { margin-bottom: 10px; }
.category-title { color: var(--soft); font-size: 10px; text-transform: uppercase; letter-spacing: 0.09em; padding: 6px 8px; }
.text-link {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 8px 10px;
  border-radius: 7px;
}
.text-link:hover { background: var(--surface-2); color: var(--text); }
.text-link.active { background: var(--surface-2); color: var(--text); }
.text-link.overridden::after { content: " custom"; color: var(--accent); font-size: 10px; }

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 34px;
}
.gate-card h1 { font-size: 24px; margin-top: 22px; }
.gate-card p { color: var(--muted); }
.gate-card .brand-mark { width: 46px; height: 46px; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(3, 4, 5, 0.76);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 30;
}
.modal-card {
  width: min(430px, 100%);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 24px;
}
.modal-card h2 { margin-bottom: 8px; }
.modal-card input { margin-top: 18px; }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  background: #14171b;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  padding: 12px 16px;
  max-width: 340px;
  color: var(--text);
  z-index: 40;
}

[hidden] { display: none !important; }

@media (max-width: 1000px) {
  .shell { grid-template-columns: 190px minmax(0, 1fr); }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .texts-layout { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 16px;
    gap: 16px;
  }
  #nav { grid-template-columns: repeat(5, minmax(0, 1fr)); display: grid; }
  .nav-item { text-align: center; padding: 9px 5px; font-size: 12px; }
  .sidebar-foot { display: none; }
  .main { padding: 22px 16px 40px; }
  .cards { grid-template-columns: 1fr 1fr; }
  .topbar { align-items: flex-start; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
  h1 { font-size: 23px; }
  .form-row { flex-direction: column; }
}

.section-gap { margin-top: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid label, .field-label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; }
.field-label { margin-top: 16px; }
.small-area { min-height: 120px; }
.select { width: 100%; background: #0b0c0e; border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; color: var(--text); margin-top: 4px; }
.channel-list { display: grid; gap: 7px; max-height: 340px; overflow: auto; }
.channel-item { border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; color: var(--muted); display: flex; justify-content: space-between; gap: 10px; }
.channel-item strong { color: var(--text); font-weight: 500; }
.compact { margin-top: 8px; }
.poly-cards { margin-bottom: 16px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

.sync { color: #9cb6e8; border-color: #263b5c; background: #0d1522; }
.sync::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 7px; box-shadow: 0 0 0 3px #142238; }
.pnl-layout { grid-template-columns: minmax(300px, 0.75fr) minmax(0, 1.25fr); align-items: start; }
.pnl-frame { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #000; min-height: 220px; display: grid; place-items: center; }
.pnl-frame img { display: block; width: 100%; height: auto; }
.pnl-frame:has(img[hidden]) { display: none; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
