/* Tema — valores copiados 1:1 do veja/enviar.txt */

html[data-theme="dark"] {
    --bg: #0d1210;
    --bg-glow: #1a2621;
    --surface: #141b18;
    --surface2: #0f1512;
    --border: #23302b;
    --accent: #4fd88a;
    --accent-glow: rgba(79, 216, 138, .38);
    --accent-soft: rgba(79, 216, 138, .10);
    --accent-light: #7be8ad;
    --success: #4fd88a;
    --danger: #ff6b6b;
    --danger-soft: rgba(255, 107, 107, .10);
    --warning: #f5c26b;
    --text: #e8ede9;
    --text-muted: #8ea092;
    --text-dim: #4c6157;

    --accent-dim: rgba(79, 216, 138, .34);
    --danger-dim: rgba(255, 107, 107, .38);
    --warn-soft: rgba(245, 194, 107, .12);
    --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 14px 34px rgba(0, 0, 0, .38);
    --on-accent: #06210f;

    --ink: #e8ede9;
    --muted: #8ea092;
    --line: #23302b;
    --accent-strong: #7be8ad;
    --ok: #4fd88a;
    --ok-soft: rgba(79, 216, 138, .10);
    --warn: #f5c26b;
}

html[data-theme="light"] {
    --bg: #e9f1ec;
    --bg-glow: #cfe8d6;
    --surface: #ffffff;
    --surface2: #dfebe4;
    --border: #a9c2b3;
    --accent: #157a45;
    --accent-glow: rgba(21, 122, 69, .32);
    --accent-soft: rgba(21, 122, 69, .15);
    --accent-light: #0e5c34;
    --success: #157a45;
    --danger: #b9352f;
    --danger-soft: rgba(185, 53, 47, .12);
    --warning: #93590c;
    --text: #12201a;
    --text-muted: #45564c;
    --text-dim: #6e8377;

    --accent-dim: rgba(21, 122, 69, .38);
    --danger-dim: rgba(185, 53, 47, .38);
    --warn-soft: rgba(147, 89, 12, .12);
    --shadow: 0 1px 2px rgba(18, 32, 26, .06), 0 12px 28px rgba(18, 32, 26, .09);
    --on-accent: #ffffff;

    --ink: #12201a;
    --muted: #45564c;
    --line: #a9c2b3;
    --accent-strong: #0e5c34;
    --ok: #157a45;
    --ok-soft: rgba(21, 122, 69, .15);
    --warn: #93590c;
}

/* Find-My — sistema visual compacto */

:root {
    --bg: #f3f5f8;
    --surface: #ffffff;
    --surface2: #f8fafc;
    --ink: #0f172a;
    --text: #1e293b;
    --muted: #64748b;
    --line: #e3e8ef;
    --accent: #0f766e;
    --accent-strong: #115e59;
    --accent-soft: #ecfdf5;
    --accent-dim: #ccfbf1;
    --danger: #b91c1c;
    --danger-soft: #fef2f2;
    --danger-dim: #fecaca;
    --ok: #15803d;
    --ok-soft: #f0fdf4;
    --warn: #b45309;
    --warn-soft: #fffbeb;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 10px 26px rgba(15, 23, 42, .045);
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

body.is-centered { display: grid; place-items: center; padding: 24px; min-height: 100vh; }
body.modal-open { overflow: hidden; }

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; color: var(--ink); }
p { margin: 0; }

.muted { color: var(--muted); font-size: 12px; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- Estrutura ---------- */

.page { max-width: 880px; margin: 0 auto; padding: 22px 18px 64px; }

.topbar {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    padding-bottom: 14px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--line);
}

.brand h1 { font-size: 15px; letter-spacing: -.01em; }

.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.nav { display: flex; gap: 2px; }

.nav-link {
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    transition: background .15s, color .15s;
}

.nav-link:hover { color: var(--ink); background: var(--surface); }
.nav-link.is-active { background: var(--ink); color: #fff; }

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.page-title { font-size: 20px; letter-spacing: -.025em; }
.page-sub { margin-top: 3px; font-size: 12.5px; color: var(--muted); max-width: 60ch; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
}

.card + .card { margin-top: 12px; }

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.card-head h2 {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--muted);
}

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 268px; gap: 14px; align-items: start; }
.layout-wide { grid-template-columns: minmax(0, 1fr); }

.layout { grid-template-columns: 1fr; }

.section-gap { margin-top: 14px; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 9px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    border: 1px solid var(--accent-dim);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .02em;
}

.chip-warn { background: var(--warn-soft); color: var(--warn); border-color: #fde68a; }

/* ---------- Formulário ---------- */

.field { display: block; margin-bottom: 16px; }

.field-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 10px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .09em;
    margin-bottom: 6px;
}

.label-note { font-size: 10.5px; font-weight: 600; color: var(--muted); text-transform: none; letter-spacing: 0; }

input[type="text"], input[type="password"], input[type="search"], input[type="date"], textarea, select {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface2);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    transition: border-color .12s, background .12s, box-shadow .12s;
}

textarea { resize: vertical; line-height: 1.5; }

input:focus, textarea:focus, select:focus {
    outline: none;
    background: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, .1);
}

textarea.is-invalid { border-color: var(--danger); }

.field-help {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-top: 6px;
    font-size: 11px;
    color: var(--muted);
}

.field-help .is-error, #recipients-count.is-error { color: var(--danger); font-weight: 600; }
#counter.is-over { color: var(--danger); font-weight: 600; }

.field-error { margin-top: 6px; font-size: 11.5px; color: var(--danger); font-weight: 500; }

.fixed-value {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface2);
    font-size: 13px;
}

.fixed-value strong { font-family: var(--mono); letter-spacing: .02em; }

/* ---------- Chips de validação ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }

.chip-item {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 7px;
    border: 1px solid var(--line);
    background: var(--surface2);
    color: var(--text);
    font-variant-numeric: tabular-nums;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chip-item.is-ok { background: var(--ok-soft); border-color: #bbf7d0; color: var(--ok); }
.chip-item.is-dup { background: var(--surface2); color: var(--muted); font-weight: 500; }
.chip-item.is-error { background: var(--danger-soft); border-color: var(--danger-dim); color: var(--danger); }
.chip-item.is-var {
    background: var(--accent-soft);
    border-color: var(--accent-dim);
    color: var(--accent-strong);
    font-family: var(--mono);
    font-weight: 500;
}

/* ---------- Botões ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font: inherit;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    transition: background .12s, border-color .12s, opacity .12s, transform .05s;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); }
.btn-primary:disabled { background: #cbd5e1; color: #78879b; }

.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: #cbd5e1; }
.btn-ghost:disabled { opacity: .5; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #991b1b; }

.btn-sm { padding: 7px 12px; font-size: 12px; }

.btn-block { width: 100%; }

.btn-mini {
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 8px;
    padding: 4px 9px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
    transition: border-color .12s, color .12s, background .12s;
}

.btn-mini:hover { border-color: #cbd5e1; color: var(--ink); }
.btn-mini-danger { color: var(--danger); border-color: var(--danger-dim); }
.btn-mini-danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-mini:disabled { opacity: .45; cursor: not-allowed; }

.link-mini {
    font-size: 11.5px;
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
}

.link-mini:hover { text-decoration: underline; }

.form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

/* ---------- Variáveis do envio ---------- */

.variables { margin-bottom: 16px; }
.variables[hidden] { display: none; }

