:root {
  --bg: #f7f5f6;
  --surface: #ffffff;
  --surface-soft: #fbfafb;
  --ink: #1e1a1c;
  --muted: #736b6f;
  --line: #e9e3e6;
  --pink: #e40067;
  --pink-dark: #be0055;
  --pink-soft: #fff0f6;
  --green: #17a968;
  --green-soft: #eaf8f1;
  --orange: #d78b16;
  --red: #d94150;
  --shadow: 0 18px 55px rgba(52, 31, 41, .12);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 26px 18px; background: #171315; color: #fff; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 11px; padding: 0 10px; font-size: 17px; font-weight: 800; }
.brand-mark { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--pink); color: #fff; font-weight: 900; }
.nav-list { display: grid; gap: 5px; margin-top: 42px; }
.nav-item { width: 100%; border: 0; background: transparent; color: #aca5a8; border-radius: 12px; padding: 12px 13px; display: flex; align-items: center; gap: 12px; font-size: 14px; text-align: left; }
.nav-item span { width: 22px; font-size: 18px; text-align: center; }
.nav-item:hover, .nav-item.active { color: #fff; background: rgba(255, 255, 255, .08); }
.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.09); }
.danger-text:hover { color: #ff8a96; }

.main-content { width: min(1120px, 100%); margin: 0 auto; padding: 30px 44px 72px; }
.topbar { min-height: 72px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.topbar h1 { margin: 3px 0 0; font-size: 25px; letter-spacing: -.5px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.eyebrow { margin: 0; color: var(--pink); font-size: 10px; font-weight: 900; letter-spacing: 1.4px; }
.plan-badge { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 7px 11px; font-size: 10px; font-weight: 800; letter-spacing: .7px; }
.avatar-button, .large-avatar { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--pink-soft); color: var(--pink); display: grid; place-items: center; font-weight: 900; }

.welcome-card { padding: 34px 36px; border-radius: 24px; background: linear-gradient(125deg, #23181e 0%, #3b1a2a 60%, #6c183c 100%); color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 30px; overflow: hidden; position: relative; }
.welcome-card::after { content: ""; width: 230px; height: 230px; border-radius: 50%; position: absolute; right: -55px; top: -105px; border: 45px solid rgba(228,0,103,.24); }
.welcome-card > * { position: relative; z-index: 1; }
.welcome-label { color: #ff82ba; font-size: 10px; font-weight: 900; letter-spacing: 1.5px; }
.welcome-card h2 { margin: 9px 0 7px; font-size: clamp(25px, 3vw, 34px); letter-spacing: -1px; }
.welcome-card p { color: #d5c9cf; max-width: 610px; margin: 0; line-height: 1.55; font-size: 14px; }

.section-block { margin-top: 34px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 14px; }
.section-heading h2 { font-size: 18px; margin: 4px 0 0; }
.text-button, .inline-button { border: 0; color: var(--pink); background: transparent; font-size: 12px; font-weight: 800; padding: 4px; }
.text-button:hover, .inline-button:hover { color: var(--pink-dark); }

.status-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.status-card { border: 1px solid var(--line); background: var(--surface); padding: 17px; border-radius: var(--radius); display: flex; align-items: center; gap: 13px; text-align: left; transition: transform .18s, box-shadow .18s; }
.status-card:hover, .action-card:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(52,31,41,.08); }
.service-icon { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; font-weight: 900; }
.service-icon.whatsapp { color: #128c58; background: var(--green-soft); }
.service-icon.instagram { color: var(--pink); background: var(--pink-soft); }
.service-icon.bot { color: #6955c9; background: #f0edff; }
.status-copy { display: grid; gap: 4px; min-width: 0; }
.status-copy strong { font-size: 14px; }
.status-copy small { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-dot { width: 9px; height: 9px; margin-left: auto; border-radius: 50%; background: #bbb4b7; flex: 0 0 auto; box-shadow: 0 0 0 4px rgba(140,130,135,.1); }
.status-dot.ok { background: var(--green); box-shadow: 0 0 0 4px rgba(23,169,104,.11); }
.status-dot.warn { background: var(--orange); box-shadow: 0 0 0 4px rgba(215,139,22,.11); }
.status-dot.fail { background: var(--red); box-shadow: 0 0 0 4px rgba(217,65,80,.11); }

.action-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.action-card { border: 1px solid var(--line); background: var(--surface); padding: 17px 18px; border-radius: var(--radius); display: grid; grid-template-columns: 40px minmax(0,1fr) 15px; align-items: center; gap: 13px; text-align: left; transition: transform .18s, box-shadow .18s; }
.action-card .action-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--surface-soft); border: 1px solid var(--line); display: grid; place-items: center; font-size: 18px; }
.action-card > span:nth-child(2) { display: grid; gap: 4px; }
.action-card strong { font-size: 13px; }
.action-card small { color: var(--muted); font-size: 11px; }
.action-card b { color: #aaa2a6; font-size: 24px; font-weight: 300; }

.activity-list { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.activity-item { display: flex; align-items: center; gap: 13px; padding: 14px 17px; border-bottom: 1px solid var(--line); }
.activity-item:last-child { border-bottom: 0; }
.activity-bullet { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.activity-bullet.fail { background: var(--red); }
.activity-item span:nth-child(2) { display: grid; gap: 3px; min-width: 0; }
.activity-item strong { font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity-item small { color: var(--muted); font-size: 10px; }
.empty-state { color: var(--muted); text-align: center; padding: 26px; margin: 0; font-size: 12px; }

.btn { border: 0; border-radius: 12px; padding: 12px 17px; font-weight: 800; font-size: 13px; transition: filter .15s, transform .15s; }
.btn:hover { filter: brightness(.97); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: wait; }
.btn.primary { background: var(--pink); color: #fff; }
.btn.secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: #fff1f2; color: var(--red); border: 1px solid #ffd7db; }
.btn.full { width: 100%; }
.button-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }

.modal-overlay { position: fixed; inset: 0; z-index: 100; padding: 22px; background: rgba(23,19,21,.58); backdrop-filter: blur(6px); display: grid; place-items: center; }
.modal-shell { width: min(620px, 100%); max-height: min(88vh, 850px); background: var(--surface); border-radius: 22px; box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.modal-header { padding: 22px 24px 17px; display: flex; justify-content: space-between; align-items: start; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 4px 0 0; font-size: 20px; }
.modal-close { width: 34px; height: 34px; border: 0; border-radius: 10px; background: var(--surface-soft); color: var(--muted); font-size: 25px; line-height: 1; }
.modal-body { overflow-y: auto; padding: 22px 24px 26px; }
.modal-panel { display: none; }
.modal-panel.active { display: block; }

.connection-summary { border: 1px solid var(--line); background: var(--surface-soft); border-radius: 14px; padding: 15px; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center; }
.connection-summary > div { display: flex; align-items: center; gap: 10px; }
.connection-summary .status-dot { margin: 0; }
.connection-summary small { color: var(--muted); font-size: 10px; text-align: right; }
.center-box { text-align: center; border: 1px solid var(--line); border-radius: 16px; padding: 18px; margin-bottom: 14px; }
.center-box p { color: var(--muted); font-size: 12px; margin: 10px 0 0; }
.qr-image { width: 220px; max-width: 100%; padding: 8px; background: #fff; border-radius: 12px; }
.pairing-code { margin-top: 12px; padding: 13px; border-radius: 12px; background: #171315; color: #fff; font-size: 30px; font-weight: 900; letter-spacing: 5px; }
.stack-actions { display: grid; gap: 10px; }
.form-card { background: var(--surface-soft); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: grid; gap: 9px; }

.switch-row, .check-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 1px solid var(--line); background: var(--surface-soft); border-radius: 14px; padding: 15px; margin-bottom: 16px; }
.switch-row > div, .check-card span { display: grid; gap: 4px; }
.switch-row strong, .check-card strong { font-size: 13px; }
.switch-row small, .check-card small { color: var(--muted); font-size: 10px; }
.check-card { justify-content: flex-start; cursor: pointer; }
.check-card input { width: 17px; height: 17px; accent-color: var(--pink); }
.switch { position: relative; width: 44px; height: 24px; flex: 0 0 auto; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: #ccc5c8; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; top: 3px; left: 3px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 2px 7px rgba(0,0,0,.15); }
.switch input:checked + span { background: var(--pink); }
.switch input:checked + span::before { transform: translateX(20px); }

.field { display: grid; gap: 7px; margin-bottom: 16px; }
.field label { color: #4c4548; font-size: 11px; font-weight: 800; }
.field small { color: var(--muted); font-size: 10px; }
input, textarea { width: 100%; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 12px; padding: 12px 13px; outline: 0; font-size: 13px; }
input:focus, textarea:focus { border-color: #f08bb8; box-shadow: 0 0 0 3px var(--pink-soft); }
textarea { resize: vertical; min-height: 110px; }
.form-grid { display: grid; grid-template-columns: 1fr 140px; gap: 12px; }
.search-input { margin-bottom: 12px; }

.tabs { display: flex; gap: 5px; padding: 4px; border-radius: 12px; background: var(--surface-soft); margin-bottom: 14px; }
.tab { flex: 1; border: 0; border-radius: 9px; background: transparent; color: var(--muted); padding: 9px; font-size: 11px; font-weight: 800; }
.tab.active { color: var(--ink); background: var(--surface); box-shadow: 0 3px 10px rgba(50,30,40,.07); }
.tab span { display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px; margin-left: 4px; border-radius: 999px; color: var(--pink); background: var(--pink-soft); }
.group-list { max-height: 330px; overflow: auto; border: 1px solid var(--line); border-radius: 14px; margin-bottom: 16px; }
.group-item { display: flex; align-items: center; gap: 10px; padding: 12px 13px; border-bottom: 1px solid var(--line); font-size: 12px; cursor: pointer; }
.group-item:last-child { border-bottom: 0; }
.group-item input { width: 16px; height: 16px; accent-color: var(--pink); }
.group-item small { color: var(--muted); margin-left: auto; }

.webhook-box, .info-box { border: 1px solid #f7c6dc; background: var(--pink-soft); border-radius: 14px; padding: 13px; margin-bottom: 16px; }
.webhook-box { display: grid; gap: 7px; }
.webhook-box span, .webhook-box code, .info-box { font-size: 10px; }
.webhook-box code { overflow-wrap: anywhere; color: #6d3150; }
.result-box { border-radius: 14px; background: var(--surface-soft); border: 1px solid var(--line); padding: 13px; margin-top: 12px; font-size: 11px; line-height: 1.6; }
.result-box.ok { color: #11784c; background: var(--green-soft); border-color: #cceede; }
.result-box.fail { color: #a92935; background: #fff1f2; border-color: #ffd7db; }
.advanced-box { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 16px; }
.advanced-box summary { color: var(--muted); font-size: 11px; font-weight: 800; cursor: pointer; margin-bottom: 15px; }
.file-input { border-style: dashed; }
.image-preview { display: flex; align-items: end; gap: 10px; }
.image-preview img { width: 120px; height: 120px; object-fit: cover; border-radius: 12px; }
.modal-toolbar { display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; margin-bottom: 10px; }
.history-list { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.history-row { padding: 12px 14px; display: grid; gap: 4px; border-bottom: 1px solid var(--line); }
.history-row:last-child { border-bottom: 0; }
.history-row strong { font-size: 11px; }
.history-row small { color: var(--muted); font-size: 10px; }
.history-row.fail strong { color: var(--red); }
.company-card { display: flex; align-items: center; gap: 13px; margin-bottom: 20px; }
.large-avatar { width: 54px; height: 54px; font-size: 19px; }
.company-card > div { display: grid; gap: 4px; }
.company-card small { color: var(--muted); font-size: 11px; }
.toast { position: fixed; right: 25px; bottom: 25px; z-index: 200; max-width: 360px; padding: 12px 16px; border-radius: 12px; background: #171315; color: #fff; font-size: 12px; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .22s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.fail { background: #a92935; }

.auth-page { min-height: 100vh; background: #171315; }
.auth-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(340px, .9fr) minmax(520px, 1.1fr); }
.auth-brand { padding: clamp(36px, 6vw, 78px); color: #fff; display: flex; flex-direction: column; justify-content: space-between; background: radial-gradient(circle at 15% 90%, rgba(228,0,103,.3), transparent 38%), #171315; }
.brand.light { padding: 0; }
.light-text { color: #ff82ba; }
.auth-brand h1 { max-width: 560px; font-size: clamp(38px, 5vw, 67px); letter-spacing: -2.5px; line-height: 1.02; margin: 15px 0 20px; }
.auth-brand p:not(.eyebrow) { max-width: 520px; color: #c9bec3; line-height: 1.65; font-size: 14px; }
.auth-benefits { display: grid; gap: 10px; color: #d8cdd2; font-size: 12px; }
.auth-form-wrap { display: grid; place-items: center; padding: 30px; background: var(--bg); }
.auth-card { width: min(440px, 100%); }
.auth-tabs { margin-bottom: 24px; background: #ece7e9; }
.auth-form { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 30px; box-shadow: 0 18px 50px rgba(52,31,41,.08); }
.auth-form h2 { margin: 5px 0 24px; font-size: 25px; }
.form-error { min-height: 18px; margin: 12px 0 0; color: var(--red); font-size: 11px; text-align: center; }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 76px minmax(0,1fr); }
  .sidebar { padding: 22px 12px; }
  .brand > span:last-child, .nav-item:not(.active) > span + *, .nav-item { font-size: 0; }
  .brand { justify-content: center; padding: 0; }
  .nav-item { justify-content: center; padding: 12px; }
  .nav-item span { font-size: 18px; }
  .main-content { padding: 26px 26px 64px; }
  .status-grid { grid-template-columns: 1fr; }
  .auth-layout { grid-template-columns: 1fr; }
  .auth-brand { min-height: 340px; gap: 40px; }
}

@media (max-width: 620px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 50; top: auto; bottom: 0; width: 100%; height: 66px; padding: 8px 10px; flex-direction: row; }
  .sidebar .brand, .sidebar-footer { display: none; }
  .nav-list { margin: 0; width: 100%; grid-template-columns: repeat(6, 1fr); gap: 2px; }
  .nav-item { padding: 9px 4px; }
  .main-content { padding: 20px 16px 94px; }
  .topbar { margin-bottom: 18px; }
  .topbar h1 { font-size: 21px; }
  .plan-badge { display: none; }
  .welcome-card { padding: 26px 23px; align-items: flex-start; flex-direction: column; }
  .welcome-card .btn { width: 100%; }
  .action-grid { grid-template-columns: 1fr; }
  .modal-overlay { padding: 0; align-items: end; }
  .modal-shell { width: 100%; max-height: 93vh; border-radius: 22px 22px 0 0; }
  .modal-header, .modal-body { padding-left: 18px; padding-right: 18px; }
  .form-grid, .button-row { grid-template-columns: 1fr; }
  .connection-summary { align-items: flex-start; flex-direction: column; gap: 8px; }
  .connection-summary small { text-align: left; }
  .auth-brand { display: none; }
  .auth-form-wrap { min-height: 100vh; padding: 18px; }
  .auth-form { padding: 24px 20px; }
}
