/* renderer/styles.css — ZaloSender Operator Console (UI/UX v2, professional refresh)
   Light + Dark themes via [data-theme]. All class names kept compatible with app.js. */

:root {
  /* Brand */
  --brand: #0068ff;
  --brand-2: #2e90ff;
  --brand-3: #00c2ff;
  --brand-dark: #0050cc;
  --brand-ring: rgba(0, 104, 255, 0.18);

  /* Surfaces (light) */
  --bg: #eef2f7;
  --bg-2: #e6ecf4;
  --card: #ffffff;
  --card-2: #f8fafc;
  --sidebar-1: #0a1424;
  --sidebar-2: #0e1b30;

  /* Ink */
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e3e9f1;
  --line-2: #eef2f7;

  /* Status */
  --ok: #16a34a;
  --ok-bg: #f0fdf4;
  --ok-line: #bbf7d0;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --warn-line: #fde68a;
  --err: #dc2626;
  --err-bg: #fef2f2;
  --err-line: #fecaca;

  /* Geometry */
  --r-sm: 9px;
  --r: 13px;
  --r-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 6px 18px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 12px 34px rgba(15, 23, 42, 0.12);

  /* Type */
  --font: "Inter", system-ui, -apple-system, sans-serif;
  --font-display: "Space Grotesk", var(--font);
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

[data-theme="dark"] {
  --bg: #070d18;
  --bg-2: #0a1322;
  --card: #0f1a2c;
  --card-2: #132238;
  --sidebar-1: #060b15;
  --sidebar-2: #0a1322;
  --ink: #e8eef7;
  --ink-soft: #c5d2e3;
  --muted: #8294ad;
  --faint: #5d6f88;
  --line: #1d2c42;
  --line-2: #16243a;
  --ok-bg: #0c1f17;
  --ok-line: #14532d;
  --warn-bg: #211803;
  --warn-line: #5a3b09;
  --err-bg: #220c0c;
  --err-line: #5a1414;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 22px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
::selection { background: var(--brand-ring); }

html, body { height: 100%; }
body {
  display: flex;
  height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(1100px 600px at 78% -8%, color-mix(in srgb, var(--brand) 8%, transparent), transparent 60%),
    var(--bg);
  overflow: hidden;
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* Scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 35%, transparent); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--muted) 55%, transparent); background-clip: padding-box; }

