:root {
  --ink: #f0ece9; --ink-2: #d5ceca; --muted: #958b86; --line: #2b2421; --line-strong: #3a2c26;
  --paper: #15110f; --paper-raised: #1a1513; --canvas: #0d0a09; --accent: #de794e; --accent-bright: #ee8a5f;
  --accent-soft: #2e1d17; --green: #7fb998; --green-soft: #192720; --amber: #d6a357; --amber-soft: #2b2418;
  --blue: #8db7c6; --blue-soft: #1d2529; --radius: 8px; --shadow: 0 24px 70px rgba(0, 0, 0, .36);
}
* { box-sizing: border-box; }
html { font-size: 16px; color-scheme: dark; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.45; }
body::before { content: ""; position: fixed; inset: 0; pointer-events: none; background: radial-gradient(circle at 8% 0%, rgba(222,121,78,.08), transparent 28%), radial-gradient(circle at 92% 100%, rgba(104,45,30,.1), transparent 30%); z-index: -1; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
[hidden] { display: none !important; }
.boot-screen { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 28px; background: radial-gradient(circle at 20% 0%, rgba(222,121,78,.12), transparent 35%), var(--canvas); }
.boot-screen img { width: 132px; height: auto; }
.boot-spinner { width: 24px; height: 24px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: boot-spin .7s linear infinite; }
@keyframes boot-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .boot-spinner { animation-duration: 1.4s; } }
.auth-screen { min-height: 100vh; padding: 24px; display: grid; place-items: center; background: radial-gradient(circle at 20% 0%, rgba(222,121,78,.16), transparent 35%), var(--canvas); }
.auth-card { width: min(420px, 100%); padding: 38px; border: 1px solid var(--line-strong); border-radius: 10px; background: rgba(21,17,15,.96); box-shadow: var(--shadow); }
.auth-logo { width: 132px; height: auto; display: block; margin-bottom: 42px; }
.auth-card h1 { margin: 8px 0 12px; font-size: 2rem; }
.auth-card > p { color: var(--muted); font-size: .86rem; }
.auth-card form { display: grid; gap: 15px; margin-top: 26px; }
.auth-card form .button { width: 100%; margin-top: 3px; }
.auth-feedback { min-height: 20px; margin: 8px 0 0; text-align: center; color: var(--accent) !important; }
.auth-link { display: block; margin: 15px auto 0; padding: 4px; border: 0; background: transparent; color: var(--muted); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.auth-link:hover { color: var(--text); }
.invite-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; margin-top: 18px; }
.invite-form input { min-height: 42px; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 28px 18px 20px; background: #100d0c; color: white; display: flex; flex-direction: column; z-index: 20; border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 30px; min-height: 30px; }
.brand-logo { width: 110px; height: auto; display: block; }
.brand-product { padding-left: 12px; border-left: 1px solid #3a322e; color: #8d8580; font-size: .67rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.nav-list { display: grid; gap: 4px; }
.nav-item { appearance: none; border: 1px solid transparent; width: 100%; border-radius: 7px; padding: 11px 12px; display: flex; align-items: center; gap: 11px; background: transparent; color: #8f8782; cursor: pointer; text-align: left; font-size: .86rem; font-weight: 600; transition: .18s ease; }
.nav-item:hover { background: #181311; color: var(--ink); border-color: #251e1b; }
.nav-item.active { background: var(--accent-soft); color: var(--accent-bright); border-color: #4a291d; }
.nav-icon { width: 19px; text-align: center; font-size: 1rem; }
.nav-count { margin-left: auto; min-width: 24px; padding: 1px 7px; border-radius: 999px; text-align: center; background: #28211e; font-size: .72rem; }
.nav-item.active .nav-count { background: var(--accent); color: #130d0a; }
.sidebar-card { margin-top: auto; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: #15110f; }
.sidebar-card .eyebrow { color: #796f6a; }
.sidebar-card strong { display: block; margin: 7px 0 11px; font-size: .9rem; }
.sidebar-card small { color: #776e69; }
.progress { height: 4px; background: #2c2522; border-radius: 10px; overflow: hidden; margin-bottom: 9px; }
.progress span { display: block; width: 0; height: 100%; background: var(--accent); border-radius: inherit; transition: width .35s ease; }
.sidebar-footer { display: flex; align-items: center; gap: 10px; padding: 18px 10px 0; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent); border: 1px solid #4a291d; font-size: .7rem; font-weight: 800; }
.sidebar-footer strong, .sidebar-footer small { display: block; }
.sidebar-user { min-width: 0; flex: 1; }
.sidebar-user strong, .sidebar-user small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-button { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 5px; background: transparent; color: var(--muted); cursor: pointer; }
.logout-button:hover { color: var(--accent); border-color: #4a291d; }
.sidebar-footer strong { font-size: .8rem; }
.sidebar-footer small { color: #786f6a; font-size: .7rem; }
.main { min-width: 0; }
.topbar { min-height: 108px; padding: 25px clamp(24px, 4vw, 56px); display: flex; justify-content: space-between; align-items: center; gap: 24px; border-bottom: 1px solid var(--line); background: rgba(13,10,9,.88); backdrop-filter: blur(16px); position: sticky; top: 0; z-index: 10; }
.eyebrow { font-size: .62rem; font-weight: 800; letter-spacing: .16em; color: var(--accent); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.45rem, 2.2vw, 2rem); font-weight: 500; letter-spacing: -.04em; line-height: 1.1; }
h2 { margin-bottom: 0; font-size: 1.35rem; font-weight: 550; letter-spacing: -.035em; }
h3 { margin-bottom: 5px; font-size: .95rem; font-weight: 600; letter-spacing: -.02em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.button { min-height: 42px; border: 1px solid transparent; border-radius: 6px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; text-decoration: none; cursor: pointer; font-size: .82rem; font-weight: 700; transition: .18s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--accent); color: #160d09; box-shadow: 0 10px 28px rgba(222,121,78,.12); }
.button-primary:hover { background: var(--accent-bright); }
.button-ghost { background: #171210; border-color: var(--line); }
.button-ghost:hover { border-color: #584036; background: #1c1613; }
.button-whatsapp { background: #5e9e77; color: #08110b; }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); cursor: pointer; font-size: 1.2rem; }
.mobile-only { display: none; }
.view-root { padding: 32px clamp(24px, 4vw, 56px) 56px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.stat-icon { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 5px; background: var(--accent-soft); color: var(--accent); font-weight: 900; }
.stat-card strong { display: block; font-size: 1.85rem; font-weight: 500; letter-spacing: -.055em; line-height: 1; margin-bottom: 8px; }
.stat-card small { color: var(--muted); }
.delta { font-size: .64rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--green); background: var(--green-soft); padding: 4px 7px; border-radius: 4px; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, .75fr); gap: 14px; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel-head { min-height: 70px; padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); }
.panel-head p { margin: 2px 0 0; color: var(--muted); font-size: .76rem; }
.text-button { border: 0; background: transparent; color: var(--accent); cursor: pointer; font-size: .76rem; font-weight: 800; }
.pipeline { padding: 9px 20px 18px; }
.pipeline-row { display: grid; grid-template-columns: 126px minmax(0,1fr) 28px; gap: 14px; align-items: center; padding: 11px 0; }
.pipeline-label { font-size: .75rem; font-weight: 650; }
.pipeline-track { height: 5px; border-radius: 10px; background: #28211e; overflow: hidden; }
.pipeline-fill { height: 100%; border-radius: inherit; background: var(--accent) !important; min-width: 3px; }
.pipeline-value { font-size: .75rem; font-weight: 800; text-align: right; }
.followup-list { padding: 5px 8px 8px; }
.followup-item { padding: 13px 12px; display: grid; grid-template-columns: 38px minmax(0,1fr) auto; gap: 11px; align-items: center; border-radius: 6px; cursor: pointer; }
.followup-item:hover { background: #1b1613; }
.date-chip { width: 38px; height: 40px; border-radius: 5px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; line-height: 1; border: 1px solid #3b261f; }
.date-chip strong { font-size: .86rem; }
.date-chip small { font-size: .54rem; font-weight: 850; text-transform: uppercase; }
.followup-item h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.followup-item p { margin: 0; color: var(--muted); font-size: .71rem; }
.status-pill { border-radius: 4px; padding: 5px 8px; font-size: .64rem; font-weight: 750; white-space: nowrap; background: var(--blue-soft); color: var(--blue); }
.status-pill.overdue { background: var(--accent-soft); color: var(--accent); }
.empty { padding: 42px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: 5px; }
.toolbar { margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.search-wrap { position: relative; flex: 1; max-width: 400px; }
.search-wrap span { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-wrap input { width: 100%; min-height: 43px; padding: 0 14px 0 38px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); }
.filter-group { display: flex; gap: 7px; overflow-x: auto; }
.filter-chip { border: 1px solid var(--line); border-radius: 5px; background: var(--paper); color: var(--muted); padding: 8px 12px; cursor: pointer; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.filter-chip.active { background: var(--accent-soft); border-color: #4a291d; color: var(--accent); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th { padding: 12px 18px; text-align: left; background: #110e0d; color: var(--muted); font-size: .63rem; letter-spacing: .1em; text-transform: uppercase; }
td { padding: 14px 18px; border-top: 1px solid var(--line); font-size: .8rem; }
tr[data-id] { cursor: pointer; }
tr[data-id]:hover td { background: #1a1513; }
.lead-cell { display: flex; align-items: center; gap: 10px; }
.lead-avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 5px; background: var(--accent-soft); color: var(--accent); font-size: .68rem; font-weight: 900; }
.lead-cell strong, .lead-cell small { display: block; }
.lead-cell small { color: var(--muted); font-size: .69rem; }
.stage-select { border: 0; border-radius: 4px; padding: 6px 9px; font-size: .69rem; font-weight: 750; max-width: 170px; }
.row-actions { display: flex; justify-content: flex-end; gap: 6px; }
.mini-button { border: 1px solid var(--line); border-radius: 5px; background: #181311; padding: 6px 9px; cursor: pointer; font-weight: 750; font-size: .69rem; }
.library-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.library-toolbar > div { display: grid; gap: 3px; }
.library-toolbar strong { font-size: .9rem; }
.library-toolbar span { color: var(--muted); font-size: .72rem; }
.message-layout { display: grid; grid-template-columns: 310px minmax(0, 1fr); gap: 14px; align-items: start; }
.script-library { overflow: hidden; }
.script-group + .script-group { border-top: 1px solid var(--line); }
.script-group-head { display: flex; align-items: center; padding: 8px; gap: 5px; background: #110e0d; }
.script-group-toggle { flex: 1; min-width: 0; display: grid; grid-template-columns: 15px minmax(0,1fr) auto; align-items: center; gap: 7px; padding: 7px; border: 0; background: transparent; cursor: pointer; text-align: left; }
.script-group-toggle > span { color: var(--accent); transition: transform .18s ease; }
.script-group:not(.open) .script-group-toggle > span { transform: rotate(-90deg); }
.script-group-toggle strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .75rem; }
.script-group-toggle small { min-width: 22px; padding: 2px 6px; border-radius: 999px; background: var(--paper-raised); color: var(--muted); text-align: center; font-size: .62rem; }
.script-group-actions { display: flex; opacity: .55; transition: opacity .18s ease; }
.script-group-head:hover .script-group-actions, .script-group-actions:focus-within { opacity: 1; }
.script-group-actions button { width: 27px; height: 27px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); cursor: pointer; }
.script-group-actions button:hover { background: var(--paper-raised); color: var(--ink); }
.step-list { padding: 9px; }
.step-item { width: 100%; border: 1px solid transparent; border-radius: 6px; padding: 11px; display: flex; gap: 11px; align-items: center; background: transparent; text-align: left; cursor: pointer; }
.step-item:hover, .step-item.active { background: var(--accent-soft); border-color: #3b261f; }
.script-icon { width: 28px; height: 28px; flex: 0 0 28px; display: grid; place-items: center; border-radius: 4px; background: #211a17; color: var(--accent); font-size: .8rem; font-weight: 850; }
.step-item.active .script-icon { background: var(--accent); color: #160d09; }
.step-number { width: 28px; height: 28px; flex: 0 0 28px; display: grid; place-items: center; border-radius: 4px; background: var(--accent); color: #160d09; font-size: .68rem; font-weight: 850; }
.step-item strong, .step-item small { display: block; }
.step-item strong { font-size: .77rem; }
.step-item small { color: var(--muted); font-size: .64rem; }
.message-editor { padding: 24px; }
.message-editor textarea { width: 100%; min-height: 300px; margin: 15px 0; resize: vertical; border: 1px solid var(--line); border-radius: 6px; padding: 16px; line-height: 1.65; background: #100d0c; }
.message-editor-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.message-editor-head p { margin: 4px 0 0; color: var(--muted); font-size: .77rem; }
.message-meta-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(170px, .6fr); gap: 13px; margin-top: 24px; }
.message-content-label { margin-top: 16px; }
.message-content-label textarea { margin: 0; }
.editor-helper { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.editor-helper > span { color: var(--muted); font-size: .69rem; }
.token-row { display: flex; flex-wrap: wrap; gap: 6px; }
.token { padding: 5px 8px; border: 1px solid transparent; border-radius: 4px; background: var(--accent-soft); color: var(--accent); font: 700 .67rem ui-monospace, SFMono-Regular, Menlo, monospace; cursor: pointer; }
.token:hover { border-color: #5b3022; }
.library-empty, .editor-empty { min-height: 280px; display: grid; place-content: center; justify-items: center; padding: 32px; text-align: center; }
.library-empty p, .editor-empty p { max-width: 360px; margin: 7px 0 20px; color: var(--muted); font-size: .8rem; }
.empty-icon { width: 44px; height: 44px; display: grid; place-items: center; margin-bottom: 14px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 1.2rem; }
.library-modal { width: min(500px, calc(100vw - 28px)); }
.library-modal .modal-head p { max-width: 390px; margin: 6px 0 0; color: var(--muted); font-size: .78rem; }
.library-modal form { display: grid; gap: 15px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.setting-card { padding: 22px; }
.setting-card p { color: var(--muted); font-size: .82rem; min-height: 40px; }
.setting-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.danger-text { color: #d66d5d; }
.modal { width: min(680px, calc(100vw - 28px)); max-height: calc(100vh - 28px); border: 1px solid var(--line-strong); border-radius: 9px; padding: 24px; background: var(--paper-raised); color: var(--ink); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(5,3,3,.78); backdrop-filter: blur(5px); }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 22px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
label { display: grid; gap: 7px; color: var(--ink-2); font-size: .73rem; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 5px; padding: 10px 11px; color: var(--ink); background: #100d0c; outline: none; }
input::placeholder, textarea::placeholder { color: #625a56; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(222,121,78,.12); }
.span-2 { grid-column: span 2; }
.modal-actions { margin-top: 22px; display: flex; justify-content: flex-end; gap: 9px; }
.message-preview { white-space: pre-wrap; margin-top: 16px; min-height: 210px; max-height: 42vh; overflow: auto; padding: 18px; border-radius: 6px; background: #100d0c; border: 1px solid var(--line); font-size: .88rem; line-height: 1.65; }
.split-actions { justify-content: space-between; align-items: center; }
.split-actions > div { display: flex; gap: 9px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); padding: 11px 16px; border-radius: 6px; background: var(--accent); color: #160d09; font-size: .76rem; font-weight: 800; opacity: 0; pointer-events: none; transition: .22s ease; z-index: 100; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (max-width: 1080px) { .stat-grid { grid-template-columns: repeat(2, minmax(0,1fr)); } .content-grid { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .app-shell { display: block; } .sidebar { position: fixed; left: 0; transform: translateX(-105%); width: 260px; transition: transform .22s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); } .mobile-only { display: inline-grid; place-items: center; flex: 0 0 40px; } .topbar { min-height: 88px; padding: 18px; gap: 12px; }
  .topbar > div:nth-child(2) { min-width: 0; } .topbar-actions .button-ghost { display: none; } .topbar-actions .button-primary { padding: 0 12px; }
  .view-root { padding: 20px 16px 40px; } .stat-grid { gap: 10px; } .stat-card { padding: 16px; } .stat-card strong { font-size: 1.45rem; }
  .toolbar, .library-toolbar { align-items: stretch; flex-direction: column; } .search-wrap { max-width: none; } .message-layout, .settings-grid { grid-template-columns: 1fr; }
  .script-library .step-list { display: grid; overflow: visible; } .message-meta-grid { grid-template-columns: 1fr; } .form-grid { grid-template-columns: 1fr; } .span-2 { grid-column: auto; }
  .modal { padding: 20px; } .split-actions { align-items: stretch; flex-direction: column-reverse; } .split-actions > div { display: grid; grid-template-columns: 1fr 1fr; } .split-actions .danger-text { width: 100%; }
}
@media (max-width: 430px) { .stat-grid { grid-template-columns: 1fr 1fr; } .stat-card small { font-size: .67rem; } .stat-top { margin-bottom: 12px; } h1 { font-size: 1.25rem; } .button { font-size: .77rem; } }
