/* ---------------------------------------------------------------------------------------
   Base
   --------------------------------------------------------------------------------------- */

:root {
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --surface-sunken: #f1f5f9;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-muted: #64748b;
    --accent: #2563eb;
    --accent-soft: #dbeafe;
    --danger: #dc2626;
    --success: #16a34a;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .1);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, .1), 0 2px 4px -2px rgba(15, 23, 42, .1);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, .1), 0 4px 6px -4px rgba(15, 23, 42, .1);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--surface-muted);
}

button {
    font: inherit;
    color: inherit;
}

a {
    color: var(--accent);
}

/* ---------------------------------------------------------------------------------------
   Controles genericos
   --------------------------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    white-space: nowrap;
    transition: background .12s, border-color .12s;
}

.btn:hover:not(:disabled) {
    background: var(--surface-sunken);
}

.btn:disabled {
    opacity: .45;
    cursor: default;
}

.btn--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn--primary:hover:not(:disabled) {
    background: #1d4ed8;
}

.btn--danger {
    color: var(--danger);
    border-color: #fecaca;
}

.btn--danger:hover:not(:disabled) {
    background: #fef2f2;
}

.btn--icon {
    padding: 7px 9px;
}

.btn--ghost {
    border-color: transparent;
    background: transparent;
}

.btn--ghost:hover:not(:disabled) {
    background: var(--surface-sunken);
}

.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 14px;
}

.field > label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .03em;
}

.input,
.select,
.textarea {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    background: var(--surface);
    font: inherit;
    color: inherit;
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: 2px solid var(--accent-soft);
    border-color: var(--accent);
}

.textarea {
    min-height: 90px;
    resize: vertical;
}

.empty-state {
    padding: 48px 24px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state i {
    display: block;
    font-size: 40px;
    margin-bottom: 12px;
    opacity: .4;
}

/* Carimbo da versao publicada. Canto inferior esquerdo, longe do zoom do editor, que fica no centro
   de baixo. Quase invisivel em repouso e legivel ao passar o mouse: quem procura sabe onde olhar, e
   quem nao procura nao e incomodado por uma data no rodape de toda pagina. */
.app-version {
    position: fixed;
    left: 8px;
    bottom: 6px;
    z-index: 10;
    font-size: 10px;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
    opacity: .35;
    /* O texto precisa poder ser selecionado e receber o hover do title — dai nao usar
       pointer-events: none, que seria o atalho obvio para nao atrapalhar o canvas. */
    background: var(--surface);
    padding: 1px 5px;
    border-radius: 4px;
}

.app-version:hover {
    opacity: 1;
}

/* ---------------------------------------------------------------------------------------
   Listagem de mapas
   --------------------------------------------------------------------------------------- */

.page {
    max-width: 1000px;
    margin: 0 auto;
    padding: 40px 24px;
}

.page__header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
}

.page__header h1 {
    margin: 0 0 4px;
    font-size: 24px;
}

.page__header p {
    margin: 0;
    color: var(--text-muted);
}

.map-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.map-card {
    display: flex;
    flex-direction: column;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: box-shadow .15s, transform .15s;
}

.map-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.map-card__title {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 600;
}

.map-card__title a {
    color: inherit;
    text-decoration: none;
}

.map-card__title a:hover {
    color: var(--accent);
}

.map-card__description {
    flex: 1;
    margin: 0 0 14px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.5;
}

.map-card__meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.map-card__actions {
    display: flex;
    gap: 6px;
}

/* ---------------------------------------------------------------------------------------
   Editor: moldura
   --------------------------------------------------------------------------------------- */

.editor {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.editor__topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    z-index: 30;
}