/* ───────────────────────────── Sidebar ───────────────────────────── */
#sidebar {
  width: 248px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  color: #c2cfe0;
  background: linear-gradient(180deg, var(--sidebar-1), var(--sidebar-2));
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}
.brand { display: flex; gap: 12px; align-items: center; padding: 6px 8px 22px; }
.logo {
  width: 40px; height: 40px; border-radius: 13px;
  background: linear-gradient(135deg, var(--brand), var(--brand-3));
  color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 19px;
  display: grid; place-items: center;
  box-shadow: 0 6px 16px rgba(0, 104, 255, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.brand b { display: block; font-family: var(--font-display); color: #fff; font-size: 15.5px; letter-spacing: -0.01em; }
.brand small { display: block; font-size: 9px; letter-spacing: 0.16em; color: #647691; text-transform: uppercase; margin-top: 3px; }

#nav { flex: 1; display: flex; flex-direction: column; gap: 3px; overflow-y: auto; min-height: 0; padding-right: 2px; }
#nav button {
  position: relative;
  display: flex; gap: 11px; align-items: center;
  width: 100%; padding: 11px 13px;
  border: 0; border-radius: 10px; background: transparent;
  color: #94a3b8; font-family: var(--font); font-size: 13px; font-weight: 500;
  cursor: pointer; text-align: left; transition: background .16s, color .16s;
}
#nav button .ico { display: flex; opacity: 0.7; transition: opacity .16s, color .16s; }
#nav button:hover { background: rgba(255, 255, 255, 0.06); color: #e6edf6; }
#nav button:hover .ico { opacity: 1; }
#nav button.active { background: linear-gradient(90deg, rgba(0, 104, 255, 0.22), rgba(0, 104, 255, 0.08)); color: #fff; font-weight: 600; }
#nav button.active .ico { opacity: 1; color: #6db0ff; }
#nav button.active::before {
  content: ""; position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 22px; border-radius: 0 4px 4px 0; background: linear-gradient(180deg, var(--brand-3), var(--brand));
}

.profile {
  display: flex; gap: 10px; align-items: center;
  background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 13px; padding: 10px; margin-bottom: 9px;
}
.profile img, .profile .av, .profile-lg img, .profile-lg .av {
  width: 38px; height: 38px; border-radius: 50%; object-fit: cover;
  background: linear-gradient(135deg, var(--brand), var(--brand-3));
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.profile b { font-size: 12.5px; color: #fff; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.profile small { font-size: 10px; color: #6c7e98; font-family: var(--font-mono); }

.sync {
  display: flex; gap: 9px; align-items: center;
  background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 13px; padding: 11px 13px; font-size: 12px; color: #c2cfe0; margin-top: 4px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot.off { background: #5d6f88; }
.dot.on { background: #22c55e; box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.22); animation: pulse 2.2s ease infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

.side-tools { display: flex; gap: 8px; margin-top: 10px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; padding: 0; border-radius: 10px; cursor: pointer;
  color: var(--muted); background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm); transition: .16s;
}
.icon-btn:hover { color: var(--brand); background: var(--card-2); border-color: var(--brand); }

/* ───────────────────────────── Main / header ───────────────────────────── */
main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; position: relative; }

#topbar-progress {
  position: absolute; top: 0; left: 0; right: 0; height: 3px; z-index: 60;
  background: transparent; overflow: hidden; opacity: 0; transition: opacity .3s;
}
#topbar-progress.on { opacity: 1; }
#topbar-progress > span {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--brand), var(--brand-3));
  box-shadow: 0 0 10px rgba(0, 104, 255, 0.6); transition: width .35s ease;
}

header, .app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 28px; background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.header-left { min-width: 0; }
header h1, #title { font-family: var(--font-display); font-size: 20px; font-weight: 700; letter-spacing: -0.015em; }
.header-sub, #subtitle { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.header-right { display: flex; align-items: center; gap: 10px; }

.badge {
  font-size: 12px; font-weight: 600; color: var(--warn);
  background: var(--warn-bg); border: 1px solid var(--warn-line);
  padding: 6px 13px; border-radius: 99px;
}
.badge.ok { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-line); }
.badge::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 7px; vertical-align: middle; opacity: .85; }