.vars { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.vars:empty { display: none; }

.var-field { display: flex; flex-direction: column; gap: 5px; }
.var-field.is-list { grid-column: 1 / -1; }

.var-caption {
    align-self: flex-start;
    font-family: var(--mono);
    font-size: 10.5px;
    font-weight: 600;
    color: var(--accent-strong);
    background: var(--accent-soft);
    border: 1px solid var(--accent-dim);
    border-radius: 6px;
    padding: 1px 6px;
}

.var-picker { display: flex; flex-direction: column; gap: 6px; }
.picker-row { display: flex; align-items: center; gap: 6px; }
.picker-row .var-list { flex: 1; }

.picker-remove {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--muted);
    border-radius: 8px;
    width: 28px;
    height: 28px;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    flex: 0 0 auto;
    font-family: inherit;
}

.picker-remove:hover { color: var(--danger); border-color: var(--danger-dim); background: var(--danger-soft); }
.picker-add { align-self: flex-start; }

.var-list {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface2);
    font: inherit;
    font-size: 12.5px;
    cursor: pointer;
}

.var-hint { margin: 2px 0 0; font-size: 10.5px; color: var(--muted); }
.tpl-no-vars { font-size: 11.5px; color: var(--muted); margin: 6px 0 0; }

/* ---------- Editor de variáveis ---------- */

.var-editor { display: flex; flex-direction: column; gap: 8px; }

.var-row {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 9px 11px;
    background: var(--surface2);
}

.var-row-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.var-type { width: auto; padding: 4px 7px; font-size: 11.5px; border-radius: 7px; }

/* ---------- Histórico ---------- */

.hist-toolbar { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0 11px;
    transition: border-color .12s, background .12s;
}

.search-box:focus-within { border-color: var(--accent); background: #fff; }
.search-box input { flex: 1; border: 0; background: none; padding: 9px 0; box-shadow: none; }
.search-box input:focus { box-shadow: none; background: none; }
.search-box .search-icon { font-size: 12px; opacity: .5; }
.search-clear { border: 0; background: none; color: var(--muted); font-size: 15px; cursor: pointer; padding: 2px 4px; }
.search-clear:hover { color: var(--danger); }

.filters-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.segmented { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface2); border: 1px solid var(--line); border-radius: 999px; }
.seg { position: relative; }
.seg input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg span {
    display: inline-block;
    padding: 5px 11px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--muted);
    cursor: pointer;
    transition: background .12s, color .12s;
}
.seg input:checked + span { background: var(--ink); color: #fff; }

.date-field { display: flex; align-items: center; gap: 5px; font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.date-field input { width: auto; padding: 5px 7px; font-size: 11.5px; text-transform: none; letter-spacing: 0; }

.hist-list { display: flex; flex-direction: column; gap: 7px; }

.hist-item {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface2);
    padding: 10px 12px;
    transition: border-color .12s, box-shadow .12s, background .12s;
}

.hist-item:hover { border-color: #cfd8e3; background: #fff; }
.hist-item.is-selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-dim); background: #fff; }

.hist-top { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }

.hist-check {
    all: unset;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 1.5px solid #cbd5e1;
    cursor: pointer;
    flex: 0 0 auto;
    transition: background .12s, border-color .12s;
}

.hist-item.is-selected .hist-check { background: var(--accent); border-color: var(--accent); }

.hist-phones { font-family: var(--mono); font-size: 11.5px; font-weight: 600; color: var(--ink); }

.hist-when { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--muted); }

.hist-msg {
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    cursor: pointer;
    margin-bottom: 6px;
}

.hist-msg:hover { color: var(--ink); }
.hist-msg.is-copied::after { content: " ✓ copiado"; color: var(--accent); font-weight: 700; font-size: 10.5px; }

.hist-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.hist-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10.5px;
    font-weight: 700;
    background: var(--surface);
    color: var(--muted);
    border: 1px dashed var(--line);
    border-radius: 999px;
    padding: 2px 9px;
    cursor: text;
    outline: none;
    min-width: 56px;
}

.hist-tag:focus { border-style: solid; border-color: var(--accent); color: var(--accent-strong); background: var(--accent-soft); }
.hist-tag.is-saved { border-style: solid; border-color: var(--accent-dim); background: var(--accent-soft); color: var(--accent-strong); }

.hist-actions { display: none; gap: 6px; margin-left: auto; }
.hist-item.is-selected .hist-actions { display: flex; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: .03em;
    white-space: nowrap;
}

.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-fail { background: var(--danger-soft); color: var(--danger); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-dry { background: #eff6ff; color: #1d4ed8; }
.badge-idle { background: #eef2f6; color: var(--muted); }
.badge-busy { background: var(--accent-soft); color: var(--accent-strong); }

.bulkbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface2);
    margin-bottom: 10px;
    font-size: 11.5px;
}

.bulk-actions { display: flex; gap: 6px; margin-left: auto; }

.check-all { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
    font-size: 11.5px;
}

.pager-buttons { display: flex; gap: 6px; }
.is-disabled { opacity: .4; pointer-events: none; }

.empty { font-size: 12.5px; color: var(--muted); padding: 18px 4px; text-align: center; }

/* ---------- Estatísticas e listas curtas ---------- */

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.stats div { background: var(--surface2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; }
.stats dt { font-size: 9.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.stats dd { margin: 2px 0 0; font-size: 20px; font-weight: 700; font-family: var(--mono); color: var(--ink); }
.stats dd.is-bad { color: var(--danger); }

.mini-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 11.5px; }
.mini-list li { display: flex; align-items: center; gap: 8px; }
.mini-time { color: var(--muted); white-space: nowrap; font-family: var(--mono); font-size: 10px; }
.mini-body { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Templates e listas ---------- */

.tpl-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }

.tpl-item {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface2);
    padding: 10px 12px;
    transition: border-color .12s, background .12s;
}

.tpl-item:hover { border-color: #cfd8e3; background: #fff; }
.tpl-item.is-editing { border-color: var(--accent); background: #fff; }

.tpl-head { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tpl-head strong { font-size: 12.5px; color: var(--ink); }
.tpl-actions { display: flex; gap: 5px; align-items: center; flex: 0 0 auto; }
.inline-form { display: inline; margin: 0; }

.tpl-body { margin: 6px 0 0; font-size: 12px; color: var(--text); white-space: pre-wrap; word-break: break-word; }

.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 18px; align-items: start; }
 .split { grid-template-columns: 1fr; } 

/* ---------- Modal ---------- */

.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 18px; }
.modal[hidden] { display: none; }

.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .5); backdrop-filter: blur(2px); }

.modal-card {
    position: relative;
    width: min(100%, 520px);
    max-height: min(88vh, 760px);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .3);
    animation: modal-in .15s ease-out;
}

.modal-card.is-wide { width: min(100%, 640px); }

@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.99); } }

.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 10px; }
.modal-head h2 { font-size: 15px; }

.modal-close {
    border: 0;
    background: transparent;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    color: var(--muted);
    padding: 0 4px;
    border-radius: 8px;
}

.modal-close:hover { color: var(--ink); background: var(--surface2); }

.modal-body { padding: 0 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px 16px; }
.modal-foot:empty { display: none; }

.modal-lead { font-size: 12.5px; color: var(--text); margin-bottom: 10px; }
.modal-note { font-size: 11px; color: var(--muted); margin-bottom: 10px; }

.modal-msg {
    background: var(--surface2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text);
    max-height: 130px;
    overflow-y: auto;
    margin-bottom: 12px;
}

