:root {
    color-scheme: dark;
    --bg: #080b10;
    --surface: #0f141d;
    --surface-2: #141b27;
    --panel: rgba(18, 24, 34, .92);
    --panel-strong: rgba(21, 29, 42, .98);
    --text: #f4f7fb;
    --muted: #a7b1c1;
    --soft: #d6dde8;
    --line: rgba(222, 231, 242, .12);
    --accent: #14e0a8;
    --accent-2: #4f8cff;
    --danger: #ff5d73;
    --warning: #f4b740;
    --ok: #2ddf89;
    --row: rgba(255, 255, 255, .035);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(115deg, rgba(20, 224, 168, .10) 0%, transparent 24%),
        linear-gradient(245deg, rgba(79, 140, 255, .10) 0%, transparent 26%),
        linear-gradient(145deg, #080b10 0%, #10151f 50%, #090b10 100%);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 5;
    pointer-events: none;
    background: linear-gradient(120deg, transparent 0%, rgba(20, 224, 168, .08) 45%, transparent 58%);
    transform: translateX(-100%);
    animation: page-sheen 1.35s ease-out .15s forwards;
}

a {
    color: inherit;
    text-decoration: none;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(470px, 100%);
    padding: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(15, 20, 29, .94);
    box-shadow: 0 24px 80px rgba(0, 0, 0, .42);
    backdrop-filter: blur(18px);
}

.login-brand,
.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}

.login-brand img,
.logo img {
    display: block;
    width: 96px;
    height: auto;
    filter: brightness(0) invert(1);
}

.login-brand span,
.logo span {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 10px;
    border-radius: 8px;
    color: #07100d;
    background: var(--accent);
    font-size: 12px;
    font-weight: 800;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    max-width: 820px;
    font-size: clamp(32px, 4vw, 52px);
    line-height: 1.02;
}

h2 {
    font-size: 20px;
}

.muted {
    color: var(--muted);
    line-height: 1.6;
    max-width: 680px;
}

.login-form {
    display: grid;
    gap: 16px;
    margin-top: 24px;
}

label {
    display: grid;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

input {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    outline: none;
    color: var(--text);
    background: rgba(255, 255, 255, .075);
}

input:focus {
    border-color: rgba(94, 241, 197, .65);
    box-shadow: 0 0 0 4px rgba(94, 241, 197, .1);
}

button {
    height: 48px;
    border: 0;
    border-radius: 8px;
    color: #06110e;
    background: var(--accent);
    font-weight: 800;
    cursor: pointer;
}

.alert,
.notice {
    margin-top: 18px;
    padding: 14px 16px;
    border: 1px solid rgba(255, 200, 90, .28);
    border-radius: 8px;
    color: #ffe4a3;
    background: rgba(255, 200, 90, .1);
}

.notice.danger {
    border-color: rgba(255, 100, 124, .35);
    color: #ffc4ce;
    background: rgba(255, 100, 124, .1);
}

.app-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 28px;
    border-right: 1px solid var(--line);
    background: rgba(8, 11, 16, .88);
    backdrop-filter: blur(20px);
}

.logo {
    font-weight: 800;
}

.sidebar-copy {
    margin: 18px 0 30px;
    color: var(--muted);
    line-height: 1.5;
}

nav {
    display: grid;
    gap: 8px;
}

nav a,
.logout {
    padding: 13px 14px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--muted);
    font-weight: 700;
}

nav a:hover,
.logout:hover {
    border-color: var(--line);
    color: var(--text);
    background: rgba(255, 255, 255, .05);
}

.content {
    width: min(1500px, 100%);
    padding: 34px;
}

.hero {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    min-height: 190px;
    padding-bottom: 28px;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.hero-actions span {
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--soft);
    background: rgba(255, 255, 255, .06);
    font-size: 13px;
    font-weight: 700;
}

.kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.kpis article,
.panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: 0 18px 48px rgba(0, 0, 0, .22);
    backdrop-filter: blur(16px);
    animation: rise-in .55s ease both;
}

.kpis article {
    position: relative;
    overflow: hidden;
    padding: 20px;
}

