/* Soapee CRM · UI */
:root {
  --navy: #1A344D; --navy-deep: #0E2236; --navy-ink: #071523;
  --teal: #44B49C; --teal-deep: #2E8F7B; --teal-bright: #5FD9BF; --teal-soft: #DDF5EC;
  --sun: #FFC532; --red: #DF3131; --red-soft: #FDE4E1; --amber: #B7791F; --amber-soft: #FFF4D6; --blue: #1F4E86; --blue-soft: #E6F0FA;
  --foam: #F5FAF8; --mist: #E4F2EE; --line: #E1EAE7; --ink: #14212E; --soft: #5B6B7A; --faint: #93A1AD;
  --display: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif; --body: "Instrument Sans", system-ui, sans-serif;
  --radius: 14px; --sidebar: 248px; --ease: cubic-bezier(.16, 1, .3, 1);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--body); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--foam); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { font-family: var(--display); letter-spacing: -.02em; margin: 0; color: var(--navy); }
h1 { font-size: 1.6rem; font-weight: 800; } h2 { font-size: 1.15rem; font-weight: 800; } h3 { font-size: 1rem; font-weight: 700; }
.muted { color: var(--soft); } .faint { color: var(--faint); } .small { font-size: .85rem; } .tiny { font-size: .75rem; }
.mono { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* boot */
.boot { min-height: 100vh; display: grid; place-items: center; background: var(--navy-deep); }
.boot__logo { font-family: var(--display); font-weight: 800; font-size: 2.2rem; color: #fff; letter-spacing: -.04em; } .boot__logo span { color: var(--teal); }
.boot__bar { width: 120px; height: 3px; background: rgba(255,255,255,.12); border-radius: 3px; margin: 14px auto 0; overflow: hidden; } .boot__bar span { display: block; height: 100%; width: 40%; background: var(--teal); animation: boot 1s ease-in-out infinite alternate; }
@keyframes boot { to { transform: translateX(200%); } }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(60% 50% at 80% 0%, rgba(68,180,156,.25), transparent 60%), var(--navy-deep); }
.auth__card { width: min(420px, 100%); background: #fff; border-radius: 22px; padding: 36px; box-shadow: 0 40px 80px -30px rgba(0,0,0,.6); }
.auth__logo { font-family: var(--display); font-weight: 800; font-size: 1.8rem; color: var(--navy); letter-spacing: -.04em; margin-bottom: 4px; } .auth__logo span { color: var(--teal); }
.auth__card p.muted { margin: 0 0 22px; }

/* layout */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.side { background: var(--navy-deep); color: #fff; padding: 20px 16px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; }
.side__logo { font-family: var(--display); font-weight: 800; font-size: 1.4rem; letter-spacing: -.04em; padding: 6px 12px 18px; } .side__logo span { color: var(--teal); } .side__logo small { display: block; font-family: var(--body); font-weight: 600; font-size: .65rem; letter-spacing: .16em; color: rgba(255,255,255,.45); text-transform: uppercase; margin-top: -2px; }
.side a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: rgba(255,255,255,.72); font-weight: 600; font-size: .92rem; transition: background .2s, color .2s; }
.side a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side a.is-active { background: rgba(68,180,156,.18); color: #fff; }
.side a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.side a .badge { margin-left: auto; }
.side__foot { margin-top: auto; padding: 12px; font-size: .82rem; color: rgba(255,255,255,.55); border-top: 1px solid rgba(255,255,255,.08); }
.side__foot b { display: block; color: #fff; font-weight: 600; }
.side__foot button { background: none; border: 0; color: var(--teal-bright); padding: 4px 0 0; font-weight: 600; }
.main { min-width: 0; padding: 26px clamp(18px, 3vw, 40px) 60px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.topbar h1 { display: flex; align-items: center; gap: 12px; }
.topbar__actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.mobile-nav { display: none; }

/* cards & grids */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card + .card { margin-top: 16px; }
.card h2 { margin-bottom: 12px; }
.grid { display: grid; gap: 16px; } .grid-2 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: repeat(3, 1fr); } .grid-4 { grid-template-columns: repeat(4, 1fr); }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; transition: transform .3s var(--ease), box-shadow .3s; }
.kpi:hover { transform: translateY(-2px); box-shadow: 0 16px 40px -24px rgba(14,34,54,.4); }
.kpi b { font-family: var(--display); font-size: 1.9rem; font-weight: 800; letter-spacing: -.04em; color: var(--navy); line-height: 1.1; }
.kpi span { font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--soft); }
.kpi small { color: var(--faint); font-size: .8rem; }
.kpi--alert b { color: var(--red); } .kpi--good b { color: var(--teal-deep); }

/* pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .74rem; font-weight: 700; letter-spacing: .03em; white-space: nowrap; background: #EEF1F4; color: #4A5A69; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.pill--active, .pill--paid, .pill--converted, .pill--complete { background: var(--teal-soft); color: #0E6B4E; }
.pill--recent, .pill--sent, .pill--contacted, .pill--booked { background: var(--blue-soft); color: var(--blue); }
.pill--due, .pill--quoted, .pill--overdue { background: var(--amber-soft); color: #7A5200; }
.pill--lapsing { background: #FBE9D4; color: #8A4B08; }
.pill--dormant, .pill--void, .pill--closed, .pill--cancelled { background: #EEF1F4; color: #6B7A88; }
.pill--new { background: #EDE7FB; color: #4E33A8; }
.pill--danger { background: var(--red-soft); color: #A32D22; }
.pill--draft { background: #EEF1F4; color: #4A5A69; }
.sub-yes { color: var(--teal-deep); font-weight: 700; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 999px; border: 1px solid transparent; font-weight: 700; font-size: .9rem; background: var(--navy); color: #fff; white-space: nowrap; transition: background .2s, transform .2s var(--ease), box-shadow .2s; }
.btn:hover { background: var(--navy-deep); } .btn:disabled { opacity: .55; cursor: default; }
.btn--primary { background: var(--teal); color: #fff; box-shadow: 0 8px 20px -10px rgba(68,180,156,.9); } .btn--primary:hover { background: var(--teal-deep); }
.btn--ghost { background: #fff; color: var(--navy); border-color: var(--line); } .btn--ghost:hover { background: var(--foam); }
.btn--danger { background: var(--red-soft); color: #A32D22; } .btn--danger:hover { background: #F9CFCA; }
.btn--wa { background: #25D366; color: #fff; } .btn--wa:hover { background: #1EBE5A; }
.btn--sm { padding: 6px 12px; font-size: .8rem; }
.btn--icon { padding: 8px; width: 36px; height: 36px; }
.btn svg { width: 16px; height: 16px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .field > label { font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--soft); }
.field input, .field select, .field textarea, .input { width: 100%; padding: 10px 13px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; color: var(--ink); transition: border-color .2s, box-shadow .2s; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 4px rgba(68,180,156,.18); }
.field textarea { resize: vertical; min-height: 90px; }
.field--check { flex-direction: row; align-items: center; gap: 10px; } .field--check input { width: auto; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-grid .span-2 { grid-column: span 2; } .form-grid .span-all { grid-column: 1 / -1; }
.help { font-size: .82rem; color: var(--soft); margin: 4px 0 0; }
.form-error { color: var(--red); font-weight: 600; font-size: .9rem; margin-top: 8px; }
.search { position: relative; } .search input { padding-left: 38px; } .search svg { position: absolute; left: 12px; top: 50%; translate: 0 -50%; width: 18px; height: 18px; color: var(--faint); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters select, .filters input { padding: 9px 12px; border-radius: 999px; border: 1.5px solid var(--line); background: #fff; font-size: .88rem; }
.filters .search input { padding-left: 36px; min-width: 260px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1.5px solid var(--line); background: #fff; font-size: .82rem; font-weight: 600; color: var(--navy); }
.chip.is-on { background: var(--navy); border-color: var(--navy); color: #fff; }

/* table */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--soft); padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #FAFCFB; position: sticky; top: 0; }
th.sortable { cursor: pointer; } th.sortable:hover { color: var(--navy); } th .dir { margin-left: 4px; color: var(--teal); }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.row-link { cursor: pointer; } tbody tr.row-link:hover td { background: var(--foam); }
td.r, th.r { text-align: right; } td.nowrap { white-space: nowrap; }
.td-name b { display: block; color: var(--navy); } .td-name small { color: var(--faint); }
.empty { padding: 40px; text-align: center; color: var(--soft); }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0 0; font-size: .85rem; color: var(--soft); }
td select, td input { padding: 6px 8px; border-radius: 8px; border: 1.5px solid var(--line); background: #fff; font-size: .85rem; }
.inline-select { padding: 5px 8px; border-radius: 999px; border: 1.5px solid var(--line); background: #fff; font-size: .8rem; font-weight: 600; }

/* client detail */
.detail-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; align-items: flex-start; margin-bottom: 18px; }
.detail-head .sub, .lead-card .sub { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin-top: 8px; color: var(--soft); font-size: .9rem; }
.sub span { display: inline-flex; align-items: center; gap: 6px; }
.sub svg, .lead-card svg:not(.btn svg) { width: 15px; height: 15px; flex: none; }
.detail-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 16px; align-items: start; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 18px; }
.fact span { display: block; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); font-weight: 700; } .fact b { font-weight: 600; color: var(--ink); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; } .tabs button { background: none; border: 0; padding: 10px 14px; font-weight: 700; color: var(--soft); border-bottom: 2px solid transparent; margin-bottom: -1px; } .tabs button.is-on { color: var(--navy); border-color: var(--teal); }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.timeline li { display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: start; }
.timeline .ico { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--mist); color: var(--navy); font-size: .75rem; font-weight: 800; }
.timeline .ico.t-whatsapp { background: #DFF7E8; color: #0E6B4E; } .timeline .ico.t-email { background: var(--blue-soft); color: var(--blue); } .timeline .ico.t-payment, .timeline .ico.t-invoice { background: var(--amber-soft); color: #7A5200; } .timeline .ico.t-job { background: var(--teal-soft); color: #0E6B4E; }
.timeline .body { background: var(--foam); border-radius: 10px; padding: 8px 12px; font-size: .9rem; white-space: pre-line; } .timeline .meta { font-size: .75rem; color: var(--faint); margin-top: 3px; }
.notes-box { white-space: pre-line; background: var(--foam); border-radius: 10px; padding: 12px; font-size: .9rem; }
.due-list { list-style: none; margin: 0; padding: 0; } .due-list li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); align-items: center; font-size: .9rem; } .due-list li:last-child { border: 0; }
.due-list .when { font-weight: 700; white-space: nowrap; } .due-list .when.late { color: var(--red); }