.modal-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 5px; max-height: 220px; overflow-y: auto; }
.modal-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
    padding: 6px 9px;
    border-radius: 8px;
    background: var(--surface2);
    border: 1px solid var(--line);
}
.modal-list li.is-done { background: #fff; }

.progress { height: 5px; border-radius: 999px; background: var(--line); overflow: hidden; margin-bottom: 12px; }
.progress[hidden] { display: none; }
.progress-fill { height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .25s ease; }
.progress-fill.is-error { background: var(--danger); }

/* ---------- Toast ---------- */

.toast-stack { position: fixed; right: 16px; bottom: 16px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }

.toast {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 13px;
    border-radius: var(--radius-sm);
    background: var(--ink);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 12px 30px rgba(15, 23, 42, .28);
    animation: toast-in .18s ease-out;
}

.toast.is-error { background: var(--danger); }
.toast.is-out { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }

@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Login ---------- */

.login-card {
    width: min(100%, 340px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 22px;
}

.login-card .brand { margin-bottom: 16px; }
.login-card .field { margin-bottom: 12px; }

.alert {
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    margin-bottom: 10px;
    border: 1px solid transparent;
    font-size: 12px;
}

.alert-error { background: var(--danger-soft); border-color: var(--danger-dim); color: #7f1d1d; }
.alert-ok { background: var(--ok-soft); border-color: #bbf7d0; color: #14532d; }

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---------- Histórico: detalhes e etiqueta ---------- */

.hist-check {
    appearance: none;
    -webkit-appearance: none;
    margin: 0;
    padding: 0;
}

.hist-tag:empty::before {
    content: attr(data-placeholder);
    color: var(--muted);
    font-weight: 600;
    opacity: .75;
}

.hist-more { display: inline-block; }

.hist-more summary {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--muted);
    cursor: pointer;
    list-style: none;
}

.hist-more summary::-webkit-details-marker { display: none; }
.hist-more summary:hover { color: var(--accent); }

.hist-recipients {
    list-style: none;
    margin: 7px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
    font-family: var(--mono);
}

.hist-recipients li { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
/* ---------- Utilitários ---------- */

.var {
    font-family: var(--mono);
    font-size: .92em;
    background: var(--accent-soft);
    color: var(--accent-strong);
    border: 1px solid var(--accent-dim);
    border-radius: 5px;
    padding: 0 4px;
}

.head-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.toast-stack.is-out { transition: opacity .25s; opacity: 0; }
/* ---------- Importar ---------- */

input[type="file"] {
    width: 100%;
    padding: 10px;
    border: 1px dashed var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface2);
    font-size: 12px;
    color: var(--muted);
    cursor: pointer;
}

input[type="file"]::file-selector-button {
    margin-right: 10px;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
}

code {
    font-family: var(--mono);
    font-size: .92em;
    background: var(--surface2);
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 0 4px;
}
/* ================================================================== *
 *  Tema escuro (referência do Lovable)
 * ================================================================== */

:root {
    --bg: #070b0a;
    --surface: #0c1210;
    --surface2: #0a100e;
    --ink: #eef6f0;
    --text: #cfdcd3;
    --muted: #7e8f86;
    --line: #1b2622;
    --accent: #b6f24d;
    --accent-strong: #c8fb6a;
    --accent-soft: rgba(182, 242, 77, .1);
    --accent-dim: rgba(182, 242, 77, .28);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, .1);
    --danger-dim: rgba(248, 113, 113, .35);
    --ok: #86efac;
    --ok-soft: rgba(134, 239, 172, .1);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, .1);
    --shadow: 0 24px 60px rgba(0, 0, 0, .5);
}

body {
    background:
        radial-gradient(120% 90% at 50% -10%, #123021 0%, #070b0a 55%, #050807 100%);
    color: var(--text);
}

h1, h2, h3 { color: var(--ink); }

.topbar { border-bottom-color: var(--line); }
.brand h1 { color: var(--ink); }

.nav-link { color: var(--muted); }
.nav-link:hover { color: var(--ink); background: var(--surface); }
.nav-link.is-active { background: var(--accent); color: #0a1206; }

.card {
    background: var(--surface);
    border-color: var(--line);
    box-shadow: var(--shadow);
}

.page-title { color: var(--ink); }

input[type="text"], input[type="password"], input[type="search"], input[type="date"], textarea, select {
    background: var(--surface2);
    border-color: var(--line);
    color: var(--ink);
}

input:focus, textarea:focus, select:focus {
    background: #0a110e;
    border-color: rgba(182, 242, 77, .55);
    box-shadow: 0 0 0 3px rgba(182, 242, 77, .12);
}

input::placeholder, textarea::placeholder { color: #4c5b53; }

.fixed-value { background: var(--surface2); border-color: var(--line); }
.fixed-value strong { color: var(--accent); }

.btn-primary { background: var(--accent); color: #0a1206; }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); }
.btn-primary:disabled { background: #22302a; color: #6b7a72; }

.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent-dim); color: var(--ink); }

.btn-mini { background: var(--surface2); border-color: var(--line); color: var(--text); }
.btn-mini:hover { border-color: var(--accent-dim); color: var(--ink); }
.btn-mini-danger { color: var(--danger); border-color: var(--danger-dim); }
.btn-mini-danger:hover { background: var(--danger-soft); }

.link-mini { color: var(--accent); }

.chip {
    background: var(--accent-soft);
    border-color: var(--accent-dim);
    color: var(--accent);
}

.chip-item { background: var(--surface2); border-color: var(--line); color: var(--text); }
.chip-item.is-ok { background: var(--ok-soft); border-color: rgba(134, 239, 172, .3); color: var(--ok); }
.chip-item.is-error { background: var(--danger-soft); border-color: var(--danger-dim); color: var(--danger); }
.chip-item.is-var { background: var(--accent-soft); border-color: var(--accent-dim); color: var(--accent); }

.hist-item, .tpl-item { background: var(--surface2); border-color: var(--line); }
.hist-item:hover, .tpl-item:hover { background: #0e1512; border-color: #26332c; }
.hist-item.is-selected { background: #0e1512; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-dim); }
.tpl-item.is-editing { background: #0e1512; border-color: var(--accent); }

.hist-check { border-color: #3a4741; }
.hist-item.is-selected .hist-check { background: var(--accent); border-color: var(--accent); }

.hist-when, .mini-time { color: var(--muted); }
.hist-tag { background: var(--surface); border-color: var(--line); color: var(--muted); }
.hist-tag.is-saved { background: var(--accent-soft); border-color: var(--accent-dim); color: var(--accent); }

.badge-idle { background: #16211c; color: var(--muted); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-fail { background: var(--danger-soft); color: var(--danger); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-dry { background: rgba(96, 165, 250, .12); color: #93c5fd; }
.badge-busy { background: var(--accent-soft); color: var(--accent); }

.bulkbar, .search-box, .segmented, .stats div, .var-row, .var-list {
    background: var(--surface2);
    border-color: var(--line);
}

.search-box:focus-within { border-color: rgba(182, 242, 77, .5); background: #0a110e; }
.seg span { color: var(--muted); }
.seg input:checked + span { background: var(--accent); color: #0a1206; }

.modal-backdrop { background: rgba(3, 6, 5, .72); }
.modal-card { background: #0c1210; border: 1px solid var(--line); }
.modal-head h2 { color: var(--ink); }
.modal-msg, .modal-list li { background: var(--surface2); border-color: var(--line); color: var(--text); }

.toast { background: #16211c; border: 1px solid var(--line); color: var(--ink); }
.toast.is-error { background: #3b1516; border-color: var(--danger-dim); }

.empty, .muted, .tpl-no-vars { color: var(--muted); }

.progress { background: #16211c; }

.sr-only { border: 0; }
.brand { display: flex; align-items: center; gap: 8px; }

.brand-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px rgba(182, 242, 77, .8);
}
/* ================================================================== *
 *  Mobile: barra inferior + botão flutuante
 * ================================================================== */

.fab {
    position: fixed;
    right: 18px;
    bottom: 22px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--accent);
    color: #0a1206;
    box-shadow: 0 10px 26px rgba(0, 0, 0, .45), 0 0 28px rgba(182, 242, 77, .35);
    z-index: 55;
    text-decoration: none;
    transition: transform .1s, box-shadow .15s, filter .15s;
}

.fab:hover { filter: brightness(1.06); box-shadow: 0 12px 30px rgba(0, 0, 0, .5), 0 0 34px rgba(182, 242, 77, .45); }
.fab:active { transform: scale(.96); }
.fab svg { width: 24px; height: 24px; }

.tabbar { display: none; }

.page { padding-bottom: 96px; }

.topbar { gap: 10px; }
.topbar .nav { display: none; }

.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: rgba(9, 14, 12, .94);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    z-index: 50;
}

.tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 2px;
    color: var(--muted);
    text-decoration: none;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .01em;
}

.tab svg { width: 21px; height: 21px; }
.tab.is-active { color: var(--accent); }

.fab { bottom: calc(82px + env(safe-area-inset-bottom)); right: 16px; }

.modal-foot { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }

/* fundo cobre a página inteira */
html { min-height: 100%; }
body {
    min-height: 100vh;
    background-attachment: fixed;
    background-size: cover;
    background-repeat: no-repeat;
}
/* ================================================================== *
 *  CAMADA RESPONSIVA — mobile-first
 *  base: < 600px · tablet: >= 600px · desktop: >= 1024px
 * ================================================================== */

/* ---------- base (mobile) ---------- */

.page { padding: 16px 14px calc(96px + env(safe-area-inset-bottom)); }

.nav { display: none; }

.page-title { font-size: 19px; }
.page-sub { font-size: 12px; }

.layout,
.split { grid-template-columns: minmax(0, 1fr); }

.card { padding: 14px; border-radius: 12px; }

.topbar { padding-bottom: 12px; margin-bottom: 16px; }

.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: rgba(9, 14, 12, .94);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    z-index: 50;
}

.tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 2px;
    color: var(--muted);
    text-decoration: none;
    font-size: 10px;
    font-weight: 700;
}

.tab svg { width: 21px; height: 21px; }
.tab.is-active { color: var(--accent); }

.fab { bottom: calc(82px + env(safe-area-inset-bottom)); }

.modal-foot { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }

/* ---------- tablet ---------- */


/* ---------- desktop ---------- */

/* ---------- Cabeçalho do cartão, caixa de info e ações de linha ---------- */

.card-title {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
}

.card-title h2 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -.01em;
    color: var(--ink);
    text-transform: none;
}

.card-title .muted { font-size: 12px; margin-top: 2px; }

.card-icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border-radius: 11px;
    background: var(--accent-soft);
    border: 1px solid var(--accent-dim);
    color: var(--accent);
}

.card-icon svg { width: 20px; height: 20px; }

.info-box {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 13px;
    margin-bottom: 18px;
    border: 1px solid var(--accent-dim);
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
}

.info-box strong { display: block; font-size: 12.5px; color: var(--ink); }
.info-box p { margin-top: 2px; font-size: 11.5px; color: var(--text); }

.info-check {
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--accent);
    color: #0a1206;
    font-size: 11px;
    font-weight: 800;
    margin-top: 1px;
}

.label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.label-row .field-label { margin-bottom: 0; }

.link-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.link-action svg { width: 14px; height: 14px; }
.link-action:hover { color: var(--accent-strong); }

.label-row .link-action { margin-top: 0; }
/* Chips clicáveis (copiar / remover) */

.chip-item { display: inline-flex; align-items: center; gap: 6px; }
.chip-item.is-clickable { cursor: pointer; }
.chip-item.is-clickable:hover { filter: brightness(1.15); }

.chip-remove {
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    font-size: 12px;
    line-height: 1;
    padding: 0 2px;
    cursor: pointer;
    opacity: .6;
}

.chip-remove:hover { opacity: 1; }
/* Ajustes de tema — sítios que tinham cores fixas */

body {
    background:
        radial-gradient(circle at 15% -10%, var(--bg-glow) 0%, transparent 45%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    transition: background .2s, color .2s;
}

.topbar { border-bottom-color: var(--border); }
.brand h1 { color: var(--text); }

.nav-link { color: var(--text-muted); }
.nav-link:hover { color: var(--text); background: var(--surface); }
.nav-link.is-active { background: var(--accent); color: var(--on-accent); }

.card { background: var(--surface); border-color: var(--border); }

input, textarea, select {
    background: var(--surface2);
    border-color: var(--border);
    color: var(--text);
}

input::placeholder, textarea::placeholder { color: var(--text-dim); }

input:focus, textarea:focus, select:focus {
    background: var(--surface);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-light); }
.btn-primary:disabled { background: var(--surface2); color: var(--text-dim); border-color: var(--border); }

.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--accent-dim); color: var(--accent); }

.btn-mini { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-mini:hover { border-color: var(--accent-dim); color: var(--accent); }

.seg input:checked + span { background: var(--accent); color: var(--on-accent); }

.modal-card { background: var(--surface); border: 1px solid var(--border); }
.modal-head h2 { color: var(--text); }
.modal-msg, .modal-list li { background: var(--surface2); border-color: var(--border); color: var(--text); }
.modal-backdrop { background: rgba(4, 8, 6, .6); }

.toast { background: var(--surface); border: 1px solid var(--accent-dim); color: var(--text); }
.toast.is-error { background: var(--surface); border-color: var(--danger-dim); color: var(--danger); }

.progress { background: var(--surface2); }
.badge-idle { background: var(--surface2); color: var(--text-muted); }

.hist-item:hover, .tpl-item:hover { background: var(--surface); border-color: var(--accent-dim); }
.hist-item.is-selected, .tpl-item.is-editing { background: var(--surface); border-color: var(--accent); }

.hist-check { border-color: var(--text-dim); }

.search-box { background: var(--surface2); border-color: var(--border); }
.search-box:focus-within { background: var(--surface); border-color: var(--accent); }

.search-clear {
    border: 0;
    background: none;
    color: var(--text-muted);
    font-size: 15px;
    text-decoration: none;
    padding: 2px 4px;
}

.search-clear:hover { color: var(--danger); }

/* Alternador de tema */

.theme-toggle {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: color .15s, border-color .15s;
}

.theme-toggle:hover { color: var(--accent); border-color: var(--accent-dim); }
.theme-toggle svg { width: 17px; height: 17px; }

html[data-theme="dark"] .icon-sun { display: none; }
html[data-theme="light"] .icon-moon { display: none; }

/* ---------- Ferramentas das listas (templates/listas) ---------- */

.list-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.order-select {
    width: auto;
    padding: 4px 8px;
    font-size: 11.5px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    cursor: pointer;
}

.pick-item {
    appearance: none;
    -webkit-appearance: none;
    width: 15px;
    height: 15px;
    padding: 0;
    margin: 0;
    border: 1.5px solid var(--text-dim);
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    flex: 0 0 auto;
    transition: background .12s, border-color .12s;
}

.pick-item:checked {
    background: var(--accent);
    border-color: var(--accent);
}

.tpl-head .pick-item { margin-right: 2px; }

/* ---------- Pré-visualização da mensagem ---------- */

.preview {
    margin-top: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface2);
    padding: 12px 14px;
}

.preview-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.preview-from {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: .04em;
}

.preview-when { font-size: 10px; color: var(--text-dim); }

.preview-body {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    min-height: 20px;
}

.preview-body.is-empty { color: var(--text-dim); font-style: italic; }

.preview-meta {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
    font-size: 10.5px;
    color: var(--text-muted);
    text-align: right;
}

/* alinhar os dois cartões de templates/listas */
.split { align-items: stretch; }
.split > .card { height: 100%; }
/* nome do item encostado à esquerda, ao lado do checkbox */
.tpl-head strong { flex: 1; text-align: left; }
.tpl-head { gap: 8px; }
/* ================================================================== *
 *  Variáveis obrigatórias: vermelho por preencher, verde preenchida
 * ================================================================== */

.var-field.is-empty .var-caption {
    border-color: var(--danger);
    color: var(--danger);
    background: var(--danger-soft);
}

.var-field.is-empty input,
.var-field.is-empty .var-list {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px var(--danger-soft);
}

.var-field.is-filled .var-caption {
    border-color: var(--accent-dim);
    color: var(--accent);
    background: var(--accent-soft);
}

.var-field.is-filled input,
.var-field.is-filled .var-list {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* chip do utilizador (abre o resumo) */
.chip-user {
    cursor: pointer;
    font-family: inherit;
    padding: 4px 10px;
}

.chip-user svg { width: 13px; height: 13px; }

/* ================================================================== *
 *  Mobile: aspeto de aplicação nativa
 * ================================================================== */

html { -webkit-tap-highlight-color: transparent; }

body { font-size: 15px; }

.page { padding: 12px 12px calc(104px + env(safe-area-inset-bottom)); }

.topbar {
    position: sticky;
    top: 0;
    z-index: 45;
    margin: -12px -12px 14px;
    padding: 12px 12px 10px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.brand h1 { font-size: 17px; }

.card { border-radius: 18px; padding: 16px; }

.card-title h2 { font-size: 18px; }
.card-title .muted { font-size: 12.5px; }

input[type="text"], input[type="password"], input[type="search"], textarea, select {
    font-size: 16px;           /* evita o zoom do iOS */
    min-height: 50px;
    padding: 12px 14px;
    border-radius: 12px;
}

textarea { min-height: 96px; }

.btn {
    min-height: 50px;
    font-size: 15px;
    border-radius: 12px;
}

.btn-sm { min-height: 40px; font-size: 13.5px; }

.form-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    text-align: center;
}

.form-actions .btn { width: 100%; }

.tabbar { padding-top: 8px; }
.tab { font-size: 11px; gap: 4px; }
.tab svg { width: 24px; height: 24px; }

.fab { width: 60px; height: 60px; }
.fab svg { width: 28px; height: 28px; }

.chips { gap: 6px; }
.chip-item { font-size: 12.5px; padding: 6px 10px; border-radius: 9px; }

.hist-msg, .tpl-body { font-size: 14px; }

.page-title { font-size: 22px; }
.page-sub { font-size: 13px; }

.field-label { font-size: 11px; }
.field-help, .muted { font-size: 12px; }

.mini-list { font-size: 13px; }
.stats dd { font-size: 24px; }
/* Mensagem gerada por template: dica de duplo clique e estado editável */

#message[readonly] { cursor: pointer; }

#message.is-unlocked {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.link-action[hidden] { display: none; }

.label-row { gap: 6px; }
.label-row .link-action { font-size: 12.5px; }
.info-box { padding: 12px 14px; }
.fixed-value { font-size: 14px; }
.preview, .card .section-gap { margin-top: 16px; }
/* ---------- Lista compacta de templates ---------- */

.tpl-picker {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.tpl-option {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface2);
    color: var(--text);
    font: inherit;
    cursor: pointer;
    text-align: left;
    transition: border-color .12s, background .12s;
}

.tpl-option strong { font-size: 12.5px; font-weight: 700; }
.tpl-option span { font-size: 10.5px; color: var(--text-muted); }

.tpl-option:hover { border-color: var(--accent-dim); }

.tpl-option.is-active {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}

.tpl-option.is-active span { color: var(--accent); opacity: .85; }

.tpl-option { padding: 10px 14px; border-radius: 12px; }
.tpl-option strong { font-size: 13.5px; }
.tpl-option span { font-size: 11px; }
/* Lista compacta de templates: uma linha de metadados */
.tpl-item { padding: 9px 11px; }
.tpl-meta {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    margin: 4px 0 0;
    font-size: 10.5px;
    color: var(--text-muted);
    line-height: 1.4;
}
.tpl-preview {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
    opacity: .8;
}
/* Alinhar os dois cartões (templates / listas) na horizontal */
.split { align-items: start; gap: 14px; }
.split > .card { height: 100%; }
.split .card-head { min-height: 30px; align-items: center; }

.btn-move {
    font-family: var(--mono);
    font-size: 12px;
    padding: 3px 7px;
    line-height: 1;
}

.tpl-actions { flex-wrap: wrap; }
/* ---------- Caixa das variáveis do template ---------- */

.variables {
    border: 1px solid var(--accent-dim);
    border-radius: 14px;
    padding: 12px 14px 14px;
    background: color-mix(in srgb, var(--accent-soft) 55%, transparent);
    margin-bottom: 18px;
}

.variables > .field-label {
    margin-bottom: 10px;
    color: var(--accent);
    letter-spacing: .12em;
}

.vars { gap: 12px; }

.list-vars {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin-top: 10px;
}
/* Escolha em "+ Novo" */
.choice {
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: 100%;
    padding: 14px 16px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface2);
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color .12s, background .12s;
}

.choice strong { font-size: 14px; }
.choice span { font-size: 11.5px; color: var(--text-muted); }
.choice:hover { border-color: var(--accent); background: var(--accent-soft); }
.choice:hover strong { color: var(--accent); }
/* Variáveis: um valor só, tudo junto e compacto */
.var-field.is-list { grid-column: auto; }
.vars { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.variables .var-field { gap: 6px; }

.vars { grid-template-columns: 1fr 1fr; gap: 8px; }
.variables { padding: 10px 12px 12px; }
.var-list, .variables input { min-height: 42px; padding: 8px 10px; font-size: 15px; }
/* O que vem de dentro da lista fica por baixo, alinhado */
.list-vars { grid-column: 1 / -1; grid-template-columns: 1fr; }
/* ---------- Loader do envio (Uiverse, adaptado ao tema) ---------- */

.spinner-wrap {
    display: grid;
    place-items: center;
    height: 56px;
    margin: 4px 0 10px;
}

.spinner-wrap[hidden] { display: none; }

.spinner {
    position: relative;
    width: 9px;
    height: 9px;
    transform: scale(3.2);
}

.spinner div {
    position: absolute;
    width: 50%;
    height: 150%;
    background: var(--accent);
    transform: rotate(calc(var(--rotation) * 1deg)) translate(0, calc(var(--translation) * 1%));
    animation: spinner-fzua35 1s calc(var(--delay) * 1s) infinite ease;
}

.spinner div:nth-child(1) { --delay: 0.1; --rotation: 36; --translation: 150; }
.spinner div:nth-child(2) { --delay: 0.2; --rotation: 72; --translation: 150; }
.spinner div:nth-child(3) { --delay: 0.3; --rotation: 108; --translation: 150; }
.spinner div:nth-child(4) { --delay: 0.4; --rotation: 144; --translation: 150; }
.spinner div:nth-child(5) { --delay: 0.5; --rotation: 180; --translation: 150; }
.spinner div:nth-child(6) { --delay: 0.6; --rotation: 216; --translation: 150; }
.spinner div:nth-child(7) { --delay: 0.7; --rotation: 252; --translation: 150; }
.spinner div:nth-child(8) { --delay: 0.8; --rotation: 288; --translation: 150; }
.spinner div:nth-child(9) { --delay: 0.9; --rotation: 324; --translation: 150; }
.spinner div:nth-child(10) { --delay: 1; --rotation: 360; --translation: 150; }

@keyframes spinner-fzua35 {
    0%, 10%, 20%, 30%, 50%, 60%, 70%, 80%, 90%, 100% {
        transform: rotate(calc(var(--rotation) * 1deg)) translate(0, calc(var(--translation) * 1%));
    }

    50% {
        transform: rotate(calc(var(--rotation) * 1deg)) translate(0, calc(var(--translation) * 1.5%));
    }
}
/* ================================================================== *
 *  Modal de entrega
 * ================================================================== */

.send-ring {
    position: relative;
    width: 96px;
    height: 96px;
    margin: 6px auto 14px;
}

.send-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }

.ring-bg {
    fill: none;
    stroke: var(--surface2);
    stroke-width: 5;
}

.ring-fill {
    fill: none;
    stroke: var(--accent);
    stroke-width: 5;
    stroke-linecap: round;
    stroke-dasharray: 163.4;
    stroke-dashoffset: 163.4;
    transition: stroke-dashoffset .45s cubic-bezier(.2,.8,.2,1), stroke .2s;
    filter: drop-shadow(0 0 6px var(--accent-glow));
}

.send-ring-label {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
}

.send-ring-label strong {
    font-family: var(--mono);
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
}

.send-ring-label span {
    font-size: 9.5px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-muted);
}

.send-list { gap: 6px; }

.send-row {
    display: flex;
    align-items: center;
    gap: 9px;
    animation: row-in .22s ease-out both;
}

@keyframes row-in {
    from { opacity: 0; transform: translateY(4px); }
}

.send-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: 0 0 auto;
    background: var(--text-dim);
    transition: background .2s, box-shadow .2s;
}

.send-dot.badge-idle { background: var(--text-dim); }

.send-dot.badge-busy {
    background: var(--accent);
    box-shadow: 0 0 0 0 var(--accent-glow);
    animation: dot-pulse 1.1s ease-out infinite;
}

@keyframes dot-pulse {
    0%   { box-shadow: 0 0 0 0 var(--accent-glow); }
    100% { box-shadow: 0 0 0 8px rgba(0,0,0,0); }
}

.send-dot.badge-ok { background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }
.send-dot.badge-fail { background: var(--danger); box-shadow: 0 0 8px var(--danger-soft); }
.send-dot.badge-dry { background: var(--accent); opacity: .6; }

.send-row .num { flex: 1; }

/* barra com brilho enquanto corre */
.progress { position: relative; overflow: hidden; }
.progress-fill { position: relative; }
.progress-fill::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent);
    animation: shimmer 1.2s linear infinite;
}