.kpis article:nth-child(1) { animation-delay: .04s; }
.kpis article:nth-child(2) { animation-delay: .08s; }
.kpis article:nth-child(3) { animation-delay: .12s; }
.kpis article:nth-child(4) { animation-delay: .16s; }

.kpis article::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--accent);
}

.kpis article::after,
.panel::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(110deg, transparent 0%, rgba(255, 255, 255, .08) 45%, transparent 58%);
    opacity: 0;
    transform: translateX(-100%);
}

.kpis article:hover::after,
.panel:hover::after {
    opacity: 1;
    animation: card-sheen .9s ease;
}

.kpis span {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.kpis strong {
    display: block;
    margin-top: 12px;
    color: var(--text);
    font-size: 30px;
    line-height: 1;
}

.kpis small {
    display: block;
    margin-top: 10px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.grid-two {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, .85fr);
    align-items: start;
    gap: 18px;
    margin-bottom: 18px;
}

.forecast-column {
    display: grid;
    gap: 18px;
}

.panel {
    position: relative;
    padding: 22px;
    overflow: hidden;
}

.ai-panel {
    margin-bottom: 18px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.chart-help {
    max-width: 680px;
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.ai-badge {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 12px;
    border: 1px solid rgba(20, 224, 168, .35);
    border-radius: 8px;
    color: var(--accent);
    background: rgba(20, 224, 168, .08);
    font-size: 12px;
    font-weight: 800;
}

.ai-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 12px;
}

@media (min-width: 1180px) {
    .ai-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.ai-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 190px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    animation: rise-in .55s ease both;
    background: rgba(255, 255, 255, .045);
}

.ai-card:nth-child(1) { animation-delay: .08s; }
.ai-card:nth-child(2) { animation-delay: .14s; }
.ai-card:nth-child(3) { animation-delay: .2s; }
.ai-card:nth-child(4) { animation-delay: .26s; }
.ai-card:nth-child(5) { animation-delay: .32s; }
.ai-card:nth-child(6) { animation-delay: .38s; }
.ai-card:nth-child(7) { animation-delay: .44s; }
.ai-card:nth-child(8) { animation-delay: .5s; }

.ai-card span {
    display: inline-flex;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.ai-card strong {
    display: block;
    color: var(--text);
    line-height: 1.25;
}

.ai-card p {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.ai-card b {
    display: inline-flex;
    width: fit-content;
    margin-top: 18px;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, .07);
    font-size: 13px;
}

.ai-card.danger {
    box-shadow: inset 4px 0 0 rgba(255, 93, 115, .9);
}

.ai-card.warning {
    box-shadow: inset 4px 0 0 rgba(244, 183, 64, .9);
}

.ai-card.success {
    box-shadow: inset 4px 0 0 rgba(45, 223, 137, .8);
}

.ai-card.neutral {
    box-shadow: inset 4px 0 0 rgba(79, 140, 255, .75);
}

canvas {
    width: 100% !important;
    height: 360px !important;
    max-height: 360px;
}

#topProductsChart {
    height: 400px !important;
    max-height: 400px;
}

#forecastChart,
#stockHealthChart {
    height: 320px !important;
    max-height: 320px;
}

#deadValueChart {
    height: 330px !important;
    max-height: 330px;
}

.forecast-list {
    display: grid;
    gap: 10px;
}

.coverage-summary {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin-top: 16px;
}

.coverage-card {
    min-height: 82px;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .045);
}

.coverage-card span,
.coverage-card small {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
}

.coverage-card strong {
    display: block;
    margin: 8px 0 4px;
    color: var(--text);
    font-size: 22px;
    line-height: 1;
}

.coverage-card.zerado {
    box-shadow: inset 3px 0 0 rgba(255, 93, 115, .9);
}

.coverage-card.ate-7-dias {
    box-shadow: inset 3px 0 0 rgba(244, 183, 64, .9);
}

.coverage-card.entre-8-30-dias {
    box-shadow: inset 3px 0 0 rgba(79, 140, 255, .9);
}

.coverage-card.acima-de-30-dias {
    box-shadow: inset 3px 0 0 rgba(45, 223, 137, .85);
}