#view { flex: 1; overflow: auto; padding: 26px 28px; scroll-behavior: smooth; }
#view > * { animation: fadeup .28s ease both; }
@keyframes fadeup { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ───────────────────────────── Cards / layout ───────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 22px; box-shadow: var(--shadow);
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid2.acc-grid { grid-template-columns: minmax(300px, 380px) 1fr; align-items: start; }
.camp-layout { display: grid; grid-template-columns: 300px 1fr; gap: 20px; align-items: start; }
h2 { font-family: var(--font-display); font-size: 16px; font-weight: 700; margin-bottom: 4px; letter-spacing: -0.01em; display: flex; align-items: center; gap: 8px; }
h2 svg { color: var(--brand); }
h3 { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
p.sub { color: var(--muted); font-size: 13px; margin-bottom: 15px; line-height: 1.55; }

.page-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.wrap { display: flex; gap: 8px; flex-wrap: wrap; }
.banner {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; margin-bottom: 16px;
  border-radius: var(--r-sm); font-size: 13px; line-height: 1.5;
  background: color-mix(in srgb, var(--brand) 7%, var(--card)); border: 1px solid color-mix(in srgb, var(--brand) 22%, var(--line)); color: var(--ink-soft);
}

.info-card {
  border-radius: var(--r); padding: 18px; border: 1px solid var(--line); background: var(--card-2);
  font-size: 13px; line-height: 1.6; color: var(--ink-soft);
}
.info-card h3 { margin-bottom: 8px; color: var(--ink); }
.info-card p { color: var(--muted); }
.info-card.warn { background: var(--warn-bg); border-color: var(--warn-line); }
.info-card.warn h3 { color: #92560a; }

/* ───────────────────────────── Buttons ───────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: linear-gradient(180deg, var(--brand-2), var(--brand)); color: #fff;
  border: 0; border-radius: 10px; padding: 10px 16px;
  font-family: var(--font); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: transform .12s, box-shadow .16s, filter .16s, background .16s;
  white-space: nowrap; box-shadow: 0 4px 12px rgba(0, 104, 255, 0.28);
}
.btn:hover { filter: brightness(1.05); box-shadow: 0 6px 18px rgba(0, 104, 255, 0.36); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; filter: none; }
.btn .ico { display: flex; }
.btn.sm { padding: 7px 12px; font-size: 12px; border-radius: 9px; box-shadow: 0 3px 9px rgba(0, 104, 255, 0.25); }
.btn.lg { padding: 12px 20px; font-size: 14px; }
.btn.block { width: 100%; }

.btn.ghost { background: var(--card); color: var(--ink-soft); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.btn.ghost:hover { background: var(--card-2); color: var(--ink); border-color: color-mix(in srgb, var(--brand) 35%, var(--line)); filter: none; }
.btn.danger { background: linear-gradient(180deg, #f87171, #ef4444); box-shadow: 0 4px 12px rgba(220, 38, 38, 0.28); }
.btn.ghost.danger { background: var(--card); color: var(--err); border-color: var(--err-line); box-shadow: var(--shadow-sm); }
.btn.ghost.danger:hover { background: var(--err-bg); border-color: var(--err); }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

/* ───────────────────────────── Forms ───────────────────────────── */
.fld { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin: 12px 0 6px; }
.fld:first-child { margin-top: 0; }
input, textarea, select {
  width: 100%; font-family: var(--font); font-size: 13px; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 10px 12px; transition: border-color .16s, box-shadow .16s; outline: none;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, textarea:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-ring); }
textarea { resize: vertical; min-height: 92px; line-height: 1.55; }
select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 34px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-inline { display: flex; gap: 10px; align-items: center; }
.form-section { padding: 16px 0; border-top: 1px solid var(--line-2); }
.form-section:first-child { border-top: 0; padding-top: 0; }
.form-section-title { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-size: 13px; font-weight: 700; color: var(--ink); margin-bottom: 10px; }
.form-section-title .ico { color: var(--brand); display: flex; }
.time-row { display: flex; gap: 8px; align-items: center; }

/* Switch */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; }
.switch { position: relative; display: inline-block; width: 44px; height: 25px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: color-mix(in srgb, var(--muted) 45%, transparent); border-radius: 99px; cursor: pointer; transition: .2s; }
.slider::before { content: ""; position: absolute; height: 19px; width: 19px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); }
.switch input:checked + .slider { background: linear-gradient(180deg, var(--brand-2), var(--brand)); }
.switch input:checked + .slider::before { transform: translateX(19px); }

/* ───────────────────────────── Chips / tags ───────────────────────────── */
.chip {
  --chip-color: #475569;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 99px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  cursor: pointer; transition: .15s; white-space: nowrap; line-height: 1;
}
.chip:hover { color: var(--ink); border-color: color-mix(in srgb, var(--chip-color) 55%, var(--line)); background: color-mix(in srgb, var(--chip-color) 8%, var(--card)); }
.chip.on { background: var(--chip-color); border-color: transparent; color: #fff; box-shadow: 0 2px 9px color-mix(in srgb, var(--chip-color) 38%, transparent); }
.chip svg { opacity: .9; }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 8px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
}

.day-btn {
  width: 42px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--muted); font-size: 12px; font-weight: 700;
  cursor: pointer; transition: .15s;
}
.day-btn:hover { border-color: var(--brand); color: var(--ink); }
.day-btn.on { background: linear-gradient(180deg, var(--brand-2), var(--brand)); color: #fff; border-color: transparent; box-shadow: 0 3px 9px rgba(0, 104, 255, 0.3); }

/* ───────────────────────────── Tables ───────────────────────────── */
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table thead th {
  position: sticky; top: 0; z-index: 2; text-align: left; font-size: 11px; font-weight: 700;
  letter-spacing: 0.03em; text-transform: uppercase; color: var(--muted);
  background: var(--card-2); padding: 11px 14px; border-bottom: 1px solid var(--line);
}
table tbody td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); color: var(--ink-soft); vertical-align: middle; }
table tbody tr { transition: background .12s; }
table tbody tr:hover td { background: color-mix(in srgb, var(--brand) 4%, transparent); }
table tbody tr:last-child td { border-bottom: 0; }
.table-wrap { border: 1px solid var(--line); border-radius: var(--r); overflow: auto; max-height: 62vh; background: var(--card); box-shadow: var(--shadow-sm); }
td.ok, .ok { color: var(--ok); }
td.warn, .warn { color: var(--warn); }
td.err, .err { color: var(--err); }
.dim { color: var(--faint); }
.mono, small.mono, .meta { font-family: var(--font-mono); font-size: 11.5px; }

