:root {
  --bg0: #0b1210;
  --bg1: #12201c;
  --ink: #e8f2ee;
  --muted: #8aa399;
  --line: rgba(232, 242, 238, 0.1);
  --accent: #3ddc97;
  --accent2: #f0c75e;
  --danger: #ff6b6b;
  --card: rgba(18, 32, 28, 0.88);
  --radius: 16px;
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --display: "Syne", "IBM Plex Sans", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg0);
  padding: 16px 16px 40px;
  padding-top: max(16px, env(safe-area-inset-top));
}

.bg {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 420px at 10% -10%, rgba(61, 220, 151, 0.18), transparent 55%),
    radial-gradient(700px 380px at 100% 0%, rgba(240, 199, 94, 0.12), transparent 50%),
    linear-gradient(180deg, var(--bg1), var(--bg0) 55%);
}
.bg::after {
  content: "";
  position: absolute; inset: 0;
  background-image: linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.35;
  mask-image: linear-gradient(180deg, #000 0%, transparent 80%);
}

.top {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 18px;
  animation: rise 0.45s ease both;
}
.eyebrow {
  margin: 0 0 4px;
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent); font-weight: 600;
}
h1 {
  margin: 0; font-family: var(--display); font-weight: 800;
  font-size: clamp(1.5rem, 5vw, 1.9rem); letter-spacing: -0.03em;
}
.ghost {
  width: 42px; height: 42px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card);
  color: var(--ink); font-size: 1.2rem; cursor: pointer;
}
.ghost.sm { width: 34px; height: 34px; font-size: 1rem; }

.kpis {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin-bottom: 16px;
  animation: rise 0.5s ease 0.05s both;
}
.kpis article {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 10px 8px; text-align: center;
}
.kpis span {
  display: block; font-size: 10px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px;
}
.kpis strong {
  font-family: var(--mono); font-size: 0.95rem; font-weight: 500;
}

.tabs {
  display: flex; gap: 8px; margin-bottom: 14px;
}
.tab {
  flex: 1; border: 1px solid var(--line); background: transparent;
  color: var(--muted); border-radius: 999px; padding: 10px;
  font-weight: 600; cursor: pointer;
}
.tab.active {
  background: rgba(61, 220, 151, 0.15);
  border-color: rgba(61, 220, 151, 0.45);
  color: var(--ink);
}
.tab:disabled { opacity: 0.35; cursor: not-allowed; }

.view { animation: rise 0.4s ease both; }
.hidden { display: none !important; }

.action-bar {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-bottom: 18px;
}
.action-bar .primary { grid-column: 1 / -1; }

.btn {
  border: 1px solid var(--line); background: var(--card);
  color: var(--ink); border-radius: 12px; padding: 11px 12px;
  font: inherit; font-weight: 600; cursor: pointer;
}
.btn.sm { padding: 7px 10px; font-size: 13px; border-radius: 10px; }
.btn.primary {
  background: rgba(61, 220, 151, 0.2);
  border-color: rgba(61, 220, 151, 0.5);
  color: var(--accent);
}
.btn.danger {
  background: rgba(255, 107, 107, 0.12);
  border-color: rgba(255, 107, 107, 0.4);
  color: var(--danger);
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 8px 0 10px;
}
.section-head h2 {
  margin: 0; font-family: var(--display); font-size: 1.05rem; font-weight: 700;
}

.item-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.item-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 14px; cursor: pointer;
  transition: border-color 0.2s;
}
.item-card:hover { border-color: rgba(61, 220, 151, 0.4); }
.item-card .row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.item-card h3 {
  margin: 0; font-size: 0.95rem; font-weight: 600;
}
.item-card .preview {
  margin: 6px 0 0; color: var(--muted); font-size: 13px;
  white-space: pre-wrap; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
.item-card .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tag {
  font-size: 10px; font-weight: 600; padding: 3px 7px; border-radius: 999px;
  background: rgba(255,255,255,0.06); color: var(--muted);
}
.tag.on { background: rgba(61, 220, 151, 0.15); color: var(--accent); }
.tag.off { background: rgba(255, 107, 107, 0.12); color: var(--danger); }
.tag.media { background: rgba(240, 199, 94, 0.15); color: var(--accent2); }
.empty-hint {
  color: var(--muted); font-size: 13px; padding: 12px;
  border: 1px dashed var(--line); border-radius: 12px; text-align: center;
}

.bot-card {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 12px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 14px 12px;
  margin-bottom: 10px; cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}
.bot-card:active { transform: scale(0.985); }
.bot-card:hover { border-color: rgba(61, 220, 151, 0.4); }
.bot-card h2 {
  margin: 0; font-family: var(--display); font-size: 1.05rem; font-weight: 700;
}
.bot-card .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.bot-card .nums {
  grid-column: 1 / -1;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  margin-top: 4px;
}
.bot-card .nums div {
  background: rgba(0,0,0,0.22); border-radius: 10px; padding: 8px 6px; text-align: center;
}
.bot-card .nums b {
  display: block; font-family: var(--mono); font-size: 0.95rem; font-weight: 500;
}
.bot-card .nums span { font-size: 10px; color: var(--muted); }
.pill {
  align-self: start; font-size: 11px; font-weight: 600;
  padding: 4px 8px; border-radius: 999px;
  background: rgba(240, 199, 94, 0.15); color: var(--accent2);
}
.pill.on { background: rgba(61, 220, 151, 0.15); color: var(--accent); }
.pill.err { background: rgba(255, 107, 107, 0.15); color: var(--danger); }

.back {
  border: 0; background: transparent; color: var(--accent);
  font-weight: 600; padding: 0 0 12px; cursor: pointer;
}
.detail-head h2 {
  margin: 0; font-family: var(--display); font-size: 1.35rem;
}
.detail-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.actions-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin: 14px 0;
}
.detail-kpis {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  margin: 14px 0;
}
.detail-kpis article {
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--card); padding: 12px;
}
.detail-kpis span { color: var(--muted); font-size: 11px; }
.detail-kpis strong {
  display: block; margin-top: 4px;
  font-family: var(--mono); font-size: 1.25rem; font-weight: 500;
}

