/* ============================================================
   SISTEMA DE METAS — tema claro (branco, preto, azul Tiffany)
   Todas as cores são variáveis: um tema escuro futuro só redefine :root.
   ============================================================ */
:root {
    --bg:          #F5F7F7;
    --surface:     #FFFFFF;
    --surface-2:   #F5F7F7;
    --border:      #E1E7E8;
    --border-2:    #CBD4D8;
    --line:        #EEF2F3;

    --ink:         #111417;   /* preto da marca */
    --text-2:      #4B5560;   /* cinza-azulado */
    --muted:       #5E6A75;

    --tiffany:      #81D8D0;  /* azul Tiffany: preenchimentos, destaques */
    --tiffany-mid:  #2BA89F;  /* barras de progresso */
    --tiffany-soft: #E6F6F4;
    --tiffany-tint: #C9EEE9;
    --teal:         #086B67;  /* texto e botões sobre branco */
    --teal-hover:   #054845;

    --emerald:      #0E7A55;  /* dinheiro garantido */
    --emerald-soft: #E2F3EA;
    --lost:         #B8C1C8;  /* deixado na mesa */
    --warn:         #9A5B00;
    --warn-soft:    #FFF4E0;
    --danger:       #B3263F;
    --danger-soft:  #FCEBEE;

    --side-bg:     #111417;
    --side-text:   #C9D1D6;
    --side-muted:  #A7B0B7;
    --side-line:   #262B30;

    --radius:      14px;
    --radius-sm:   10px;
    --shadow:      0 1px 2px rgba(17,20,23,.04);
    --font:        'DM Sans', system-ui, sans-serif;
    --font-title:  'Syne', 'DM Sans', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.45;
    background: var(--bg);
    color: var(--ink);
}
a { color: var(--teal); }
a:hover { color: var(--teal-hover); }
h1, h2, h3 { font-family: var(--font-title); margin: 0; }
img { max-width: 100%; }

