/* ANITOKU Support Agent — admin panel */
:root {
  --bg: #0a0a12;
  --bg-1: #10101c;
  --bg-2: #16162a;
  --bg-3: #1e1e36;
  --line: #262645;
  --line-soft: #1c1c33;
  --txt: #e8e8f5;
  --txt-dim: #9a9ab8;
  --txt-mute: #6a6a8a;
  --brand: #8b5cf6;
  --brand-2: #a78bfa;
  --brand-glow: rgba(139, 92, 246, 0.25);
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  --info: #60a5fa;
  --radius: 12px;
  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--txt);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

/* ── login ───────────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(900px 500px at 20% -10%, rgba(139, 92, 246, 0.16), transparent 60%),
    radial-gradient(700px 400px at 90% 110%, rgba(96, 165, 250, 0.10), transparent 60%),
    var(--bg);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 34px 30px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.logo { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.logo-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), #6366f1);
  display: grid; place-items: center;
  font-weight: 800; font-size: 17px; color: #fff;
  box-shadow: 0 0 20px var(--brand-glow);
}
.logo-text { font-size: 17px; font-weight: 700; letter-spacing: 0.4px; }
.login-sub { color: var(--txt-mute); font-size: 12.5px; margin-bottom: 26px; }

/* ── layout ──────────────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--line-soft);
  padding: 18px 12px;
  display: flex; flex-direction: column; gap: 3px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .logo { padding: 0 8px 16px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 9px;
  color: var(--txt-dim); cursor: pointer;
  font-size: 13.5px; font-weight: 500;
  border: 1px solid transparent;
  transition: background .12s, color .12s;
  user-select: none;
}
.nav-item:hover { background: var(--bg-2); color: var(--txt); }
.nav-item.active { background: var(--bg-3); color: #fff; border-color: var(--line); }
.nav-item .ico { width: 17px; text-align: center; font-size: 14px; }
.nav-item .badge {
  margin-left: auto; background: var(--brand); color: #fff;
  font-size: 10.5px; padding: 1px 6px; border-radius: 20px; font-weight: 700;
}
.nav-sep { height: 1px; background: var(--line-soft); margin: 10px 6px; }

.main { padding: 22px 26px 60px; max-width: 1400px; overflow-x: hidden; }

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin-bottom: 20px; flex-wrap: wrap;
}
.page-title { font-size: 21px; font-weight: 700; letter-spacing: -0.2px; }
.page-desc { color: var(--txt-mute); font-size: 12.5px; margin-top: 2px; }

.page { display: none; }
.page.active { display: block; animation: fade .16s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ── cards & grid ────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-1);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 17px 18px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.7px; color: var(--txt-dim); margin-bottom: 13px;
  display: flex; align-items: center; gap: 8px; justify-content: space-between;
}

.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.c3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); }

.stat { background: var(--bg-1); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 15px 16px; }
.stat-label { font-size: 11px; color: var(--txt-mute); text-transform: uppercase; letter-spacing: 0.6px; }
.stat-value { font-size: 25px; font-weight: 700; margin-top: 4px; letter-spacing: -0.6px; }
.stat-sub { font-size: 11.5px; color: var(--txt-mute); margin-top: 2px; }
.stat.ok .stat-value { color: var(--ok); }
.stat.warn .stat-value { color: var(--warn); }
.stat.err .stat-value { color: var(--err); }

/* ── controls ────────────────────────────────────────────────────────────── */
label.field { display: block; margin-bottom: 13px; }
label.field > span { display: block; font-size: 12px; color: var(--txt-dim); margin-bottom: 5px; font-weight: 500; }
label.field > small { display: block; color: var(--txt-mute); font-size: 11px; margin-top: 4px; }

input[type="text"], input[type="password"], input[type="number"], textarea, select {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--txt);
  padding: 9px 11px;
  border-radius: 9px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, textarea:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
textarea { resize: vertical; min-height: 88px; font-family: var(--mono); font-size: 12.5px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--txt-mute); }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--brand); color: #fff; border: none;
  padding: 9px 16px; border-radius: 9px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: filter .12s, transform .06s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { filter: brightness(1.12); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: var(--bg-2); border: 1px solid var(--line); color: var(--txt-dim); }