/* ───────────────────────────── Empty / states ───────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 54px 24px; text-align: center; color: var(--muted);
  border: 1.5px dashed var(--line); border-radius: var(--r); background: var(--card-2);
}
.empty-state .ico { color: var(--faint); opacity: .7; display: flex; }
.empty-state b { color: var(--ink); font-size: 15px; }

/* ───────────────────────────── Account tab ───────────────────────────── */
.acc-layout { display: grid; grid-template-columns: minmax(290px, 360px) 1fr; gap: 20px; align-items: start; }
.acc-side { display: flex; flex-direction: column; gap: 14px; }
.profile-lg { display: flex; gap: 14px; align-items: center; }
.profile-lg img, .profile-lg .av { width: 56px; height: 56px; font-size: 20px; }
.profile-lg b { font-size: 17px; font-family: var(--font-display); display: block; }
.profile-lg small { display: block; font-size: 11.5px; color: var(--muted); font-family: var(--font-mono); margin-top: 2px; }

.stat-pills { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-pill {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 14px 10px; text-align: center; box-shadow: var(--shadow-sm); transition: .15s;
}
.stat-pill:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--brand) 30%, var(--line)); }
.stat-pill b { display: block; font-family: var(--font-display); font-size: 24px; color: var(--brand); line-height: 1; }
.stat-pill span { display: block; font-size: 11px; color: var(--muted); margin-top: 5px; font-weight: 600; }

.msg-feed { display: flex; flex-direction: column; gap: 7px; max-height: 230px; overflow-y: auto; margin-top: 8px; }
.msg-line { font-size: 12.5px; line-height: 1.5; padding: 8px 11px; border-radius: 10px; background: var(--card-2); border: 1px solid var(--line-2); color: var(--ink-soft); }
.msg-line.out { background: color-mix(in srgb, var(--brand) 10%, var(--card)); border-color: color-mix(in srgb, var(--brand) 22%, var(--line)); }
.msg-line .dim { font-weight: 700; color: var(--muted); margin-right: 4px; }

.qr {
  display: grid; place-items: center; width: 218px; height: 218px; margin: 4px auto 0;
  background: var(--card-2); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden;
}
.qr img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.qr-hint { text-align: center; font-size: 12.5px; color: var(--brand); margin-top: 10px; font-weight: 600; }

.acc-preview { display: flex; flex-direction: column; min-height: 560px; padding: 0; overflow: hidden; }
.acc-preview-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.acc-preview-head h2 { margin: 0; }
.acc-preview-head .sub { margin: 4px 0 0; }
.preview-warn { font-size: 12px; color: var(--warn); background: var(--warn-bg); border-bottom: 1px solid var(--warn-line); padding: 9px 20px; font-weight: 600; }
.zalo-embed { flex: 1; min-height: 460px; background: var(--card-2); }
.preview-placeholder {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; text-align: center; padding: 40px; color: var(--muted);
}
.preview-placeholder .ico { color: var(--faint); opacity: .55; }
.preview-placeholder b { color: var(--ink); font-size: 15px; }
.preview-placeholder p { max-width: 380px; font-size: 13px; line-height: 1.6; }

/* ───────────────────────────── Campaigns ───────────────────────────── */
.camp-list { display: flex; flex-direction: column; gap: 10px; }
.camp-item {
  display: flex; align-items: center; gap: 12px; padding: 13px 15px;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--card);
  cursor: pointer; transition: .15s; box-shadow: var(--shadow-sm);
}
.camp-item:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); transform: translateX(2px); box-shadow: var(--shadow); }
.camp-item.active { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 6%, var(--card)); }
.camp-item .name { font-weight: 700; color: var(--ink); font-size: 13.5px; }
.camp-item .meta { color: var(--muted); font-size: 11.5px; margin-top: 2px; font-family: var(--font); }
.dot-status { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; background: var(--faint); }
.dot-status.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }

