/* TopoEML2 — estilos base (sem framework) */
:root {
    --bg: #f3f5f7;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e2e8f0;
    --text: #1e293b;
    --muted: #64748b;
    --primary: #0f766e;
    --primary-ink: #ffffff;
    --primary-soft: #ccfbf1;
    --accent: #f59e0b;
    --danger: #dc2626;
    --sidebar: #0f3d3e;
    --sidebar-ink: #d1fae5;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 2px 8px rgba(15, 23, 42, .04);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 15px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b1416;
        --surface: #121e21;
        --surface-2: #17262a;
        --border: #24383d;
        --text: #e2e8f0;
        --muted: #94a3b8;
        --primary: #14b8a6;
        --primary-ink: #04201d;
        --primary-soft: #123c38;
        --sidebar: #08201f;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); line-height: 1.45; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .6rem; line-height: 1.25; }
h3 { font-size: 1.02rem; }
code { font-size: .85em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

/* ── Estrutura ───────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 240px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-ink);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: .6rem; padding: 1.2rem 1.2rem 1rem; color: #fff; font-weight: 700; font-size: 1.15rem; }
.brand svg { width: 28px; height: 28px; color: #5eead4; }
.brand:hover { text-decoration: none; }
.sidebar nav { display: flex; flex-direction: column; padding: .4rem .6rem; gap: 2px; flex: 1; overflow-y: auto; }
.nav-link { color: var(--sidebar-ink); padding: .55rem .8rem; border-radius: 8px; }
.nav-link:hover { background: rgba(255, 255, 255, .07); text-decoration: none; }
.nav-link.active { background: rgba(94, 234, 212, .16); color: #fff; font-weight: 600; }
.nav-link.sub { font-size: .9rem; padding-left: 1.4rem; opacity: .85; }
.nav-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; opacity: .55; padding: 1rem .8rem .3rem; }
.sidebar-foot { border-top: 1px solid rgba(255, 255, 255, .1); padding: .8rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.me { display: flex; align-items: center; gap: .55rem; color: #fff; min-width: 0; }
.me:hover { text-decoration: none; }
.me small { display: block; opacity: .7; font-size: .75rem; }
.me strong { display: block; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #14b8a6; color: #04201d; display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.sidebar .btn-link { color: var(--sidebar-ink); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: .8rem; padding: 1rem 1.6rem; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 500; }
.topbar h1 { font-size: 1.2rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-toggle { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; font-size: 1.2rem; padding: .2rem .6rem; color: var(--text); cursor: pointer; }
.content { padding: 1.4rem 1.6rem 3rem; max-width: 1400px; width: 100%; }

@media (max-width: 900px) {
    .sidebar { position: fixed; left: 0; top: 0; z-index: 1000; transform: translateX(-100%); transition: transform .2s; }
    .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .35); }
    .menu-toggle { display: inline-block; }
    .content { padding: 1rem; }
    .topbar { padding: .8rem 1rem; }
}

/* ── Componentes ─────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem 1.2rem; margin-bottom: 1.1rem; }
.table-card { padding: 0; overflow: hidden; }
.table-card > h3, .table-card > p, .table-card > .add-row { padding: 1rem 1.2rem 0; }
.table-card > .add-row { padding-bottom: 1rem; }
.table-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .9rem 1.2rem; border-bottom: 1px solid var(--border); }
.table-head h3 { margin: 0; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .65rem .9rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.table tbody tr:hover { background: var(--surface-2); }
.table-sm th, .table-sm td { padding: .45rem .7rem; font-size: .9rem; }
.table tr.inactive td { opacity: .55; }
.table input[type=text] { min-width: 180px; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem !important; }
.muted { color: var(--muted); }
.block { display: block; }
.pre { white-space: pre-wrap; }
.hint { color: var(--muted); font-size: .88rem; margin: .3rem 0; }
.section-title { font-size: 1.05rem; margin: 1.4rem 0 .7rem; }

.badge { --c: #64748b; display: inline-block; padding: .18rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap;
    background: color-mix(in srgb, var(--c) 15%, transparent); color: var(--c); border: 1px solid color-mix(in srgb, var(--c) 35%, transparent); }
@supports not (background: color-mix(in srgb, red 10%, white)) { .badge { background: var(--c); color: #fff; } }
.flag { display: inline-block; font-size: .72rem; font-weight: 700; border-radius: 6px; padding: 0 .35rem; margin-left: .25rem; vertical-align: middle; }
.flag-prio { background: #fef3c7; color: #b45309; }
.flag-unit { background: #dbeafe; color: #1d4ed8; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; padding: .5rem .95rem; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary); filter: brightness(1.08); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #2b1700; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: .3rem .65rem; font-size: .85rem; }
.btn-lg { padding: .75rem 1.4rem; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; padding: 0; color: var(--primary); cursor: pointer; font: inherit; }
.btn-link.danger { color: var(--danger); }

.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

/* ── Formulários ─────────────────────────────────────────── */
.form fieldset { border: 0; padding: 0; margin: 0 0 1.4rem; }
.form legend { font-weight: 700; font-size: 1rem; margin-bottom: .7rem; padding: 0; }
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .8rem; min-width: 0; }
.field > span { font-size: .84rem; font-weight: 600; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=search], input[type=tel], select, textarea {
    font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .65rem; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 40%, transparent); border-color: var(--primary); }
