/* Cores pelos tokens do Fluent UI, que o <fluent-design-theme mode="system"> troca entre claro e
   escuro. O segundo valor de cada var() vale até o JS do Fluent carregar, e segue o sistema também. */
:root {
    color-scheme: light dark;
    --bg: var(--neutral-layer-2, #f5f5f5);
    --surface: var(--neutral-layer-1, #ffffff);
    --text: var(--neutral-foreground-rest, #242424);
    --muted: var(--neutral-foreground-hint, #616161);
    --stroke: var(--neutral-stroke-rest, #d1d1d1);
    --accent: var(--accent-fill-rest, #0f6cbd);
    --ok: #107c10;
    --warn: #b35900;
    --bad: #c50f1f;
    --series-0: #0f6cbd;
    --series-1: #2d9d78;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: var(--neutral-layer-2, #1b1b1b);
        --surface: var(--neutral-layer-1, #292929);
        --text: var(--neutral-foreground-rest, #ffffff);
        --muted: var(--neutral-foreground-hint, #adadad);
        --stroke: var(--neutral-stroke-rest, #4d4d4d);
        --accent: var(--accent-fill-rest, #479ef5);
        --ok: #54b054;
        --warn: #f7a046;
        --bad: #f1707b;
        --series-0: #479ef5;
        --series-1: #5ec29e;
    }
}

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--body-font, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif);
}

a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
/* O Blazor põe o foco no título a cada navegação (leitor de tela anuncia a página); o contorno não ajuda quem vê. */
h1:focus { outline: none; }
h2 { font-size: 1.2rem; margin: 0; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Topo e página */
.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: .6rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--stroke);
}
.brand { font-weight: 600; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.brand span, .brand-accent { color: var(--accent); }
.who { display: flex; align-items: center; gap: .75rem; }
.who-name { color: var(--muted); }
.logout { margin: 0; }
.page { max-width: 1200px; margin: 0 auto; padding: 1.25rem; }

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; box-sizing: border-box; }
.login-card {
    width: 100%; max-width: 380px; box-sizing: border-box; padding: 2rem;
    background: var(--surface); border: 1px solid var(--stroke); border-radius: 8px;
}
.login-form { display: flex; flex-direction: column; gap: .4rem; }
.login-form label { margin-top: .6rem; font-weight: 600; }
.login-form fluent-button { margin-top: 1rem; }
.code-input { font-size: 1.4rem; letter-spacing: .2em; text-align: center; }
.small { font-size: .875rem; }
.login-form + .small { margin-top: 1.25rem; }
input[type=email], input[type=password], input[type=search], input.code-input, select {
    font: inherit; color: var(--text); background: var(--surface);
    border: 1px solid var(--stroke); border-radius: 4px; padding: .45rem .6rem;
}
input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.validation-message, .form-error { color: var(--bad); margin: .2rem 0 0; }
.notice { padding: .6rem .8rem; border-left: 4px solid var(--warn); background: var(--surface); }

.back { margin: 0 0 .75rem; }
.back a { text-decoration: none; }
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
.title-row h1 { margin: 0; }
.title-row + .muted { margin: .4rem 0 1.25rem; }

/* Cartões */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat { display: flex; flex-direction: column; gap: .25rem; padding: 1rem; }
.stat-label { color: var(--muted); font-size: .9rem; }
.stat-value { font-size: 2rem; font-weight: 600; line-height: 1.2; }
.stat-detail { color: var(--muted); font-size: .85rem; }

/* Curvas */
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.trend { margin: 0; padding: 1rem; background: var(--surface); border: 1px solid var(--stroke); border-radius: 8px; }
.trend figcaption { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; margin-bottom: .5rem; }
.trend-title { font-weight: 600; }
.legend { display: flex; gap: .9rem; color: var(--muted); font-size: .85rem; }
.legend-item { display: inline-flex; align-items: center; gap: .3rem; }
.swatch { width: .8rem; height: .2rem; border-radius: 2px; background: currentColor; }
.legend-item.series-0 .swatch { background: var(--series-0); }
.legend-item.series-1 .swatch { background: var(--series-1); }
.trend svg { width: 100%; height: auto; display: block; }
.trend .line { fill: none; stroke-width: 2; }
.trend .line.series-0 { stroke: var(--series-0); }
.trend .line.series-1 { stroke: var(--series-1); }
.trend .dot.series-0 { fill: var(--series-0); }
.trend .dot.series-1 { fill: var(--series-1); }
.trend .axis, .trend .grid { stroke: var(--stroke); stroke-width: 1; }
.trend .grid { stroke-dasharray: 4 4; }
.trend .tick { fill: var(--muted); font-size: 11px; }
.trend .tick.end { text-anchor: end; }

/* Escritórios */
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .75rem; }
.search { display: flex; gap: .5rem; margin: 0; }
.search input[type=search] { min-width: 14rem; }
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--stroke); border-radius: 8px; }
.data-table th, .data-table td { padding: .55rem .7rem; text-align: left; border-bottom: 1px solid var(--stroke); }
.data-table thead th { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.data-table thead a { color: inherit; text-decoration: none; }
.data-table thead a:hover { text-decoration: underline; }
.data-table tbody th { font-weight: 600; }
.data-table tbody th a { color: inherit; }
.data-table tr.attention { background: color-mix(in srgb, var(--bad) 8%, var(--surface)); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.status { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .8rem; font-weight: 600; border: 1px solid currentColor; white-space: nowrap; }
.status-active { color: var(--ok); }
.status-cooling { color: var(--warn); }
.status-inactive { color: var(--bad); }
.status-never { color: var(--muted); }
.pager { display: flex; gap: 1rem; justify-content: center; align-items: center; margin: 1rem 0; }
.footnote { font-size: .85rem; margin-top: 1.5rem; }

/* Celular: a tabela vira um cartão por escritório, cada célula com o nome da coluna na frente. */
@media (max-width: 720px) {
    .page { padding: .9rem; }
    .search { width: 100%; flex-wrap: wrap; }
    .search input[type=search] { flex: 1; min-width: 0; }
    .data-table, .data-table tbody, .data-table tr, .data-table th, .data-table td { display: block; }
    .data-table { border: 0; background: transparent; }
    .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .data-table tr { background: var(--surface); border: 1px solid var(--stroke); border-radius: 8px; margin-bottom: .75rem; padding: .5rem .75rem; }
    .data-table th, .data-table td { border: 0; padding: .25rem 0; display: flex; justify-content: space-between; gap: 1rem; }
    .data-table td::before { content: attr(data-label); color: var(--muted); }
    .data-table tbody th { font-size: 1.05rem; }
    .data-table .num { text-align: right; }
}