.camp-editor { display: flex; flex-direction: column; }
.camp-form-col { display: flex; flex-direction: column; }
.camp-preview-col { display: flex; flex-direction: column; gap: 14px; }
.camp-bubble-wrap, .camp-progress, .camp-summary { background: var(--card-2); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.camp-summary { display: flex; flex-direction: column; gap: 9px; }
.camp-summary-item { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; }
.camp-summary-item span { color: var(--muted); }
.camp-summary-item b { color: var(--ink); }
.settings-foot, .settings-test { margin-top: 16px; }
.settings-grid { display: grid; gap: 16px; }
.settings-grid-2col { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.settings-header { margin-bottom: 20px; }
.settings-header h1 { font-family: var(--font-display); font-size: 22px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.settings-card { display: flex; flex-direction: column; gap: 10px; }
.settings-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.settings-card-head h2 { display: flex; align-items: center; gap: 8px; font-size: 15px; margin: 0; }
.settings-badge {
  font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 99px;
  background: var(--card-2); color: var(--muted); border: 1px solid var(--line);
}
.settings-badge.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.settings-badge.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.settings-hint { font-size: 12px; color: var(--muted); line-height: 1.5; margin-top: 4px; }
.settings-hint.ok { color: var(--ok); }
.settings-hint.err { color: var(--err); }
.settings-hint.hidden { display: none; }
.settings-toggle-main { margin: 4px 0 8px; padding: 10px 12px; background: var(--card-2); border-radius: var(--r-sm); border: 1px solid var(--line); }
.settings-tg-fields { display: flex; flex-direction: column; gap: 10px; transition: opacity .2s; }
.settings-tg-fields.disabled { opacity: .45; pointer-events: none; }
.input-with-btn { display: flex; gap: 8px; align-items: stretch; }
.input-with-btn input { flex: 1; }
.input-with-btn .btn { flex-shrink: 0; padding: 0 12px; }
.fld .hint { font-weight: 400; color: var(--faint); font-size: 11px; }
.api-endpoints { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.api-endpoints code {
  font-family: var(--font-mono); font-size: 11.5px; padding: 6px 10px;
  background: var(--card-2); border: 1px solid var(--line); border-radius: var(--r-sm); color: var(--ink-soft);
}
.settings-foot { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding-top: 8px; border-top: 1px solid var(--line); }

/* Bars */
.bar, .bar-lg { width: 100%; height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar-lg { height: 11px; }
.bar > span, .bar-lg > span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-3)); border-radius: 99px; transition: width .4s ease; }

/* ───────────────────────────── Media ───────────────────────────── */
.media-gallery, .media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 12px; }
.media-card, .media-thumb {
  position: relative; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden;
  background: var(--card-2); cursor: pointer; transition: .15s; aspect-ratio: 1; box-shadow: var(--shadow-sm);
}
.media-card:hover, .media-thumb:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.media-card img, .media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-thumb.on { border: 2px solid var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.media-thumb.on::after { content: "✓"; position: absolute; top: 5px; right: 6px; width: 19px; height: 19px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 12px; display: grid; place-items: center; font-weight: 700; }
.media-card-foot, .thumb-name { font-size: 10px; color: var(--muted); padding: 5px 7px; background: var(--card); border-top: 1px solid var(--line-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb-name { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0, 0, 0, 0.55); color: #fff; border: 0; }
.media-preview-lg { width: 100%; border-radius: var(--r-sm); border: 1px solid var(--line); max-height: 320px; object-fit: contain; background: var(--card-2); }

/* ───────────────────────────── Content tab ───────────────────────────── */
.content-layout, .content-split { display: grid; grid-template-columns: 280px 1fr; gap: 20px; align-items: start; }
.content-left { display: flex; flex-direction: column; gap: 12px; }
.content-right, .content-preview-pane { display: flex; flex-direction: column; gap: 12px; }
.file-list { display: flex; flex-direction: column; gap: 5px; max-height: 56vh; overflow-y: auto; }
.file-item {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 10px 12px; border: 1px solid transparent; border-radius: var(--r-sm);
  background: transparent; color: var(--ink-soft); font-size: 13px; cursor: pointer; transition: .14s;
}
.file-item:hover { background: var(--card-2); }
.file-item.active { background: color-mix(in srgb, var(--brand) 8%, var(--card)); border-color: color-mix(in srgb, var(--brand) 28%, var(--line)); color: var(--ink); font-weight: 600; }
.preview-box { background: var(--card-2); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; min-height: 120px; font-size: 13px; line-height: 1.6; white-space: pre-wrap; color: var(--ink-soft); }

/* ───────────────────────────── Zalo bubble preview ───────────────────────────── */
.zalo-phone { background: linear-gradient(160deg, #cfe0ff, #eaf2ff); border-radius: 16px; padding: 14px; }
[data-theme="dark"] .zalo-phone { background: linear-gradient(160deg, #16243a, #0f1a2c); }
.zalo-chat-head { font-size: 11px; font-weight: 700; color: var(--brand); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px; }
.zalo-bubble { background: #fff; border-radius: 4px 16px 16px 16px; padding: 11px 14px; font-size: 13px; line-height: 1.55; color: #0f172a; white-space: pre-wrap; box-shadow: 0 2px 8px rgba(15, 23, 42, 0.1); max-width: 88%; }
.zalo-badge { display: inline-block; font-size: 10px; font-weight: 700; color: var(--brand); }
.bubble-imgs { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.bubble-img { width: 70px; height: 70px; object-fit: cover; border-radius: 8px; }

/* ───────────────────────────── Logs / run progress ───────────────────────────── */
.log-stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px 18px; box-shadow: var(--shadow-sm); border-left: 3px solid var(--brand);
}
.stat-card.ok { border-left-color: var(--ok); }
.stat-card.warn { border-left-color: var(--warn); }
.stat-card.err { border-left-color: var(--err); }
.stat-card b { display: block; font-family: var(--font-display); font-size: 26px; color: var(--ink); line-height: 1; }
.stat-card span { display: block; font-size: 11.5px; color: var(--muted); margin-top: 6px; font-weight: 600; }

.console, .console-lg, .test-log, .run-feed {
  font-family: var(--font-mono); font-size: 12px; line-height: 1.7;
  background: #07101e; color: #cfe0f5; border: 1px solid #16243a; border-radius: var(--r);
  padding: 14px 16px; overflow-y: auto;
}
.console-lg { max-height: 420px; }
.console, .test-log { max-height: 260px; }
.run-feed { max-height: 200px; }
.console > div, .run-feed-line, .test-log-line { padding: 1px 0; white-space: pre-wrap; word-break: break-word; }
.console .info, .test-log-line { color: #9fb4d0; }
.console .success { color: #5fe39a; }
.console .warning { color: #ffcf6b; }
.console .error { color: #ff8a8a; }
.console .dim { color: #56708f; }

.run-progress-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.run-current { font-size: 12.5px; color: var(--muted); margin: 10px 0; }
.run-current b { color: var(--ink); }
.run-meta { font-size: 11.5px; color: var(--faint); font-family: var(--font-mono); }
.run-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0; }
.run-stat { text-align: center; background: var(--card-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 6px; }
.run-stat b { display: block; font-family: var(--font-display); font-size: 20px; color: var(--ink); line-height: 1; }
.run-stat span { display: block; font-size: 10.5px; color: var(--muted); margin-top: 5px; font-weight: 600; }

.run-status { font-size: 11px; font-weight: 700; padding: 4px 11px; border-radius: 99px; text-transform: uppercase; letter-spacing: 0.04em; }
.run-status.idle { color: var(--muted); background: var(--card-2); border: 1px solid var(--line); }
.run-status.running { color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, var(--card)); border: 1px solid color-mix(in srgb, var(--brand) 30%, var(--line)); }
.run-status.running::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); margin-right: 6px; animation: pulse 1s infinite; }
.run-status.done { color: var(--ok); background: var(--ok-bg); border: 1px solid var(--ok-line); }
.run-status.warn { color: var(--warn); background: var(--warn-bg); border: 1px solid var(--warn-line); }

/* ───────────────────────────── Toast ───────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(8px);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px;
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg); z-index: 200;
  max-width: 460px; animation: toastin .26s ease both;
}
[data-theme="dark"] .toast { background: #1c2c44; border: 1px solid var(--line); }
@keyframes toastin { from { opacity: 0; transform: translateX(-50%) translateY(16px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* Misc lists used by app.js */
.check-list { display: flex; flex-direction: column; gap: 6px; }
.check-item { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--ink-soft); }

/* Responsive */
@media (max-width: 1180px) {
  .acc-layout, .grid2.acc-grid, .camp-layout, .content-layout, .content-split { grid-template-columns: 1fr; }
}
@media (max-width: 920px) {
  #sidebar { width: 70px; }
  .brand div, #nav button span:not(.ico), .profile div, .sync span:last-child { display: none; }
  #nav button { justify-content: center; }
  .grid2, .form-grid { grid-template-columns: 1fr; }
}