.editor__title {
    font-weight: 600;
    font-size: 15px;
    margin-right: auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.editor__body {
    position: relative;
    flex: 1;
    display: flex;
    min-height: 0;
}

.toolbar-group {
    display: flex;
    gap: 2px;
    padding: 0 6px;
    border-left: 1px solid var(--border);
}

.toolbar-group:first-of-type {
    border-left: none;
}

/* ---------------------------------------------------------------------------------------
   Canvas
   --------------------------------------------------------------------------------------- */

.map-viewport {
    position: relative;
    flex: 1;
    overflow: hidden;
    background-color: var(--surface-muted);
    background-image: radial-gradient(circle, var(--border-strong) 1px, transparent 1px);
    background-size: 24px 24px;
    touch-action: none;
    cursor: grab;
    user-select: none;
}

.map-viewport.is-panning {
    cursor: grabbing;
}

.map-viewport.is-dragging-node {
    cursor: grabbing;
}

/* Camada do pan/zoom. O transform e escrito pelo JS; o Blazor nao renderiza style aqui, senao
   cada re-render apagaria a posicao da tela. */
.map-canvas {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
}

/* Camada do conteudo. As dimensoes vem do layout, entao quem manda no style e o Blazor. */
.map-content {
    position: relative;
}

/* Primeira passada: os nos precisam ser renderizados para serem medidos, mas mostrar essa
   passada com o layout ainda estimado produziria um salto visivel. */
.map-content.is-measuring {
    opacity: 0;
}

.edge-layer {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    overflow: visible;
}

.edge-temp {
    stroke: var(--accent);
    stroke-width: 2;
    stroke-dasharray: 6 4;
}

.cross-link {
    stroke-dasharray: 7 5;
    opacity: .75;
}

.cross-link-hit {
    pointer-events: stroke;
    cursor: pointer;
    stroke: transparent;
    stroke-width: 14;
    fill: none;
}

.cross-link-label {
    font-size: 11px;
    fill: var(--text-muted);
    paint-order: stroke;
    stroke: var(--surface-muted);
    stroke-width: 4px;
    stroke-linejoin: round;
}

/* ---------------------------------------------------------------------------------------
   No
   --------------------------------------------------------------------------------------- */

.node {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 7px;

    /* width: max-content e obrigatorio, nao cosmetico.
       Um elemento absoluto sem largura encolhe ate caber no espaco QUE SOBRA do contenedor a partir
       do seu 'left'. Como a largura do contenedor vem do layout, e o layout vem da medicao dos nos,
       isso fecha um laco: contenedor estreito -> no medido estreito -> layout estreito. Um no
       proximo da borda direita era medido menor do que o texto exige, quebrava linha sem precisar, e
       o botao de novo filho — posicionado pela largura do layout — caia dentro do proprio no. */
    width: max-content;
    max-width: 260px;
    padding: 7px 12px;
    border: 2px solid transparent;
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    cursor: grab;
    translate: var(--drag-dx, 0) var(--drag-dy, 0);
}

.node:hover {
    box-shadow: var(--shadow-md);
}

.node.is-selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-md);
}

.node.is-dragging {
    opacity: .65;
    z-index: 20;
    cursor: grabbing;
}

/* Fora do filtro: o no continua legivel e clicavel, so recua para o fundo. Esconde-lo quebraria a
   leitura da arvore — o que se procura so faz sentido no lugar onde esta. */
.node.is-dimmed {
    opacity: .28;
}

.node.is-dimmed:hover {
    opacity: .75;
}

.node.is-root {
    padding: 11px 18px;
    font-size: 17px;
    font-weight: 700;
}

.node--depth1 {
    font-size: 14px;
    font-weight: 600;
}

.node--depth2 {
    font-size: 13px;
}

.node--deep {
    font-size: 12.5px;
    color: #334155;
}

.node__text {
    white-space: pre-wrap;
    word-break: break-word;
    outline: none;
    min-width: 12px;
}

.node[data-editing] {
    cursor: text;
}

.node[data-editing] .node__text {
    cursor: text;
    user-select: text;
}

.node__icon {
    flex-shrink: 0;
    font-size: 15px;
    line-height: 1;
}

.node__badges {
    display: flex;
    gap: 3px;
    flex-shrink: 0;
    font-size: 11px;
    color: var(--text-muted);
}

.node__accent {
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 3px;
}

.node--side-left .node__accent {
    left: auto;
    right: 0;
}