/* leads */
.lead-card { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: start; }
.lead-card .msg { background: var(--foam); border-radius: 10px; padding: 10px 12px; margin-top: 8px; white-space: pre-line; font-size: .9rem; }

/* invoice editor */
.items-table td { padding: 6px 8px; } .items-table input { width: 100%; }
.totals { margin-left: auto; width: 280px; font-size: .95rem; } .totals div { display: flex; justify-content: space-between; padding: 5px 0; } .totals .grand { border-top: 2px solid var(--navy); font-weight: 800; font-size: 1.15rem; padding-top: 10px; margin-top: 4px; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(7,21,35,.55); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 20px; z-index: 100; animation: fade .2s; }
.modal { background: #fff; border-radius: 18px; width: min(640px, 100%); max-height: 92vh; overflow: auto; padding: 26px; box-shadow: 0 40px 80px -30px rgba(0,0,0,.6); animation: pop .3s var(--ease); }
.modal--wide { width: min(900px, 100%); }
.modal h2 { margin-bottom: 14px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0 } } @keyframes pop { from { transform: translateY(14px) scale(.98); opacity: 0 } }
.preview { background: var(--foam); border-radius: 10px; padding: 12px 14px; white-space: pre-line; font-size: .92rem; max-height: 260px; overflow: auto; }

