:root {
    --font-ui: "Segoe UI", "Helvetica Neue", sans-serif;
    --radius-lg: 26px;
    --radius-md: 18px;
    --radius-sm: 12px;
    --shadow-soft: 0 24px 60px rgba(0, 0, 0, 0.14);
    --shadow-card: 0 16px 44px rgba(0, 0, 0, 0.18);
}

:root[data-theme="dark"] {
    --bg: #0f1218;
    --bg-accent: #161b24;
    --panel-soft: rgba(255, 255, 255, 0.03);
    --panel-strong: #f6f3ef;
    --text: #f8fafc;
    --text-soft: #b7c0d1;
    --text-muted: #8b95a7;
    --line: rgba(255, 255, 255, 0.10);
    --line-strong: rgba(255, 255, 255, 0.16);
    --brand: #8a43d1;
    --brand-2: #df7341;
    --danger: #ff6b6b;
    --kpi-text: #1f2a3a;
}

:root[data-theme="light"] {
    --bg: #f4f6fb;
    --bg-accent: #ffffff;
    --panel-soft: rgba(17, 24, 39, 0.03);
    --panel-strong: #ffffff;
    --text: #172033;
    --text-soft: #47536b;
    --text-muted: #69758c;
    --line: rgba(23, 32, 51, 0.10);
    --line-strong: rgba(23, 32, 51, 0.18);
    --brand: #7d3cc7;
    --brand-2: #d86833;
    --danger: #c34545;
    --kpi-text: #182237;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    font-family: var(--font-ui);
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(138, 67, 209, 0.16), transparent 24%),
        radial-gradient(circle at top right, rgba(223, 115, 65, 0.10), transparent 22%),
        linear-gradient(180deg, var(--bg-accent) 0%, var(--bg) 100%);
    transition: background 0.25s ease, color 0.25s ease;
}

body.dashboard-page {
    background: #0f1218;
}

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

button,
input,
select {
    font: inherit;
}

.shell {
    max-width: 1800px;
    margin: 0 auto;
    padding: 12px 28px 42px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 18px;
    margin-bottom: 34px;
}

.nav {
    display: flex;
    gap: 18px;
    align-items: center;
    flex: 1 1 auto;
}

.nav a {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text-soft);
    font-size: 0.98rem;
    padding: 8px 0;
    border-bottom: 1px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.nav a:hover,
.nav a.active {
    color: var(--text);
    transform: translateY(-1px);
}

.nav-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid var(--line-strong);
    display: inline-block;
    position: relative;
}

.nav a.active .nav-dot::after {
    content: "";
    position: absolute;
    inset: 3px;
    border-radius: 50%;
}

.dot-red::after,
.nav a.active .dot-red::after {
    background: #ff5b61;
}

.dot-amber::after,
.nav a.active .dot-amber::after {
    background: #ffcc66;
}

.dot-slate::after,
.nav a.active .dot-slate::after {
    background: #b8c2d8;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hero {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    padding-bottom: 22px;
    margin-bottom: 30px;
    border-bottom: 1px solid var(--line);
}

.hero-dashboard {
    margin-top: 36px;
}

.eyebrow {
    margin: 0 0 10px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.page-title {
    margin: 0;
    font-size: clamp(3rem, 5vw, 4.6rem);
    line-height: 1.02;
    letter-spacing: -0.04em;
    color: var(--text);
}

.page-title-sm {
    font-size: clamp(2rem, 3vw, 2.9rem);
}

.inline-form {
    display: flex;
    align-items: end;
    gap: 12px;
}

.inline-filter label {
    min-width: 160px;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 30px;
    padding-bottom: 30px;
    border-bottom: 1px solid var(--line);
}

.kpi-card {
    background: var(--panel-strong);
    color: var(--kpi-text);
    border-radius: 14px;
    padding: 24px 20px 20px;
    box-shadow: none;
    display: grid;
    place-items: center;
    text-align: center;
    min-height: 108px;
}

.kpi-card span {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.82rem;
    color: #6d7c95;
}

.kpi-card strong {
    font-size: clamp(1.9rem, 2.4vw, 2.3rem);
    margin-bottom: 8px;
}

.chart-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 22px;
}