.users-fold {
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--card); padding: 4px 12px 12px;
}
.users-fold summary {
  cursor: pointer; font-weight: 600; padding: 12px 0; color: var(--ink);
}
.toolbar {
  display: grid; grid-template-columns: 1fr 110px; gap: 8px;
  margin-bottom: 10px;
}
.toolbar input, .toolbar select,
.field input, .field textarea {
  border: 1px solid var(--line); background: rgba(0,0,0,0.25);
  color: var(--ink); border-radius: 12px; padding: 11px 12px;
  font: inherit; width: 100%;
}
.field textarea { resize: vertical; min-height: 160px; line-height: 1.45; }

.table-wrap {
  overflow: auto; border: 1px solid var(--line);
  border-radius: 14px; background: rgba(0,0,0,0.18);
}
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--line); }
th {
  color: var(--muted); font-weight: 600; font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.06em;
  position: sticky; top: 0; background: #15241f;
}
td.mono { font-family: var(--mono); }
.dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger);
}
.dot.ok { background: var(--accent); }

.pager {
  display: flex; align-items: center; justify-content: center;
  gap: 14px; margin-top: 12px;
}
.pager button {
  width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card);
  color: var(--ink); cursor: pointer;
}

.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom));
  animation: fade 0.2s ease both;
}
.modal-sheet {
  width: min(520px, 100%);
  max-height: min(88vh, 720px);
  overflow: auto;
  background: #101a17;
  border: 1px solid var(--line);
  border-radius: 20px 20px 16px 16px;
  padding: 16px;
  animation: rise 0.25s ease both;
}
.modal-sheet header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.modal-sheet h3 {
  margin: 0; font-family: var(--display); font-size: 1.15rem;
}
.field { display: block; margin-bottom: 12px; }
.field span {
  display: block; font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px;
}
.check {
  display: flex; align-items: center; gap: 8px;
  font-weight: 600; margin-bottom: 8px;
}
.hint { color: var(--muted); font-size: 12px; margin: 0 0 12px; line-height: 1.4; }
.modal-actions {
  display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px;
}
.modal-actions .btn { min-width: 96px; }
.pick-tools { display: flex; gap: 8px; margin-bottom: 10px; }
.pick-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.pick-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card);
  cursor: pointer;
}
.pick-row.on {
  border-color: rgba(61, 220, 151, 0.45);
  background: rgba(61, 220, 151, 0.1);
}
.pick-row input { accent-color: var(--accent); }
.pick-row .name { font-weight: 600; flex: 1; }
.pick-row .meta { color: var(--muted); font-size: 12px; }

.foot {
  margin: 18px 0 0; text-align: center;
  color: var(--muted); font-size: 12px;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-sheet.tall { max-height: min(94vh, 900px); }
.editor-block {
  border: 1px solid var(--line); border-radius: 14px;
  background: rgba(0,0,0,0.18); padding: 12px; margin-bottom: 12px;
}
.editor-toolbar {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px;
}
.rich-edit {
  min-height: 140px; max-height: 240px; overflow: auto;
  border: 1px solid var(--line); border-radius: 12px;
  background: rgba(0,0,0,0.25); padding: 12px;
  line-height: 1.45; outline: none; margin-bottom: 10px;
  white-space: pre-wrap; word-break: break-word;
}
.rich-edit:empty:before {
  content: attr(data-placeholder); color: var(--muted);
}
.btn.block, .file-btn.block { width: 100%; display: block; text-align: center; }
.btn.block { margin-top: 4px; }
.row-btns {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px;
}
.file-btn { display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.media-preview {
  border-radius: 12px; overflow: hidden; min-height: 80px;
  background: rgba(0,0,0,0.3); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px; padding: 8px;
}
.media-preview.empty { color: var(--muted); font-size: 13px; }
.media-preview img, .media-preview video {
  max-width: 100%; max-height: 200px; border-radius: 8px;
}
.btn-list { display: flex; flex-direction: column; gap: 6px; }
.btn-card {
  display: flex; justify-content: space-between; gap: 8px; align-items: center;
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); cursor: pointer;
}
.btn-card .meta { color: var(--muted); font-size: 12px; margin-top: 2px; word-break: break-all; }
.section-head.tight { margin: 0 0 8px; }
.section-head.tight h2 { font-size: 0.95rem; }
.steps {
  margin: 0 0 14px; padding-left: 18px; color: var(--muted); font-size: 13px; line-height: 1.5;
}
.sticky-actions {
  position: sticky; bottom: 0; background: #101a17;
  padding-top: 10px; margin-top: 8px;
}

@media (max-width: 420px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  th:nth-child(5), td:nth-child(5) { display: none; }
  .actions-grid { grid-template-columns: 1fr; }
}