/* toasts */
.toasts { position: fixed; left: 50%; bottom: 24px; translate: -50% 0; display: flex; flex-direction: column; gap: 8px; z-index: 200; pointer-events: none; }
.toast { padding: 12px 18px; border-radius: 999px; background: var(--navy-deep); color: #fff; font-weight: 600; font-size: .9rem; box-shadow: 0 20px 50px -20px rgba(0,0,0,.6); animation: pop .3s var(--ease); }
.toast--error { background: var(--red); } .toast--ok { background: var(--teal-deep); }

/* misc */
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--teal); color: var(--navy-deep); font-size: .7rem; font-weight: 800; }
.stat-row { display: flex; gap: 8px; flex-wrap: wrap; }
.status-bar { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.status-bar button { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px; text-align: left; } .status-bar b { display: block; font-family: var(--display); font-size: 1.3rem; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .8rem; background: var(--navy-deep); color: #C9F0E4; padding: 12px; border-radius: 10px; overflow: auto; white-space: pre; }
.copy-row { display: flex; gap: 8px; align-items: center; } .copy-row input { flex: 1; }
.spark { display: flex; gap: 4px; align-items: flex-end; height: 60px; } .spark div { flex: 1; background: var(--teal); border-radius: 4px 4px 0 0; min-height: 3px; position: relative; } .spark div span { position: absolute; bottom: -18px; left: 0; right: 0; text-align: center; font-size: .65rem; color: var(--faint); }

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .mobile-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--navy-deep); z-index: 90; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .mobile-nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; color: rgba(255,255,255,.65); font-size: .62rem; font-weight: 700; padding: 6px 8px; border-radius: 10px; } .mobile-nav a.is-active { color: var(--teal-bright); } .mobile-nav svg { width: 20px; height: 20px; }
  .main { padding: 18px 16px 90px; }
  .grid-2, .grid-3, .grid-4, .detail-grid { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .totals { width: 100%; }
  .filters .search input { min-width: 0; width: 100%; }
}

