/* ============ TOKENS ============ */
:root {
  --bg: #f4f5f2;
  --bg-2: #eceee9;
  --card: #ffffff;
  --ink: #15181b;
  --ink-2: #3a3f45;
  --muted: #6c727a;
  --line: #e3e5e0;
  --accent: #0f7b4f;
  --accent-2: #12a067;
  --accent-soft: #e2f3ea;
  --accent-ink: #ffffff;
  --fat: #c5d9cd;
  --warn: #b26b00;
  --warn-soft: #fdf0d9;
  --danger: #c93a2f;
  --danger-soft: #fbe6e3;
  --shadow: 0 1px 2px rgba(16, 24, 20, .04), 0 4px 16px rgba(16, 24, 20, .05);
  --shadow-lg: 0 12px 40px rgba(16, 24, 20, .18);
  --radius: 18px;
  --radius-sm: 11px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1113;
    --bg-2: #171a1d;
    --card: #181b1f;
    --ink: #eef0ed;
    --ink-2: #c9cdc8;
    --muted: #8d939a;
    --line: #272b30;
    --accent: #3ccf8e;
    --accent-2: #5be0a3;
    --accent-soft: #15301f;
    --accent-ink: #062014;
    --fat: #2c4a39;
    --warn: #f0b04f;
    --warn-soft: #33270f;
    --danger: #ff7a6b;
    --danger-soft: #3a1b18;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1113;
  --bg-2: #171a1d;
  --card: #181b1f;
  --ink: #eef0ed;
  --ink-2: #c9cdc8;
  --muted: #8d939a;
  --line: #272b30;
  --accent: #3ccf8e;
  --accent-2: #5be0a3;
  --accent-soft: #15301f;
  --accent-ink: #062014;
  --fat: #2c4a39;
  --warn: #f0b04f;
  --warn-soft: #33270f;
  --danger: #ff7a6b;
  --danger-soft: #3a1b18;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* ============ BASE ============ */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }
h1 { font-size: 28px; font-weight: 800; }
h2 { font-size: 16px; font-weight: 700; }
h3 { font-size: 17px; font-weight: 700; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ============ BOTÕES ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 42px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 600; font-size: 14px; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 30%, transparent); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { background: var(--bg-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 88%, #000); }
.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border-radius: 12px; border: 1px solid transparent; background: transparent; color: var(--ink-2);
}
.icon-btn:hover { background: var(--bg-2); color: var(--ink); }

/* ============ MARCA ============ */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; letter-spacing: -0.02em; }
.brand-mark {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
}
.brand-mark svg { stroke-width: 2.6; }
.brand-lg { font-size: 20px; }
.brand-lg .brand-mark { width: 40px; height: 40px; border-radius: 12px; }
.brand-lg .brand-mark svg { width: 22px; height: 22px; }

/* ============ CAMPOS ============ */
.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  height: 44px; padding: 0 12px; width: 100%; min-width: 0;
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; }
select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238d939a' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
input[type="date"] { padding-right: 8px; }
.money { position: relative; }
.money i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--muted); font-size: 14px; pointer-events: none; }
.money input { padding-left: 38px; font-variant-numeric: tabular-nums; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-error { color: var(--danger); background: var(--danger-soft); padding: 10px 12px; border-radius: 10px; font-size: 14px; }

/* ============ LOGIN ============ */
.login {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(900px 500px at 10% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 60%),
    radial-gradient(700px 400px at 110% 110%, color-mix(in srgb, var(--accent-2) 12%, transparent), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line);
  border-radius: 24px; padding: 32px 28px; box-shadow: var(--shadow-lg);
  display: grid; gap: 8px; animation: rise .4s ease;
}
.login-card .brand { margin-bottom: 16px; }
.login-card h1 { font-size: 24px; }
.login-card form { display: grid; gap: 16px; margin-top: 16px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 46px; }
.pw-toggle { position: absolute; right: 4px; top: 4px; width: 36px; height: 36px; border: none; background: none; color: var(--muted); border-radius: 8px; display: grid; place-items: center; }
.pw-toggle:hover { color: var(--ink); }

/* ============ TOPO ============ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px); -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.sync { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); padding: 0 10px; height: 32px; border-radius: 99px; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.sync[data-state="saving"] .sync-dot { background: var(--warn); animation: pulse 1s infinite; }
.sync[data-state="error"] { color: var(--danger); background: var(--danger-soft); }
.sync[data-state="error"] .sync-dot { background: var(--danger); }
.i-moon { display: none; }
:root[data-theme="dark"] .i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: none; }
  :root:not([data-theme="light"]) .i-moon { display: block; }
}
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 240px; z-index: 30;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 6px;
  box-shadow: var(--shadow-lg); animation: pop .15s ease;
}
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: none; background: none; padding: 10px 12px; border-radius: 9px; font-size: 14px; }
.menu button:hover { background: var(--bg-2); }
.menu button.danger { color: var(--danger); }
.menu hr { border: none; border-top: 1px solid var(--line); margin: 6px 0; }

/* ============ LAYOUT ============ */
.container { max-width: 1200px; margin: 0 auto; padding: 24px 20px 100px; display: grid; gap: 20px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head .muted { font-size: 14px; margin-bottom: 2px; }
.segmented { display: inline-flex; background: var(--bg-2); border-radius: 12px; padding: 4px; gap: 2px; }
.segmented button { border: none; background: none; padding: 7px 14px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.segmented button.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head-wrap { flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 20px; }
.grid-2-alt { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

/* ============ KPIs ============ */
.kpis { display: grid; grid-template-columns: 1.4fr repeat(4, 1fr); gap: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); display: grid; gap: 6px; align-content: start; min-width: 0; }
.kpi-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.kpi-value { font-size: 23px; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-warn { color: var(--warn); }
.kpi-foot { font-size: 12.5px; color: var(--muted); }
.kpi-hero {
  background: linear-gradient(140deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 70%, #0a3d27) 100%);
  border-color: transparent; color: #fff; position: relative; overflow: hidden;
}
:root[data-theme="dark"] .kpi-hero { background: linear-gradient(140deg, #127a4e 0%, #0b4a30 100%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .kpi-hero { background: linear-gradient(140deg, #127a4e 0%, #0b4a30 100%); } }
.kpi-hero::after { content: ""; position: absolute; right: -40px; bottom: -60px; width: 180px; height: 180px; border-radius: 50%; background: rgba(255, 255, 255, .08); }
.kpi-hero .kpi-top { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; opacity: .9; gap: 8px; }
.kpi-hero .kpi-value { font-size: 32px; }
.kpi-hero .kpi-foot { color: rgba(255, 255, 255, .78); }
.badge { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 99px; background: rgba(255, 255, 255, .18); white-space: nowrap; }
.badge:empty { display: none; }

/* ============ META ============ */
.goal-body { display: flex; align-items: center; gap: 22px; }
.ring {
  --p: 0; flex-shrink: 0; width: 132px; height: 132px; border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--bg-2) 0);
  display: grid; place-items: center; transition: --p .6s;
}
.ring-inner { width: 104px; height: 104px; border-radius: 50%; background: var(--card); display: grid; place-content: center; text-align: center; }
.ring-inner strong { font-size: 24px; font-weight: 800; letter-spacing: -0.03em; }
.ring-inner span { font-size: 12px; color: var(--muted); }
.goal-info { display: grid; gap: 12px; min-width: 0; }
.goal-info div { display: grid; }
.goal-info span { font-size: 12.5px; }
.goal-info strong { font-size: 17px; font-variant-numeric: tabular-nums; }

/* ============ GRÁFICO ============ */
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw-fat { background: var(--fat); }
.sw-lucro { background: var(--accent); }
.chart-scroll { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.chart { display: flex; align-items: stretch; gap: 6px; height: 200px; min-width: 520px; }
.month { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; position: relative; }
.bars { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 3px; border-bottom: 1px solid var(--line); padding-bottom: 1px; }
.bar { width: 42%; max-width: 18px; border-radius: 5px 5px 2px 2px; min-height: 2px; transition: height .5s cubic-bezier(.2, .8, .2, 1); }
.bar-fat { background: var(--fat); }
.bar-lucro { background: var(--accent); }
.bar-neg { background: var(--danger); }
.month-label { font-size: 11.5px; color: var(--muted); text-align: center; white-space: nowrap; }
.month.current .month-label { color: var(--ink); font-weight: 700; }
.tip {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); font-size: 12px; padding: 8px 10px; border-radius: 9px;
  white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .12s; z-index: 2;
  font-variant-numeric: tabular-nums; line-height: 1.45;
}
.month:hover .tip, .month:focus .tip { opacity: 1; }
.month:first-child .tip { left: 0; transform: none; }
.month:last-child .tip { left: auto; right: 0; transform: none; }

/* ============ TIPOS / TOP ============ */
.types { display: grid; gap: 14px; }
.type-row { display: grid; gap: 6px; }
.type-head { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.type-head strong { font-variant-numeric: tabular-nums; }
.type-track { height: 8px; background: var(--bg-2); border-radius: 99px; overflow: hidden; }
.type-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 99px; transition: width .5s; }
.top { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; counter-reset: top; }
.top li { min-width: 0; display: flex; align-items: center; gap: 12px; padding: 8px 4px; counter-increment: top; border-bottom: 1px solid var(--line); }
.top li:last-child { border-bottom: none; }
.top li::before { content: counter(top); width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--bg-2); color: var(--ink-2); flex-shrink: 0; }
.top li:first-child::before { background: var(--accent-soft); color: var(--accent); }
.top .t-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.top .t-name small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.top .t-val { font-weight: 700; font-variant-numeric: tabular-nums; flex-shrink: 0; white-space: nowrap; }
.mini-empty { color: var(--muted); font-size: 14px; padding: 12px 0; }

/* ============ VENDAS ============ */
.count { display: inline-grid; place-items: center; min-width: 26px; height: 22px; padding: 0 7px; margin-left: 6px; border-radius: 99px; background: var(--bg-2); font-size: 12px; color: var(--muted); vertical-align: 2px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters select { width: auto; height: 40px; }
.search { position: relative; display: block; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.search input { height: 40px; padding-left: 36px; width: 220px; }
.table-wrap { overflow-x: auto; margin: 0 -20px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 12px 20px 12px 0; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--bg-2); }
.table tbody tr:last-child td { border-bottom: none; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.c-client { white-space: normal !important; min-width: 180px; }
.c-client strong { display: block; font-weight: 700; }
.c-client small { color: var(--muted); font-size: 12.5px; }
.profit { font-weight: 800; color: var(--accent); }
.profit.neg { color: var(--danger); }
.pill { display: inline-flex; align-items: center; gap: 6px; border: none; padding: 4px 11px; border-radius: 99px; font-size: 12.5px; font-weight: 700; transition: filter .15s; }
.pill:hover { filter: brightness(.95); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.pago { background: var(--accent-soft); color: var(--accent); }
.pill.pendente { background: var(--warn-soft); color: var(--warn); }
.pay-method { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; padding-left: 2px; }
.actions-col { width: 1%; }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; }
.row-actions .icon-btn { width: 34px; height: 34px; border-radius: 9px; }
.row-actions .icon-btn.del:hover { color: var(--danger); background: var(--danger-soft); }
.empty { text-align: center; padding: 40px 16px 24px; display: grid; justify-items: center; gap: 8px; }
.empty-icon { width: 56px; height: 56px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin-bottom: 6px; }
.empty-icon svg { width: 26px; height: 26px; }
.empty .btn { margin-top: 10px; }

/* ============ MODAL ============ */
.modal {
  border: none; padding: 0; border-radius: 22px; width: min(600px, calc(100% - 24px));
  background: var(--card); color: var(--ink); box-shadow: var(--shadow-lg); max-height: calc(100dvh - 24px);
}
.modal[open] { animation: rise .2s ease; }
.modal::backdrop { background: rgba(8, 12, 10, .45); backdrop-filter: blur(3px); }
.modal-sm { width: min(420px, calc(100% - 24px)); }
.modal form { display: flex; flex-direction: column; max-height: calc(100dvh - 24px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px 24px; }
.modal-head h2 { font-size: 19px; }
.modal-body { padding: 12px 24px 8px; display: grid; gap: 14px; overflow-y: auto; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 14px 24px 22px; }
.spacer { flex: 1; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row .grow { grid-column: span 1; }
.profit-preview { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 14px; }
.profit-preview strong { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.profit-preview.neg { background: var(--danger-soft); color: var(--danger); }
.toggle-group { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg-2); border-radius: var(--radius-sm); padding: 4px; height: 44px; }
.toggle-group button { border: none; background: none; border-radius: 8px; font-weight: 600; font-size: 14px; color: var(--muted); }
.toggle-group button.active[data-v="pago"] { background: var(--card); color: var(--accent); box-shadow: var(--shadow); }
.toggle-group button.active[data-v="pendente"] { background: var(--card); color: var(--warn); box-shadow: var(--shadow); }
.confirm-body { text-align: center; justify-items: center; padding-top: 28px; }
.confirm-icon { width: 52px; height: 52px; border-radius: 16px; background: var(--danger-soft); color: var(--danger); display: grid; place-items: center; }
.confirm-icon svg { width: 24px; height: 24px; }

/* ============ FAB / TOAST / BOOT ============ */
.fab {
  display: none; position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 15;
  width: 58px; height: 58px; border-radius: 18px; border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 45%, transparent);
  place-items: center;
}
.fab svg { width: 26px; height: 26px; stroke-width: 2.4; }
.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; width: max-content; max-width: calc(100% - 32px); }
.toast { background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 12px; font-size: 14px; font-weight: 500; box-shadow: var(--shadow-lg); animation: rise .2s ease; display: flex; align-items: center; gap: 8px; }
.toast.error { background: var(--danger); color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); transition: .2s; }
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 200; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes spin { to { transform: rotate(360deg); } }
@property --p { syntax: "<number>"; inherits: false; initial-value: 0; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ============ RESPONSIVO ============ */
@media (max-width: 1080px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi-hero { grid-column: 1 / -1; }
  .grid-2, .grid-2-alt { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  h1 { font-size: 24px; }
  .container { padding: 18px 16px 110px; gap: 16px; }
  .topbar-inner { padding: 10px 16px; }
  .hide-sm { display: none; }
  .sync-text { display: none; }
  .sync { padding: 0 8px; }
  .fab { display: grid; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; padding: 7px 6px; font-size: 13px; }
  .kpis { gap: 10px; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 19px; }
  .kpi-hero .kpi-value { font-size: 28px; }
  .card { padding: 16px; }
  .goal-body { gap: 16px; }
  .ring { width: 112px; height: 112px; }
  .ring-inner { width: 88px; height: 88px; }
  .ring-inner strong { font-size: 20px; }
  .filters { width: 100%; }
  .search { flex: 1 1 100%; }
  .search input { width: 100%; }
  .filters select { flex: 1; }

  /* Tabela vira cartões */
  .table-wrap { margin: 0; overflow: visible; }
  .table thead { display: none; }
  .table, .table tbody { display: block; }
  .table tbody { display: grid; gap: 10px; }
  .table tr {
    display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
    padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--card);
  }
  .table tbody tr:hover { background: var(--card); }
  .table td { display: block; padding: 0 !important; border: none; white-space: normal; }
  .table td.c-client { grid-column: 1; min-width: 0; }
  .table td.c-date { grid-column: 1; grid-row: 2; font-size: 13px; color: var(--muted); }
  .table td.c-value, .table td.c-cost { display: none; }
  .table td.c-profit { grid-column: 2; grid-row: 1; text-align: right !important; font-size: 17px; }
  .table td.c-status { grid-column: 1; grid-row: 3; margin-top: 6px; }
  .table td.c-status .pay-method { display: inline; margin-left: 6px; }
  .table td.c-actions { grid-column: 2; grid-row: 2 / span 2; align-self: end; }
  .table td.c-profit::after { content: attr(data-sub); display: block; font-size: 12px; font-weight: 500; color: var(--muted); }

  .modal { width: 100%; max-width: 100%; border-radius: 22px 22px 0 0; margin: auto 0 0; max-height: 94dvh; }
  .modal form { max-height: 94dvh; }
  .modal-sm { border-radius: 22px 22px 0 0; }
  .modal-body { padding: 8px 18px; }
  .modal-head { padding: 16px 16px 4px 18px; }
  .modal-foot { padding: 12px 18px calc(18px + env(safe-area-inset-bottom)); }
  .row { grid-template-columns: 1fr; gap: 14px; }
  .toasts { bottom: calc(90px + env(safe-area-inset-bottom)); }
}
@media (max-width: 380px) {
  .kpis { grid-template-columns: 1fr; }
  .goal-body { flex-direction: column; align-items: flex-start; }
}

/* ============ ABAS ============ */
.tabs { display: flex; gap: 4px; background: var(--bg-2); padding: 4px; border-radius: 12px; }
.tabs button {
  display: inline-flex; align-items: center; gap: 7px; border: none; background: none;
  padding: 7px 14px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted);
}
.tabs button svg { width: 16px; height: 16px; }
.tabs button.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.tab-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: 11.5px; font-weight: 700; display: inline-grid; place-items: center; }
.tab-count:empty { display: none; }

/* ============ LEADS ============ */
.lead-stats { display: flex; gap: 22px; }
.lead-stats div { display: grid; text-align: right; }
.lead-stats span { font-size: 12.5px; color: var(--muted); }
.lead-stats strong { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.funnel { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.stage {
  text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; box-shadow: var(--shadow); display: grid; gap: 2px; position: relative; overflow: hidden;
  transition: border-color .15s, transform .1s;
}
.stage:hover { border-color: var(--muted); }
.stage:active { transform: translateY(1px); }
.stage::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c, var(--line)); }
.stage span { font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage strong { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stage.active { border-color: var(--c, var(--accent)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c, var(--accent)) 18%, transparent); }

/* cores do funil */
.st-todos { --c: var(--ink-2); }
.st-a-contatar { --c: #8a9099; }
.st-contatado { --c: #2f7de1; }
.st-interessado { --c: #d98a00; }
.st-fechado { --c: var(--accent); }
.st-descartado { --c: #c9574c; }

.leads-table .c-lead { white-space: normal; min-width: 220px; }
.leads-table .c-lead strong { display: block; font-weight: 700; }
.leads-table .c-lead small { display: block; color: var(--muted); font-size: 12.5px; }
.leads-table .c-lead .lead-obs { color: var(--ink-2); font-size: 12.5px; margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 380px; }
.rating { color: var(--warn); font-weight: 600; }
.c-contact { white-space: nowrap; }
.c-contact .phone { display: block; font-variant-numeric: tabular-nums; font-size: 14px; }
.c-contact .contact-btns { display: flex; gap: 4px; margin-top: 4px; }
.mini-btn {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px; border-radius: 8px;
  font-size: 12.5px; font-weight: 600; text-decoration: none; border: 1px solid var(--line); color: var(--ink-2); background: var(--card);
}
.mini-btn svg { width: 14px; height: 14px; }
.mini-btn:hover { border-color: var(--muted); color: var(--ink); }
.mini-btn.wpp { color: #128c4b; border-color: color-mix(in srgb, #25d366 40%, var(--line)); background: color-mix(in srgb, #25d366 8%, var(--card)); }
:root[data-theme="dark"] .mini-btn.wpp { color: #4fe08f; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .mini-btn.wpp { color: #4fe08f; } }
.no-phone { color: var(--muted); font-size: 13px; }

/* selects em formato de etiqueta */
select.tag {
  height: 32px; width: auto; max-width: 100%; padding: 0 28px 0 12px; border-radius: 99px; font-size: 12.5px; font-weight: 700;
  border: 1px solid transparent; background-color: color-mix(in srgb, var(--c, var(--muted)) 14%, var(--card)); color: var(--c, var(--ink-2));
  background-position: right 10px center; cursor: pointer;
}
select.tag:hover { border-color: color-mix(in srgb, var(--c, var(--muted)) 45%, transparent); }
select.tag option { color: var(--ink); background: var(--card); }
.site-ok { --c: var(--accent); }
.site-check { --c: #d98a00; }
.site-has { --c: #c9574c; }

.due { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.due small { font-size: 11.5px; font-weight: 700; padding: 2px 7px; border-radius: 99px; }
.due.late small { background: var(--danger-soft); color: var(--danger); }
.due.today small { background: var(--warn-soft); color: var(--warn); }
.due-empty { color: var(--muted); font-size: 13px; }
.date-inline { height: 32px; width: 150px; font-size: 13px; padding: 0 8px; border-radius: 9px; }

.row-3 { grid-template-columns: 1.3fr 1fr 1fr; }

/* toast com ação */
.toast button { border: none; background: rgba(255, 255, 255, .16); color: inherit; font-weight: 700; padding: 5px 10px; border-radius: 8px; margin-left: 6px; font-size: 13px; }
:root[data-theme="light"] .toast button { background: rgba(255, 255, 255, .18); }

@media (max-width: 1080px) {
  .funnel { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .brand-text { display: none; }
}
@media (max-width: 720px) {
  .tabs button { padding: 7px 10px; }
  .tabs button svg { display: none; }
  .lead-stats { width: 100%; justify-content: space-between; gap: 10px; }
  .lead-stats div { text-align: left; }
  .lead-stats strong { font-size: 18px; }
  .funnel { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stage { padding: 10px 12px; }
  .stage strong { font-size: 19px; }

  /* lead vira cartão */
  .leads-table tr { grid-template-columns: 1fr 1fr; gap: 10px 10px; }
  .leads-table td.c-lead { grid-column: 1 / -1; grid-row: auto; min-width: 0; }
  .leads-table td.c-contact { grid-column: 1 / -1; grid-row: auto; }
  .leads-table td.c-contact .phone { display: none; }
  .leads-table td.c-contact .contact-btns { margin-top: 0; }
  .leads-table td.c-lstatus { grid-column: 1; grid-row: auto; }
  .leads-table td.c-lsite { grid-column: 2; grid-row: auto; }
  .leads-table td.c-due { grid-column: 1; grid-row: auto; }
  .leads-table td.c-lactions { grid-column: 2; grid-row: auto; align-self: end; }
  .leads-table td.c-lstatus::before, .leads-table td.c-due::before, .leads-table td.c-lsite::before {
    content: attr(data-label); display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 4px;
  }
  .leads-table select.tag { width: 100%; }
  .leads-table .date-inline { width: 100%; }
  .leads-table .due { display: grid; grid-template-columns: 1fr; gap: 4px; }
  .leads-table .due small { justify-self: start; }
  .leads-table .c-lead .lead-obs { max-width: none; }
  #viewLeads .filters .search { flex: 1 1 100%; }
  #viewLeads .filters select { flex: 1 1 calc(50% - 4px); min-width: 0; }
  #viewLeads .filters #lCategoria { flex-basis: 100%; }
  .row-3 { grid-template-columns: 1fr 1fr; }
  .row-3 .field:first-child { grid-column: 1 / -1; }
}
@media (max-width: 420px) {
  .tabs button { font-size: 13px; padding: 7px 8px; }
  .tab-count { display: none; }
}

/* ===== Disparo assistido ===== */
.modal-wide { width: min(640px, calc(100% - 24px)); }
.d-lead { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--bg-2); }
.d-lead strong { display: block; font-size: 16px; }
.d-lead small { color: var(--muted); }
.d-models { display: flex; flex-wrap: wrap; gap: 6px; }
.d-models button { height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink-2); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.d-models button.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.d-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.d-name { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.d-name input { width: 130px; height: 34px; }
.d-editor { display: grid; gap: 12px; border-top: 1px dashed var(--line); padding-top: 12px; }
.d-editor-btns { display: flex; gap: 6px; align-items: end; justify-content: flex-end; }
.d-editor code { font-size: 12px; background: var(--bg-2); padding: 1px 4px; border-radius: 4px; }
.d-done { text-align: center; padding: 24px 0; }
@media (max-width: 720px) { .d-name { margin-left: 0; } .modal-foot #dPrev { display: none; } }
.d-lead small { display: block; }
.d-warn { color: var(--warn) !important; margin-top: 4px; }
/* ===== Gerar leads ===== */
.head-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.g-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.g-list { display: grid; gap: 6px; max-height: 46dvh; overflow-y: auto; }
.g-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; }
.g-item:hover { border-color: var(--muted); }
.g-item input { margin-top: 3px; accent-color: var(--accent); }
.g-item small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.g-item.dup { opacity: .55; cursor: default; }
.hot, .dup-tag { font-style: normal; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; vertical-align: 2px; }
.hot { background: var(--warn-soft); color: var(--warn); }
.dup-tag { background: var(--bg-2); color: var(--muted); }
/* ===== Assistente ===== */
.chat-top svg { width: 16px; height: 16px; }
@media (max-width: 720px) { .chat-top span { display: none; } }
.chat-modal { width: min(720px, calc(100% - 24px)); }
.chat-wrap { display: flex; flex-direction: column; height: min(82dvh, 760px); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 8px 24px 12px; display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; flex-direction: column; gap: 6px; max-width: 88%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg .bubble { padding: 10px 14px; border-radius: 16px; line-height: 1.5; font-size: 14.5px; background: var(--bg-2); color: var(--ink); white-space: normal; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 6px; }
.msg.assistant .bubble { border-bottom-left-radius: 6px; }
.typing span { animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
.chat-leads { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--card); width: 100%; }
.chat-leads-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.chat-leads-head small { color: var(--muted); }
.chat-leads ul { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 6px; }
.chat-leads li b { display: block; font-size: 14px; }
.chat-leads li small { color: var(--muted); font-size: 12.5px; }
.chat-leads-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.chat-form { display: flex; gap: 8px; align-items: flex-end; padding: 12px 24px 20px; border-top: 1px solid var(--line); }
.chat-form textarea { flex: 1; resize: none; min-height: 44px; max-height: 140px; }
.chat-empty { margin: auto; text-align: center; max-width: 420px; padding: 24px 0; }
.chat-sugs { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 12px; }
.chat-sugs button { border: 1px solid var(--line); background: var(--card); color: var(--ink-2); border-radius: 999px; padding: 7px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.chat-sugs button:hover { border-color: var(--accent); color: var(--accent); }
.chat-form textarea { width: auto; min-width: 0; }
/* ===== Contas / solicitação de acesso ===== */
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.login-alt { text-align: center; margin-top: 18px; font-size: 14px; color: var(--muted); }
.invisible { visibility: hidden; }
.signup-card { max-width: 520px; }
.steps { display: flex; gap: 6px; margin: 4px 0 18px; }
.steps i { flex: 1; height: 4px; border-radius: 4px; background: var(--line); }
.steps i.on { background: var(--accent); }
.su-step { display: grid; gap: 14px; }
.su-step h1 { font-size: 22px; }
.su-step > .muted { margin-top: -8px; }
.su-nav { display: flex; align-items: center; gap: 8px; margin-top: 18px; }
.su-done { text-align: center; padding: 12px 0; justify-items: center; }
.confirm-icon.ok { background: var(--accent-soft); color: var(--accent); }
.su-owner { font-size: 13px; color: var(--muted); }
.su-owner summary { cursor: pointer; }
.su-owner .field { margin-top: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 34px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink-2); font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.chip:hover { border-color: var(--muted); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
/* ===== Acessos ===== */
.ac-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.ac-item { display: grid; gap: 10px; }
.ac-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.ac-top strong { display: block; font-size: 16px; }
.ac-top small { color: var(--muted); font-size: 12.5px; }
.ac-contact { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.ac-perfil { font-size: 13.5px; color: var(--ink-2); line-height: 1.6; margin: 0; }
.ac-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.tag.ac-pendente { background: var(--warn-soft); color: var(--warn); }
.tag.ac-aprovado { background: var(--accent-soft); color: var(--accent); }
.tag.ac-bloqueado, .tag.ac-recusado { background: var(--danger-soft); color: var(--danger); }
/* ===== Sugestões ===== */
.sug-card { margin-bottom: 16px; }
.sug-card .card-head { margin-bottom: 10px; }
.sug-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); margin-top: 12px; }
.sug-item { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }
.sug-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; margin-bottom: 8px; }
.sug-head small { color: var(--muted); font-size: 12px; }
.sug-q { display: flex; flex-wrap: wrap; gap: 6px; }
.sug-how { margin: 14px 0 0; padding-left: 20px; color: var(--muted); font-size: 13px; line-height: 1.7; }

/* =====================================================================
   VISUAL 2.0 — mais limpo, cara de app no iPhone, leve no celular
   ===================================================================== */
:root { --radius: 20px; --radius-sm: 12px; --ease: cubic-bezier(.2, .8, .2, 1); }
body {
  background:
    radial-gradient(1200px 520px at 50% -260px, color-mix(in srgb, var(--accent) 9%, transparent), transparent 70%),
    var(--bg);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}
h1 { letter-spacing: -0.035em; }
.card, .kpi, .stage { box-shadow: 0 1px 0 rgba(255,255,255,.03) inset, var(--shadow); }
.card { border-color: color-mix(in srgb, var(--line) 85%, transparent); }
.btn { border-radius: 14px; transition: background .15s, border-color .15s, transform .15s var(--ease), box-shadow .15s; }
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, #fff), var(--accent)); }
.btn-wpp { background: #25d366; color: #06301a; font-weight: 700; text-decoration: none; height: 50px; border-radius: 16px; box-shadow: 0 6px 20px rgba(37, 211, 102, .3); }
.btn-wpp:hover { background: #22c55e; }
.btn-wpp svg { width: 20px; height: 20px; }
.chip, .stage, .mini-btn, .icon-btn { transition: background .15s, border-color .15s, color .15s, transform .15s var(--ease); }
.chip:active, .stage:active, .mini-btn:active { transform: scale(.96); }

/* Topo: respeita a área do relógio/notch quando vira app */
.topbar { padding-top: env(safe-area-inset-top); border-bottom-color: color-mix(in srgb, var(--line) 70%, transparent); }
.brand-mark { box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent); }

/* Login */
.login { padding-top: calc(24px + env(safe-area-inset-top)); padding-bottom: calc(24px + env(safe-area-inset-bottom)); align-content: center; gap: 18px; }
.login-card { animation: none; border-radius: 28px; padding: 34px 28px 28px; }
.credit { text-align: center; font-size: 12.5px; color: var(--muted); letter-spacing: .01em; }
.credit strong { color: var(--ink-2); font-weight: 700; }
.app-credit { text-align: center; font-size: 12px; color: var(--muted); padding: 8px 0 0; }
.app-credit strong { color: var(--ink-2); }

/* Conta criada */
.conta-form { display: grid; gap: 14px; }
.conta-pronta { display: grid; gap: 12px; justify-items: center; text-align: center; padding: 6px 0 4px; }
.cred { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cred div { background: var(--bg-2); border-radius: 12px; padding: 10px 12px; text-align: left; display: grid; }
.cred span { font-size: 12px; color: var(--muted); }
.cred strong { font-size: 16px; font-variant-numeric: tabular-nums; word-break: break-all; }

/* Banner "instalar no iPhone" */
.install { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 60;
  display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 18px;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-lg); font-size: 13.5px; }
.install img { width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0; }
.install p { flex: 1; line-height: 1.4; }
.install b { color: var(--ink); }
.install .share { display: inline-block; vertical-align: -3px; width: 15px; height: 15px; color: var(--accent); }

/* Animações do GSAP: os elementos animados ganham camada própria só durante a animação */
.gsap-on .modal[open] { animation: none; }
.gsap-on .toast { animation: none; }

/* Celular: abas viram barra inferior estilo app */
@media (max-width: 720px) {
  .topbar-inner { padding: 10px 16px; }
  .tabs {
    position: fixed; z-index: 40; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom));
    justify-content: space-around; gap: 2px; padding: 6px; border-radius: 22px;
    background: color-mix(in srgb, var(--card) 86%, transparent);
    -webkit-backdrop-filter: saturate(160%) blur(16px); backdrop-filter: saturate(160%) blur(16px);
    border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
    box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
  }
  .tabs button { flex: 1; flex-direction: column; gap: 3px; padding: 7px 4px; font-size: 11px; border-radius: 16px; position: relative; }
  .tabs button svg { display: block; width: 21px; height: 21px; }
  .tabs button.active { background: var(--accent-soft); color: var(--accent); box-shadow: none; }
  .tab-count { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 17px; height: 17px; font-size: 10px; padding: 0 4px; background: var(--accent); color: var(--accent-ink); display: inline-grid; }
  .tab-count:empty { display: none; }
  .container { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
  .fab { bottom: calc(92px + env(safe-area-inset-bottom)); border-radius: 20px; }
  .toasts { bottom: calc(160px + env(safe-area-inset-bottom)); }
  .install { bottom: calc(92px + env(safe-area-inset-bottom)); }
  .login .install { bottom: calc(12px + env(safe-area-inset-bottom)); }
  .login-card { padding: 28px 20px 22px; border-radius: 26px; }
  .modal { border-radius: 26px 26px 0 0; }
}
@media (max-width: 420px) { .tab-count { display: inline-grid; } .tabs button { font-size: 10.5px; } }

/* Quando aberto como app (tela de início) */
@media (display-mode: standalone) {
  body { overscroll-behavior-y: none; }
}
@media (max-width: 720px) {
  /* Sem blur no cabeçalho do celular: o blur prende a barra de abas fixa e pesa no iPhone */
  .topbar { -webkit-backdrop-filter: none; backdrop-filter: none; background: var(--bg); }
}

/* ===== Acessos 2.0 ===== */
#viewAcessos { max-width: 860px; }
.ac-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ac-head .muted { font-size: 14px; margin-bottom: 2px; }
.ac-sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.ac-head-btns { display: flex; gap: 8px; align-items: center; }
.ac-head-btns .btn svg { width: 16px; height: 16px; stroke-width: 2.4; }
.ac-refresh { border: 1px solid var(--line); width: 42px; height: 42px; border-radius: 14px; }
.ac-refresh:active svg { transform: rotate(-90deg); transition: transform .3s; }

.ac-seg { display: inline-flex; gap: 4px; padding: 4px; background: var(--bg-2); border-radius: 14px; justify-self: start; }
.ac-seg button { display: inline-flex; align-items: center; gap: 8px; border: none; background: none; padding: 8px 14px; border-radius: 10px; font-size: 14px; font-weight: 600; color: var(--muted); transition: background .15s, color .15s; }
.ac-seg button span { min-width: 22px; height: 20px; padding: 0 6px; border-radius: 99px; background: color-mix(in srgb, var(--muted) 16%, transparent); font-size: 12px; font-weight: 700; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; }
.ac-seg button.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.ac-seg button.has span { background: var(--accent); color: var(--accent-ink); }

.ac-list { display: grid; gap: 10px; grid-template-columns: 1fr; }
.ac-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center;
  background: var(--card); border: 1px solid color-mix(in srgb, var(--line) 85%, transparent); border-radius: 18px;
  padding: 14px 16px; box-shadow: var(--shadow); transition: border-color .15s;
}
.ac-row:hover { border-color: var(--line); }
.ac-avatar {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-weight: 800; font-size: 15px; letter-spacing: .02em;
  color: hsl(var(--h) 55% 40%); background: hsl(var(--h) 60% 92%);
}
:root[data-theme="dark"] .ac-avatar { color: hsl(var(--h) 70% 75%); background: hsl(var(--h) 35% 20%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ac-avatar { color: hsl(var(--h) 70% 75%); background: hsl(var(--h) 35% 20%); } }
.ac-main { min-width: 0; display: grid; gap: 3px; }
.ac-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ac-name strong { font-size: 15.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.ac-meta { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.ac-badge.novo { background: var(--accent-soft); color: var(--accent); }
.ac-badge.admin { background: var(--bg-2); color: var(--ink-2); }
.ac-badge.bloq { background: var(--danger-soft); color: var(--danger); }
.ac-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.ac-chips span { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--ink-2); background: var(--bg-2); padding: 3px 9px; border-radius: 99px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-chips svg { width: 12px; height: 12px; }
.ac-actions { display: flex; align-items: center; gap: 6px; }
.ac-actions .btn { height: 36px; }
.ac-no { color: var(--muted); }
.ac-no:hover { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); background: var(--danger-soft); }
.ac-wa { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; color: #128c4b; background: color-mix(in srgb, #25d366 12%, var(--card)); border: 1px solid color-mix(in srgb, #25d366 35%, var(--line)); }
.ac-wa svg { width: 17px; height: 17px; }
:root[data-theme="dark"] .ac-wa { color: #4fe08f; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ac-wa { color: #4fe08f; } }

.ac-empty { display: grid; justify-items: center; text-align: center; gap: 8px; padding: 48px 20px; border: 1.5px dashed var(--line); border-radius: 20px; }
.ac-empty-icon { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 4px; }
.ac-empty-icon svg { width: 26px; height: 26px; }
.ac-empty p { color: var(--muted); font-size: 14px; max-width: 360px; }

@media (max-width: 720px) {
  .ac-head { align-items: center; }
  .ac-head-btns .btn { padding: 0 14px; }
  .ac-seg { display: flex; width: 100%; }
  .ac-seg button { flex: 1; justify-content: center; padding: 8px 6px; font-size: 13px; gap: 6px; }
  .ac-row { grid-template-columns: auto minmax(0, 1fr); padding: 14px; gap: 12px; }
  .ac-actions { grid-column: 1 / -1; }
  .ac-actions .btn { flex: 1; }
  .ac-wa { flex-shrink: 0; }
}

/* Janela aberta sem "modo modal" (alguns navegadores embutidos): mantém centralizada e por cima de tudo */
dialog.modal[open]:not(:modal) {
  position: fixed; inset: 0; margin: auto; z-index: 1000;
  box-shadow: 0 0 0 100vmax rgba(8, 12, 10, .55), var(--shadow-lg);
}
@media (max-width: 720px) {
  dialog.modal[open]:not(:modal) { margin: auto 0 0; }
}
body:has(dialog.modal[open]:not(:modal))::after { content: ""; position: fixed; inset: 0; z-index: 999; }
