/* Precificador Odontologico — sistema de design proprio, sem dependencia externa.
   Paleta: teal clinico, neutros quentes, sem vermelho agressivo.
   Regras: 1) tudo em rem, 2) contraste AA, 3) nada de sombra pesada,
   4) nenhum espaçamento critico vem de style="" na view — tudo aqui. */

:root {
    --teal-900: #0b3b3c;
    --teal-800: #10514f;
    --teal-700: #176b66;
    --teal-600: #1f8a80;
    --teal-500: #2aa79a;
    --teal-100: #e3f4f1;
    --teal-50: #f2faf8;

    --sand-50: #fbf9f6;
    --sand-100: #f5f1ea;
    --sand-200: #e7e0d5;

    --ink-900: #1b2320;
    --ink-700: #3b4642;
    --ink-500: #6b7570;
    --ink-300: #98a29d;

    --ok-700: #1c6b45;
    --ok-100: #e2f5ea;
    --warn-700: #8a5a12;
    --warn-100: #fdf0d9;
    --danger-700: #9a2f2f;
    --danger-100: #fbe7e4;

    --radius: 12px;
    --radius-sm: 8px;
    --border: 1px solid var(--sand-200);
    --shadow: 0 1px 2px rgba(27, 35, 32, .06), 0 8px 24px -18px rgba(27, 35, 32, .35);
    --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;

    /* Larguras: a pagina acompanha telas grandes e nao vira coluna estreita. */
    --page-max: 1440px;
    --page-pad: clamp(1rem, 2.2vw, 2.25rem);
    --field-gap: 1rem 1.15rem;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 0.9375rem;
    line-height: 1.55;
    color: var(--ink-900);
    background: var(--sand-50);
}

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5rem; font-weight: 650; }
h1 { font-size: clamp(1.35rem, 1.1rem + .7vw, 1.65rem); letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--teal-700); text-decoration: none; }
a:hover { text-decoration: underline; }
small { color: var(--ink-500); }

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

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    background: var(--teal-900);
    color: #fff;
    border-bottom: 3px solid var(--teal-600);
}

.topbar-inner {
    max-width: var(--page-max);
    margin: 0 auto;
    padding: .6rem var(--page-pad);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.brand {
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #fff;
    display: flex;
    align-items: center;
    gap: .55rem;
    font-size: 1rem;
}
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 1.6rem; height: 1.6rem;
    border-radius: 6px;
    background: linear-gradient(140deg, var(--teal-500), var(--teal-600));
    display: grid; place-items: center;
    font-size: .8rem; font-weight: 800;
}

.brand-text { display: grid; gap: .05rem; line-height: 1.15; }
.brand-name { font-weight: 700; }
.brand-tag {
    font-size: .64rem;
    font-weight: 500;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .5);
}

/* --- Ambientes: Resultado x Definicoes x Controle ------------------------ */

.env-tabs {
    display: flex;
    align-items: stretch;
    gap: .3rem;
    margin-left: auto;
    flex-wrap: wrap;
}
.env-tab {
    display: grid;
    gap: .05rem;
    padding: .3rem .75rem;
    border: 1px solid transparent;
    border-radius: 8px;
    color: rgba(255, 255, 255, .72);
}
.env-tab:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.env-tab.is-active { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .2); color: #fff; }
.env-tab-label { font-size: .875rem; font-weight: 600; }
.env-tab-hint { font-size: .68rem; color: rgba(255, 255, 255, .55); }
.env-tab.is-active .env-tab-hint { color: rgba(255, 255, 255, .8); }
.topbar-user { margin-left: 0; }

