:root {
    --bg: #eef2f6;
    --surface: #ffffff;
    --surface-strong: #f8fbff;
    --border: #d9e2ec;
    --text: #1f2933;
    --text-muted: #64748b;
    --brand: #d81b27;
    --brand-dark: #a81a20;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --warn: #f59e0b;
    --warn-bg: #fef3c7;
    --ok: #16a34a;
    --ok-bg: #dcfce7;
    --radius: 14px;
    --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: linear-gradient(180deg, #f9fbff 0%, #eef2f6 100%);
    color: var(--text);
    line-height: 1.6;
}

::selection {
    background: rgba(216, 27, 39, 0.15);
}

.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

.card, .form-card, .table-responsive {
    border-radius: var(--radius);
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1050;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}
.topbar-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 20px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}
.brand img {
    height: 38px;
    display: block;
}
.brand span {
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.03em;
}
.login-logo {
    display: block;
    margin: 0 auto 18px;
    height: 64px;
}
.topbar .nav {
    display: flex;
    gap: 18px;
    flex: 1;
}
.topbar .nav a {
    color: var(--text-muted);
    font-weight: 600;
    transition: color 0.2s ease;
}
.topbar .nav a:hover,
.topbar .nav a.active {
    color: var(--brand);
}
.user-box {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.user-menu { position: relative; }
.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 9px;
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
    color: var(--text-muted);
    padding: 6px 10px 6px 6px;
    border-radius: 999px;
}
.user-menu-trigger:hover { background: var(--bg); }
.avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.user-menu-name { white-space: nowrap; }
.chevron { font-size: 0.7rem; }
.user-menu-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 170px;
    overflow: hidden;
    z-index: 20;
}
.user-menu-dropdown.open { display: block; }
.user-menu-dropdown a {
    display: block;
    padding: 11px 16px;
    color: var(--text);
    font-size: 0.9rem;
}
.user-menu-dropdown a:hover { background: var(--bg); text-decoration: none; }
.user-menu-dropdown a + a { border-top: 1px solid var(--border); }

h1 { font-size: 1.5rem; margin: 0 0 6px; }
h2 { font-size: 1.15rem; margin: 0 0 10px; }
.subtitle { color: var(--text-muted); margin: 0 0 22px; }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    border-radius: 999px;
    background: var(--brand);
    color: #fff;
    border: none;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 12px 24px rgba(216, 27, 39, 0.16);
}
.btn:hover {
    background: var(--brand-dark);
    transform: translateY(-1px);
    text-decoration: none;
}
.btn-ghost {
    background: transparent;
    color: var(--brand);
    border: 1px solid var(--border);
    box-shadow: none;
}
.btn-ghost:hover {
    background: rgba(216, 27, 39, 0.08);
}
.btn-danger {
    background: var(--danger);
    box-shadow: 0 12px 24px rgba(220, 38, 38, 0.18);
}
.btn-danger:hover {
    background: #b91c1c;
}
.btn-sm {
    padding: 8px 14px;
    font-size: 0.84rem;
}

.toolbar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    align-items: center;
}

input[type=text], input[type=email], input[type=password], input[type=search], select, textarea {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.92rem;
    background: var(--surface);
    color: var(--text);
    width: 100%;
}
label { font-weight: 600; font-size: 0.86rem; display: block; margin-bottom: 5px; color: var(--text-muted); }
.field { margin-bottom: 16px; }
.form-card {
    background: var(--surface);
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: var(--radius);
    padding: 28px;
    max-width: 720px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.05);
}
.checkbox-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.checkbox-row input { width: auto; }
.checkbox-row label { margin: 0; font-weight: 500; color: var(--text); }

.grid-empresas {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.card {
    background: var(--surface);
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.05);
    display: block;
    color: inherit;
    transition: transform 0.2s ease, border-color 0.2s ease;
}
.card:hover {
    transform: translateY(-2px);
    border-color: var(--brand);
    text-decoration: none;
}

.card-title { font-weight: 700; font-size: 1.02rem; margin-bottom: 2px; }
.card-sub { color: var(--text-muted); font-size: 0.83rem; margin-bottom: 14px; }

.progress-track {
    background: var(--bg);
    border-radius: 999px;
    height: 9px;
    overflow: hidden;
    margin-bottom: 8px;
}
.progress-fill { height: 100%; border-radius: 999px; }
.progress-fill.status-ok { background: var(--ok); }
.progress-fill.status-warn { background: var(--warn); }
.progress-fill.status-danger { background: var(--danger); }

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 700;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }

.ultimo-100 { font-size: 0.8rem; color: var(--text-muted); }
.ultimo-100 strong { color: var(--text); }

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.04);
}
th, td {
    text-align: left;
    padding: 16px 18px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
    font-size: 0.92rem;
}
th {
    color: var(--text-muted);
    font-weight: 700;
    background: #f8fbff;
}
tr:last-child td {
    border-bottom: none;
}
tr:hover td {
    background: rgba(216, 27, 39, 0.04);
}

.checklist {
    list-style: none;
    padding: 0;
    margin: 0;
    background: var(--surface);
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.04);
}
.checklist li {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}
.checklist li:last-child {
    border-bottom: none;
}
.checklist li.done {
    background: var(--ok-bg);
}
.checklist input[type=checkbox] {
    width: 22px;
    height: 22px;
    margin-top: 4px;
    cursor: pointer;
}
.etapa-nome {
    font-weight: 700;
    font-size: 0.98rem;
}
.etapa-meta {
    font-size: 0.84rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.flash { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 18px; font-size: 0.9rem; }
.flash-success { background: var(--ok-bg); color: var(--ok); }
.flash-error { background: var(--danger-bg); color: var(--danger); }

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px 48px;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f6 100%);
}
.login-card {
    background: var(--surface);
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: calc(var(--radius) * 1.2);
    padding: 36px 30px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 22px 60px rgba(15, 23, 42, 0.09);
}
.login-card h1 {
    text-align: center;
    margin-bottom: 24px;
    font-size: 1.65rem;
}
.login-logo {
    height: 72px;
    display: block;
    margin: 0 auto 18px;
}
.login-card .form-control {
    border-radius: 12px;
}
.login-card .btn {
    width: 100%;
}

.login-card p,
.login-card .subtitle {
    text-align: center;
}

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14120f;
        --surface: #201d1a;
        --border: #35312c;
        --text: #ececec;
        --text-muted: #a3a09b;
        --brand: #ff5148;
        --brand-dark: #ff746c;
        --danger-bg: #3a1e1c;
        --warn-bg: #3a2f1a;
        --ok-bg: #16301f;
    }
}