@keyframes shimmer {
    from { transform: translateX(-100%); }
    to   { transform: translateX(100%); }
}

.progress-fill[style*="width: 100%"]::after { animation: none; opacity: 0; }

/* conclusão */
.modal-card.is-done .send-ring .ring-fill { filter: drop-shadow(0 0 10px var(--accent-glow)); }
.modal-card.is-done .send-ring-label strong { animation: pop .35s ease-out; }

@keyframes pop {
    0% { transform: scale(.85); }
    60% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

.send-ring { width: 84px; height: 84px; }
.send-ring-label strong { font-size: 15px; }
.modal-card { width: 100%; max-height: 90vh; }
/* Spinner dentro de botões (estilo Flowbite) */
.btn-spinner {
    width: 15px;
    height: 15px;
    margin-right: 7px;
    animation: btn-spin 1s linear infinite;
    flex: 0 0 auto;
}

.btn { gap: 0; }

@keyframes btn-spin {
    to { transform: rotate(360deg); }
}

.btn:disabled .btn-spinner { opacity: .9; }

.btn-spinner { width: 17px; height: 17px; }
/* ---------- Modo simulador ---------- */

.chip-sim-off { background: var(--surface2); color: var(--text-muted); border-color: var(--border); text-decoration: none; }
.chip-sim-on {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: var(--danger-dim);
    text-decoration: none;
    animation: sim-blink 2s ease-in-out infinite;
}

@keyframes sim-blink { 50% { opacity: .65; } }

.sim-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.sim-banner {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 13px;
    margin-bottom: 12px;
    border: 1px dashed var(--danger-dim);
    border-radius: var(--radius);
    background: var(--danger-soft);
}

.sim-banner strong { font-size: 11.5px; color: var(--danger); text-transform: uppercase; letter-spacing: .08em; }
.sim-banner span { font-size: 11.5px; color: var(--text); }
/* ponto de estado acompanha o badge (sem JS extra) */
.send-row:has(.badge-ok) .send-dot { background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }
.send-row:has(.badge-fail) .send-dot { background: var(--danger); box-shadow: 0 0 8px var(--danger-soft); }
.send-row:has(.badge-busy) .send-dot { background: var(--accent); animation: dot-pulse 1.1s ease-out infinite; }
.send-row:has(.badge-idle) .send-dot { background: var(--text-dim); }
/* ---------- Loader de 12 barras (spinner.txt), pequeno ---------- */

.loader-wrap {
    display: grid;
    place-items: center;
    height: 30px;
    margin: 2px 0 8px;
}

.loader-wrap[hidden] { display: none; }

.loader {
    position: relative;
    width: 22px;
    height: 22px;
}

.loader div {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 2px;
    height: 6px;
    margin: -11px 0 0 -1px;
    background: var(--accent);
    border-radius: 2px;
    transform-origin: 1px 11px;
    animation: loader-fade 1.2s linear infinite;
}

@keyframes loader-fade {
    0%, 100% { opacity: .15; }
    50%      { opacity: 1; }
}

.loader div:nth-child(1)  { transform: rotate(0deg);   animation-delay: -1.1s; }
.loader div:nth-child(2)  { transform: rotate(30deg);  animation-delay: -1.0s; }
.loader div:nth-child(3)  { transform: rotate(60deg);  animation-delay: -0.9s; }
.loader div:nth-child(4)  { transform: rotate(90deg);  animation-delay: -0.8s; }
.loader div:nth-child(5)  { transform: rotate(120deg); animation-delay: -0.7s; }
.loader div:nth-child(6)  { transform: rotate(150deg); animation-delay: -0.6s; }
.loader div:nth-child(7)  { transform: rotate(180deg); animation-delay: -0.5s; }
.loader div:nth-child(8)  { transform: rotate(210deg); animation-delay: -0.4s; }
.loader div:nth-child(9)  { transform: rotate(240deg); animation-delay: -0.3s; }
.loader div:nth-child(10) { transform: rotate(270deg); animation-delay: -0.2s; }
.loader div:nth-child(11) { transform: rotate(300deg); animation-delay: -0.1s; }
.loader div:nth-child(12) { transform: rotate(330deg); animation-delay: 0s; }

/* ---------- Variáveis no formato "label na borda" ---------- */

.variables { background: var(--surface); }

.var-field {
    position: relative;
    padding-top: 10px;
}

.var-caption {
    position: absolute;
    top: 0;
    left: 10px;
    z-index: 1;
    padding: 0 5px;
    background: var(--surface);
    border: 0;
    border-radius: 4px;
    font-family: var(--sans);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.var-field.is-empty .var-caption { color: var(--danger); background: var(--surface); }
.var-field.is-filled .var-caption { color: var(--accent); background: var(--surface); }

.variables input,
.variables .var-list {
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--surface2);
}

.var-field.is-empty input,
.var-field.is-empty .var-list { border-color: var(--danger); box-shadow: none; }

.var-field.is-filled input,
.var-field.is-filled .var-list { border-color: var(--accent); box-shadow: none; }

.list-vars .var-field { padding-top: 10px; }
/* ---------- Botão "Editar" (estrutura do editar.txt, cores nossas) ---------- */

.btn-edit {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    width: 108px;
    height: 40px;
    padding: 0 18px;
    border: 0;
    border-radius: 10px;
    background: var(--accent);
    color: var(--on-accent);
    font: inherit;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    box-shadow: 4px 4px 0 var(--accent-dim);
    transition-duration: .3s;
    overflow: hidden;
}

.btn-edit-svg {
    width: 13px;
    fill: currentColor;
    position: absolute;
    right: 18px;
    transition-duration: .3s;
}

.btn-edit:hover { color: transparent; }
.btn-edit:hover .btn-edit-svg { right: 43%; }

.btn-edit:active {
    transform: translate(3px, 3px);
    box-shadow: 1px 1px 0 var(--accent-dim);
}

.modal-foot .btn-edit { margin-right: auto; }
/* ---------- Ações rápidas do histórico ---------- */

.hist-quick {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 4px 0 8px;
}

.hist-act {
    flex: 1 1 auto;
    text-align: center;
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    border: 1px solid transparent;
    transition: filter .12s, border-color .12s;
}

.hist-act.accent { background: var(--accent); color: var(--on-accent); }
.hist-act.accent:hover { filter: brightness(1.07); }

.hist-act.secondary {
    background: var(--surface2);
    color: var(--text);
    border-color: var(--border);
}

.hist-act.secondary:hover { border-color: var(--accent-dim); color: var(--accent); }
/* Histórico: dono + destinatários, ações só na seleção, links clicáveis */
.hist-owner {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-soft);
    border: 1px solid var(--accent-dim);
    border-radius: 999px;
    padding: 2px 8px;
}

