/* =========================================================
   Telegram Broadcast Pro — design system
   ========================================================= */

:root {
  color-scheme: dark;

  --bg: #0a0e15;
  --surface: #10151f;
  --surface-2: #161d29;
  --surface-3: #1d2634;
  --border: #1e2735;
  --border-strong: #2b3646;

  --text: #e9eef6;
  --text-2: #b3bfd0;
  --muted: #7d8b9e;
  --faint: #5a6577;

  --accent: #2f9ce8;
  --accent-hover: #48abee;
  --accent-ink: #ffffff;
  --accent-soft: rgba(47, 156, 232, .13);
  --accent-line: rgba(47, 156, 232, .35);

  --ok: #35c07a;
  --ok-soft: rgba(53, 192, 122, .13);
  --err: #f0575c;
  --err-soft: rgba(240, 87, 92, .13);
  --warn: #eda63c;
  --warn-soft: rgba(237, 166, 60, .13);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, .28);
  --shadow-lg: 0 16px 44px rgba(0, 0, 0, .42);

  --r-sm: 8px;
  --r-md: 11px;
  --r-lg: 16px;
  --r-full: 999px;

  --sidebar-w: 244px;
  --ease: cubic-bezier(.4, 0, .2, 1);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Display", "Segoe UI",
    Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "SF Mono", ui-monospace, Consolas, monospace;
}

:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef2f7;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --faint: #94a3b8;

  --accent: #1d84d1;
  --accent-hover: #1a75ba;
  --accent-soft: rgba(29, 132, 209, .09);
  --accent-line: rgba(29, 132, 209, .28);

  --ok: #12915a;
  --ok-soft: rgba(18, 145, 90, .1);
  --err: #d93a3f;
  --err-soft: rgba(217, 58, 63, .09);
  --warn: #b8760c;
  --warn-soft: rgba(184, 118, 12, .11);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, .07);
  --shadow-lg: 0 18px 44px rgba(15, 23, 42, .13);
}

* { box-sizing: border-box; }

/* Kelas komponen (mis. .status-pill { display:flex }) mengalahkan aturan
   [hidden] bawaan browser, jadi paksa di sini. */
[hidden] { display: none !important; }

html, body { height: 100%; }

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

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

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-full); border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ico { width: 18px; height: 18px; flex: 0 0 auto; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ico-sm { width: 15px; height: 15px; }
.ico-lg { width: 22px; height: 22px; }

/* =========================================================
   LOCK SCREEN
   ========================================================= */

#lock-screen { display: none; }
body.locked > .shell { display: none; }

body.locked #lock-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.lock-card {
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 36px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.lock-card h1 { margin: 14px 0 8px; font-size: 18px; letter-spacing: -.01em; }
.lock-card p { margin: 0 0 8px; color: var(--text-2); }
.lock-cmd {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 11px 14px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  margin: 16px 0;
}

/* =========================================================
   LOGIN
   ========================================================= */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 460px at 50% -12%, var(--accent-soft), transparent 70%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 396px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 34px;
  box-shadow: var(--shadow-lg);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 24px;
}

.login-card h1 { margin: 0; font-size: 17px; letter-spacing: -.01em; }
.login-card .sub { margin: 4px 0 26px; color: var(--muted); font-size: 13px; }

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(140deg, var(--accent), #1c6fb0);
  display: grid;
  place-items: center;
  color: #fff;
  box-shadow: 0 4px 14px rgba(47, 156, 232, .3);
  flex: 0 0 auto;
}

/* =========================================================
   SHELL
   ========================================================= */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand .name { font-size: 14px; font-weight: 650; letter-spacing: -.01em; line-height: 1.25; }
.sidebar-brand .ver { font-size: 11px; color: var(--faint); }

.nav { padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }

.nav-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 14px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 11px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  text-align: left;
  transition: background .15s var(--ease), color .15s var(--ease);
}

.nav-item { justify-content: flex-start; } /* tumpuk aturan `button` di atas */
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .ico { opacity: .85; }
.nav-item.active .ico { opacity: 1; }
.nav-item .count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-3);
  border-radius: var(--r-full);
  padding: 1px 8px;
}
.nav-item.active .count { background: var(--accent); color: var(--accent-ink); }

.sidebar-foot { border-top: 1px solid var(--border); padding: 12px; }

