/* TipBot — tema "Clean Fintech" (claro padrão + dark). Compartilhado por
   client-login / client-panel / client-admin. Fontes carregadas no <head>:
   Bricolage Grotesque (display/corpo) + Spline Sans Mono (dados).
   Canais: Tippy = verde #1e3a2c · Telegram = azul. Marca/CTA = verde. */

:root {
  --bg: #f4f3ee;
  --bg-grad: none;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #faf9f5;
  --text: #14140f;
  --on-ink: #f4f3ee;
  --muted: #6f6c62;
  --muted-2: #9a968a;
  --border: #d8d4c7;
  --border-soft: #e4e1d6;
  --hover: #faf9f5;
  --sw-bg: #e8e5db;

  --accent: #b8860b;            /* marca / destaque (dourado, igual dashboard) */
  --accent-h: #9a7209;
  --accent-soft: rgba(184,134,11,0.13);
  --on: #1a9d4e;                /* positivo / ligado (verde) */
  --on-bg: rgba(26,157,78,0.12);
  --danger: #d23b3b;
  --danger-bg: rgba(210,59,59,0.10);
  --warn: #b8860b;

  --tippy: #1e3a2c;             /* canal Tippy (verde escuro) */
  --tippy-soft: #e5ece7;
  --tele: #1d7fb8;             /* canal Telegram (azul) */
  --tele-soft: #e0eef7;

  --radius: 18px;
  --radius-sm: 11px;
  --shadow: 0 2px 6px rgba(20,20,15,0.06);
  --shadow-lg: 0 24px 60px -28px rgba(20,20,15,0.32);
  --font: "Bricolage Grotesque", -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Spline Sans Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

/* Dark = "operations desk" do dashboard: azul-carvão profundo + brilho radial. */
html[data-theme="dark"] {
  --bg: #0b0e13;
  --bg-grad: radial-gradient(1200px 600px at 82% -10%, #18212e 0%, transparent 60%),
             radial-gradient(900px 500px at 0% 0%, #14110a 0%, transparent 55%);
  --bg-2: #131922;
  --surface: #131922;
  --surface-2: #1a212c;
  --text: #e9eef6;
  --on-ink: #0b0e13;
  --muted: #8b97a8;
  --muted-2: #5d6776;
  --border: #283140;
  --border-soft: #1e2630;
  --hover: #1a212c;
  --sw-bg: #212a37;

  --accent: #f0b429;            /* marca / destaque (dourado, igual dashboard) */
  --accent-h: #ffd166;
  --accent-soft: rgba(240,180,41,0.15);
  --on: #4ade80;                /* positivo / ligado (verde) */
  --on-bg: rgba(74,222,128,0.14);
  --danger: #fb6f6f;
  --danger-bg: rgba(251,111,111,0.14);
  --warn: #f0b429;

  --tippy: #4ade80;            /* canal Tippy (verde vivo) */
  --tippy-soft: rgba(74,222,128,0.16);
  --tele: #5aa9e6;
  --tele-soft: rgba(90,169,230,0.16);

  --shadow: 0 18px 50px -24px rgba(0,0,0,0.8);
  --shadow-lg: 0 24px 60px -22px rgba(0,0,0,0.85);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background-color: var(--bg); background-image: var(--bg-grad); background-attachment: fixed;
  color: var(--text);
  font-family: var(--font); -webkit-font-smoothing: antialiased;
  min-height: 100vh; transition: background-color 0.25s, color 0.25s;
}
a { color: var(--accent); text-decoration: none; }
code, .mono { font-family: var(--mono); }

.wrap { max-width: 800px; margin: 0 auto; padding: 26px 22px 80px; }

/* ----------------------------- topbar ----------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding-bottom: 24px; margin-bottom: 28px; border-bottom: 2px solid var(--text);
}
.brand { display: flex; align-items: center; gap: 13px; }
.brand .logo {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-h)); color: #1a1205;
  display: grid; place-items: center; font-weight: 800; font-size: 17px; letter-spacing: -0.03em;
  box-shadow: 0 6px 18px -8px var(--accent);
}
.brand h1 { font-size: 21px; margin: 0; font-weight: 800; letter-spacing: -0.03em; }
.brand .sub { font-size: 13px; color: var(--muted); margin-top: 1px; font-weight: 500; }

.who { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }
.who b { color: var(--text); font-weight: 700; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; flex: 0 0 auto;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; font-size: 16px; display: grid; place-items: center; transition: 0.15s;
}
.icon-btn:hover { border-color: var(--text); }

/* ------------------------------ cards ------------------------------ */
.card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 22px; margin-bottom: 18px;
  transition: background 0.25s, border-color 0.25s;
}
.card h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 0 0 4px; font-weight: 700; }
.card .hint { font-size: 13.5px; color: var(--muted); margin: 0 0 16px; line-height: 1.55; }

/* --------------------------- strategy list -------------------------- */
.strat-list { background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.strat {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 20px; border-bottom: 1.5px solid var(--border-soft);
  transition: background 0.13s;
}
.strat:last-child { border-bottom: 0; }
.strat:hover { background: var(--hover); }
.strat.on { background: transparent; }
.strat .num {
  flex: 0 0 auto; min-width: 34px; height: 34px; padding: 0 8px;
  border-radius: 9px; display: grid; place-items: center;
  font-family: var(--mono); font-weight: 700; font-size: 14px;
  background: var(--accent-soft); color: var(--accent);
}
.strat.on .num { background: var(--accent); color: #1a1205; }
.strat .meta { flex: 1 1 auto; min-width: 0; }
.strat .meta .name {
  font-size: 15px; font-weight: 700; letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.strat .meta .key { font-family: var(--mono); font-size: 11px; color: var(--muted-2); margin-top: 2px; }

/* toggles por canal (tokens Tippy / Telegram) na direita da linha */
.ch-toggles { display: flex; gap: 14px; align-items: flex-start; justify-content: flex-end; flex: 0 0 auto; flex-wrap: nowrap; }
.ch-toggle { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ch-lbl { font-size: 10px; color: var(--muted-2); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; max-width: 84px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* lista de tokens (cada um = um canal Tippy) */
.tok-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.tok-list:empty { display: none; }
.tok-item {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface-2); border: 1.5px solid var(--border-soft);
  border-radius: var(--radius-sm); padding: 12px 15px;
}
.tok-item .tok-info { display: flex; align-items: center; gap: 9px; flex: 1 1 auto; min-width: 0; flex-wrap: wrap; }
.tok-item .tok-info code { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.tok-item .tok-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.tok-empty { font-size: 13.5px; color: var(--muted); }

/* barra "marcar/desmarcar todas" por canal */
.strat-toolbar { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.strat-toolbar:empty { display: none; }
.sa-group {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted);
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 12px; padding: 7px 13px;
}
.sa-lbl { font-weight: 700; color: var(--muted); }
.sa-group a, .strat-toolbar a { cursor: pointer; color: var(--text); font-weight: 600; }

/* --------------------------- toggle switch -------------------------- */
.switch { position: relative; flex: 0 0 auto; width: 44px; height: 25px; cursor: pointer; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px;
  background: var(--sw-bg); border: 1.5px solid var(--border);
  transition: background 0.18s, border-color 0.18s;
}
.switch .thumb {
  position: absolute; top: 2.5px; left: 2.5px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff;
  transition: transform 0.18s; box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track + .thumb { transform: translateX(19px); }
/* cores por canal */
.switch input[data-ch="tippy"]:checked + .track { background: var(--tippy); border-color: var(--tippy); }
.switch input[data-ch="telegram"]:checked + .track { background: var(--tele); border-color: var(--tele); }
.switch input:disabled ~ .track { opacity: 0.5; cursor: wait; }

/* ------------------------------ campos/token ------------------------ */
.token-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.field {
  flex: 1 1 260px; background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  padding: 12px 14px; font-size: 14px; font-family: var(--mono);
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field::placeholder { color: var(--muted-2); }

.field-error {
  color: var(--danger); font-size: 13px; margin-top: 10px; line-height: 1.45;
  background: var(--danger-bg); border: 1.5px solid var(--danger);
  border-radius: var(--radius-sm); padding: 9px 13px;
}
.field-error:empty { display: none; }

.cred-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.cred-view .token-status { margin-top: 0; }

/* mini-ajuda colapsável */
.help { margin: -2px 0 16px; font-size: 13px; }
.help summary {
  cursor: pointer; color: var(--accent); font-weight: 700;
  list-style: none; display: inline-flex; align-items: center; gap: 6px; user-select: none;
}
.help summary::-webkit-details-marker { display: none; }
.help summary::before { content: "▸"; display: inline-block; transition: transform 0.15s; font-size: 11px; }
.help[open] summary::before { transform: rotate(90deg); }
.help ol { margin: 10px 0 0; padding-left: 20px; color: var(--muted); line-height: 1.65; }
.help ol li { margin-bottom: 5px; }
.help a { color: var(--accent); font-weight: 700; }

.token-status { font-size: 13.5px; color: var(--muted); margin-top: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.token-status code { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
}
.badge.ok, .badge.tippy { background: var(--tippy-soft); color: var(--tippy); }
.badge.tele { background: var(--tele-soft); color: var(--tele); }
.badge.none { background: var(--danger-bg); color: var(--danger); }

/* ------------------------------ buttons ----------------------------- */
.btn {
  border: 1.5px solid var(--text); background: transparent; color: var(--text);
  border-radius: var(--radius-sm); padding: 10px 16px; font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: var(--font); transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--text); color: var(--on-ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1a1205; }
.btn.primary:hover { background: var(--accent-h); color: #1a1205; }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.ghost { border-color: var(--border); color: var(--muted); }
.btn.ghost:hover { background: var(--hover); color: var(--text); border-color: var(--border); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 7px 13px; font-size: 13px; }

/* ------------------------------ login ------------------------------- */
.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 390px; box-shadow: var(--shadow-lg); }
.login-card .brand { justify-content: center; flex-direction: column; text-align: center; margin-bottom: 22px; }
.login-card .logo { width: 54px; height: 54px; font-size: 22px; border-radius: 15px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.input {
  width: 100%; background: var(--bg); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); padding: 12px 14px;
  font-size: 15px; font-family: var(--font); outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-card .btn { width: 100%; margin-top: 6px; }
.error-msg {
  background: var(--danger-bg); border: 1.5px solid var(--danger); color: var(--danger);
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13.5px; margin-bottom: 14px; display: none;
}
.error-msg.show { display: block; }

/* ------------------------------ table ------------------------------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1.5px solid var(--border-soft); }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 700; }
td b { font-weight: 700; }
td .pill, .pill { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill.on { background: var(--on-bg); color: var(--on); }
.pill.off { background: var(--danger-bg); color: var(--danger); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ------------------------------ toast ------------------------------- */
.toast-host { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; pointer-events: none; }
.toast {
  background: var(--surface); border: 1.5px solid var(--border); color: var(--text);
  border-radius: 12px; padding: 11px 18px; font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow-lg); animation: toast-in 0.2s ease;
}
.toast.ok { border-color: var(--accent); }
.toast.err { border-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ------------------------------ modal ------------------------------ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 60; background: rgba(20,20,15,0.45); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  width: 100%; max-width: 440px; background: var(--surface);
  border: 1.5px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 24px; animation: toast-in 0.18s ease;
}
.modal h3 { margin: 0 0 4px; font-size: 19px; font-weight: 800; letter-spacing: -0.02em; }
.modal .modal-sub { font-size: 13px; color: var(--muted); margin: 0 0 18px; }
.modal .form-group label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.modal .form-group { margin-bottom: 14px; }
.modal .field-note { font-size: 11.5px; color: var(--muted-2); margin-top: 5px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

.muted-note { font-size: 12.5px; color: var(--muted-2); margin-top: 18px; text-align: center; }
.loading { color: var(--muted); font-size: 14px; padding: 20px 0; text-align: center; }

/* ------------------------------ tabs ------------------------------- */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; flex-wrap: wrap; border-bottom: 2px solid var(--border-soft); }
.tab {
  background: transparent; border: none; color: var(--muted);
  padding: 10px 16px; font-size: 14px; font-weight: 700; cursor: pointer;
  font-family: var(--font); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tabpanel { display: none; }
.tabpanel.active { display: block; }

/* -------------------------- service cards -------------------------- */
.svc {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface-2); border: 1.5px solid var(--border-soft);
  border-radius: var(--radius-sm); padding: 15px 17px; margin-bottom: 10px;
}
.svc.on { border-color: var(--on); }
.dot { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; background: var(--muted-2); }
.svc.on .dot { background: var(--on); box-shadow: 0 0 0 4px var(--on-bg); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.svc .svc-meta { flex: 1 1 auto; min-width: 0; }
.svc .svc-name { font-size: 15px; font-weight: 700; }
.svc .svc-sub { font-family: var(--mono); font-size: 11.5px; color: var(--muted-2); margin-top: 2px; }
.svc .svc-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* --------------------------- global toggles ------------------------ */
.global-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: var(--surface-2); border: 1.5px solid var(--border-soft);
  border-radius: var(--radius-sm); padding: 15px 17px; margin-bottom: 10px;
}
.global-row .g-info .g-name { font-size: 15px; font-weight: 800; letter-spacing: -0.01em; }
.global-row .g-info .g-desc { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.global-row.live { border-color: var(--danger); background: var(--danger-bg); }
.state-tag { font-size: 12px; font-weight: 700; padding: 3px 11px; border-radius: 999px; }
.state-tag.on { background: var(--on-bg); color: var(--on); }
.state-tag.off { background: var(--bg); color: var(--muted); }
.state-tag.live { background: var(--danger-bg); color: var(--danger); }

/* --------------------------- strategy matrix ----------------------- */
.matrix { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.matrix th, .matrix td { padding: 10px 8px; border-bottom: 1.5px solid var(--border-soft); text-align: center; }
.matrix th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 700; }
.matrix td.s-name { text-align: left; }
.matrix .s-num { display: inline-block; min-width: 26px; padding: 1px 6px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); font-family: var(--mono); font-weight: 700; font-size: 12px; margin-right: 8px; }
.matrix .s-label { font-weight: 700; }
.matrix tbody tr:hover { background: var(--hover); }

.matrix-toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.matrix-toolbar .chk { display: flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--muted); cursor: pointer; }
.matrix-toolbar .chk input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.field.mini { flex: 0 0 auto; width: auto; padding: 8px 12px; font-size: 13.5px; font-family: var(--font); }
.mtx-count { margin-left: auto; font-family: var(--mono); font-size: 12.5px; color: var(--muted-2); }

/* botão-célula on/off da matriz */
.celltog {
  width: 30px; height: 30px; border-radius: 9px; padding: 0;
  border: 1.5px solid var(--border); background: transparent;
  color: var(--muted-2); cursor: pointer; display: inline-grid; place-items: center;
  font-size: 14px; line-height: 1; font-family: var(--font); transition: 0.13s;
}
.celltog:hover { border-color: var(--text); color: var(--text); }
.celltog:active { transform: scale(0.92); }
.celltog.on { border-color: transparent; color: #fff; font-weight: 800; background: var(--accent); }
.celltog.on[data-chan="tippy"], .celltog.on[data-chan="tippy2"] { background: var(--tippy); }
.celltog.on[data-chan="telegram"] { background: var(--tele); }
.celltog:disabled { opacity: 0.5; cursor: wait; }

@media (max-width: 540px) {
  .strat .meta .key { display: none; }
  .who .name-full { display: none; }
}
