/* botadmin — clean light UI, no framework.
   Variable names are a contract: page-embedded <style> blocks use them too. */
:root {
  --bg:#f4f5f7; --fg:#16181d; --muted:#7a8089; --card:#ffffff;
  --border:#e6e8ec; --accent:#6d4aff; --good:#1f9d55; --bad:#dc3545; --warn:#b7791f;
  --radius:14px; --radius-s:9px;
  --shadow:0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
}
* { box-sizing: border-box; }
body { margin:0; font-family:-apple-system,"Segoe UI",Roboto,"Vazirmatn",sans-serif;
       background:var(--bg); color:var(--fg); font-size:15px; }
a { color:var(--accent); text-decoration:none; }
a:hover { text-decoration:underline; }
code { font-family:ui-monospace,monospace; color:#8a4fd3; font-size:.86em;
       background:#f1ecfb; padding:1px 5px; border-radius:5px; }
h1 { font-size:1.45rem; margin:.2rem 0 1rem; }
h2 { font-size:1.1rem; }
h3 { font-size:1rem; }

/* ── App shell: sidebar + content ─────────────────────────────────────── */
.shell { display:flex; min-height:100vh; }
.side { width:212px; flex-shrink:0; background:var(--card);
        border-right:1px solid var(--border); padding:18px 12px;
        display:flex; flex-direction:column; gap:6px;
        position:sticky; top:0; height:100vh; }
.brand { font-weight:700; font-size:1.05rem; color:var(--fg); padding:4px 10px 16px;
         display:flex; align-items:center; gap:8px; }
.brand:hover { text-decoration:none; }
.brand-ic { background:var(--accent); border-radius:10px; padding:4px 6px; font-size:.9rem; }
.side-nav { display:flex; flex-direction:column; gap:2px; }
.side-nav a { color:#454b54; padding:9px 12px; border-radius:var(--radius-s);
              font-weight:500; }
.side-nav a:hover { background:#f1f2f5; text-decoration:none; }
.side-nav a.active { background:#efeaff; color:var(--accent); font-weight:600; }
.side-nav a.newbot { margin-top:10px; border:1px dashed #c9bfff; color:var(--accent); }
.side-foot { margin-top:auto; padding:10px 12px; border-top:1px solid var(--border);
             display:flex; justify-content:space-between; align-items:center; }
.who { color:var(--muted); font-size:.85rem; }
.logout { color:var(--bad); font-size:.85rem; }
.container { flex:1; max-width:1180px; margin:0 auto; padding:26px 28px; min-width:0; }

/* ── Cards / stat tiles ───────────────────────────────────────────────── */
.card, .tot { background:var(--card); border:1px solid var(--border);
              border-radius:var(--radius); box-shadow:var(--shadow); }
.card { padding:18px; margin-bottom:16px; }
.totals { display:flex; gap:12px; flex-wrap:wrap; margin:0 0 18px; }
.tot { padding:14px 18px; display:flex; flex-direction:column; min-width:150px; }
.tot .k { color:var(--muted); font-size:.8rem; }
.tot .v { font-size:1.3rem; font-weight:650; margin-top:4px; }

.fleet-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(290px,1fr));
              gap:14px; }
.fleet-card { background:var(--card); border:1px solid var(--border);
              border-radius:var(--radius); box-shadow:var(--shadow); padding:16px;
              display:flex; flex-direction:column; gap:10px; }
.fleet-card .fc-head { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.fleet-card .fc-name { font-weight:650; font-size:1.05rem; color:var(--fg); }
.fleet-card .fc-stats { display:grid; grid-template-columns:1fr 1fr; gap:6px 12px;
                        font-size:.88rem; }
.fleet-card .fc-stats .k { color:var(--muted); }
.fleet-card .fc-foot { margin-top:auto; display:flex; justify-content:flex-end; }

/* ── Tables ───────────────────────────────────────────────────────────── */
table.grid, table.table { width:100%; border-collapse:collapse; background:var(--card);
  border:1px solid var(--border); border-radius:var(--radius); overflow:hidden;
  box-shadow:var(--shadow); }
.grid th, .grid td, .table th, .table td { padding:.65rem .8rem;
  border-bottom:1px solid var(--border); text-align:left; vertical-align:middle; }
.grid th, .table th { background:#fafbfc; font-weight:600; color:var(--muted);
  font-size:.82rem; text-transform:uppercase; letter-spacing:.02em; }
.grid tr:last-child td, .table tr:last-child td { border-bottom:none; }
.grid tr.warn { background:rgba(183,121,31,.07); }

/* ── Pills / badges ───────────────────────────────────────────────────── */
.pill { display:inline-block; padding:2px 10px; border-radius:999px;
        font-size:.78rem; font-weight:600; background:#eef0f3; color:#5a6069; }
.pill.active   { background:#e2f6e9; color:#177a43; }
.pill.inactive { background:#fdeaea; color:#b3261e; }
.pill.failed   { background:#fdeaea; color:#b3261e; }
.pill.unknown  { background:#eef0f3; color:#5a6069; }

/* ── Buttons / inputs ─────────────────────────────────────────────────── */
button, .btn { background:var(--fg); color:#fff; border:none; padding:.5rem 1rem;
  border-radius:var(--radius-s); cursor:pointer; font-size:.9rem; font-weight:550;
  display:inline-flex; align-items:center; gap:6px; }
button:hover, .btn:hover { background:#000; text-decoration:none; filter:none; }
button:disabled { opacity:.45; cursor:default; }
.btn-ghost, button.btn-ghost { background:transparent; color:var(--fg);
  border:1px solid var(--border); }
.btn-ghost:hover { background:#f1f2f5; }
input, select, textarea { background:#fff; color:var(--fg);
  border:1px solid var(--border); padding:.5rem .7rem; border-radius:var(--radius-s);
  font-size:.95rem; font-family:inherit; }
input:focus, select:focus, textarea:focus { outline:none; border-color:var(--accent);
  box-shadow:0 0 0 3px rgba(109,74,255,.12); }
label { display:block; margin:.6rem 0; color:var(--muted); font-size:.9rem; }
label input { display:block; margin-top:4px; width:100%; }
.inline-label { display:inline-flex; align-items:center; gap:6px; margin:0; }
.inline-label input { width:auto; display:inline; margin:0; }
form.inline { display:inline-flex; gap:.4rem; align-items:center; }
.muted { color:var(--muted); }

/* ── Login ────────────────────────────────────────────────────────────── */
.login-card { max-width:360px; margin:10vh auto; background:var(--card);
  border:1px solid var(--border); padding:2rem; border-radius:var(--radius);
  box-shadow:var(--shadow); }
.login-card h1 { text-align:center; margin-top:0; }
.login-card button { width:100%; padding:.65rem; margin-top:1rem; font-size:1rem;
  justify-content:center; }

/* ── Flash / tabs / logs / env ────────────────────────────────────────── */
.flash { padding:.7rem 1rem; border-radius:var(--radius-s); margin:0 0 12px;
  font-size:.92rem; }
.flash.error { background:#fdeaea; color:#9f1d17; border:1px solid #f5c2c0; }
.flash.success { background:#e2f6e9; color:#14693a; border:1px solid #bfe8cd; }

.tabs { display:flex; gap:4px; border-bottom:1px solid var(--border); margin:0 0 18px; }
.tabs a { padding:.5rem 1rem; color:var(--muted); border-bottom:2px solid transparent;
  font-weight:550; }
.tabs a:hover { text-decoration:none; color:var(--fg); }
.tabs a.active { color:var(--accent); border-bottom-color:var(--accent); }

pre.log { background:#14171c; color:#d6dde6; padding:1rem;
  border-radius:var(--radius-s); max-height:600px; overflow:auto; font-size:.84rem;
  line-height:1.45; }
table.env td input { width:100%; font-family:ui-monospace,monospace; }
.logs-form { display:flex; gap:.5rem; margin:.75rem 0; }
.logs-form input[name="q"] { flex:1; }

/* ── Bot text editor (chat preview) ───────────────────────────────────── */
.texts-toolbar { display:flex; gap:12px; align-items:center; margin-bottom:14px; }
.texts-toolbar input[type=search] { flex:1; max-width:480px; }
.texts-layout { display:flex; gap:18px; align-items:flex-start; }
.texts-nav { width:215px; flex-shrink:0; position:sticky; top:18px;
  background:var(--card); border:1px solid var(--border);
  border-radius:var(--radius); box-shadow:var(--shadow); padding:8px;
  display:flex; flex-direction:column; gap:2px; }
.texts-nav a { color:#454b54; padding:8px 10px; border-radius:var(--radius-s);
  font-size:.88rem; font-weight:500; }
.texts-nav a:hover { background:#f1f2f5; text-decoration:none; }
.texts-nav a.active { background:#efeaff; color:var(--accent); font-weight:600; }
.texts-main { flex:1; min-width:0; }

.tg-section.hide { display:none; }
.phone { background:#e7ebf0; border:1px solid var(--border);
  border-radius:var(--radius); padding:16px; }
.tg-chat { display:flex; flex-direction:column; gap:10px; }
.tg-item.dim { display:none; }
.tg-bubble { background:#fff; border-radius:4px 16px 16px 16px;
  padding:10px 14px; max-width:640px; box-shadow:var(--shadow); }
.tg-text { white-space:pre-wrap; line-height:1.65; font-size:.92rem; }
.tg-meta { display:flex; align-items:center; gap:8px; margin-top:3px;
  font-size:.74rem; }
.crumb { color:var(--muted); font-size:.74rem; }
.badge-custom { background:#efeaff; color:var(--accent); border-radius:999px;
  padding:1px 8px; font-size:.72rem; font-weight:600; }
.edit-ic { background:transparent; border:1px solid var(--border); color:var(--fg);
  padding:1px 7px; border-radius:7px; font-size:.78rem; }
.edit-ic:hover { background:#fff; border-color:var(--accent); }

.tg-kb { display:flex; flex-direction:column; gap:6px; margin-top:2px; }
.tg-btnwrap { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.tg-btn { display:inline-block; background:#ffffffd9; border:1px solid #d6dbe3;
  color:#2a6fb8; border-radius:10px; padding:7px 16px; font-size:.9rem;
  font-weight:550; text-align:center; min-width:140px; }
.tg-sub { border-left:3px solid #d8cfff; margin:2px 0 2px 6px; padding-left:12px; }
.tg-sub > summary { list-style:none; cursor:pointer; display:flex;
  align-items:center; gap:10px; flex-wrap:wrap; }
.tg-sub > summary::-webkit-details-marker { display:none; }
.sub-hint { color:var(--muted); font-size:.78rem; }
.tg-sub[open] > summary .sub-hint { color:var(--accent); }
.tg-sub-body { margin-top:10px; }

.savebar { position:sticky; bottom:0; display:flex; gap:16px; align-items:center;
  justify-content:flex-end; background:var(--card); border:1px solid var(--border);
  border-radius:var(--radius); box-shadow:0 -2px 12px rgba(16,24,40,.08);
  padding:10px 16px; margin-top:16px; }

dialog { border:none; border-radius:var(--radius); box-shadow:0 10px 40px
  rgba(16,24,40,.25); padding:18px; width:min(560px, 92vw); }
dialog::backdrop { background:rgba(16,24,40,.45); }
dialog textarea { width:100%; line-height:1.7; }
.dlg-actions { display:flex; gap:8px; margin-top:12px; justify-content:flex-end; }