/* Indicadores de soltura */
.node.is-drop-child {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.node.is-drop-before {
    box-shadow: 0 -3px 0 0 var(--accent), var(--shadow-sm);
}

.node.is-drop-after {
    box-shadow: 0 3px 0 0 var(--accent), var(--shadow-sm);
}

.node.is-link-target {
    border-color: #7c3aed;
    background: #f5f3ff;
}

/* Marcador de colapsar/expandir */
.collapse-toggle {
    position: absolute;
    width: 16px;
    height: 16px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid currentColor;
    border-radius: 50%;
    background: var(--surface);
    font-size: 9px;
    line-height: 1;
    cursor: pointer;
    z-index: 5;
}

.collapse-toggle:hover {
    background: var(--surface-sunken);
}

.collapse-toggle__count {
    font-size: 9px;
    font-weight: 700;
}

/* ---------------------------------------------------------------------------------------
   Toolbar flutuante do no
   --------------------------------------------------------------------------------------- */

.node-toolbar {
    position: absolute;
    display: flex;
    align-items: center;
    gap: 1px;

    /* Mesmo motivo do .node: sem isso a barra e espremida quando o no esta perto da borda. */
    width: max-content;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    z-index: 25;
    white-space: nowrap;
}

.node-toolbar button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 7px;
    background: transparent;
    cursor: pointer;
    font-size: 15px;
}

.node-toolbar button:hover {
    background: var(--surface-sunken);
}

.node-toolbar__divider {
    width: 1px;
    height: 20px;
    margin: 0 3px;
    background: var(--border);
}

.node-add {
    position: absolute;
    width: 20px;
    height: 20px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    cursor: pointer;
    z-index: 24;
    box-shadow: var(--shadow-sm);
}

.node-add:hover {
    background: #1d4ed8;
}

/* ---------------------------------------------------------------------------------------
   Popovers (cor, icone, link)
   --------------------------------------------------------------------------------------- */

.popover {
    position: absolute;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    z-index: 40;
}

.popover__title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: .03em;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(6, 24px);
    gap: 6px;
}

.color-swatch {
    width: 24px;
    height: 24px;
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
}

.color-swatch.is-selected {
    border-color: var(--text);
}

.icon-picker {
    width: 300px;
}

/* Editor de rotulo da conexao cruzada */
.link-editor {
    position: absolute;
    width: max-content;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    z-index: 30;
}

.link-editor__row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
}

.link-editor__row .input {
    width: 190px;
}

.icon-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    max-height: 220px;
    overflow-y: auto;
    margin-top: 8px;
}

.icon-grid button {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    font-size: 16px;
}

.icon-grid button:hover {
    background: var(--surface-sunken);
}

.icon-grid button.is-selected {
    background: var(--accent-soft);
    color: var(--accent);
}

/* ---------------------------------------------------------------------------------------
   Painel lateral
   --------------------------------------------------------------------------------------- */

.inspector {
    width: 340px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    z-index: 20;
}

.inspector__header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 1;
}