/* ---------- Estrutura ---------- */
.app { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side {
    flex: 1 1 230px; max-width: 260px;
    background: var(--side-bg); color: var(--side-text);
    display: flex; flex-direction: column;
}
.side-brand { display: flex; align-items: center; gap: 12px; padding: 22px 22px 18px; border-bottom: 1px solid var(--side-line); }
.side-logo {
    width: 38px; height: 38px; border-radius: 10px; background: var(--tiffany); color: var(--ink);
    display: flex; align-items: center; justify-content: center; font-family: var(--font-title); font-weight: 800; flex-shrink: 0;
    overflow: hidden;
}
.side-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.side-brand strong { display: block; font-family: var(--font-title); font-size: 14px; color: #E8ECEE; }
.side-brand span { font-size: 12px; color: var(--side-muted); }
.side-user { display: flex; align-items: center; gap: 10px; padding: 14px 22px; border-bottom: 1px solid var(--side-line); }
.side-user .avatar { background: var(--tiffany-soft); color: var(--teal); }
.side-user strong { display: block; font-weight: 500; color: #E8ECEE; }
.side-user span { font-size: 11px; color: var(--side-muted); text-transform: uppercase; letter-spacing: .5px; }
.side-unidade { padding: 12px 22px; border-bottom: 1px solid var(--side-line); }
.side-unidade label { font-size: 11px; color: var(--side-muted); text-transform: uppercase; letter-spacing: .5px; display: block; margin-bottom: 6px; }
.side-unidade select {
    width: 100%; min-height: 40px; background: #1C2126; color: #E8ECEE; border: 1px solid #333A40;
    border-radius: 8px; padding: 0 10px; font: inherit;
}
.side-nav { padding: 10px 0; display: flex; flex-direction: column; flex: 1; }
.side-nav .sec { padding: 16px 22px 6px; font-size: 11px; font-weight: 600; color: var(--side-muted); text-transform: uppercase; letter-spacing: 1px; }
.side-nav a {
    display: flex; align-items: center; gap: 10px; padding: 10px 22px; min-height: 42px;
    color: var(--side-text); text-decoration: none; border-left: 3px solid transparent;
}
.side-nav a:hover { color: #fff; background: rgba(255,255,255,.04); }
.side-nav a.ativo { color: var(--tiffany); border-left-color: var(--tiffany); background: rgba(129,216,208,.10); }
.side-nav .contador { margin-left: auto; font-size: 11px; padding: 1px 8px; border-radius: 999px; background: #3a2f12; color: #F5C56A; }
.side-foot { padding: 14px 22px; border-top: 1px solid var(--side-line); }
.side-foot a { color: var(--side-muted); text-decoration: none; display: inline-flex; gap: 8px; align-items: center; min-height: 36px; }
.side-foot a:hover { color: #fff; }

.main { flex: 999 1 560px; min-width: 0; padding: 28px 32px 48px; display: flex; flex-direction: column; gap: 20px; }

@media (max-width: 860px) {
    .side { max-width: none; flex-basis: 100%; }
    .side-nav { flex-direction: row; overflow-x: auto; padding: 0 8px; }
    .side-nav .sec { display: none; }
    .side-nav a { border-left: none; border-bottom: 3px solid transparent; white-space: nowrap; padding: 10px 14px; }
    .side-nav a.ativo { border-bottom-color: var(--tiffany); }
    .side-user, .side-foot { display: none; }
    .main { padding: 20px 16px 40px; }
}

/* ---------- Cabeçalho de página ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; }
.page-head .eyebrow { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.page-head h1 { font-size: 26px; font-weight: 700; margin-top: 4px; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.page-head .acoes { display: flex; gap: 10px; flex-wrap: wrap; }
.trilha { font-size: 12px; color: var(--muted); }

/* ---------- Grades ---------- */
.grid { display: grid; gap: 16px; align-items: start; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); }
.grid-form { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); }
.grid-form .cheia { grid-column: 1 / -1; }
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.linha { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.entre { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }

/* ---------- Cartões ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; min-width: 0;
}
.card h2 { font-size: 16px; font-weight: 700; }
.card .sub { font-size: 12px; color: var(--muted); }
.kpi .rot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.kpi .val { font-family: var(--font-title); font-size: 34px; font-weight: 800; line-height: 1.1; }
.kpi .det { color: var(--text-2); font-size: 13px; }
.ponto { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.cor-ganho { color: var(--emerald); } .bg-ganho { background: var(--emerald); }
.cor-jogo  { color: var(--teal); }    .bg-jogo  { background: var(--tiffany); }
.cor-perd  { color: var(--text-2); }  .bg-perd  { background: var(--lost); }
.cor-aviso { color: var(--warn); }
.cor-erro  { color: var(--danger); }
.cor-muted { color: var(--muted); }

.nota { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; }
.nota.tiffany { background: var(--tiffany-soft); border-color: #BFE9E4; }
.nota.verde { background: var(--emerald-soft); border-color: #BFE3CF; }
.nota.aviso { background: var(--warn-soft); border-color: #F0D9A8; color: #5C3A00; }
.nota.erro { background: var(--danger-soft); border-color: #F2C2CB; color: #7A1A2B; }

/* ---------- Botões ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 0 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
    font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn-pri { background: var(--teal); color: #fff; }
.btn-pri:hover { background: var(--teal-hover); color: #fff; }
.btn-sec { background: var(--surface); color: var(--ink); border-color: var(--border-2); font-weight: 500; }
.btn-sec:hover { background: var(--surface-2); color: var(--ink); }
.btn-perigo { background: var(--surface); color: var(--danger); border-color: #F2C2CB; font-weight: 500; }
.btn-perigo:hover { background: var(--danger-soft); color: var(--danger); }
.btn-txt { background: none; border: none; color: var(--teal); padding: 0 6px; min-height: 36px; font-weight: 600; }
.btn-pq { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn-larga { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Formulários ---------- */
label.campo { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 500; color: var(--ink); }
label.campo small { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number],
input[type=date], input[type=search], select, textarea {
    min-height: 44px; border: 1px solid var(--border-2); border-radius: 8px; padding: 0 12px;
    font: inherit; font-size: 14px; color: var(--ink); background: #fff; width: 100%;
}
textarea { padding: 10px 12px; min-height: 90px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--tiffany); outline-offset: 0; border-color: var(--teal); }
input[type=file] { font-size: 13px; }
fieldset { border: none; padding: 0; margin: 0; }
legend { font-size: 13px; font-weight: 500; margin-bottom: 8px; padding: 0; }
.opcoes { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.opcao {
    min-height: 48px; border: 1px solid var(--border-2); border-radius: 8px; display: flex; align-items: center; gap: 8px;
    padding: 0 12px; cursor: pointer; background: #fff;
}
.opcao:has(input:checked) { border: 2px solid var(--teal); background: var(--tiffany-soft); }
.check { display: flex; align-items: center; gap: 8px; min-height: 36px; }

/* ---------- Tabelas ---------- */
.tabela-box { overflow-x: auto; }
table.tabela { width: 100%; border-collapse: collapse; }
.tabela th { font-size: 12px; color: var(--muted); font-weight: 500; text-align: left; padding: 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tabela td { padding: 11px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tabela tr:last-child td { border-bottom: none; }
.tabela .num { text-align: right; white-space: nowrap; }
.tabela tbody tr:hover { background: #FAFBFB; }

/* ---------- Selos ---------- */
.selo { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 3px 10px; border-radius: 999px; font-weight: 500; white-space: nowrap; }
.selo-tiffany { background: var(--tiffany-soft); color: var(--teal); }
.selo-verde { background: var(--emerald-soft); color: var(--emerald); }
.selo-cinza { background: #EEF2F3; color: var(--text-2); }
.selo-aviso { background: var(--warn-soft); color: var(--warn); }
.selo-erro { background: var(--danger-soft); color: var(--danger); }
.selo-preto { background: var(--ink); color: var(--tiffany); }

.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--tiffany-soft); color: var(--teal); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; flex-shrink: 0; }

/* ---------- Progresso ---------- */
.barra { position: relative; height: 10px; background: #E6ECEE; border-radius: 5px; }
.barra > i { display: block; height: 100%; border-radius: 5px; background: var(--tiffany-mid); max-width: 100%; }
.barra > i.ok { background: var(--emerald); }
.barra .proj { position: absolute; top: -4px; width: 2px; height: 18px; background: var(--ink); }
.empilhada { display: flex; height: 22px; border-radius: 6px; overflow: hidden; gap: 2px; background: #EEF2F3; }
.empilhada > i { display: block; height: 100%; }
.legenda { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.legenda .rot { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legenda .rot i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.legenda .v { font-weight: 700; font-size: 18px; margin-top: 4px; }

.escada { position: relative; padding-top: 4px; }
.escada .faixas { display: flex; height: 30px; border-radius: 6px; overflow: hidden; gap: 2px; font-size: 12px; font-weight: 600; }
.escada .faixas > div { display: flex; align-items: center; justify-content: center; padding: 0 6px; white-space: nowrap; overflow: hidden; }
.escada .marca { position: absolute; top: 0; width: 3px; height: 38px; background: var(--ink); border-radius: 2px; }

.meta-item { display: flex; flex-direction: column; gap: 8px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.meta-item:last-child { border-bottom: none; padding-bottom: 0; }

.funil-linha { display: grid; grid-template-columns: 96px minmax(0, 1fr) 56px; align-items: center; gap: 12px; }
.funil-linha .trilho { height: 26px; background: var(--surface-2); border-radius: 5px; }
.funil-linha .trilho > i { display: flex; align-items: center; height: 26px; border-radius: 5px; background: var(--tiffany-tint); padding-left: 10px; font-weight: 600; font-style: normal; min-width: 32px; }

.item-lista { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item-lista:last-child { border-bottom: none; }
.item-lista .t { font-weight: 500; }
.item-lista .s { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- Funil em colunas ---------- */
.kanban-box { overflow-x: auto; padding-bottom: 8px; }
.kanban { display: grid; grid-template-columns: repeat(6, minmax(230px, 1fr)); gap: 12px; min-width: 1420px; }
.kcol { background: #EEF2F3; border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 10px; min-height: 420px; }
.kcol-head { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 4px 8px; border-bottom: 3px solid var(--lost); }
.kcol-head strong { font-weight: 700; }
.kcard { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.kcard .nome { font-weight: 600; }
.kcard .acoes { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.kcard form { display: inline; }

/* ---------- Abas ---------- */
.abas { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.abas a { min-height: 44px; display: inline-flex; align-items: center; padding: 0 14px; color: var(--text-2); text-decoration: none; border-bottom: 3px solid transparent; }
.abas a.ativo { color: var(--ink); font-weight: 600; border-bottom-color: var(--tiffany); }

/* ---------- Mensagens ---------- */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); font-weight: 500; }
.flash-sucesso { background: var(--emerald-soft); color: #0A5A3F; border: 1px solid #BFE3CF; }
.flash-erro { background: var(--danger-soft); color: #7A1A2B; border: 1px solid #F2C2CB; }
.flash-aviso { background: var(--warn-soft); color: #5C3A00; border: 1px solid #F0D9A8; }

.vazio { text-align: center; color: var(--muted); padding: 24px 12px; }

/* ---------- Diálogo ---------- */
dialog { border: none; border-radius: var(--radius); padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(17,20,23,.25); }
dialog::backdrop { background: rgba(17,20,23,.45); }
dialog .dlg { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
dialog .dlg-head { display: flex; justify-content: space-between; align-items: center; }
dialog .dlg-head h2 { font-size: 18px; }
dialog .dlg-foot { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg); }
.login-card { width: min(400px, 100%); }
.login-card .marca { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }

/* ---------- Utilidades ---------- */
.dir { text-align: right; }
.forte { font-weight: 700; }
.grande { font-family: var(--font-title); font-size: 28px; font-weight: 800; }
.pq { font-size: 12px; }
.oculto { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
hr.div { border: none; border-top: 1px solid var(--border); margin: 0; }

/* ---------- v2.1: contas a receber, tarefas, ficha da cliente ---------- */
.btn-link { background: none; border: none; padding: 0; font: inherit; color: var(--teal); text-decoration: underline; cursor: pointer; }
.timeline { display: flex; flex-direction: column; }
.timeline .ev { display: grid; grid-template-columns: 34px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.timeline .ev:last-child { border-bottom: none; }
.timeline .ic { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2, #EEF2F3); display: flex; align-items: center; justify-content: center; color: var(--text-2); }
.timeline .ic.t-venda { background: #E2F3EA; color: var(--emerald); }
.timeline .ic.t-orc { background: #E6F6F4; color: var(--teal); }
.timeline .ic.t-tarefa { background: #FFF4E0; color: var(--warn); }
.timeline .quando { font-size: 12px; color: var(--muted); }
.tarefa { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tarefa:last-child { border-bottom: none; }
.tarefa .feita-btn { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--tiffany); background: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; color: transparent; padding: 0; }
.tarefa .feita-btn:hover, .tarefa .feita-btn:focus-visible { background: var(--tiffany); color: var(--ink, #111417); }
.tarefa .t { font-weight: 600; }
.tarefa .s { font-size: 13px; color: var(--muted); }
.tarefa.atrasada .s .quando { color: var(--danger); font-weight: 600; }
.termo-texto { white-space: pre-line; line-height: 1.6; font-size: 14px; border: 1px solid var(--line); border-radius: 8px; padding: 14px; background: #fff; max-height: 320px; overflow: auto; }
#tab-formas td { white-space: normal; }
#tab-formas td.num { text-align: right; min-width: 9em; }
.side-foot { display: flex; flex-direction: column; gap: 4px; }
.side-foot a.side-versao { display: block; font-size: 12px; min-height: 0; line-height: 1.45; }
.side-foot a.side-versao span { display: block; color: var(--side-muted); opacity: .8; }
.side-foot a.side-versao .cor-aviso { color: #F0C674; opacity: 1; }
.release { padding: 16px 0; border-bottom: 1px solid var(--line); }
.release:last-child { border-bottom: none; }
.release ul { margin: 8px 0 0; padding-left: 20px; line-height: 1.6; }

/* ---------- v2.4: marca Control Clin ---------- */
.side-logo img.sem-fundo { background: transparent; }
.side-foot a.side-versao .side-produto { display: flex; align-items: center; gap: 6px; color: #E8ECEE; font-family: var(--font-title); font-size: 13px; margin-bottom: 2px; }
.side-foot a.side-versao .side-produto img { width: 18px; height: 18px; }
.login-logo { text-align: center; margin-bottom: 8px; }
.login-logo img { width: min(260px, 80%); height: auto; display: block; margin: 4px auto 8px; }

/* ---------- v2.5: grupos recolhíveis no menu ---------- */
.nav-grupo summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; padding: 16px 22px 6px; font-size: 11px; font-weight: 600; color: var(--side-muted); text-transform: uppercase; letter-spacing: 1px; user-select: none; }
.nav-grupo summary::-webkit-details-marker { display: none; }
.nav-grupo summary::after { content: ''; width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform .15s; margin-right: 2px; }
.nav-grupo[open] summary::after { transform: rotate(45deg); }
.nav-grupo summary:hover, .nav-grupo summary:focus-visible { color: #fff; }
@media (max-width: 860px) {
    .nav-grupo { display: flex; }
    .nav-grupo summary { padding: 10px 14px; white-space: nowrap; }
}

/* combo de busca (cliente na venda direta) */
.combo { position: relative; }
.combo-lista { position: absolute; left: 0; right: 0; top: 100%; z-index: 30; margin-top: 4px; background: var(--surface); border: 1px solid var(--border-2); border-radius: 10px; box-shadow: 0 10px 30px rgba(17,20,23,.12); max-height: 300px; overflow-y: auto; }
.combo-lista button { display: block; width: 100%; text-align: left; background: none; border: none; border-bottom: 1px solid var(--line); padding: 9px 12px; font: inherit; cursor: pointer; }
.combo-lista button:last-child { border-bottom: none; }
.combo-lista button:hover, .combo-lista button[aria-selected="true"] { background: var(--tiffany-soft); }
.combo-lista button strong { display: block; font-weight: 600; }
.combo-lista button span { font-size: 12px; color: var(--muted); }