/* SEO */
.delta { font-weight: 700; } .delta.up { color: #0E6B4E; } .delta.down { color: #A32D22; }
.spark--tall { height: 110px; } .spark__axis { display: flex; justify-content: space-between; font-size: .7rem; color: var(--faint); margin-top: 6px; }
.pos { display: inline-block; padding: 2px 8px; border-radius: 999px; font-weight: 700; background: #EEF1F4; } .pos-top { background: var(--teal-soft); color: #0E6B4E; } .pos-page1 { background: var(--blue-soft); color: var(--blue); } .pos-page2 { background: var(--amber-soft); color: #7A5200; } .pos-deep { background: #EEF1F4; color: var(--soft); }
.score { font-family: var(--display); font-weight: 800; } .score.good { color: #0E6B4E; } .score.mid { color: #B7791F; } .score.bad { color: #A32D22; }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; } .dot-pass { background: #2EAA7B; } .dot-warn { background: #F0B429; } .dot-fail { background: #DF3131; }
.stars { color: #F9AD4D; letter-spacing: .08em; }
.progress { height: 8px; border-radius: 4px; background: var(--mist); margin-top: 10px; overflow: hidden; } .progress span { display: block; height: 100%; background: var(--teal); border-radius: 4px; transition: width .6s var(--ease); }
.tasks { list-style: none; margin: 0; padding: 0; } .task { display: grid; grid-template-columns: auto 1fr auto auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); } .task:last-child { border: 0; } .task input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--teal); } .task--done b { text-decoration: line-through; color: var(--soft); } .task a svg { width: 12px; height: 12px; vertical-align: -1px; } .task--na { opacity: .5; }
@media (max-width: 640px) { .task { grid-template-columns: auto 1fr; } .task select, .task button { grid-column: 2; } }

/* Website editor */
.pubbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding: 14px 18px; border-radius: var(--radius); background: #fff; border: 1px solid var(--line); margin-bottom: 16px; }
.pubbar.has-drafts { border-color: var(--sun); background: #FFF9E6; }
.editor { display: grid; grid-template-columns: 220px 1fr; gap: 16px; align-items: start; }
.editor__nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 16px; }
.editor__nav a { padding: 9px 12px; border-radius: 10px; font-weight: 600; font-size: .9rem; color: var(--soft); display: flex; align-items: center; justify-content: space-between; }
.editor__nav a.is-on { background: var(--navy); color: #fff; } .editor__nav a:hover:not(.is-on) { background: #fff; }
.dotdraft { width: 8px; height: 8px; border-radius: 50%; background: var(--sun); }
.fld { padding: 14px 0; border-bottom: 1px solid var(--line); } .fld:last-child { border: 0; }
.fld__head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; font-weight: 700; font-size: .9rem; color: var(--navy); }
.fld__head .draft { font-style: normal; font-size: .7rem; padding: 2px 8px; border-radius: 999px; background: var(--sun); color: var(--navy-deep); margin-left: 6px; }
.fld input:not([type=color]):not([type=file]), .fld textarea, .fld select { width: 100%; padding: 10px 13px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; }
.fld input:focus, .fld textarea:focus, .fld select:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 4px rgba(68,180,156,.18); }
.fld input[type=color] { width: 52px; height: 42px; border: 1.5px solid var(--line); border-radius: 10px; padding: 2px; background: #fff; }
.media { display: grid; grid-template-columns: 160px 1fr; gap: 14px; align-items: start; } .media img, .media video { width: 160px; height: 110px; object-fit: cover; border-radius: 10px; background: var(--mist); border: 1px solid var(--line); }
.review-row { padding: 12px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; background: var(--foam); } .review-row .btn-row { margin-top: 8px; }
@media (max-width: 960px) { .editor { grid-template-columns: 1fr; } .editor__nav { position: static; flex-direction: row; flex-wrap: wrap; } .media { grid-template-columns: 1fr; } }
