/* MadTiger CRM — folha de estilos (sem dependências externas) */
:root {
    /* Paleta preto e branco; verde/âmbar/vermelho só para estados */
    --bg: #f4f4f4;
    --surface: #ffffff;
    --surface-2: #fafafa;      /* rodapés de modais, caixas secundárias */
    --border: #e2e2e2;
    --border-strong: #c4c4c4;
    --text: #111111;
    --muted: #6b6b6b;
    --faint: #bbbbbb;
    --accent: #111111;
    --accent-dark: #333333;
    --accent-soft: #ececec;
    --on-accent: #ffffff;      /* texto sobre --accent */
    --hover: #f7f7f7;          /* linhas de tabela */
    --btn-hover: #f0f0f0;
    --input-bg: #ffffff;
    --focus: #b5b5b5;
    --link-underline: rgba(0, 0, 0, .25);
    --column: #ececec;         /* colunas do quadro */
    --column-over: #dcdcdc;
    --bar: #c4c4c4;            /* barras do gráfico */
    --mark: #fde68a;           /* realce na pesquisa */
    --mark-active: #525252;
    --pill-ink: #000000;       /* mistura para o texto das etapas */
    --ok: #15803d;
    --ok-soft: #e8f6ec;
    --ok-border: #bfe5c9;
    --warn: #b45309;
    --warn-soft: #fdf3e2;
    --warn-border: #f5d49a;
    --warn-row: #fffbeb;
    --warn-text: #78350f;
    --warn-title: #92400e;
    --danger: #b91c1c;
    --danger-soft: #fdecec;
    --danger-border: #f3c4c4;
    /* Tipos de cliente (o tipo "Outro" usa a cor normal das etiquetas) */
    --type-clube: #1d4ed8;       --type-clube-soft: #e3ecfd;
    --type-sad: #6d28d9;         --type-sad-soft: #efe8fd;
    --type-associacao: #0f766e;  --type-associacao-soft: #ddf4f0;
    --type-revendedor: #b45309;  --type-revendedor-soft: #fdeedb;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(0, 0, 0, .05);
    color-scheme: light;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Modo escuro: o tema vem de data-theme no <html> (partials/theme-head); só no ecrã, a impressão fica sempre clara */
@media screen {
    :root[data-theme="dark"] {
        /* Cinzentos médios (não preto) e texto mais claro, para mais contraste entre fundo, cartões e texto */
        --bg: #1f2023;
        --surface: #2c2d31;
        --surface-2: #34363a;
        --border: #45474d;
        --border-strong: #63666d;
        --text: #f4f4f5;
        --muted: #b8bac0;
        --faint: #74767d;
        --accent: #f4f4f5;
        --accent-dark: #d6d7da;
        --accent-soft: #3d3f44;
        --on-accent: #18181b;
        --hover: #36383d;
        --btn-hover: #3d3f44;
        --input-bg: #232428;
        --focus: #7a7d85;
        --link-underline: rgba(255, 255, 255, .4);
        --column: #26272b;
        --column-over: #313338;
        --bar: #55585f;
        --mark: #854d0e;
        --mark-active: #a16207;
        --pill-ink: #ffffff;
        --type-clube: #93b4f5;       --type-clube-soft: #1c2a44;
        --type-sad: #c4a8f5;         --type-sad-soft: #2b2342;
        --type-associacao: #6fd3c2;  --type-associacao-soft: #15322e;
        --type-revendedor: #f0b46a;  --type-revendedor-soft: #3a2a17;
        --ok: #4ade80;
        --ok-soft: #12291b;
        --ok-border: #1f4d2e;
        --warn: #fbbf24;
        --warn-soft: #2b2110;
        --warn-border: #5c4415;
        --warn-row: #231c0c;
        --warn-text: #fcd34d;
        --warn-title: #fbbf24;
        --danger: #f87171;
        --danger-soft: #2c1414;
        --danger-border: #5c2323;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4);
        color-scheme: dark;
    }
    :root[data-theme="dark"] .sidebar { border-right: 1px solid var(--border); }
    /* O logótipo é preto: no cartão de login escuro é mostrado a branco */
    :root[data-theme="dark"] .auth .logo { filter: brightness(0) invert(1); }
    :root[data-theme="dark"] .modal::backdrop { background: rgba(0, 0, 0, .7); }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: var(--accent); text-decoration: underline; text-decoration-color: var(--link-underline); text-underline-offset: 2px; }
a:hover { text-decoration-color: currentColor; }
.sidebar a, .brand, .btn, .kcard a, .column .add, .pagination a, a.badge { text-decoration: none; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }

/* Layout */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: #0a0a0a; color: #e5e5e5; padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 4px 10px 20px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand .logo { width: 160px; max-width: 100%; height: auto; display: block; }
/* O logótipo original é preto: no menu escuro é mostrado a branco */
.brand .logo-on-dark { filter: brightness(0) invert(1); }
.brand-sub { font-size: 11px; font-weight: 700; letter-spacing: 3px; color: #fff; opacity: .7; }
.auth .brand-sub { color: var(--text); }
.sidebar a.nav { display: block; padding: 8px 10px; border-radius: 8px; color: #cfcfcf; }
.sidebar a.nav:hover { background: #1f1f1f; color: #fff; }
.sidebar a.nav.active { background: #fff; color: #000; font-weight: 600; }
.sidebar .spacer { flex: 1; }
.sidebar .who { padding: 10px; border-top: 1px solid #262626; font-size: 13px; }
.sidebar .who small { color: #9a9a9a; display: block; }
.sidebar .who form button { background: none; border: 0; color: #fff; text-decoration: underline; text-underline-offset: 2px; opacity: .8; padding: 0; cursor: pointer; font: inherit; margin-top: 6px; }
.sidebar .who form button:hover { opacity: 1; }
.theme-toggle { display: flex; align-items: center; gap: 8px; width: 100%; margin: 0 0 8px; padding: 7px 10px; border-radius: 8px; border: 1px solid #262626; background: none; color: #cfcfcf; font: inherit; font-size: 13px; cursor: pointer; }
.theme-toggle:hover { background: #1f1f1f; color: #fff; }
.theme-toggle svg { width: 16px; height: 16px; flex: none; }
.theme-toggle [hidden] { display: none; }
.main { padding: 26px 32px 60px; max-width: 1280px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 2px; }

/* Cards & grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
/* Numa grelha o espaçamento vem do gap: sem esta regra, o 2.º cartão em diante descia 16px e ficava mais baixo */
.grid > .card + .card { margin-top: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.stack > * + * { margin-top: 16px; }

.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .hint { font-size: 12px; color: var(--muted); }
.up { color: var(--ok); } .down { color: var(--danger); }
/* Painel: cartões que levam à lista, "nada registado" em vez de um 0, e a definição de cada indicador */
a.stat-link { display: block; color: inherit; text-decoration: none; }
a.stat-link:hover { border-color: var(--accent); }
.stat .value.value-none { font-size: 16px; font-weight: 600; color: var(--muted); padding: 5px 0 4px; }
.def { font-size: 12px; color: var(--muted); margin: -6px 0 10px; }
.section-title { margin: 28px 0 10px; font-size: 18px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
tbody tr:hover { background: var(--hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
th.sortable a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
th.sortable a:hover, th.sorted a { color: var(--text); }
th.sortable .sort-icon { font-size: 10px; color: var(--faint); }
th.sorted .sort-icon { color: var(--text); }
.empty { color: var(--muted); text-align: center; padding: 24px; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.4; white-space: nowrap; vertical-align: middle; background: var(--accent-soft); color: var(--muted); }
/* No título da página: centrado com o texto grande e com espaço entre badges */
h1 .badge { margin-left: 4px; position: relative; top: -2px; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.accent { background: var(--accent-soft); color: var(--accent-dark); }
.badge.type-clube { background: var(--type-clube-soft); color: var(--type-clube); }
.badge.type-sad { background: var(--type-sad-soft); color: var(--type-sad); }
.badge.type-associacao { background: var(--type-associacao-soft); color: var(--type-associacao); }
.badge.type-revendedor { background: var(--type-revendedor-soft); color: var(--type-revendedor); }

/* Forms */
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
    width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: var(--input-bg); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); border-color: var(--accent); }
textarea { min-height: 80px; resize: vertical; }
.field { margin-bottom: 14px; }
.field .error { color: var(--danger); font-size: 12px; margin-top: 3px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: auto; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.checks .check { margin: 0; }
.field[hidden] { display: none; }
.contacts-table td { padding: 4px 6px; }
.contacts-table th { padding: 4px 6px; }
.contacts-table td:last-child { width: 1%; white-space: nowrap; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.contact-list li { display: block; }
.contact-view { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.contact-view[hidden], .contact-form[hidden] { display: none; }
.contact-actions { display: flex; gap: 10px; white-space: nowrap; }
.contact-form { border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-top: 8px; background: var(--surface-2); }
.contact-form .field { margin-bottom: 0; }
.contact-form .form-actions { margin-top: 10px !important; }
.contact-form .alert { padding: 6px 10px; margin-bottom: 8px; }
.form-actions { display: flex; gap: 8px; margin-top: 8px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.filters .field { margin: 0; }
.filters input, .filters select { width: auto; min-width: 140px; }
/* Links (ex.: "Limpar") com a mesma altura dos botões, para ficarem alinhados ao centro com "Filtrar" */
.filters .btn.link { padding: 8px 6px; border: 1px solid transparent; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--btn-hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { color: var(--danger); border-color: var(--danger-border); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 500; }
.inline { display: inline; }

/* Alerts */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.alert.success { background: var(--ok-soft); color: var(--ok); border: 1px solid var(--ok-border); }
.alert.error { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger-border); }
.alert ul { margin: 0; padding-left: 18px; }

/* Chart (barras CSS) */
.bars { display: flex; align-items: end; gap: 14px; height: 180px; padding-top: 10px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: end; height: 100%; gap: 6px; }
.bars .bar .fill { width: 100%; max-width: 56px; background: var(--bar); border-radius: 6px 6px 0 0; min-height: 2px; }
.bars .bar.current .fill { background: var(--accent); }
.bars .bar .v { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bars .bar .l { font-size: 12px; color: var(--muted); }

/* Lists */
/* Dossier do cliente */
.file-drop.dragging { outline: 2px dashed var(--accent); outline-offset: -6px; background: var(--hover); }
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.file-item { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; background: var(--surface); }
.file-thumb { aspect-ratio: 4 / 3; background: var(--accent-soft); display: grid; place-items: center; overflow: hidden; }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-ext { font-size: 20px; font-weight: 700; text-transform: uppercase; color: var(--muted); letter-spacing: .5px; }
.file-body { padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.file-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-actions { display: flex; gap: 12px; margin-top: 4px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
/* Badge/botão à direita de uma linha com duas linhas de texto: centrado na vertical, sem esticar nem partir */
.list li > .badge, .list li > .btn { align-self: center; flex-shrink: 0; white-space: nowrap; }
.list li > .badge { line-height: 1.4; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
dl.details { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; margin: 0; }
dl.details dt { color: var(--muted); }
dl.details dd { margin: 0; }

/* Timeline de contactos */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: 0; }
.timeline .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Linhas da venda */
.sale-lines td { padding: 6px; }
.sale-lines select { min-width: 260px; }
.sale-lines input[type=number] { width: 80px; }
.totals { margin-left: auto; width: 300px; }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.totals .grand { font-size: 18px; font-weight: 700; border-top: 1px solid var(--border); padding-top: 8px; margin-top: 4px; }

/* Quadro Kanban (pipeline) */
.board { display: grid; grid-template-columns: repeat(8, minmax(200px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.column { background: var(--column); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 300px; }
.column-head { padding: 10px 12px 8px; border-top: 4px solid var(--stage, #d4d4d4); border-radius: var(--radius) var(--radius) 0 0; }
.column-head .title { color: var(--text); display: flex; justify-content: space-between; align-items: center; font-weight: 700; }
.column-head .count { background: var(--surface); border-radius: 999px; padding: 0 8px; font-size: 12px; color: var(--muted); }
.column-head .sum { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.column-body { flex: 1; padding: 4px 8px 8px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; border-radius: 0 0 var(--radius) var(--radius); transition: background .15s; }
.column-body.over { background: var(--column-over); }
.column .add { margin: 0 8px 8px; text-align: center; padding: 6px; border-radius: 8px; color: var(--muted); border: 1px dashed var(--border-strong); }
.column .add:hover { background: var(--surface); color: var(--accent); }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px; cursor: grab; box-shadow: var(--shadow); }
.kcard:hover { border-color: var(--border-strong); }
.kcard.dragging { opacity: .45; }
.kcard .k-title { font-weight: 600; display: block; color: var(--text); }
.kcard .k-title:hover { color: var(--accent); }
.kcard .k-contact { font-size: 13px; color: var(--muted); }
.kcard .k-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 12px; gap: 6px; }
.kcard .k-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.kcard .k-owner { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: 9px; font-weight: 700; flex: none; }
.kcard .k-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; padding-top: 7px; border-top: 1px dashed var(--border); font-size: 11px; color: var(--muted); }
.kcard .k-meta time { white-space: nowrap; }
.kcard .k-seller { display: inline-flex; align-items: center; gap: 5px; min-width: 0; color: var(--text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kcard { cursor: pointer; }
.kcard:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.kcard.flash { animation: kflash .9s ease-out; }
@keyframes kflash { from { box-shadow: 0 0 0 3px var(--accent); } to { box-shadow: var(--shadow); } }

.kcard .k-items { display: block; color: var(--muted); font-size: 11px; }

/* Produtos da oportunidade */
.items-editor { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 4px; }
.items-table td, .items-table th { padding: 6px 8px; }
.items-table input[type=number] { width: 70px; text-align: right; padding: 4px 6px; }
.items-table tfoot td { border-bottom: 0; padding-top: 10px; }
.items-add { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.items-add input[type=number] { width: 80px; }
.items-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.items-import { display: flex; align-items: center; gap: 10px; }
.items-editor .alert { padding: 8px 12px; margin-bottom: 10px; }
.items-table .row-notes { margin-top: 4px; padding: 4px 8px; font-size: 12px; border-style: dashed; }
.items-table .row-notes:focus { border-style: solid; }
.items-table .row-actions { white-space: nowrap; }
.team-import { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-bottom: 12px; background: var(--surface-2); }
.team-import label { display: block; font-weight: 600; margin-bottom: 6px; }
.team-import textarea { width: 100%; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.team-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.team-models { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.team-file { margin-top: 4px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 12px; }
.chip small { opacity: .7; }
.chip button { border: 0; background: var(--accent-dark); color: var(--on-accent); width: 18px; height: 18px; border-radius: 50%; cursor: pointer; line-height: 1; padding: 0; }
.chip button:hover { background: var(--danger); color: #fff; }
.items-table .row-actions .btn + .btn { margin-left: 10px; }

/* Autocomplete */
.autocomplete { position: relative; flex: 1; min-width: 0; }
.ac-list { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 30px rgba(0, 0, 0, .15); max-height: 280px; overflow-y: auto; }
.ac-list li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.ac-list li.active, .ac-list li[data-i]:hover { background: var(--accent); color: var(--on-accent); }
.ac-list li.active .ac-meta, .ac-list li[data-i]:hover .ac-meta { color: inherit; opacity: .75; }
.ac-list .ac-meta { color: var(--muted); white-space: nowrap; font-size: 12px; }
.ac-list .ac-empty { color: var(--muted); cursor: default; }
.ac-list mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }
.ac-list li.active mark, .ac-list li[data-i]:hover mark { background: var(--mark-active); color: #fff; }
input[readonly] { background: var(--bg); color: var(--muted); }

/* Modal */
.modal { border: 0; border-radius: 14px; padding: 0; width: min(780px, calc(100vw - 32px)); max-height: calc(100vh - 48px); box-shadow: 0 20px 60px rgba(0,0,0,.25); background: var(--surface); color: var(--text); }
.modal::backdrop { background: rgba(0, 0, 0, .55); }
.modal[open] { animation: modal-in .15s ease-out; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.modal form { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.modal-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; padding: 18px 20px 12px; border-bottom: 1px solid var(--border); }
.modal-close { background: none; border: 0; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); padding: 0 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: space-between; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.modal-foot-left { display: flex; gap: 8px; }
.invalid { border-color: var(--danger) !important; background: var(--danger-soft) !important; }
.btn:disabled { opacity: .6; cursor: wait; }

.board-toast { position: fixed; bottom: 18px; right: 18px; background: var(--accent); color: var(--on-accent); padding: 10px 14px; border-radius: 8px; font-size: 13px; opacity: 0; transition: opacity .2s; pointer-events: none; }
.board-toast.show { opacity: 1; }
/* Cor por fase do pipeline */
.stage-novo { --stage: #64748b; }        /* cinza-azulado */
.stage-contactado { --stage: #2563eb; }  /* azul */
.stage-necessidades { --stage: #0891b2; } /* ciano */
.stage-orcamento { --stage: #7c3aed; }    /* roxo */
.stage-proposta { --stage: #c026d3; }     /* magenta */
.stage-negociacao { --stage: #d97706; }   /* âmbar */
.stage-ganho { --stage: #16a34a; }       /* verde */
.stage-perdido { --stage: #dc2626; }     /* vermelho */

/* A cor da fase aparece no topo da coluna, num ponto junto ao nome e na faixa dos cartões */
.column-head .title [data-label] { display: inline-flex; align-items: center; gap: 7px; }
.column-head .title [data-label]::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--stage); }
.column-body .kcard { border-left: 4px solid var(--stage); }
.column-body.over { background: color-mix(in srgb, var(--stage) 12%, var(--column)); }

/* Paginação */
.pagination { display: flex; gap: 4px; margin-top: 16px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 5px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
.pagination .active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.pagination .disabled { color: var(--faint); }

/* Login */
.auth { min-height: 100vh; display: grid; place-items: center; background: #0a0a0a; }
.auth .card { width: 360px; }
.auth .brand { align-items: center; padding: 4px 0 20px; }
.auth .brand .logo { width: 220px; }

@media (max-width: 960px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
    .sidebar .spacer { display: none; }
    .theme-toggle { width: auto; margin: 0 0 6px; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .main { padding: 18px; }
}

/* ---------- <select> com autocomplete (select-autocomplete.js) ---------- */
.select-ac { flex: none; }
.select-ac input { padding-right: 28px; background: var(--input-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23737373' stroke-width='2.5'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4-4'/%3E%3C/svg%3E") no-repeat right 10px center; }
.filters .select-ac input { min-width: 200px; }
.ac-list li.ac-none { color: var(--muted); font-style: italic; }
select.invalid + .select-ac input { border-color: var(--danger) !important; background-color: var(--danger-soft) !important; }

/* ---------- Oportunidades: tabela, detalhe e histórico ---------- */
.stage-pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; vertical-align: middle;
              background: color-mix(in srgb, var(--stage) 12%, var(--surface)); color: color-mix(in srgb, var(--stage) 80%, var(--pill-ink)); }
.stage-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--stage); }
.details { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }
.history { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--border); }
.history-item { position: relative; padding: 0 0 14px 4px; font-size: 13px; }
.history-item::before { content: ""; position: absolute; left: -21px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }
.history-item.type-criada::before { background: var(--accent); }
.history-item.type-eliminada::before { border-color: var(--danger); background: var(--danger); }
.history-item.type-restaurada::before { border-color: var(--ok); background: var(--ok); }
/* Orçamentos */
.history-item.type-criado::before { background: var(--accent); }
.history-item.type-autorizado::before, .history-item.type-restaurado::before { border-color: var(--ok); background: var(--ok); }
.history-item.type-recusado::before, .history-item.type-eliminado::before { border-color: var(--danger); background: var(--danger); }
.history-head time { font-size: 12px; margin-left: 4px; }
.history-changes { margin: 4px 0 0; padding-left: 16px; font-size: 12px; }
.history-changes li { margin: 2px 0; }
.history del { color: var(--muted); }
.history ins { text-decoration: none; font-weight: 600; }
.modal-quotes { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 10px; }
.modal-quotes-head { font-weight: 600; margin-bottom: 6px; }
.modal-quotes ul { list-style: none; margin: 0; padding: 0; }
.modal-quotes li { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center; padding: 5px 0; font-size: 13px; border-bottom: 1px dashed var(--border); }
.modal-quotes li:last-child { border-bottom: 0; }
.order-group { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-top: 12px; }
.order-group-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.order-lines { margin-bottom: 8px; }
.order-lines select { min-width: 160px; }
.order-lines input[type=number] { width: 80px; text-align: right; }
.team-import select { width: auto; min-width: 280px; margin-top: 6px; }
.qualification { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin: 4px 0 14px; }
.qualification summary { cursor: pointer; font-weight: 600; }
.qualification summary .count { font-weight: 500; color: var(--muted); font-size: 12px; margin-left: 4px; }
.qualification[open] summary { margin-bottom: 12px; }
.modal-history { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 10px; }
.modal-history summary { cursor: pointer; font-weight: 600; }
.modal-history summary .count { font-weight: 500; color: var(--muted); }
.modal-history[open] summary { margin-bottom: 10px; }
.modal-history > div { max-height: 260px; overflow-y: auto; margin-bottom: 8px; }

/* ---------- Orçamentos ---------- */
.sidebar a.nav .nav-count { float: right; min-width: 20px; padding: 0 6px; border-radius: 999px; background: #d97706; color: #fff; font-size: 11px; font-weight: 700; line-height: 20px; text-align: center; }
.quote-lines .price-input { width: 95px; text-align: right; padding: 4px 6px; }
.quote-lines td .badge { margin-top: 4px; }
tr.discounted td { background: var(--warn-row); }
.approval-box { margin-top: 14px; padding: 12px 14px; border: 1px solid var(--warn-border); background: var(--warn-soft); border-radius: 8px; color: var(--warn-text); }
.approval-card { border-color: var(--warn-border); background: var(--warn-row); }
.approval-card h2 { color: var(--warn-title); }

@media print {
    .sidebar, .no-print, .theme-toggle { display: none !important; }
    .app { display: block; }
    .card { border: 0; box-shadow: none; }
}