.chart-card,
.chart-full {
    padding: 0;
    margin-bottom: 22px;
}

.chart-title {
    margin: 0 0 16px;
    font-size: 2rem;
    line-height: 1.1;
    color: var(--text);
}

.chart-embed {
    width: 100%;
}

.chart-embed-standard {
    min-height: 420px;
}

.chart-embed-wide {
    min-height: 460px;
}

.chart-embed .plotly-graph-div {
    width: 100% !important;
}

.table-card,
.form-card,
.login-card,
.flash {
    padding: 26px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--panel-soft);
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(10px);
}

.flash-stack {
    display: grid;
    gap: 12px;
    margin-bottom: 22px;
}

.flash.success {
    border-color: rgba(64, 214, 134, 0.3);
}

.flash.error {
    border-color: rgba(255, 107, 107, 0.28);
}

.theme-toggle,
.ghost,
.ghost-link,
.danger-link,
button {
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.theme-toggle,
.ghost,
.ghost-link {
    background: var(--panel-soft);
    color: var(--text);
}

button {
    padding: 12px 18px;
    background: linear-gradient(135deg, var(--brand), #6d31bf);
    color: #fff;
    box-shadow: 0 14px 28px rgba(124, 60, 199, 0.24);
}

.ghost,
.ghost-link,
.danger-link {
    padding: 11px 16px;
}

.danger-link {
    background: transparent;
    color: var(--danger);
}

.theme-toggle:hover,
.ghost:hover,
.ghost-link:hover,
.danger-link:hover,
button:hover {
    transform: translateY(-1px);
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
}

.theme-toggle-text {
    font-size: 0.95rem;
    line-height: 1;
}

.theme-toggle-track {
    width: 34px;
    height: 20px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    position: relative;
}

.theme-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fff4cf, #ffb04d);
    transition: transform 0.2s ease;
}

:root[data-theme="light"] .theme-toggle-thumb {
    transform: translateX(14px);
    background: linear-gradient(135deg, #6377ff, #9ea7ff);
}

.dashboard-page .table-card,
.dashboard-page .form-card,
.dashboard-page .login-card,
.dashboard-page .flash {
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
}

.dashboard-page .hero .inline-filter label,
.dashboard-page .hero .inline-filter select {
    min-width: 0;
    width: auto;
}

.dashboard-page .hero .inline-filter select {
    min-width: 150px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 16px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
}

th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.actions form {
    margin: 0;
}

.payment-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    padding: 7px 12px;
    font-size: 0.88rem;
    border: 1px solid var(--line-strong);
    background: rgba(255, 255, 255, 0.02);
}

.payment-chip::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.payment-nubank::before {
    background: var(--brand);
}

.payment-vale::before {
    background: var(--brand-2);
}

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

label {
    display: grid;
    gap: 8px;
    color: var(--text-soft);
    font-weight: 600;
}

input,
select {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-strong);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    outline: none;
}

input:focus,
select:focus {
    border-color: rgba(138, 67, 209, 0.7);
    box-shadow: 0 0 0 3px rgba(138, 67, 209, 0.16);
}

.form-shell {
    max-width: 760px;
}

.form-card {
    display: grid;
    gap: 18px;
}

.button-row {
    display: flex;
    gap: 12px;
    align-items: center;
}

.login-page {
    min-height: 84vh;
    display: grid;
    place-items: center;
}

.login-card {
    width: min(480px, 100%);
}

.muted {
    color: var(--text-muted);
}

.js-plotly-plot .plotly .modebar {
    background: transparent !important;
}

.js-plotly-plot .plotly .modebar-btn path {
    fill: var(--text-soft) !important;
}

@media (max-width: 1100px) {
    .kpi-grid,
    .chart-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 860px) {
    .shell {
        padding: 18px 16px 34px;
    }

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

    .nav,
    .header-actions,
    .inline-form,
    .button-row,
    .actions {
        flex-wrap: wrap;
    }

    .kpi-grid,
    .chart-grid {
        grid-template-columns: 1fr;
    }
}