input[type=color] { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.w-sm { width: 80px !important; }
.field-error { color: var(--danger); font-size: .82rem; }
.check { display: inline-flex; align-items: center; gap: .45rem; margin: .2rem 1.2rem .2rem 0; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }
.checks { margin-top: .6rem; }
.checklist { display: flex; flex-direction: column; gap: .15rem; }
.checklist.columns { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.form-card { max-width: 1100px; }
.form-actions { display: flex; gap: .6rem; flex-wrap: wrap; padding-top: .4rem; }
.total-box { background: var(--primary-soft); border-radius: 8px; padding: .7rem 1rem; font-size: 1rem; }
.total-box strong { font-size: 1.15rem; }

.grid-2, .grid-3, .grid-4 { display: grid; gap: 0 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.1rem; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
@media (max-width: 900px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
    .span-2 { grid-column: auto; }
}

.filters { padding: 1rem 1.2rem .4rem; }
.filters-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 .8rem; }
.filters-actions { display: flex; gap: .5rem; flex-wrap: wrap; padding-bottom: .8rem; }
.page-actions { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-actions p { margin: 0; }
.inline-forms { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.inline-forms input, .inline-forms select { width: auto; }
.pagination { display: flex; gap: .3rem; padding: .8rem 1.2rem; flex-wrap: wrap; }
.pagination a, .pagination span { padding: .3rem .65rem; border-radius: 6px; border: 1px solid var(--border); }
.pagination .current { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }

/* ── KPIs e barras ───────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .8rem; margin-bottom: 1.1rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); }
.kpi span { display: block; font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.kpi strong { display: block; font-size: 1.45rem; margin: .2rem 0; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-size: .8rem; }
.bars { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .65rem; }
.bar-label { display: flex; justify-content: space-between; gap: .5rem; font-size: .9rem; margin-bottom: .2rem; }
.bar { height: 9px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.bar span { display: block; height: 100%; border-radius: 99px; min-width: 3px; }

/* ── Tarefas ─────────────────────────────────────────────── */
.layout-2 { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1.1rem; align-items: start; }
@media (max-width: 1100px) { .layout-2 { grid-template-columns: minmax(0, 1fr); } }
.task-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.task-head h2 { font-size: 1.35rem; margin: .2rem 0; }
.task-code { font-weight: 700; color: var(--muted); }
.task-status { text-align: right; }
.task-status .badge { font-size: .95rem; padding: .3rem .9rem; }
@media (max-width: 700px) { .task-status { text-align: left; } }
.details { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .8rem 1rem; margin: 0; }
.details dt { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.details dd { margin: .1rem 0 0; font-weight: 500; }
.actions-card { border-left: 4px solid var(--primary); }
.actions-card > * + * { margin-top: .9rem; }
.status-form { display: grid; gap: 0 .8rem; grid-template-columns: 1fr 2fr auto; align-items: end; }
.status-form .btn { margin-bottom: .8rem; }
.status-form.compact { grid-template-columns: 1fr; gap: .5rem; }
.status-form.compact .btn { margin: 0; }
@media (max-width: 700px) { .status-form { grid-template-columns: 1fr; } }
.timeline { list-style: none; margin: 0; padding: 0 0 0 1.1rem; border-left: 2px solid var(--border); }
.timeline li { position: relative; padding: 0 0 1rem .9rem; }
.timeline li::before { content: ""; position: absolute; left: -1.55rem; top: .3rem; width: 12px; height: 12px; border-radius: 50%; background: var(--c, #64748b); border: 2px solid var(--surface); }
.tl-head { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.tl-dur { font-size: .82rem; font-weight: 700; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 0 .4rem; }
.tl-body { font-size: .9rem; color: var(--muted); margin-top: .2rem; }
.tl-body p { color: var(--text); margin: .25rem 0 0; }
.files { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.files li { display: flex; flex-wrap: wrap; gap: .2rem .6rem; align-items: baseline; }
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .8rem; }
.feed li > div { margin: .2rem 0; }
.people { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .35rem; }
.people li.inactive { opacity: .5; }

.map { height: 320px; border-radius: 8px; border: 1px solid var(--border); margin-top: .5rem; z-index: 1; }
.map-sm { height: 220px; }
.map-tools { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.map-links { margin: .5rem 0 .2rem; }

.next-card { border: 2px solid var(--primary); }
.eyebrow { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--primary); font-weight: 700; }
.next-body { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: center; margin-top: .4rem; }
.next-body h2 { font-size: 1.2rem; }
.next-body p { margin: .2rem 0; }
.next-actions { display: flex; flex-direction: column; gap: .5rem; align-items: stretch; max-width: 320px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.task-card { border-top: 4px solid var(--c, var(--primary)); margin: 0; }
.task-card header { display: flex; justify-content: space-between; gap: .6rem; align-items: flex-start; margin-bottom: .4rem; }

/* ── Login ───────────────────────────────────────────────── */
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.5rem;
    background: linear-gradient(160deg, #0f3d3e, #115e59 60%, #0f766e); }
.auth-card { background: var(--surface); width: 100%; max-width: 420px; border-radius: 14px; padding: 2rem; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.auth-brand { display: flex; align-items: center; gap: .7rem; margin-bottom: 1.4rem; }
.auth-brand svg { width: 40px; height: 40px; color: var(--primary); }
.auth-brand strong { display: block; font-size: 1.25rem; }
.auth-brand small { color: var(--muted); }
.auth-title { font-size: 1.25rem; }
.auth-link { text-align: center; margin: 1rem 0 0; }
.auth-foot { color: #ccfbf1; opacity: .8; font-size: .85rem; }

/* ── Impressão ───────────────────────────────────────────── */
.print-actions { display: flex; gap: .5rem; margin-bottom: 1rem; }
@media print {
    .sidebar, .topbar, .filters, .no-print, .page-actions, .actions-card { display: none !important; }
    body { background: #fff; }
    .card, .kpi { box-shadow: none; break-inside: avoid; }
}
