:root {
    color-scheme: light;
    --navy: #061638;
    --primary: #0054b8;
    --digital: #008ed6;
    --cyan: #00c4df;
    --canvas: #f4f6f9;
    --surface: #fff;
    --ink-muted: #475975;
    --border: #dce4ef;
    --field-border: #8395ae;
    --focus: var(--primary);
    --font: "Segoe UI", system-ui, -apple-system, sans-serif;
    --radius: 16px;
    --shadow: 0 16px 45px #06163812;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--navy); font: 1rem/1.5 var(--font); }
h1, h2, p, dl, dd { margin: 0; }
button, input { font: inherit; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.icon-library { position: absolute; pointer-events: none; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.brand-name { font-weight: 750; letter-spacing: -.045em; line-height: 1.05; }
.brand-logo { display: block; max-width: 100%; max-height: 72px; object-fit: contain; }
.notice { padding: 12px 14px; margin-bottom: 16px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.notice-error, .errorlist { color: #8f2020; }
.notice-error { background: #fff2f2; border-color: #f4caca; }
.skip-link { position: fixed; z-index: 4; top: 8px; left: 8px; padding: 10px 14px; background: var(--surface); transform: translateY(-180%); }
.skip-link:focus { transform: none; }

/* Área autenticada */
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.app-sidebar { --focus: var(--cyan); background: var(--navy); color: var(--surface); padding: 32px 17px; }
.sidebar-brand { display: grid; gap: 7px; padding: 2px 13px 29px; margin-bottom: 19px; border-bottom: 1px solid #ffffff22; }
.sidebar-brand a { color: inherit; text-decoration: none; font-size: 1.9rem; width: fit-content; }
.sidebar-brand a:has(.brand-logo) { width: min(100%, 174px); padding: 6px 8px; background: var(--surface); border-radius: 10px; }
.sidebar-brand > span { color: #b7c9e7; font-size: .81rem; }
.side-nav { display: grid; gap: 5px; }
.side-nav > * { display: flex; align-items: center; gap: 13px; min-height: 44px; padding: 8px 12px; border: 1px solid transparent; border-radius: 9px; }
.side-nav a { color: #e6eeff; text-decoration: none; font-size: .93rem; font-weight: 600; }
.side-nav a:hover { background: #ffffff12; }
.side-nav a[aria-current] { color: var(--surface); background: #123463; border-color: #2a5184; box-shadow: inset 3px 0 var(--cyan); }
.side-nav .nav-unavailable { color: #a1b2d0; font-size: .93rem; }
.nav-unavailable:first-of-type { margin-top: 12px; }
.app-body { min-width: 0; }
.app-header { position: relative; display: flex; align-items: center; justify-content: space-between; min-height: 75px; gap: 12px; padding: 12px clamp(18px, 4vw, 54px); background: var(--surface); border-bottom: 1px solid var(--border); }
.header-label { font-size: .88rem; font-weight: 650; color: var(--ink-muted); }
.user-controls, .user-name, .logout-button { display: flex; align-items: center; gap: 8px; min-width: 0; }
.user-controls { gap: clamp(8px, 2vw, 22px); }
.user-name { font-size: .86rem; }
.user-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-name .icon { width: 32px; height: 32px; padding: 6px; border-radius: 50%; background: #eaf2fd; color: var(--primary); }
.logout-button { min-height: 40px; padding: 5px 10px; background: var(--surface); color: var(--primary); border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: .87rem; font-weight: 650; }
.logout-button:hover { background: #ecf5ff; }
.mobile-menu { display: none; }
.app-content { max-width: 1500px; padding: clamp(22px, 4vw, 54px); margin: 0 auto; }
.page-heading { padding-bottom: 23px; margin-bottom: 26px; border-bottom: 1px solid var(--border); }
.page-heading h1, .auth-heading h1 { margin-bottom: 7px; font-size: clamp(1.9rem, 4vw, 2.7rem); line-height: 1.13; letter-spacing: -.045em; }
.page-heading p, .auth-heading p { color: var(--ink-muted); }
.metrics-section h2 { margin-bottom: 14px; font-size: 1.05rem; font-weight: 700; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.metric { padding: clamp(16px, 2vw, 24px); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: 0 6px 18px #06163809; }
.metric dt { display: grid; gap: 14px; color: var(--ink-muted); font-size: .88rem; font-weight: 650; }
.metric dd { margin-top: 5px; font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 750; letter-spacing: -.045em; line-height: 1.15; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.metric-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; color: var(--primary); background: #e8f1fe; }
.metric-icon--cotacoes { background: #e1f4fe; color: #075786; }
.metric-icon--seguros { background: #e9eefb; color: #344985; }
.metric-icon--renovacoes { background: #dff7fa; color: #145566; }

/* Autenticação */
.auth-layout { display: grid; min-height: 100vh; grid-template-columns: minmax(0, .91fr) minmax(0, 1.09fr); }
.auth-brand { position: relative; isolation: isolate; display: flex; align-items: flex-end; overflow: hidden; min-height: 260px; padding: clamp(30px, 6vw, 96px); background: linear-gradient(145deg, var(--navy) 34%, #074985 100%); color: var(--surface); }
.auth-brand::before, .auth-brand::after { position: absolute; z-index: -1; content: ""; pointer-events: none; }
.auth-brand::before { top: -7%; right: -35%; width: min(78vw, 770px); aspect-ratio: 1; border-radius: 50%; background: repeating-radial-gradient(circle, transparent 0 32px, #00c4df4a 33px 34px, transparent 35px 39px); }
.auth-brand::after { inset: 0; background: linear-gradient(0deg, #061638db, transparent 64%), radial-gradient(ellipse at 100% 35%, #008ed67a, transparent 55%); }
.auth-brand-text::before { content: ""; display: block; width: 45px; height: 3px; margin-bottom: 19px; border-radius: 10px; background: var(--cyan); }
.auth-brand .brand-name { display: block; font-size: clamp(2.65rem, 6.5vw, 6rem); }
.auth-brand .brand-logo { width: min(100%, 428px); height: auto; max-height: none; padding: 10px 15px; background: var(--surface); border-radius: 14px; }
.auth-brand p { margin-top: 12px; color: #e2efff; font-size: clamp(.92rem, 2vw, 1.25rem); }
.auth-content { display: grid; place-items: center; padding: clamp(20px, 5vw, 76px); }
.auth-card { width: min(100%, 460px); padding: clamp(23px, 4.5vw, 48px); background: var(--surface); border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow); }
.auth-heading { margin-bottom: 28px; }
.auth-form { display: grid; gap: 18px; }
.field label { display: block; margin-bottom: 6px; font-size: .92rem; font-weight: 700; }
.field input { width: 100%; min-height: 48px; padding: 10px 13px; color: var(--navy); background: var(--surface); border: 1px solid var(--field-border); border-radius: 9px; }
.field input[aria-invalid="true"] { border-color: #a92626; }
.errorlist { margin: 5px 0 0; padding-left: 18px; font-size: .88rem; }
.primary-button { display: flex; justify-content: center; align-items: center; gap: 10px; min-height: 48px; margin-top: 6px; padding: 10px 16px; border: 0; border-radius: 9px; background: var(--primary); color: var(--surface); font-weight: 700; cursor: pointer; }
.primary-button:hover { background: #003c89; }

@media (max-width: 1130px) {
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 730px) {
    .auth-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
    .auth-brand { min-height: 178px; padding: 26px; }
    .auth-brand::before { width: 420px; top: -125px; right: -105px; }
    .auth-content { align-items: start; }
    .app-shell { display: block; }
    .app-sidebar, .header-label { display: none; }
    .app-header { min-height: 64px; }
    .mobile-menu { display: block; flex: none; }
    .mobile-menu summary { display: flex; align-items: center; gap: 7px; min-height: 44px; list-style: none; cursor: pointer; }
    .mobile-menu summary::-webkit-details-marker { display: none; }
    .mobile-menu .brand-logo { max-width: 90px; max-height: 36px; }
    .auth-brand .brand-logo { width: min(100%, 228px); padding: 6px 9px; border-radius: 10px; }
    .mobile-menu .side-nav { --focus: var(--cyan); position: absolute; z-index: 2; top: calc(100% + 4px); left: 8px; min-width: 220px; max-height: min(75vh, 460px); overflow: auto; padding: 10px; background: var(--navy); border-radius: 12px; box-shadow: var(--shadow); }
    .user-name .icon { display: none; }
}

@media (max-width: 400px) {
    .app-header { padding-inline: 12px; }
    .app-content { padding-inline: 15px; }
    .metric-grid { gap: 10px; }
    .metric dt { overflow-wrap: anywhere; }
    .logout-button .icon { display: none; }
}