.user-row { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-2);
  flex: 0 0 auto;
  text-transform: uppercase;
}
.user-row .meta { min-width: 0; flex: 1; }
.user-row .meta .n { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row .meta .r { font-size: 11px; color: var(--faint); }

/* ---------- konten ---------- */

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 62px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 26px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar .titles { min-width: 0; flex: 1; }
.topbar h1 { margin: 0; font-size: 15.5px; font-weight: 650; letter-spacing: -.01em; }
.topbar .crumb { font-size: 12px; color: var(--muted); }

.page { padding: 26px; max-width: 1360px; width: 100%; }
section[hidden] { display: none; }

@media (max-width: 760px) {
  /* Ruang topbar sempit: sisakan judul, indikator jadi titik saja. */
  #bot-status .dot + span, #run-pill .dot + span { display: none; }
  .status-pill { padding: 6px; }
}

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; height: auto; position: static; flex-direction: column; }
  .nav { flex-direction: row; overflow-x: auto; padding: 8px; }
  .nav-label { display: none; }
  .nav-item { width: auto; white-space: nowrap; }
  .sidebar-foot { display: none; }
  .page { padding: 18px; }
  .topbar { padding: 0 18px; }
}

/* =========================================================
   GRID & CARD
   ========================================================= */

.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); align-items: start; }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 18px; }
.stack { display: flex; flex-direction: column; gap: 18px; }

@media (max-width: 1080px) {
  /* minmax(0,1fr), bukan 1fr: kolom `auto` ikut melebar mengikuti tabel
     dan bikin halaman bisa di-scroll horizontal. */
  .grid.two, .grid.side { grid-template-columns: minmax(0, 1fr); }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}

.card-head h2 { margin: 0; font-size: 13.5px; font-weight: 650; letter-spacing: -.005em; }
.card-head .sub { font-size: 12px; color: var(--muted); font-weight: 400; }
.card-head .grow { flex: 1; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 22px 0 12px;
}
.section-label:first-child { margin-top: 0; }
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- KPI ---------- */

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}

.kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  flex: 0 0 auto;
}
.kpi-icon.ok { background: var(--ok-soft); color: var(--ok); }
.kpi-icon.err { background: var(--err-soft); color: var(--err); }
.kpi-icon.warn { background: var(--warn-soft); color: var(--warn); }

.kpi-val { font-size: 22px; font-weight: 680; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-key { font-size: 11.5px; color: var(--muted); }

/* =========================================================
   FORM
   ========================================================= */

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }

label {
  display: block;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-2);
  margin-bottom: 6px;
}

input[type=text], input[type=password], input[type=number], input[type=url], input[type=time], select, textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
}

input::placeholder, textarea::placeholder { color: var(--faint); }

input[type=text]:focus, input[type=password]:focus, input[type=number]:focus,
input[type=url]:focus, input[type=time]:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

textarea { resize: vertical; min-height: 132px; line-height: 1.6; font-size: 13px; }
textarea.mono { font-family: var(--mono); }

select {
  appearance: none;
  padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

input[type=file] {
  width: 100%;
  font-size: 12.5px;
  color: var(--muted);
  padding: 7px 0;
}
input[type=file]::file-selector-button {
  margin-right: 12px;
  padding: 7px 13px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-3);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
input[type=file]::file-selector-button:hover { border-color: var(--accent); color: var(--accent); }

.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 0; }
.row > .shrink { flex: 0 0 auto; }

.hint { color: var(--muted); font-size: 12px; margin-top: 6px; line-height: 1.5; }
.hint code { font-family: var(--mono); font-size: 11.5px; color: var(--text-2); }

.err-text { color: var(--err); font-size: 12.5px; min-height: 17px; margin-top: 10px; }

.format-warn {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 10px;
  padding: 11px 13px;
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 32%, transparent);
  border-radius: var(--r-sm);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
}
.format-warn .ico { color: var(--warn); margin-top: 1px; }
.format-warn span { flex: 1; min-width: 0; }
.format-warn button { flex: 0 0 auto; }

/* ---------- checkbox & switch ---------- */

.checkline { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.checkline label { margin: 0; color: var(--text); font-weight: 400; font-size: 13px; cursor: pointer; }
input[type=checkbox] { width: 16px; height: 16px; margin-top: 2px; accent-color: var(--accent); cursor: pointer; flex: 0 0 auto; }

.switch { position: relative; display: inline-flex; width: 36px; height: 20px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.switch .track {
  position: absolute;
  inset: 0;
  border-radius: var(--r-full);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  transition: background .18s var(--ease), border-color .18s var(--ease);
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform .18s var(--ease), background .18s var(--ease);
}
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track::after { transform: translateX(16px); background: #fff; }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--accent-soft); }

/* =========================================================
   BUTTON
   ========================================================= */

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), transform .1s var(--ease);
}

button:hover { background: var(--surface-3); border-color: var(--muted); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }

button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 3px rgba(47, 156, 232, .3); }
button.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }

button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { background: var(--surface-3); color: var(--text); border-color: transparent; }

button.danger { color: var(--err); border-color: var(--border-strong); }
button.danger:hover:not(:disabled) { background: var(--err-soft); border-color: var(--err); }

button.sm { padding: 5px 10px; font-size: 12px; gap: 5px; }
button.full { width: 100%; }

