:root {
  color-scheme: dark;
  --bg: #0c1017;
  --panel: #141a24;
  --panel-2: #1b2330;
  --line: #2a3443;
  --text: #f4f6f8;
  --muted: #8d99aa;
  --yellow: #ffd33d;
  --yellow-soft: rgba(255, 211, 61, 0.12);
  --green: #42d39d;
  --red: #ff6a7a;
  --blue: #62a8ff;
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; min-height: 100dvh; overscroll-behavior-y: none; }
button, input, textarea, select { font: inherit; }
button { color: inherit; min-height: 42px; touch-action: manipulation; }
.hidden { display: none !important; }
.eyebrow { color: var(--yellow); font-size: 11px; font-weight: 800; letter-spacing: .14em; margin: 0 0 7px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(34px, 6vw, 54px); line-height: .98; margin-bottom: 18px; }
h2 { font-size: 30px; margin-bottom: 0; }
h3 { font-size: 20px; margin-bottom: 0; }

.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(circle at 80% 10%, rgba(255,211,61,.12), transparent 30%),
  linear-gradient(135deg, #0b0f16, #121a24); }
.auth-card { width: min(440px, 100%); padding: 38px; background: rgba(20,26,36,.94); border: 1px solid var(--line); border-radius: 26px; box-shadow: 0 30px 90px #0008; }
.auth-card p { color: var(--muted); }
.auth-card form { display: grid; gap: 12px; margin: 28px 0 18px; }
.auth-card small { color: var(--muted); }

.brand-mark { width: 62px; height: 62px; border-radius: 18px; background: var(--yellow); color: #151515; display: grid; place-items: center; font-weight: 950; margin-bottom: 28px; transform: rotate(-4deg); }
.brand-mark.small { width: 42px; height: 42px; border-radius: 12px; margin: 0; flex: 0 0 auto; }
.app { min-height: 100vh; display: grid; grid-template-columns: 260px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; border-right: 1px solid var(--line); background: #0d121a; padding: 24px 18px; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; }
.brand strong { display: block; font-size: 14px; }
.brand span { color: var(--muted); font-size: 12px; }
#nav { display: grid; gap: 7px; }
.nav-item { border: 0; background: transparent; padding: 13px 14px; border-radius: 12px; text-align: left; color: var(--muted); cursor: pointer; font-weight: 700; }
.nav-item:hover, .nav-item.active { color: var(--text); background: var(--panel-2); }
.nav-item.active::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--yellow); margin-right: 10px; }
.test-badge { margin-top: auto; border: 1px solid #6a5920; color: var(--yellow); background: var(--yellow-soft); border-radius: 12px; padding: 11px; text-align: center; font-size: 12px; font-weight: 800; }

.main { min-width: 0; padding: 28px 34px 60px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.top-actions { display: flex; gap: 10px; }
.button { border: 1px solid var(--line); border-radius: 11px; padding: 10px 15px; font-weight: 800; cursor: pointer; }
.button.primary { background: var(--yellow); border-color: var(--yellow); color: #141414; }
.button.ghost { background: var(--panel); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.text-button { border: 0; background: none; color: var(--yellow); font-weight: 800; cursor: pointer; }
.icon-button { border: 0; background: transparent; color: var(--muted); font-size: 28px; cursor: pointer; }
.page { display: none; }
.page.active { display: block; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
.metric { background: var(--panel); border: 1px solid var(--line); padding: 18px; border-radius: var(--radius); }
.metric span { color: var(--muted); font-size: 12px; }
.metric strong { display: block; font-size: 30px; margin-top: 8px; }
.metric small { color: var(--green); }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: 1.35fr .65fr; margin-bottom: 14px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 14px; overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; gap: 14px; align-items: center; margin-bottom: 18px; }
.stack { display: grid; gap: 10px; }
.queue-item, .publication-item { border: 1px solid var(--line); border-radius: 13px; padding: 13px; background: var(--panel-2); }
.queue-item strong, .publication-item strong { display: block; margin-bottom: 5px; }
.queue-item span, .publication-item span { color: var(--muted); font-size: 12px; }
.money-panel { background: linear-gradient(145deg, #20291e, var(--panel)); }
.money-total { color: var(--yellow); font-size: 48px; font-weight: 950; margin: 24px 0 8px; }
.money-panel > p { color: var(--muted); line-height: 1.5; }
.money-bars { display: flex; align-items: flex-end; height: 70px; gap: 8px; margin-top: 24px; }
.money-bars span { width: 28%; height: var(--w); border-radius: 7px 7px 2px 2px; background: linear-gradient(var(--yellow), #816d1e); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip { border: 1px solid var(--line); background: var(--panel); color: var(--muted); border-radius: 999px; padding: 8px 13px; cursor: pointer; }
.chip.active { color: #111; background: var(--yellow); border-color: var(--yellow); font-weight: 800; }
.signal-list { display: grid; gap: 10px; }
.signal-card { display: grid; grid-template-columns: 1fr auto; gap: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 15px; padding: 17px; }
.signal-card h4 { margin: 4px 0 8px; font-size: 17px; }
.signal-card p { color: var(--muted); margin-bottom: 10px; line-height: 1.45; }
.signal-meta { display: flex; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 12px; }
.signal-actions { display: flex; align-items: center; gap: 8px; }
.status { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 8px; font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: .05em; }
.status.verified { color: var(--green); background: rgba(66,211,157,.12); }
.status.unverified, .status.rumor { color: var(--red); background: rgba(255,106,122,.12); }
.status.project { color: var(--blue); background: rgba(98,168,255,.12); }
.status.opinion { color: var(--yellow); background: var(--yellow-soft); }
.money-chip { color: var(--yellow); font-weight: 900; }

.publication-layout { grid-template-columns: minmax(420px, 1fr) 380px; align-items: start; }
.publication-item { cursor: pointer; }
.publication-item.selected { border-color: var(--yellow); }
.publication-item .row { display: flex; justify-content: space-between; gap: 12px; }
.publication-actions { display: flex; gap: 8px; margin-top: 12px; }
.publication-actions .button { padding: 7px 10px; font-size: 12px; }
.phone-panel { position: sticky; top: 20px; }
.phone { background: #0b1016; border: 7px solid #050609; border-radius: 28px; overflow: hidden; min-height: 560px; box-shadow: 0 20px 50px #0006; }
.phone-top { padding: 18px; background: #202936; font-size: 13px; font-weight: 800; text-align: center; }
.telegram-post { margin: 18px 12px; padding: 14px; border-radius: 16px 16px 16px 5px; background: #1d4e3a; white-space: pre-wrap; line-height: 1.45; font-size: 14px; }

.notice { border: 1px solid #6a5920; background: var(--yellow-soft); color: #f5e5a4; padding: 14px 16px; border-radius: 13px; margin-bottom: 14px; }
.agent-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.agent-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 17px; }
.agent-card .agent-top { display: flex; justify-content: space-between; gap: 10px; }
.agent-card p { color: var(--muted); line-height: 1.45; min-height: 60px; }
.agent-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.agent-state { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 800; }
.agent-state::before { content:""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.agent-state.active::before { background: var(--green); box-shadow: 0 0 12px var(--green); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 13px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; }
td { font-size: 14px; }
.access-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.access-scroll { max-height: 430px; overflow: auto; scrollbar-gutter: stable; }
.access-scroll.compact-scroll { max-height: 260px; }
.access-scroll thead th { position: sticky; top: 0; z-index: 2; background: var(--panel); }
.count-badge { display: inline-grid; min-width: 24px; height: 24px; place-items: center; margin-left: 6px; padding: 0 7px; border-radius: 999px; color: #111; background: var(--yellow); font-size: 12px; vertical-align: 2px; }
.empty-cell { color: var(--muted); text-align: center; padding: 28px 12px; }
.table-actions { display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.text-button.danger { color: var(--red); }

input, textarea, select { width: 100%; background: #0f141c; color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--yellow); }
label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
dialog { width: min(620px, calc(100% - 24px)); max-height: calc(100dvh - 24px); overflow: auto; color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 0; }
dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(4px); }
dialog form { display: grid; gap: 15px; padding: 24px; }
.modal-head { display: flex; justify-content: space-between; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--yellow); color: #111; padding: 12px 16px; border-radius: 11px; font-weight: 800; opacity: 0; transform: translateY(15px); transition: .2s; pointer-events: none; z-index: 30; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); color: white; }
.mobile-nav { display: none; }

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 20px 18px 90px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .grid.two, .publication-layout { grid-template-columns: 1fr; }
  .access-grid { grid-template-columns: 1fr; }
  .phone-panel { position: static; }
  .agent-grid { grid-template-columns: repeat(2, 1fr); }
  .mobile-nav { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr); background: rgba(13,18,26,.96); border-top: 1px solid var(--line); padding: 7px max(7px, env(safe-area-inset-right)) calc(7px + env(safe-area-inset-bottom)) max(7px, env(safe-area-inset-left)); backdrop-filter: blur(10px); }
  .mobile-nav button { border: 0; background: transparent; color: var(--muted); padding: 9px 2px; font-size: 11px; }
  .mobile-nav button.active { color: var(--yellow); font-weight: 900; }
}

@media (max-width: 620px) {
  .topbar { align-items: flex-start; }
  .top-actions .ghost { display: none; }
  h2 { font-size: 25px; }
  .metrics { grid-template-columns: 1fr 1fr; gap: 9px; }
  .metric { padding: 14px; }
  .metric strong { font-size: 25px; }
  .panel { padding: 15px; }
  .signal-card { grid-template-columns: 1fr; }
  .signal-actions { justify-content: flex-end; }
  .agent-grid { grid-template-columns: 1fr; }
  .publication-layout { display: block; }
  .phone-panel { display: none; }
  .main { padding: 16px 12px calc(92px + env(safe-area-inset-bottom)); }
  .panel { border-radius: 15px; }
  .panel-head { align-items: flex-start; }
  .panel-head .button { padding: 9px 11px; }
  .access-scroll { max-height: 52dvh; overflow-y: auto; overflow-x: hidden; }
  .access-scroll.compact-scroll { max-height: 42dvh; }
  .access-scroll table,
  .access-scroll tbody,
  .access-scroll tr,
  .access-scroll td { display: block; width: 100%; }
  .access-scroll thead { display: none; }
  .access-scroll tr { margin-bottom: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel-2); }
  .access-scroll td { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 7px 0; border: 0; text-align: right; overflow-wrap: anywhere; }
  .access-scroll td::before { content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; text-align: left; }
  .access-scroll .empty-cell { display: block; text-align: center; }
  .access-scroll .empty-cell::before { content: none; }
  .table-actions { width: 100%; justify-content: flex-end; flex-wrap: wrap; }
  .table-actions .text-button { min-height: 40px; padding: 7px 4px; }
  dialog { width: 100%; max-width: none; max-height: 92dvh; margin: auto 0 0; border-width: 1px 0 0; border-radius: 22px 22px 0 0; }
  dialog form { padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); gap: 12px; }
  .modal-head { position: sticky; top: -18px; z-index: 3; margin: -18px -16px 0; padding: 18px 16px 10px; background: var(--panel); }
  .icon-button { min-width: 44px; min-height: 44px; padding: 0; }
  .modal-actions { position: sticky; bottom: calc(-16px - env(safe-area-inset-bottom)); z-index: 3; display: grid; grid-template-columns: 1fr 1fr; margin: 2px -16px calc(-16px - env(safe-area-inset-bottom)); padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--panel); border-top: 1px solid var(--line); }
  .modal-actions .button { width: 100%; min-height: 48px; }
  input, textarea, select { min-height: 48px; font-size: 16px; }
}