.coverage-card.sem-giro {
    box-shadow: inset 3px 0 0 rgba(125, 135, 151, .9);
}

.coverage-insight {
    margin-top: 12px;
    padding: 13px 14px;
    border: 1px solid rgba(20, 224, 168, .22);
    border-radius: 8px;
    background: rgba(20, 224, 168, .07);
}

.coverage-insight span {
    display: block;
    margin-bottom: 6px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.coverage-insight p {
    margin: 0;
    color: var(--soft);
    font-size: 13px;
    line-height: 1.45;
}

.coverage-lists {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.coverage-list {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .035);
    overflow: hidden;
}

.coverage-list summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    cursor: pointer;
    color: var(--text);
    font-weight: 800;
}

.coverage-list summary::marker {
    color: var(--accent);
}

.coverage-list summary b {
    color: var(--muted);
    font-size: 12px;
}

.coverage-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 14px;
    border-top: 1px solid var(--line);
}

.coverage-list-item strong,
.coverage-list-item small {
    display: block;
}

.coverage-list-item strong {
    color: var(--soft);
    font-size: 13px;
    line-height: 1.35;
}

.coverage-list-item small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
}

.coverage-list-item em {
    flex: 0 0 auto;
    color: var(--accent);
    font-size: 12px;
    font-style: normal;
    font-weight: 800;
}

.empty-list {
    margin: 0;
    padding: 12px 14px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 13px;
}

.forecast-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .045);
    animation: slide-soft .45s ease both;
}

.forecast-item:nth-child(2n) {
    animation-delay: .04s;
}

.forecast-item strong,
.forecast-item span {
    display: block;
}

.forecast-item span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.forecast-item b {
    white-space: nowrap;
}

.critico {
    color: var(--danger);
}

.baixo {
    color: var(--warning);
}

.saudavel {
    color: var(--ok);
}

.search {
    max-width: 300px;
}

.table-wrap {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: auto;
}

table {
    width: 100%;
    min-width: 1080px;
    border-collapse: collapse;
}

th,
td {
    padding: 15px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    font-size: 14px;
    vertical-align: middle;
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    color: var(--soft);
    background: var(--panel-strong);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

tbody tr {
    animation: fade-row .35s ease both;
}

tbody tr:nth-child(1) { animation-delay: .02s; }
tbody tr:nth-child(2) { animation-delay: .04s; }
tbody tr:nth-child(3) { animation-delay: .06s; }
tbody tr:nth-child(4) { animation-delay: .08s; }
tbody tr:nth-child(5) { animation-delay: .1s; }

tbody tr:nth-child(even) {
    background: var(--row);
}

tbody tr:hover {
    background: rgba(20, 224, 168, .07);
}

td:first-child {
    max-width: 420px;
    color: var(--text);
    font-weight: 700;
}

td:nth-child(2),
td:nth-child(5),
td:nth-child(6),
td:nth-child(7),
td:nth-child(8) {
    color: var(--soft);
    font-weight: 700;
}

td:nth-child(3) {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid currentColor;
    background: rgba(255, 255, 255, .06);
    font-size: 12px;
    font-weight: 800;
}

.critico-row {
    box-shadow: inset 4px 0 0 rgba(255, 93, 115, .86);
}

.baixo-row {
    box-shadow: inset 4px 0 0 rgba(244, 183, 64, .86);
}

.saudavel-row {
    box-shadow: inset 4px 0 0 rgba(45, 223, 137, .55);
}

.table-note {
    color: var(--muted);
    font-size: 13px;
}

@keyframes rise-in {
    from {
        opacity: 0;
        transform: translateY(14px) scale(.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes slide-soft {
    from {
        opacity: 0;
        transform: translateX(10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fade-row {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes card-sheen {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(100%);
    }
}

@keyframes page-sheen {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(100%);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
    }
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        gap: 18px;
    }

    .content {
        padding: 20px;
    }

    .hero,
    .panel-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .kpis,
    .grid-two,
    .ai-grid,
    .coverage-summary {
        grid-template-columns: 1fr;
    }
}