button.icon { padding: 6px; border-color: transparent; background: transparent; color: var(--muted); }
button.icon:hover { background: var(--surface-3); color: var(--text); }
button.icon.danger:hover { background: var(--err-soft); color: var(--err); }

.btnrow { display: flex; gap: 9px; flex-wrap: wrap; }
.btnrow.end { justify-content: flex-end; }

/* ---------- segmented ---------- */

.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 2px;
  gap: 2px;
}
.segmented button {
  border: 0;
  background: transparent;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 550;
  color: var(--muted);
  border-radius: 6px;
}
.segmented.full-seg { display: flex; width: 100%; }
.segmented.full-seg button { flex: 1; }
.segmented button:hover { background: var(--surface-3); color: var(--text); }
.segmented button.active { background: var(--accent); color: var(--accent-ink); }

/* =========================================================
   TABLE
   ========================================================= */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  text-align: left;
  padding: 9px 13px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 11px 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s var(--ease); }
tbody tr:hover { background: var(--surface-2); }

/* Kolom aksi menempel di kanan supaya tetap terjangkau saat tabel di-scroll. */
td.actions, thead th:last-child {
  position: sticky;
  right: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
}
thead th:last-child { background: var(--surface-2); z-index: 2; }
tbody tr:hover td.actions { background: var(--surface-2); }

td.actions { text-align: right; white-space: nowrap; }
td.actions .btnrow { justify-content: flex-end; flex-wrap: nowrap; gap: 2px; }
td.num { font-variant-numeric: tabular-nums; }

.mono { font-family: var(--mono); font-size: 12px; color: var(--text-2); }

/* Dibatasi supaya nama group panjang terpotong dengan elipsis, bukan
   melebarkan tabel sampai kolom aksi ter-scroll keluar layar. */
.cell-main { display: flex; align-items: center; gap: 11px; min-width: 0; max-width: 250px; }
.cell-main > div:last-child { flex: 1; min-width: 0; }
.cell-main .avatar { width: 30px; height: 30px; font-size: 11px; }
.cell-main .t { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-main .m { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-main .e { font-size: 11.5px; color: var(--err); }

/* =========================================================
   BADGE / PILL
   ========================================================= */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2.5px 9px;
  border-radius: var(--r-full);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .01em;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.on { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 26%, transparent); }
.badge.off { background: var(--surface-3); color: var(--muted); border-color: var(--border-strong); }
.badge.err { background: var(--err-soft); color: var(--err); border-color: color-mix(in srgb, var(--err) 26%, transparent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 26%, transparent); }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }

.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.dot.pulse { animation: pulse 1.6s var(--ease) infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .35; transform: scale(.8); }
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  font-weight: 550;
  color: var(--text-2);
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt { margin-top: 20px; }
.center-x { margin-left: auto; margin-right: auto; }
.dot.accent { color: var(--accent); }
.dot.neutral { color: var(--muted); }
.dot.ok { color: var(--ok); }
.dot.err { color: var(--err); }

/* =========================================================
   EMPTY STATE
   ========================================================= */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  padding: 42px 20px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}
.empty .ico { width: 30px; height: 30px; color: var(--faint); stroke-width: 1.4; }

/* =========================================================
   TOAST
   ========================================================= */

#toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 15px;
  max-width: 350px;
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow-lg);
  animation: toast-in .22s var(--ease);
}
.toast .ico { margin-top: 1px; color: var(--accent); }
.toast.ok .ico { color: var(--ok); }
.toast.err .ico { color: var(--err); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px) scale(.97); }
  to { opacity: 1; transform: none; }
}

/* =========================================================
   BUTTON EDITOR (template)
   ========================================================= */

.btn-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr) 68px 30px;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.btn-item input { font-size: 12.5px; padding: 7px 10px; }