.btn.ghost:hover:not(:disabled) { color: var(--txt); border-color: var(--brand); }
.btn.danger { background: #3b1a1f; color: var(--err); border: 1px solid #5a2530; }
.btn.danger:hover:not(:disabled) { background: #4a2028; }
.btn.ok { background: #10362c; color: var(--ok); border: 1px solid #1c5445; }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn.wide { width: 100%; justify-content: center; }

.row { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

.switch { display: flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; padding: 6px 0; }
.switch input { display: none; }
.switch .track {
  width: 38px; height: 21px; border-radius: 20px;
  background: var(--bg-3); border: 1px solid var(--line);
  position: relative; transition: background .16s, border-color .16s; flex-shrink: 0;
}
.switch .track::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--txt-mute); transition: transform .16s, background .16s;
}
.switch input:checked + .track { background: var(--brand); border-color: var(--brand); }
.switch input:checked + .track::after { transform: translateX(17px); background: #fff; }
.switch .lbl { font-size: 13px; }
.switch .lbl small { display: block; color: var(--txt-mute); font-size: 11px; }

/* ── badges & pills ──────────────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600;
  background: var(--bg-3); color: var(--txt-dim); border: 1px solid var(--line);
}
.pill.ok { background: rgba(52, 211, 153, .1); color: var(--ok); border-color: rgba(52, 211, 153, .3); }
.pill.warn { background: rgba(251, 191, 36, .1); color: var(--warn); border-color: rgba(251, 191, 36, .3); }
.pill.err { background: rgba(248, 113, 113, .1); color: var(--err); border-color: rgba(248, 113, 113, .3); }
.pill.info { background: rgba(96, 165, 250, .1); color: var(--info); border-color: rgba(96, 165, 250, .3); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.dot.pulse { animation: pulse 1.8s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

/* ── tables ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--line-soft); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; padding: 9px 12px;
  background: var(--bg-2); color: var(--txt-dim);
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px; font-weight: 700;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255, 255, 255, .018); }
td.mono, .mono { font-family: var(--mono); font-size: 12px; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 30px; text-align: center; color: var(--txt-mute); font-size: 13px; }

/* ── log console ─────────────────────────────────────────────────────────── */
.console {
  background: #070710; border: 1px solid var(--line-soft); border-radius: 10px;
  padding: 11px 13px; height: 340px; overflow-y: auto;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.65;
}
.console .ln { display: flex; gap: 8px; padding: 1px 0; white-space: pre-wrap; word-break: break-word; }
.console .t { color: #45456a; flex-shrink: 0; }
.console .s { color: var(--brand-2); flex-shrink: 0; }
.console .m { color: #b9b9d4; }
.console .ln.warn .m { color: var(--warn); }
.console .ln.error .m, .console .ln.fatal .m { color: var(--err); }
.console .ln.debug .m, .console .ln.trace .m { color: #5c5c80; }

/* ── chat view ───────────────────────────────────────────────────────────── */
.chat-layout { display: grid; grid-template-columns: 290px 1fr; gap: 14px; align-items: start; }
.chat-list { max-height: 640px; overflow-y: auto; }
.chat-item {
  padding: 10px 11px; border-radius: 9px; cursor: pointer;
  border: 1px solid transparent; margin-bottom: 3px;
}
.chat-item:hover { background: var(--bg-2); }
.chat-item.active { background: var(--bg-3); border-color: var(--line); }
.chat-item .t { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .s { font-size: 11px; color: var(--txt-mute); display: flex; gap: 6px; align-items: center; margin-top: 2px; }

.messages { height: 470px; overflow-y: auto; padding: 6px 4px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 78%; padding: 8px 12px; border-radius: 13px; font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.msg.in { background: var(--bg-2); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.out { background: #2c1f52; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.agent { background: #1d2f47; }
.msg .meta { font-size: 10px; color: var(--txt-mute); margin-top: 4px; display: flex; gap: 6px; }

/* ── misc ────────────────────────────────────────────────────────────────── */
.toast-wrap { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 999; }
.toast {
  background: var(--bg-3); border: 1px solid var(--line);
  padding: 11px 15px; border-radius: 10px; font-size: 13px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .55); max-width: 380px;
  animation: slide .2s ease;
}
.toast.ok { border-left: 3px solid var(--ok); }
.toast.err { border-left: 3px solid var(--err); }
.toast.warn { border-left: 3px solid var(--warn); }
@keyframes slide { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

.progress { height: 6px; background: var(--bg-3); border-radius: 20px; overflow: hidden; margin: 10px 0; }
.progress .bar { height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .4s ease; }

.err-msg { color: var(--err); font-size: 12.5px; margin-top: 10px; min-height: 18px; }
.hint { color: var(--txt-mute); font-size: 12px; line-height: 1.6; }
.hint code { background: var(--bg-3); padding: 1px 5px; border-radius: 4px; font-family: var(--mono); font-size: 11.5px; color: var(--brand-2); }

.steps { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.step { flex: 1; min-width: 90px; padding: 8px 10px; border-radius: 8px; background: var(--bg-2); border: 1px solid var(--line-soft); font-size: 12px; color: var(--txt-mute); }
.step.done { border-color: rgba(52, 211, 153, .35); color: var(--ok); }
.step.active { border-color: var(--brand); color: var(--brand-2); background: rgba(139, 92, 246, .08); }
.step b { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .5px; opacity: .7; }

pre.block {
  background: #070710; border: 1px solid var(--line-soft); border-radius: 9px;
  padding: 13px; overflow: auto; max-height: 420px;
  font-family: var(--mono); font-size: 11.5px; line-height: 1.6; color: #b9b9d4; white-space: pre-wrap;
}

.sep { height: 1px; background: var(--line-soft); margin: 14px 0; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; overflow-x: auto; }
  .sidebar .logo, .nav-sep { display: none; }
  .chat-layout { grid-template-columns: 1fr; }
  .main { padding: 16px; }
}

/* ── telegram connect: guide, tabs, QR ───────────────────────────────────── */
.guide {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 13px; margin-bottom: 15px;
}
.guide summary {
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--brand-2);
  list-style: none; user-select: none;
}
.guide summary::-webkit-details-marker { display: none; }
.guide summary::before { content: '▸ '; display: inline-block; transition: transform .15s; }
.guide[open] summary::before { transform: rotate(90deg); }
.guide ol { margin: 11px 0 0 17px; color: var(--txt-dim); font-size: 12.5px; line-height: 1.75; }
.guide li { margin-bottom: 3px; }
.guide p { margin-top: 10px; color: var(--txt-mute); font-size: 12px; line-height: 1.65; }
.guide code {
  background: var(--bg-3); padding: 1px 5px; border-radius: 4px;
  font-family: var(--mono); font-size: 11.5px; color: var(--brand-2);
}
.guide b { color: var(--txt-dim); }

.tabs { display: flex; gap: 5px; margin: 16px 0 14px; background: var(--bg-2); padding: 4px; border-radius: 10px; }
.tab {
  flex: 1; text-align: center; padding: 7px 10px; border-radius: 7px;
  font-size: 13px; font-weight: 600; color: var(--txt-mute); cursor: pointer;
  transition: background .12s, color .12s; user-select: none;
}
.tab:hover { color: var(--txt-dim); }
.tab.active { background: var(--bg-3); color: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }

.qr-box {
  display: grid; place-items: center; min-height: 262px;
  background: #fff; border-radius: 12px; padding: 10px;
  border: 1px solid var(--line);
}
.qr-box svg { display: block; width: 240px; height: 240px; }
.qr-empty { color: #6a6a8a; font-size: 12.5px; text-align: center; padding: 20px; }
.qr-box.loading { opacity: .5; }
.qr-scanned { color: var(--ok); font-weight: 600; font-size: 13.5px; text-align: center; padding: 30px 16px; }