.hist-quick { display: none; }
.hist-item.is-selected .hist-quick { display: flex; }

.hist-link {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-all;
}

.hist-msg { cursor: default; }
/* Ações destrutivas a vermelho; criação a verde */
.btn-mini-danger,
.btn-mini.btn-mini-danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

.btn-mini-danger:hover { background: var(--danger); filter: brightness(1.1); color: #fff; }

.btn[data-danger], #delete-selected {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

#delete-selected:disabled { background: var(--surface2); color: var(--text-dim); border-color: var(--border); }

/* criar = verde */
.btn-primary, .btn-edit { background: var(--accent); color: var(--on-accent); }
/* ---------- Paginação numerada ---------- */

.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }

.pager-nav { display: inline-flex; align-items: center; }

.pager-num, .pager-step, .pager-gap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 34px;
    padding: 0 6px;
    margin-left: -1px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
    transition: background .12s, color .12s;
}

.pager-num:first-child, .pager-step:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.pager-step:last-child, .pager-num:last-child { border-radius: 0 8px 8px 0; }

.pager-num:hover, .pager-step:hover { background: var(--surface); color: var(--accent); }

.pager-num.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
    font-weight: 800;
    position: relative;
    z-index: 1;
}

.pager-step svg { width: 15px; height: 15px; }
.pager-step.is-disabled { opacity: .4; }
.pager-gap { border-color: transparent; background: none; color: var(--text-dim); }