.inspector__header h2 {
    margin: 0;
    font-size: 14px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.inspector__body {
    padding: 14px;
}

.inspector__section {
    margin-bottom: 22px;
}

.inspector__section > h3 {
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .03em;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* Campo com um botao de acao encostado nele. O campo fica com toda a sobra; o botao so com o que
   o icone pede, para nao competir com o controle principal. */
.field__with-action {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.field__with-action > .select,
.field__with-action > .input,
.field__with-action > .textarea {
    flex: 1;
    min-width: 0;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 8px;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--surface-sunken);
    font-size: 12px;
}

.tag button {
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1;
}

/* Editor de descricao */
.rich-editor {
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    overflow: hidden;
}

.rich-editor__toolbar {
    display: flex;
    gap: 1px;
    padding: 4px;
    background: var(--surface-sunken);
    border-bottom: 1px solid var(--border);
}

.rich-editor__toolbar button {
    width: 28px;
    height: 26px;
    border: none;
    border-radius: 5px;
    background: transparent;
    cursor: pointer;
    font-size: 13px;
}

.rich-editor__toolbar button:hover {
    background: var(--surface);
}

.rich-editor__content {
    min-height: 110px;
    max-height: 320px;
    overflow-y: auto;
    padding: 9px 11px;
    outline: none;
    line-height: 1.55;
}

.rich-editor__content p {
    margin: 0 0 8px;
}

.rich-editor__content img {
    max-width: 100%;
}

.rich-editor__content:focus {
    background: #fefefe;
}

/* Comentarios */
.comment {
    padding: 9px 11px;
    margin-bottom: 8px;
    border-radius: 8px;
    background: var(--surface-sunken);
}

.comment__head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
}

.comment__author {
    font-weight: 600;
    font-size: 12px;
}

.comment__time {
    font-size: 11px;
    color: var(--text-muted);
    margin-right: auto;
}

.comment__body {
    font-size: 13px;
    line-height: 1.5;
}

.comment__body p {
    margin: 0 0 6px;
}

/* Estimativa */
.toolbar-group--rate {
    display: flex;
    align-items: center;
    gap: 5px;
}

.toolbar-group--rate > label {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.input--rate {
    width: 78px;
    padding: 5px 7px;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

/* Filtro da barra: estreito o bastante para nao roubar espaco do titulo do mapa. */
.input--filter {
    width: 190px;
    padding: 5px 8px;
    font-size: 13px;
}

/* A ajuda e ancorada neste grupo, e nao na pagina. */
.toolbar-group--filter {
    position: relative;
    align-items: center;
}

.filter-count {
    align-self: center;
    padding-left: 4px;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* Zero resultados nao e erro, mas e o caso em que a tela inteira esmaece: o vermelho evita que a
   pessoa procure defeito onde so faltou resultado. */
.filter-count--empty {
    color: var(--danger);
}

.filter-help {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 40;
    width: 420px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    font-size: 12px;
}

.filter-help dl {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 3px 12px;
    margin: 0;
}

.filter-help dt {
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    color: var(--accent);
    white-space: nowrap;
}

.filter-help dd {
    margin: 0;
    color: var(--text-muted);
}

.filter-help p {
    margin: 10px 0 0;
    color: var(--text-muted);
}

/* Alinha o valor lido com a altura do campo ao lado, para a linha nao ficar torta. */
.readout {
    display: flex;
    align-items: center;
    min-height: 34px;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.readout--muted {
    color: var(--text-muted);
    font-style: italic;
}

/* Explica por que o campo esta travado, em vez de deixar o usuario procurar onde editar. */
.readout__hint {
    margin-left: 6px;
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* O valor-hora e o unico campo do painel com botao proprio: ele so grava no clique. O botao fica
   na mesma linha do campo para que a relacao entre os dois seja obvia sem ler o texto de apoio. */
.rate-field {
    display: flex;
    gap: 6px;
    align-items: center;
}

.rate-field > .input {
    flex: 1;
    min-width: 0;
}

/* Nota abaixo de um campo, para a regra que o campo sozinho nao consegue afirmar — o valor-hora
   em branco cair no padrao da instalacao, por exemplo. */
.field__hint {
    margin: 4px 0 0;
    font-size: 11px;
    line-height: 1.4;
    color: var(--text-muted);
}

.estimate-total {
    margin-top: 10px;
    padding: 9px 11px;
    border-radius: 8px;
    background: var(--surface-sunken);
}

.estimate-total__row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    font-size: 13px;
}

.estimate-total__row strong {
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}

.estimate-total__meta {
    margin-top: 3px;
    font-size: 11px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* Virou botao em 16/08/2026 (ver o InspectorPanel): o reset existe para ele continuar parecendo o
   texto que sempre foi, e nao um botao a mais dentro do bloco de total. */
.estimate-total__pending {
    padding: 0;
    border: none;
    background: none;
    font: inherit;
    color: var(--danger);
    cursor: pointer;
}

.estimate-total__pending:hover {
    text-decoration: underline;
}

.estimate-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.estimate-table td {
    padding: 5px 4px;
    border-bottom: 1px solid var(--border);
}

.estimate-table tfoot td {
    border-bottom: none;
    border-top: 2px solid var(--border-strong);
    font-weight: 600;
    padding-top: 7px;
}

.estimate-table__name {
    /* O nome cede espaco: os numeros a direita nao podem quebrar linha. */
    word-break: break-word;
}

.estimate-table__hours,
.estimate-table__value {
    text-align: right;
    white-space: nowrap;
}

.estimate-table__pending {
    margin-left: 3px;
    color: var(--danger);
}

.estimate-note {
    display: flex;
    align-items: baseline;
    gap: 5px;
    margin: 8px 0 0;
    font-size: 11px;
    color: var(--text-muted);
}

/* O aviso de pendencia e um botao, mas continua com cara de aviso: destacar como botao competiria
   com o "Aplicar" do valor-hora, que e a unica acao de peso desta area do painel. */
.estimate-note--toggle {
    width: 100%;
    padding: 0;
    border: none;
    background: none;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}

.estimate-note--toggle:hover {
    color: var(--text);
}

.estimate-note__text {
    /* Empurra o chevron para a direita sem prender a largura do texto. */
    flex: 1;
}

.gap-list {
    margin: 6px 0 0;
    padding: 0;
    list-style: none;
    /* A lista pode ser longa: num mapa com dezenas de pendencias ela empurraria o resto do painel
       para fora da tela. Rolar aqui dentro mantem o resumo e o valor-hora ao alcance. */
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 7px;
}

.gap-list__item {
    display: block;
    width: 100%;
    padding: 5px 8px;
    border: none;
    border-bottom: 1px solid var(--border);
    background: none;
    font-family: inherit;
    font-size: 12px;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.gap-list li:last-child .gap-list__item {
    border-bottom: none;
}

.gap-list__item:hover {
    background: var(--surface-sunken);
}

.gap-list__title {
    display: block;
    word-break: break-word;
}

.gap-list__path {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    word-break: break-word;
}

/* Add-ons do no */
.addon {
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
    overflow: hidden;
}

.addon__head {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 6px 6px 6px 10px;
    background: var(--surface-sunken);
    font-size: 12px;
    font-weight: 600;
}

.addon__name {
    margin-right: auto;
}

.addon__body {
    padding: 9px 10px;
}

.addon__unknown {
    margin: 0;
    font-size: 12px;
    color: var(--text-muted);
}

.addon-catalog {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.addon-catalog__item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 8px;
    padding: 8px 10px;
    text-align: left;
    cursor: pointer;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 7px;
}

.addon-catalog__item:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.addon-catalog__item > i {
    grid-row: span 2;
    align-self: center;
    font-size: 16px;
    color: var(--accent);
}

.addon-catalog__name {
    font-size: 13px;
    font-weight: 600;
}

.addon-catalog__desc {
    font-size: 12px;
    color: var(--text-muted);
}

/* Checklist */
.checklist__progress {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 9px;
}

.checklist__bar {
    flex: 1;
    height: 5px;
    border-radius: 999px;
    background: var(--surface-sunken);
    overflow: hidden;
}

.checklist__bar > span {
    display: block;
    height: 100%;
    background: var(--accent);
    transition: width .15s ease;
}

.checklist__count {
    font-size: 11px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.checklist__item {
    display: flex;

    /* Trocado em 15/08/2026: o texto virou campo de varias linhas, e 'center' punha a caixa de
       marcar no meio do paragrafo. A caixa pertence a PRIMEIRA linha.
       align-items: center; */
    align-items: flex-start;
    gap: 7px;
    margin-bottom: 3px;
}

/* Alinha com a primeira linha do texto: 1px de borda + 3px de padding + meia linha. Nada de
   'baseline' — a de um textarea difere entre Chrome e Firefox. */
.checklist__item > input[type="checkbox"] {
    flex: none;
    margin-top: 5px;
}

.checklist__item > .btn--icon {
    flex: none;
    align-self: flex-start;
}

.checklist__text {
    flex: 1;
    min-width: 0;

    /* Sem 'block' o textarea, que e inline-block, deixa um vao de baseline embaixo. */
    display: block;
    box-sizing: border-box;
    padding: 3px 5px;
    font: inherit;
    font-size: 13px;

    /* Depois do 'font: inherit', que reseta o line-height — e as contas de altura dependem dele. */
    line-height: 1.35;
    color: inherit;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 5px;

    /* A alca de redimensionar brigaria com a altura calculada pelo autogrow. */
    resize: none;
    overflow-x: hidden;
    overflow-y: auto;

    /* Uma linha, para o campo ficar decente mesmo se o JS nao rodar; teto de ~6 linhas, a partir do
       qual o proprio campo rola em vez de empurrar a lista inteira para fora da tela. */
    min-height: calc(1.35em + 8px);
    max-height: calc(6 * 1.35em + 8px);
}

.checklist__text:hover {
    border-color: var(--border);
}

.checklist__text:focus {
    outline: none;
    background: var(--surface);
    border-color: var(--accent);
}

/* O texto riscado marca o item concluido sem precisar procurar a caixa marcada. */
.checklist__item.is-done .checklist__text {
    color: var(--text-muted);
    text-decoration: line-through;
}

.checklist__new {
    margin-top: 7px;
}

/* Anexos */
.attachment {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 9px;
    margin-bottom: 6px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 13px;
}

.attachment__name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment__size {
    font-size: 11px;
    color: var(--text-muted);
}

.attachment-thumb {
    max-width: 100%;
    border-radius: 6px;
    margin-bottom: 6px;
    display: block;
}

/* ---------------------------------------------------------------------------------------
   Rodape de zoom
   --------------------------------------------------------------------------------------- */

.zoom-bar {
    position: absolute;
    right: 18px;
    bottom: 18px;
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 5px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    box-shadow: var(--shadow-md);
    z-index: 15;
}

.zoom-bar button {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
}

.zoom-bar button:hover {
    background: var(--surface-sunken);
}

.zoom-bar__value {
    min-width: 46px;
    text-align: center;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}

/* ---------------------------------------------------------------------------------------
   Modal
   --------------------------------------------------------------------------------------- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, .45);
    z-index: 100;
}

.modal {
    width: min(540px, calc(100vw - 40px));
    max-height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

.modal__header {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}

.modal__header h2 {
    margin: 0;
    font-size: 16px;
}

.modal__body {
    padding: 18px;
    overflow-y: auto;
}

.modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 18px;
    border-top: 1px solid var(--border);
}

.code-block {
    width: 100%;
    min-height: 260px;
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.5;
    white-space: pre;
    overflow: auto;
}

/* ---------------------------------------------------------------------------------------
   Autorizacao OAuth

   Tela de fora do aplicativo: quem chega aqui veio de um conector e precisa reconhecer o que
   esta aprovando. Nada de menu ou navegacao — a unica saida e autorizar ou negar.
   --------------------------------------------------------------------------------------- */

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

.auth-card__head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.auth-card__head h1 {
    margin: 0;
    font-size: 19px;
    font-weight: 600;
}

.auth-card__icon {
    font-size: 22px;
    color: var(--accent);
}

.auth-card__icon--danger {
    color: var(--danger);
}

.auth-intro {
    margin: 0 0 20px;
    line-height: 1.5;
    color: var(--text-muted);
}

.auth-intro strong {
    color: var(--text);
}

.auth-error {
    margin: 12px 0 0;
    padding: 9px 11px;
    border-radius: var(--radius);
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--danger);
    font-size: 13px;
}

/* Documentacao das tags do modelo, no proprio dialogo de envio: quem chega com um .docx pronto
   precisa saber o que ele deve conter ANTES de escolher o arquivo. */
.template-help {
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-muted, #f8fafc);
    font-size: 13px;
    line-height: 1.5;
}

.template-help__title {
    margin: 0 0 8px;
    font-weight: 600;
}

.template-help p {
    margin: 0 0 8px;
}

.template-help code {
    padding: 1px 5px;
    border-radius: 4px;
    background: #eef2ff;
    color: #3730a3;
    font-size: 12px;
    white-space: nowrap;
}

.template-help__tags td {
    padding: 4px 8px 4px 0;
    vertical-align: top;
}

.template-help__tags td:first-child {
    white-space: normal;
}

.template-help__rule {
    margin-bottom: 0 !important;
}

/* Diagnostico do arquivo escolhido. Verde nao e enfeite: e a diferenca entre um modelo que a
   geracao preenche e um que falharia so na frente do cliente. */
.template-diagnosis {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    line-height: 1.5;
}

.template-diagnosis.is-ok {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}

.template-diagnosis.is-bad {
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.template-diagnosis__title {
    margin: 0 0 6px;
    font-weight: 600;
}

.template-diagnosis ul {
    margin: 0 0 6px;
    padding-left: 18px;
    list-style: none;
}

.template-diagnosis p {
    margin: 0 0 4px;
}

.template-diagnosis__problem {
    color: var(--danger);
}

/* Contraparte verde do .auth-error, para a confirmacao de senha trocada. */
.auth-success {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 12px 0 0;
    padding: 9px 11px;
    border-radius: var(--radius);
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #15803d;
    font-size: 13px;
}

.auth-actions {
    display: flex;
    gap: 8px;
    margin-top: 20px;
}

.auth-actions .btn {
    flex: 1;
    justify-content: center;
}

.auth-hint {
    margin: 18px 0 0;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-muted);
}

/* ---------------------------------------------------------------------------------------
   Administracao de acessos
   --------------------------------------------------------------------------------------- */

.page__subtitle {
    max-width: 60ch;
}

/* O historico do pedido e transcricao, nao frase: nasce alto o bastante para se ler um paragrafo
   sem rolar, e o usuario ainda pode esticar. */
.textarea--tall {
    min-height: 160px;
    resize: vertical;
}

.page__user {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-right: 4px;
    font-size: 12px;
    color: var(--text-muted);
}

/* Interruptor do administrador: so aparece para quem tem o papel. */
.page__switch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: 4px;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
}

.page__switch input {
    cursor: pointer;
}

/* Marca de "publico" e de "de outro usuario" no cartao do mapa. */
.map-card__badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-right: 8px;
    padding: 1px 6px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 11px;
}

.muted {
    color: var(--text-muted);
}

.admin-section {
    margin-bottom: 32px;
}

.admin-section h2 {
    margin: 0 0 12px;
    font-size: 16px;
    font-weight: 600;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.admin-table th,
.admin-table td {
    padding: 9px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.admin-table thead th {
    background: var(--surface-sunken);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-muted);
}

.admin-table tbody tr:last-child td {
    border-bottom: none;
}

.admin-table code {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 12px;
}

/* O nome secundario (login do cliente, nome de exibicao) vai numa segunda linha em cinza: na mesma
   linha ele competiria com o nome principal, que e o que se procura ao varrer a tabela. */
.admin-table__meta {
    display: block;
    margin-top: 2px;
    font-size: 11px;
    color: var(--text-muted);
}

.admin-table__actions {
    text-align: right;
    white-space: nowrap;
}

.admin-table__actions .btn + .btn {
    margin-left: 4px;
}

.btn--sm {
    padding: 3px 9px;
    font-size: 12px;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.badge--ok {
    background: #dcfce7;
    color: #166534;
}

.badge--off {
    background: var(--surface-sunken);
    color: var(--text-muted);
}

.badge--danger {
    background: #fef2f2;
    color: var(--danger);
}

.admin-note {
    margin: 10px 0 0;
    max-width: 70ch;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-muted);
}

.admin-form {
    margin-top: 18px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-width: 520px;
}

.admin-form h3 {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 600;
}

/* ---------------------------------------------------------------------------------------
   Erro do Blazor
   --------------------------------------------------------------------------------------- */

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 12px 16px;
    background: #fef3c7;
    border-top: 1px solid #fcd34d;
    box-shadow: 0 -1px 3px rgba(0, 0, 0, .1);
}

#blazor-error-ui .dismiss {
    position: absolute;
    top: 10px;
    right: 14px;
    cursor: pointer;
}