.subbar { background: var(--teal-800); border-top: 1px solid rgba(255, 255, 255, .08); }
.subbar-inner {
    max-width: var(--page-max);
    margin: 0 auto;
    padding: .28rem var(--page-pad);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.subnav { display: flex; gap: .12rem; flex-wrap: wrap; }
.subnav a {
    color: rgba(255, 255, 255, .72);
    padding: .3rem .7rem;
    border-radius: 6px;
    font-size: .84rem;
    white-space: nowrap;
}
.subnav a:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.subnav a.is-active { background: rgba(255, 255, 255, .16); color: #fff; font-weight: 600; }
.subbar-jump {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    padding: .22rem .5rem;
    border-radius: 6px;
    color: rgba(255, 255, 255, .85);
    white-space: nowrap;
}
.subbar-jump:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.subbar-jump-label { display: block; font-size: .8rem; font-weight: 600; }
.subbar-jump-hint { display: block; font-size: .66rem; color: rgba(255, 255, 255, .55); }
@media (max-width: 720px) {
    .env-tab-hint, .subbar-jump-hint { display: none; }
    .subbar-inner { flex-wrap: wrap; gap: .2rem; }
}

.page {
    width: 100%;
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 1.75rem var(--page-pad) 3.5rem;
    flex: 1;
}

/* --- Cabecalho padrao de pagina (trilha + ambiente + proposito) --------- */

.page-head { margin-bottom: 1.15rem; }
.page-head-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem 1.5rem;
    flex-wrap: wrap;
}
.page-head-text { min-width: 0; }
.page-head h1 { margin: 0 0 .25rem; }
.page-intro { margin: 0; color: var(--ink-500); max-width: 78ch; }

.crumbs {
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-wrap: wrap;
    margin-bottom: .55rem;
    font-size: .78rem;
    color: var(--ink-500);
}
.crumbs a { color: var(--ink-500); }
.crumbs a:hover { color: var(--teal-700); }
.crumbs-sep { color: var(--ink-300); }

/* Selo do ambiente: deixa explicito se a tela e resultado ou definicao. */
.kind {
    display: inline-block;
    margin-bottom: .4rem;
    padding: .1rem .5rem;
    border: 1px solid;
    border-radius: 999px;
    font-size: .66rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
}
.kind[data-kind="Resultado"] { color: var(--teal-800); background: var(--teal-50); border-color: #cbe7e2; }
.kind[data-kind="Definicao"] { color: #8a5a12; background: #fdf6e7; border-color: #f0dfb8; }
.kind[data-kind="Controle"] { color: var(--ink-700); background: var(--sand-100); border-color: var(--sand-200); }

/* --- Faixa de contexto: de onde vem / para onde vai --------------------- */

.context-note {
    display: flex;
    align-items: center;
    gap: .65rem .85rem;
    flex-wrap: wrap;
    margin-bottom: 1.15rem;
    padding: .55rem .85rem;
    border: 1px solid var(--sand-200);
    border-radius: var(--radius-sm);
    background: var(--sand-50);
}
.context-note.is-out { background: var(--teal-50); border-color: #cbe7e2; }
.context-tag {
    flex: none;
    padding: .08rem .45rem;
    border-radius: 999px;
    background: #f0dfb8;
    color: #8a5a12;
    font-size: .66rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    white-space: nowrap;
}
.context-note.is-out .context-tag { background: #cbe7e2; color: var(--teal-800); }
.context-text { flex: 1 1 20rem; margin: 0; font-size: .85rem; color: var(--ink-700); }
.context-link { font-size: .82rem; font-weight: 600; white-space: nowrap; }

/* --- Mapa do fluxo (Painel) -------------------------------------------- */

.flow-map { display: flex; align-items: stretch; gap: .5rem; flex-wrap: wrap; }
.flow-step {
    flex: 1 1 15rem;
    display: flex;
    gap: .7rem;
    padding: .8rem .9rem;
    border: 1px solid var(--sand-200);
    border-radius: var(--radius-sm);
    background: #fff;
    color: inherit;
}
a.flow-step:hover { border-color: var(--teal-500); box-shadow: var(--shadow); text-decoration: none; }
.flow-num {
    flex: none;
    width: 1.7rem;
    height: 1.7rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--teal-900);
    color: #fff;
    font-size: .8rem;
    font-weight: 700;
}
.flow-body { display: grid; gap: .12rem; min-width: 0; }
.flow-label { font-weight: 650; }
.flow-desc { font-size: .8rem; color: var(--ink-500); }
.flow-state { font-size: .75rem; font-weight: 600; color: #8a5a12; }
.flow-state.is-ok { color: var(--teal-700); }
.flow-arrow { display: grid; place-items: center; color: var(--ink-300); }
@media (max-width: 860px) {
    .flow-arrow { display: none; }
}

/* --- Primeiros passos (Painel) ----------------------------------------- */

.first-steps-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.first-step {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem .85rem;
    border: 1px solid var(--sand-200);
    border-radius: var(--radius-sm);
    background: #fff;
}
.first-step.is-done { background: var(--teal-50); border-color: #cbe7e2; }
.first-step-mark {
    flex: none;
    width: 1.55rem;
    height: 1.55rem;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--sand-100);
    color: var(--ink-500);
    font-size: .78rem;
    font-weight: 700;
}
.first-step.is-done .first-step-mark { background: var(--teal-700); color: #fff; }
.first-step-body { flex: 1 1 auto; min-width: 0; }
.first-step-label { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; font-weight: 650; }
.first-step-hint { margin: .1rem 0 0; font-size: .78rem; color: var(--ink-500); }
@media (max-width: 620px) {
    .first-step { align-items: flex-start; flex-wrap: wrap; }
}

.footer {
    border-top: var(--border);
    padding: 1.1rem var(--page-pad);
    color: var(--ink-300);
    font-size: .8rem;
    text-align: center;
}

/* --- Cartoes e grades --------------------------------------------------- */

.card {
    background: #fff;
    border: var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem clamp(1rem, 1.5vw, 1.5rem);
    margin-bottom: 1.15rem;
}
.card > :last-child { margin-bottom: 0; }
.card-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .5rem 1.25rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.card-header h2, .card-header h3 { margin: 0; }
.card-note { color: var(--ink-500); font-size: .85rem; margin: .25rem 0 0; max-width: 82ch; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.stat {
    background: #fff;
    border: var(--border);
    border-radius: var(--radius-sm);
    padding: .95rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}
.stat-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-500); }
.stat-value { font-size: 1.4rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat-hint { font-size: .8rem; color: var(--ink-500); }
.stat.is-accent { background: var(--teal-50); border-color: #cbe7e2; }

/* --- Tabelas ------------------------------------------------------------ */

.table-wrap { overflow-x: auto; max-width: 100%; margin: 0 -.35rem; padding: 0 .35rem; }
table.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th, .table td { padding: .6rem .65rem; text-align: left; border-bottom: 1px solid var(--sand-100); vertical-align: middle; }
.table th {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--ink-500);
    font-weight: 650;
    white-space: nowrap;
    vertical-align: bottom;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--sand-50); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td.strong { font-weight: 650; }
.table td.actions, .table th:last-child.actions { vertical-align: middle; }
.table tfoot td { border-top: 2px solid var(--sand-200); font-weight: 650; }
.table .muted { color: var(--ink-500); }
.table td.tight, .table th.tight { width: 1%; white-space: nowrap; }

/* Coluna-chave fixa na rolagem horizontal (tabela de precos). */
.table.sticky-first th:first-child,
.table.sticky-first td:first-child {
    position: sticky;
    left: 0;
    background: #fff;
    z-index: 1;
}
.table.sticky-first tbody tr:hover td:first-child { background: var(--sand-50); }
.table.sticky-first th:first-child { background: #fff; }

/* --- Botoes ------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .52rem .9rem;
    border-radius: 8px;
    border: 1px solid transparent;
    background: var(--teal-700);
    color: #fff;
    font: inherit;
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    line-height: 1.2;
    white-space: nowrap;
}
.btn:hover { background: var(--teal-800); text-decoration: none; color: #fff; }
.btn:focus-visible { outline: 3px solid var(--teal-100); outline-offset: 1px; }
.btn.secondary { background: #fff; color: var(--ink-700); border-color: var(--sand-200); }
.btn.secondary:hover { background: var(--sand-100); color: var(--ink-900); }
.btn.ghost { background: transparent; color: var(--teal-700); border-color: transparent; }
.btn.ghost:hover { background: var(--teal-50); }
.btn.danger { background: #fff; color: var(--danger-700); border-color: #eccfcb; }
.btn.danger:hover { background: var(--danger-100); }
.btn.small { padding: .32rem .6rem; font-size: .8rem; }
.btn.block { width: 100%; }
.btn.on-dark { color: #9dd3cb; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.actions.is-end { justify-content: flex-end; }
.actions.is-spread { justify-content: space-between; }
.actions.is-tight { gap: .35rem; flex-wrap: nowrap; }
.inline-form { display: inline; }

/* Barra de acoes do rodape de um formulario: separa dos campos. */
.form-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--sand-100);
}
.form-actions .card-note { margin: 0 0 0 auto; }

/* --- Formularios: grade de 12 colunas ----------------------------------- */

/*
 * Cada filho declara a largura desejada (.c3, .c4, .c6...). Isso substitui o
 * antigo auto-fit, que decidia o numero de colunas sozinho e embaralhava
 * campos de assuntos diferentes na mesma linha. Abaixo de 640px tudo vira
 * uma coluna, porque campo estreito no celular e pior que campo empilhado.
 */
.form-grid {
    display: grid;
    gap: var(--field-gap);
    grid-template-columns: repeat(12, minmax(0, 1fr));
    align-items: start;
}
.form-grid > * { grid-column: 1 / -1; }
.form-grid + .form-grid { margin-top: .35rem; }

@media (min-width: 640px) {
    .form-grid > .c2 { grid-column: span 2; }
    .form-grid > .c3 { grid-column: span 3; }
    .form-grid > .c4 { grid-column: span 4; }
    .form-grid > .c5 { grid-column: span 5; }
    .form-grid > .c6 { grid-column: span 6; }
    .form-grid > .c7 { grid-column: span 7; }
    .form-grid > .c8 { grid-column: span 8; }
    .form-grid > .c9 { grid-column: span 9; }
    .form-grid > .c10 { grid-column: span 10; }
    .form-grid > .c11 { grid-column: span 11; }
}

.field { display: flex; flex-direction: column; gap: .32rem; min-width: 0; }
.field > label, .field-label { font-size: .82rem; font-weight: 600; color: var(--ink-700); }
.field .help { font-size: .78rem; color: var(--ink-500); line-height: 1.45; }

/*
 * Nota dentro da grade: orienta o campo ao lado sem ocupar o lugar de um
 * campo. Antes usava a classe .field e ficava com a altura de um input vazio,
 * o que fazia a pessoa procurar o que preencher ali.
 */
.field-note {
    padding: .55rem .75rem;
    border-left: 3px solid #cbe7e2;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: var(--teal-50);
}
.field-note .field-label { display: block; margin-bottom: .1rem; font-size: .78rem; color: var(--teal-800); }
.field-note .help { margin: 0; }

/* Filtro de lista longa (ficha tecnica de insumos). */
.list-filter { margin-bottom: .6rem; }
.list-filter input { max-width: 22rem; }
.list-filter-empty { padding: .5rem .1rem; font-size: .84rem; color: var(--ink-500); }

/* O atributo hidden precisa vencer os display:flex das grades. */
[hidden] { display: none !important; }

/* Horario incoerente na agenda: o total fica "—" em vez de numero negativo. */
.table td.is-invalid { color: var(--danger-700); font-weight: 650; }
.field.is-num input { text-align: right; font-variant-numeric: tabular-nums; }
/* Campo que acompanha um botao (ex.: filtro) alinha a base com o botao. */
.form-inline { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; }
.form-inline .field { flex: 1 1 16rem; }

/*
 * Importacao por colar planilha: a colagem e codigo, nao prosa. Fonte
 * monoespacada e rolagem horizontal propria para a linha longa nao empurrar a
 * pagina; o modelo precisa copiar igual ao que a planilha espera.
 */
.import-text { font-family: var(--mono); font-size: .82rem; min-height: 9rem; resize: vertical; }
.sample-table {
    font-family: var(--mono);
    font-size: .78rem;
    line-height: 1.6;
    background: var(--sand-50);
    border: var(--border);
    border-radius: var(--radius-sm);
    padding: .7rem .85rem;
    overflow-x: auto;
    white-space: pre;
}

input[type="text"], input[type="search"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="time"], select, textarea {
    width: 100%;
    padding: .52rem .65rem;
    border: 1px solid var(--sand-200);
    border-radius: 8px;
    background: #fff;
    font: inherit;
    font-size: .9rem;
    color: var(--ink-900);
    transition: border-color .12s ease, box-shadow .12s ease;
}
input:hover, select:hover { border-color: #d7cec0; }
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--teal-500);
    box-shadow: 0 0 0 3px var(--teal-100);
}
input[type="checkbox"] { width: 1rem; height: 1rem; accent-color: var(--teal-700); }
.checkbox { display: flex; align-items: center; gap: .45rem; font-size: .88rem; }
.field-row { display: flex; gap: .5rem; align-items: center; }
.field-row > input { flex: 1 1 auto; min-width: 0; }

/* --- Agrupamento de campos (fieldset) ----------------------------------- */

.fieldset { border: 0; margin: 0 0 1.5rem; padding: 0; min-width: 0; }
.fieldset:last-child { margin-bottom: 0; }
.fieldset-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .35rem 1rem;
    flex-wrap: wrap;
    padding-bottom: .55rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--sand-100);
}
.fieldset-head h3 { margin: 0; font-size: .95rem; letter-spacing: .01em; }
.fieldset-head .card-note { margin: 0; font-size: .82rem; }

/* --- Tabelas editaveis (custos, depreciacao, pagamentos) ---------------- */

/*
 * A grade de divs antiga (.row-edit) alinhava cabecalho e campos por fracao
 * fixa e desalinhava quando o texto crescia. Como tabela, cabecalho e campo
 * compartilham as mesmas colunas por construcao. O <form> de cada linha vive
 * fora da tabela e os campos apontam para ele com o atributo form="".
 */
.form-table td { padding: .45rem .5rem; }
.form-table th { padding-top: 0; }
.form-table input[type="text"],
.form-table input[type="number"],
.form-table select { padding: .42rem .55rem; font-size: .875rem; }
.form-table .field { gap: 0; }
.form-table .col-money input { text-align: right; font-variant-numeric: tabular-nums; }
.form-table td.actions { white-space: nowrap; }
.form-table tr.is-off td { opacity: .62; }

/* Larguras de coluna: valem para qualquer tabela (a .form-table tambem e .table). */
.table .col-ordem { width: 6rem; }
.table .col-taxa { width: 9rem; }
.table .col-valor { width: 11rem; }
.table .col-check { width: 4.5rem; text-align: center; }
.table .col-check input { width: 1.05rem; height: 1.05rem; }
.table .col-hora { width: 9rem; }
.table .col-pausa { width: 8rem; }
.table .col-horas { width: 7rem; }
.table .col-recorrencia { width: 10rem; }
.table .col-vida { width: 10rem; }
.table .col-qtd { width: 11rem; }
.table .col-unidade { width: 7rem; }
.table .col-custo { width: 8rem; }

/* Coluna de acoes: largura fixa para os botoes nunca quebrarem a linha. */
.table .col-acoes { width: 9.5rem; white-space: nowrap; }
.table .col-acoes--wide { width: 15rem; }

/* Painel recolhivel de cadastro rapido dentro de um cartao. */
.add-panel {
    margin-top: 1rem;
    padding: .7rem 1rem;
    border: 1px dashed var(--sand-200);
    border-radius: var(--radius-sm);
    background: var(--sand-50);
}
.add-panel > summary {
    cursor: pointer;
    list-style: none;
    font-weight: 600;
    color: var(--teal-700);
    font-size: .9rem;
}
.add-panel > summary::-webkit-details-marker { display: none; }
.add-panel[open] > summary { margin-bottom: 1rem; }

.row-notes { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

/* --- Selos, mensagens --------------------------------------------------- */

.badge {
    display: inline-block;
    padding: .12rem .5rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .02em;
    white-space: nowrap;
}
.badge.ok { background: var(--ok-100); color: var(--ok-700); }
.badge.warn { background: var(--warn-100); color: var(--warn-700); }
.badge.danger { background: var(--danger-100); color: var(--danger-700); }
.badge.muted { background: var(--sand-100); color: var(--ink-500); }
.badge.accent { background: var(--teal-100); color: var(--teal-800); }

.flash { display: grid; gap: .5rem; margin-bottom: 1.15rem; }
.flash-item {
    padding: .7rem .9rem;
    border-radius: var(--radius-sm);
    border-left: 4px solid;
    font-size: .88rem;
}
.flash-item.success { background: var(--ok-100); border-color: var(--ok-700); color: var(--ok-700); }
.flash-item.error { background: var(--danger-100); border-color: var(--danger-700); color: var(--danger-700); }
.flash-item.info { background: var(--teal-100); border-color: var(--teal-700); color: var(--teal-800); }

.alert { padding: .75rem .9rem; border-radius: var(--radius-sm); font-size: .86rem; margin-bottom: 1rem; }
.alert.warn { background: var(--warn-100); color: var(--warn-700); }
.alert.danger { background: var(--danger-100); color: var(--danger-700); }
.alert.info { background: var(--teal-50); color: var(--teal-800); border: 1px solid #cbe7e2; }

.empty { text-align: center; padding: 2.25rem 1rem; color: var(--ink-500); }
.empty p { margin-bottom: .75rem; }

/* --- Utilitarios -------------------------------------------------------- */

.muted { color: var(--ink-500); }
.muted-sm { color: var(--ink-500); font-size: .78rem; }
.muted-xs { color: var(--ink-500); font-size: .75rem; }
.fw-normal { font-weight: 400; }
.th-note { font-size: .72rem; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--ink-300); }
.numeric { font-variant-numeric: tabular-nums; }
.stack { display: grid; gap: .9rem; }
.stack-tight { display: grid; gap: .45rem; }
.mb-2 { margin-bottom: 1.15rem; }
.mt-1 { margin-top: .55rem; }
.mt-2 { margin-top: .75rem; }
.mt-3 { margin-top: .95rem; }
.pt-0 { padding-top: 0; }
.card.narrow { max-width: 560px; }
.divider { border: 0; border-top: 1px solid var(--sand-200); margin: 1.5rem 0; }
.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;
}

/* --- Wizard ------------------------------------------------------------- */

.stepper {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: .5rem;
    margin-bottom: 1.35rem;
}
.stepper-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem .75rem;
    border-radius: var(--radius-sm);
    border: var(--border);
    background: #fff;
    font-size: .82rem;
    color: var(--ink-500);
    line-height: 1.25;
    min-width: 0;
}
.stepper-item:hover { text-decoration: none; border-color: #cddfda; }
.stepper-item.is-current { border-color: var(--teal-600); background: var(--teal-50); color: var(--teal-800); font-weight: 650; }
.stepper-item.is-done { border-color: #cbe7e2; color: var(--teal-700); }
.stepper-num {
    flex: 0 0 auto;
    width: 1.45rem; height: 1.45rem;
    border-radius: 999px;
    display: grid; place-items: center;
    background: var(--sand-100);
    font-size: .75rem;
    font-weight: 700;
}
.stepper-item.is-current .stepper-num { background: var(--teal-700); color: #fff; }
.stepper-item.is-done .stepper-num { background: var(--teal-100); color: var(--teal-800); }

.wizard-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
    margin-top: .25rem;
}
.wizard-footer .actions:last-child { margin-left: auto; }

/* Sub-abas de Configuracoes: cada premissa em uma tela curta. */
.subtabs {
    display: flex;
    gap: .4rem;
    flex-wrap: wrap;
    margin-bottom: 1.15rem;
}
.subtab {
    flex: 1 1 10.5rem;
    display: flex;
    align-items: flex-start;
    gap: .55rem;
    min-width: 0;
    padding: .6rem .75rem;
    border: var(--border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--ink-700);
}
.subtab:hover { border-color: #cddfda; color: var(--teal-800); text-decoration: none; }
.subtab.is-active {
    border-color: var(--teal-600);
    background: var(--teal-50);
    color: var(--teal-800);
    box-shadow: inset 0 0 0 1px var(--teal-600);
}
.subtab-num {
    flex: 0 0 auto;
    width: 1.3rem;
    height: 1.3rem;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: var(--sand-100);
    font-size: .7rem;
    font-weight: 700;
}
.subtab.is-active .subtab-num { background: var(--teal-700); color: #fff; }
.subtab-text { display: grid; gap: .1rem; min-width: 0; }
.subtab-label { font-size: .82rem; font-weight: 650; line-height: 1.25; }
/* Uma linha so: meta longa ("19 custo(s) · 7 deprec.") fazia uma aba crescer
   mais que as vizinhas e desalinhava a faixa inteira. */
.subtab-meta {
    font-size: .72rem;
    color: var(--ink-500);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.subtab.is-active .subtab-meta { color: var(--teal-700); }

.section-steps {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
}

@media (max-width: 900px) {
    .stepper { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
    .stepper { grid-template-columns: 1fr; }
    .subtabs { flex-direction: column; }
}

/* --- Detalhe do preco --------------------------------------------------- */

.price-hero {
    display: grid;
    gap: .9rem;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    margin-bottom: 1.15rem;
}
.price-box {
    border: var(--border);
    border-radius: var(--radius-sm);
    padding: .95rem 1.05rem;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: .1rem;
}
.price-box.is-main { background: var(--teal-900); color: #fff; border-color: var(--teal-900); }
.price-box.is-main .price-label { color: #9dd3cb; }
.price-box.is-loss { background: var(--danger-100); border-color: #eccfcb; }
.price-box.is-loss .price-value { color: var(--danger-700); }
.price-label { font-size: .74rem; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-500); }
.price-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.price-sub { font-size: .8rem; opacity: .8; }

.breakdown { width: 100%; border-collapse: collapse; font-size: .88rem; }
.breakdown td { padding: .42rem .25rem; border-bottom: 1px dashed var(--sand-200); }
.breakdown td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.breakdown tr.is-total td { border-top: 2px solid var(--sand-200); border-bottom: none; font-weight: 700; padding-top: .6rem; }
.breakdown tr.is-sub td { color: var(--ink-500); font-size: .84rem; }
.breakdown .depth { padding-left: 1.1rem; }

.split { display: grid; gap: 1.15rem; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 980px) {
    .split { grid-template-columns: 1fr; }
    .nav { margin-left: 0; width: 100%; }
}

/* Conteudo principal + painel lateral de resumo (agenda, custos). */
.layout-aside {
    display: grid;
    gap: 1.25rem;
    grid-template-columns: minmax(0, 2.05fr) minmax(0, 1fr);
    align-items: start;
}
@media (max-width: 1040px) {
    .layout-aside { grid-template-columns: minmax(0, 1fr); }
}
.panel {
    background: var(--sand-50);
    border: 1px solid var(--sand-200);
    border-radius: var(--radius-sm);
    padding: 1rem 1.1rem;
}
.panel .fieldset-head { margin-bottom: .8rem; }

/* --- Ficha tecnica de insumos (grade compacta) -------------------------- */
.supply-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(17.5rem, 1fr));
    gap: .4rem .7rem;
}
.supply-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
    padding: .3rem .5rem;
    border: 1px solid var(--sand-100);
    border-radius: var(--radius-sm);
    background: #fff;
}
.supply-item:focus-within { border-color: var(--teal-500); }
.supply-info { display: grid; gap: .05rem; min-width: 0; }
.supply-name {
    font-size: .85rem;
    font-weight: 600;
    color: var(--ink-700);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.supply-item input {
    flex: none;
    width: 5.5rem;
    padding: .32rem .45rem;
    font-size: .875rem;
    text-align: right;
}
@media (max-width: 640px) {
    .supply-grid { grid-template-columns: 1fr; }
}

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

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: linear-gradient(160deg, var(--teal-50), var(--sand-50)); }
.auth-card { width: 100%; max-width: 420px; background: #fff; border: var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.75rem; }
.auth-card h1 { font-size: 1.25rem; }
.auth-card .brand { color: var(--teal-900); margin-bottom: 1.25rem; }
.auth-card .form-actions { border-top: 0; padding-top: 0; }

/* --- Impressao ---------------------------------------------------------- */

@media print {
    .topbar, .footer, .actions, .no-print, .flash { display: none !important; }
    body { background: #fff; }
    .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
    .page { max-width: none; padding: 0; }
}

/* --- Tabela de precos para impressao / PDF ----------------------------- */
.print-header h1 { margin: 0 0 .25rem; font-size: 1.35rem; }
.print-header p { margin: 0; }
.print-section { margin-top: 1.5rem; }
.print-section h2 { font-size: 1rem; margin: 0 0 .5rem; }
.print-table { width: 100%; }
.print-footer { margin-top: 1.5rem; font-size: .82rem; color: var(--ink-500); }

@media print {
    @page { margin: 14mm; }
    body { background: #fff; }
    .topbar, .footer, .no-print, .flash { display: none !important; }
    .app-shell { min-height: 0; }
    .page { max-width: none; margin: 0; padding: 0; }
    .print-doc { color: #000; }
    .print-section { break-inside: avoid; }
    .print-table { font-size: 10.5pt; }
    .print-table th, .print-table td { padding: 4px 6px; border-color: #bbb; }
    .print-table thead { display: table-header-group; }
    .print-table tr { break-inside: avoid; }
}