/* ícones pequenos nos botões */
.btn svg, .btn-mini svg, .btn-ghost svg { width: 14px; height: 14px; }

.pager-num, .pager-step { min-width: 38px; height: 38px; }
/* Botões com ícone: alinhamento fino */
.btn, .btn-mini { white-space: nowrap; }
.btn svg, .btn-mini svg { flex: 0 0 auto; }
.btn svg + *, .btn-mini svg + * { margin-left: 6px; }
.btn-mini { display: inline-flex; align-items: center; gap: 4px; }
/* Saldo da conta */
.saldo {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--accent-soft);
    border: 1px solid var(--accent-dim);
    color: var(--accent);
    font-family: var(--mono);
    font-size: 10.5px;
    font-weight: 700;
}
.saldo.is-low { background: var(--danger-soft); border-color: var(--danger-dim); color: var(--danger); }
/* ---------- Filtros (padrão único) ---------- */

.filters-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px 14px;
    margin-bottom: 12px;
}

.filters-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
}

.f-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.f-field.f-grow { flex: 1 1 220px; }

.f-field label {
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.f-field input, .f-field select { min-height: 40px; }
.f-actions { display: flex; gap: 6px; margin-left: auto; }

/* ---------- Barra de ações em massa ---------- */

.bulk-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 12px;
    margin-bottom: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.bulk-count { font-size: 12px; color: var(--text-muted); }
.bulk-actions { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }

.f-field, .f-field.f-grow { flex: 1 1 100%; }
.f-actions { margin-left: 0; width: 100%; }
.f-actions .btn { flex: 1; }
.bulk-actions { width: 100%; margin-left: 0; }
.bulk-actions .btn { flex: 1; }
/* Operação a aplicar (barra em massa) */
.bulk-op { display: flex; align-items: flex-end; gap: 6px; margin-left: auto; }
.bulk-op .f-label { align-self: center; font-size: 9.5px; font-weight: 800; letter-spacing: .1em;
    text-transform: uppercase; color: var(--text-muted); margin-right: 2px; }
.bulk-op select { min-height: 36px; width: auto; min-width: 190px; }

.bulk-op { width: 100%; margin-left: 0; flex-wrap: wrap; }
.bulk-op select { flex: 1; min-width: 0; }
/* Pesquisa e operação nas listas de templates */
.list-search {
    min-height: 32px;
    width: 150px;
    padding: 4px 9px;
    font-size: 11.5px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
}

.bulk-op-select {
    min-height: 32px;
    width: auto;
    padding: 4px 8px;
    font-size: 11.5px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
}

.list-search { width: 100%; }
.list-tools { width: 100%; }
/* ---------- Simetria: FAB e conteúdo alinhados ---------- */

.fab {
    right: max(16px, calc((100vw - 1080px) / 2 - 8px));
    bottom: calc(80px + env(safe-area-inset-bottom));
}


/* filtros: sem datas, o campo de pesquisa ocupa o espaço */
.f-field.f-grow { flex: 1 1 320px; }

.bulk-op select { min-width: 210px; }
/* ---------- Cabeçalho de lista (simetria entre cartões) ---------- */

.list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    min-height: 46px;
    padding-bottom: 10px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.list-headline { display: flex; align-items: baseline; gap: 8px; min-width: 0; }

.list-headline h2 {
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0;
}

.list-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.list-search { min-height: 34px; width: 160px; }
.bulk-op-select { min-height: 34px; min-width: 130px; }

/* lista de perfil (dados da conta) */
.profile-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }

.profile-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.profile-list li:last-child { border-bottom: 0; padding-bottom: 0; }

.profile-icon {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    border-radius: 10px;
    background: var(--accent-soft);
    border: 1px solid var(--accent-dim);
    color: var(--accent);
}

.profile-icon svg { width: 16px; height: 16px; }
.profile-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.profile-text strong { font-size: 13px; color: var(--text); }
.profile-text small { font-size: 11.5px; color: var(--text-muted); }

.btn-mini:disabled, .btn-mini-danger:disabled {
    background: var(--surface2);
    border-color: var(--border);
    color: var(--text-dim);
}

.list-head { align-items: flex-start; }
.list-tools { width: 100%; }
.list-search { flex: 1 1 100%; width: 100%; }
.bulk-op-select { flex: 1; }
.profile-list li { align-items: flex-start; }
.profile-list .btn { flex: 0 0 auto; }
/* ---------- Menu compacto da conta ---------- */

.user-menu { position: relative; }

.user-menu > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.user-menu > summary::-webkit-details-marker { display: none; }

.user-menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 60;
    width: 240px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.um-head {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 8px 10px 10px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.um-head strong { font-size: 13px; color: var(--text); }
.um-head span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); }

.um-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--text);
    font: inherit;
    font-size: 12.5px;
    text-decoration: none;
    cursor: pointer;
}

.um-item svg { width: 15px; height: 15px; color: var(--text-muted); flex: 0 0 auto; }
.um-item:hover { background: var(--surface2); color: var(--accent); }
.um-item:hover svg { color: var(--accent); }
.um-sair { padding: 0; }
.um-sair button {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 9px 10px; border: 0; border-radius: 8px; background: none;
    color: var(--text); font: inherit; font-size: 12.5px; cursor: pointer; text-align: left;
}
.um-sair button:hover { background: var(--danger-soft); color: var(--danger); }

/* ---------- Histórico: alinhamento dos itens ---------- */