@media (max-width: 680px) {
  .btn-item { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

/* =========================================================
   TELEGRAM PREVIEW
   ========================================================= */

.tg-window {
  border-radius: var(--r-md);
  padding: 22px 18px;
  min-height: 190px;
  display: flex;
  background:
    radial-gradient(520px 300px at 22% 8%, rgba(47, 156, 232, .1), transparent 60%),
    var(--surface-2);
  border: 1px solid var(--border);
}

.tg-bubble {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 14px 14px 14px 4px;
  max-width: 400px;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
:root[data-theme="light"] .tg-bubble { background: #fff; }

.tg-bubble img.photo { display: block; width: 100%; max-height: 300px; object-fit: cover; background: var(--surface-2); }
.tg-text { padding: 10px 13px; white-space: pre-wrap; word-break: break-word; font-size: 13.5px; line-height: 1.5; }
.tg-text:empty { display: none; }
.tg-text blockquote { margin: 6px 0; padding-left: 10px; border-left: 3px solid var(--accent); color: var(--text-2); }
.tg-text code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-family: var(--mono); font-size: 12.5px; }
.tg-text pre { background: var(--surface-2); padding: 9px 11px; border-radius: 7px; overflow-x: auto; font-family: var(--mono); font-size: 12.5px; }
.tg-text tg-spoiler { background: var(--surface-2); border-radius: 3px; color: transparent; text-shadow: 0 0 7px var(--text-2); }
.tg-text a { color: var(--accent); }

.tg-buttons { display: flex; flex-direction: column; gap: 3px; padding: 3px; }
.tg-brow { display: flex; gap: 3px; }
.tg-btn {
  flex: 1;
  min-width: 0;
  background: var(--accent-soft);
  color: var(--accent);
  text-align: center;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background .15s var(--ease);
}
.tg-btn:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); text-decoration: none; }

/* =========================================================
   PROGRESS
   ========================================================= */

.progress {
  height: 8px;
  background: var(--surface-3);
  border-radius: var(--r-full);
  overflow: hidden;
  margin: 4px 0 14px;
}
.progress .bar {
  height: 100%;
  width: 0;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--accent), #5bb6f0);
  transition: width .4s var(--ease);
}
.progress.running .bar {
  background-image: linear-gradient(90deg, var(--accent), #5bb6f0), linear-gradient(115deg, transparent 30%, rgba(255,255,255,.28) 50%, transparent 70%);
  background-size: 100% 100%, 60px 100%;
  animation: shimmer 1.1s linear infinite;
}

@keyframes shimmer {
  from { background-position: 0 0, -60px 0; }
  to { background-position: 0 0, 100% 0; }
}

.stats { display: flex; gap: 8px; }
.stat {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  min-width: 0;
}
.stat .v { font-size: 19px; font-weight: 680; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.stat.ok .v { color: var(--ok); }
.stat.err .v { color: var(--err); }

.run-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: 12.5px;
  color: var(--text-2);
}

.scroll-y { max-height: 470px; overflow-y: auto; }

/* Daftar chat hasil "Ambil dari Akun" — dicentang lalu disimpan sekaligus. */
.picklist {
  max-height: 320px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 12px 0;
  padding: 4px;
}
.pickrow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 9px;
  border-radius: 8px;
  cursor: pointer;
}
.pickrow:hover { background: var(--surface-2); }
.pickrow input { flex: 0 0 auto; margin: 0; }
.pickrow.taken { opacity: 0.55; cursor: default; }
.pickrow .pi { min-width: 0; flex: 1; }
.pickrow .pt {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pickrow .pm { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.pickrow > button { flex: 0 0 auto; }

/* Daftar topic, menjorok di bawah group forum pemiliknya. */
.topicslot {
  margin: 2px 0 6px 26px;
  border-left: 2px solid var(--border-strong);
  padding-left: 6px;
}
.topicrow { padding: 6px 8px; }
.topicrow .pt { font-size: 12.5px; }
.topicnote { padding: 6px 9px; }

/* =========================================================
   MULTI-TENANT
   ========================================================= */

.tenant-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 4px 11px;
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface);
  color: var(--muted);
  max-width: 260px;
}

.tenant-switch:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.tenant-switch select {
  border: 0;
  background: transparent;
  padding: 3px 26px 3px 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  background-position: calc(100% - 12px) 55%, calc(100% - 7px) 55%;
  min-width: 0;
}
.tenant-switch select:focus { outline: none; box-shadow: none; background-color: transparent; }

.badge.master { background: linear-gradient(135deg, #d99b1a, #b8760c); color: #fff; border-color: transparent; }

.tenant-row-self { box-shadow: inset 3px 0 0 var(--accent); }

/* ---------- editor tombol menu bot ---------- */

/* card-head yang dipakai di dalam card-body, tanpa padding kiri sendiri */
.card-head.flush { padding-left: 0; padding-right: 0; }

/* Satu baris = satu tombol. Kolomnya sejajar dari atas ke bawah supaya
   jelas kolom mana milik tombol mana. */
.bot-item,
.bot-item-head {
  display: grid;
  grid-template-columns: minmax(150px, 1.7fr) 132px minmax(150px, 1.7fr) 68px 34px;
  gap: 8px;
  align-items: center;
}

.bot-item {
  padding: 10px;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.bot-item-head {
  padding: 0 10px 6px;
  font-size: 11.5px;
  font-weight: 550;
  letter-spacing: 0.02em;
  color: var(--text-2);
}

.bot-item input,
.bot-item select { margin: 0; }
.bot-item .num { text-align: center; }

/* Di layar sempit, tumpuk tapi tetap dalam kotak per tombol. */
@media (max-width: 860px) {
  .bot-item,
  .bot-item-head { grid-template-columns: 1fr 1fr; }
  .bot-item-head { display: none; }
  .bot-item .num { text-align: left; }
}