.hist-item {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.hist-item:hover { background: var(--surface); border-color: var(--accent-dim); }
.hist-item.is-selected { background: var(--surface); border-color: var(--accent); }

.hist-top { min-height: 24px; }
.hist-msg { margin: 2px 0 6px; }
.hist-foot { margin-top: 4px; }
/* ================================================================== *
 *  PADRÃO ÚNICO — o mobile é a base; o desktop mostra o mesmo,
 *  numa coluna centrada. Listas, ferramentas e botões iguais em todo o site.
 * ================================================================== */

[hidden] { display: none !important; }

/* ---------- Coluna única ---------- */

.page { max-width: 640px; }
.nav { display: none; }

.layout,
.layout-wide,
.split { grid-template-columns: minmax(0, 1fr); gap: 14px; }

.split > .card { height: auto; }
.card + .card { margin-top: 0; }
.page > .card + .card { margin-top: 14px; }

.tabbar {
    display: flex;
    padding-left: max(6px, calc((100vw - 640px) / 2));
    padding-right: max(6px, calc((100vw - 640px) / 2));
}

.fab {
    right: max(16px, calc((100vw - 640px) / 2 + 16px));
    bottom: calc(84px + env(safe-area-inset-bottom));
}

/* ---------- Topo ---------- */

.topbar-actions { flex-wrap: wrap; gap: 6px; }
.chip { white-space: nowrap; }

/* ---------- Cabeçalho da página ---------- */

.page-head { flex-direction: column; align-items: stretch; gap: 12px; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Botões ---------- */

.btn, .btn-mini, .link-mini { text-decoration: none; }
.btn:hover, .btn-mini:hover { text-decoration: none; }

.btn-mini {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 10px;
    font-size: 12.5px;
    line-height: 1;
}

.btn-mini svg { width: 14px; height: 14px; }
.btn svg + *, .btn-mini svg + * { margin-left: 0; }

.btn-move { width: 34px; padding: 0; }

/* ---------- Cabeçalho de lista: título, pesquisa, todas, operação ---------- */

.list-head {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    min-height: 0;
}

.list-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 8px;
    width: 100%;
}

.list-tools .list-search,
.list-tools select,
.list-tools .check-all {
    height: 42px;
    min-height: 42px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    font-size: 16px;
}

.list-tools .list-search { flex: 1 1 100%; width: 100%; padding: 0 12px; }
.list-tools select { flex: 1 1 0; min-width: 0; width: auto; padding: 0 10px; }

.list-tools .check-all {
    flex: 0 0 auto;
    gap: 8px;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 700;
    user-select: none;
}

/* ---------- Caixas de seleção ---------- */

.pick-item,
.check-all input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 1.5px solid var(--text-dim);
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    transition: background .12s, border-color .12s;
}

.pick-item:checked,
.check-all input[type="checkbox"]:checked,
.check-all input[type="checkbox"]:indeterminate {
    background: var(--accent);
    border-color: var(--accent);
}

.pick-item:checked::after,
.check-all input[type="checkbox"]:checked::after {
    content: "";
    width: 5px;
    height: 10px;
    margin-top: -2px;
    border: solid var(--on-accent, #0a1206);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.check-all input[type="checkbox"]:indeterminate::after {
    content: "";
    width: 10px;
    height: 2px;
    background: var(--on-accent, #0a1206);
}

/* ---------- Linhas de lista (templates, listas, utilizadores, histórico) ---------- */

.tpl-list, .hist-list { gap: 8px; }

.tpl-item, .hist-item {
    padding: 12px;
    border-radius: 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
}

.tpl-head, .hist-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    margin: 0;
    min-height: 24px;
}

.tpl-head strong { flex: 1 1 0; min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
.tpl-head .pick-item { margin: 0; }

.tpl-actions {
    flex: 1 1 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.tpl-item > :not(.tpl-head) { margin-top: 8px; }

/* conteúdo alinhado com o texto ao lado da caixa de seleção */
.tpl-item:has(> .tpl-head > .pick-item) > :not(.tpl-head),
.hist-item > :not(.hist-top) { margin-left: 30px; }

.tpl-meta, .tpl-no-vars { font-size: 12px; }

/* ---------- Histórico ---------- */

.hist-phones {
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.hist-when { margin-left: 0; flex: 0 0 auto; font-size: 11px; }
.hist-msg { margin: 8px 0 0; font-size: 14px; }
.hist-foot { margin-top: 10px; gap: 6px; }
.hist-owner { font-size: 11px; padding: 3px 9px; }
.hist-tag { font-size: 11px; padding: 3px 10px; }

.pager { margin-top: 14px; }

.hist-owner {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    background: none;
    border: 0;
    padding: 3px 0;
    color: var(--text-muted);
    font-weight: 600;
}

.hist-owner svg { width: 12px; height: 12px; }

/* ---------- Ações de linha: botões quadrados só com ícone ---------- */

.btn-icon {
    width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    flex: 0 0 auto;
}

.btn-icon svg { width: 16px; height: 16px; }

.btn-icon .btn-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.btn-icon { position: relative; }

.tpl-actions {
    flex: 0 1 auto;
    margin-left: auto;
    flex-wrap: nowrap;
    justify-content: flex-end;
}

.tpl-head strong { flex: 1 1 140px; overflow-wrap: break-word; }
.tpl-actions { flex: 0 0 auto; }

/* ---------- Ligações de ação: um só estilo ---------- */

.link-action, .link-mini { font-size: 12.5px; font-weight: 700; color: var(--accent); text-decoration: none; }
.link-action:hover, .link-mini:hover { text-decoration: underline; text-underline-offset: 3px; }

.tabbar {
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    border-top-color: var(--border);
}

html[data-theme="light"] .badge-dry { background: #dbeafe; color: #1e40af; }

/* ---------- Ações só na seleção (templates, listas, utilizadores) ---------- */

.tpl-item .tpl-actions { display: none; }
.tpl-item.is-selected .tpl-actions { display: flex; }

.list-tools .bulk-op-select { display: none; }
.list-tools.has-selection .bulk-op-select { display: inline-block; }

.tpl-item.is-selected { border-color: var(--accent); background: var(--surface); }

/* checkbox alinhado na linha do título */
.tpl-head .pick-item { margin-right: 2px; }

@media (max-width: 599px) {
    .list-tools.has-selection { width: 100%; }
    .bulk-op-select { flex: 1; }
}
/* Nome da variável visível no editor de templates (deixou de fugir) */
.var-row-head .var-caption {
    position: static;
    padding: 0;
    background: none;
    border: 0;
    font-family: var(--mono);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
    color: var(--accent);
}

.var-row { display: flex; flex-direction: column; gap: 8px; }
.var-row-head { display: flex; align-items: center; gap: 8px; }
/* ---------- Modal: corpo com scroll próprio ---------- */

.modal-card { max-height: min(90vh, 820px); }

.modal-head,
.modal-foot { flex: 0 0 auto; }

.modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
}

/* editor de variáveis: nunca empurra os botões para fora */
.var-editor { max-height: none; }
.modal-foot { border-top: 1px solid var(--border); background: var(--surface); }

@media (max-width: 599px) {
    .modal-card { max-height: 92vh; width: 100%; }
    .modal-body { padding: 0 14px; }
    .modal-head, .modal-foot { padding-left: 14px; padding-right: 14px; }
}
/* ---------- Editor de variáveis: uma linha por variável ---------- */

.var-row {
    display: block;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    background: var(--surface2);
}

.var-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.var-row-head .var-caption {
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
    position: static;
    padding: 0;
    background: none;
    border: 0;
}

.var-row-head .var-type,
.var-row-head select {
    width: auto;
    min-width: 150px;
    min-height: 36px;
    padding: 6px 10px;
    font-size: 12px;
}

.var-editor { gap: 6px; }

/* corpo do template mais baixo, sem scroll interno */
#tpl-body { min-height: 86px; max-height: 160px; }

@media (max-width: 599px) {
    .var-row-head { flex-direction: column; align-items: stretch; gap: 6px; }
    .var-row-head .var-type, .var-row-head select { width: 100%; }
}