:root {
    --bg: #f3f5f1;
    --surface: #ffffff;
    --surface-alt: #eef3ed;
    --line: #d8e1d7;
    --text: #1f2b22;
    --muted: #5f6f63;
    --brand: #1f6b52;
    --brand-dark: #174c3a;
    --danger: #b74636;
    --warning: #a36a17;
    --info: #3f6d87;
    --success: #2d7a4f;
    --shadow: 0 18px 38px rgba(26, 44, 31, 0.08);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", "Helvetica Neue", sans-serif;
    background:
        radial-gradient(circle at top right, rgba(31, 107, 82, 0.10), transparent 30%),
        linear-gradient(180deg, #f7faf6 0%, var(--bg) 100%);
    color: var(--text);
}

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

code {
    background: var(--surface-alt);
    padding: 0.15rem 0.4rem;
    border-radius: 8px;
}

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

.sidebar {
    background: linear-gradient(180deg, #18362c 0%, #1f2b22 100%);
    color: #f7f7f2;
    padding: 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 2rem;
}

.brand p {
    margin: 0.25rem 0 0;
    color: rgba(255, 255, 255, 0.68);
    font-size: 0.95rem;
}

.brand-mark {
    width: 50px;
    height: 50px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, #4ea17f, #c2dd8d);
    color: #163227;
    font-weight: 700;
}

.menu {
    display: grid;
    gap: 0.4rem;
}

.sidebar-session {
    margin-bottom: 1.25rem;
    padding: 0.95rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-session strong,
.sidebar-session p {
    display: block;
}

.sidebar-session p {
    margin: 0.2rem 0 0.8rem;
    color: rgba(255, 255, 255, 0.72);
}

.sidebar-logout {
    width: 100%;
}

.menu a {
    color: rgba(255, 255, 255, 0.86);
    padding: 0.8rem 0.9rem;
    border-radius: 12px;
    transition: 0.2s ease;
}

.menu a:hover,
.menu a.active {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.content {
    padding: 2rem;
}

.topbar {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.5rem;
}

.topbar h1 {
    margin: 0;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 2rem;
}

.topbar-subtitle {
    margin: 0.25rem 0 0;
    color: var(--muted);
}

.menu-toggle {
    display: none;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    padding: 0.75rem 1rem;
}

.flash-stack {
    display: grid;
    gap: 0.7rem;
    margin-bottom: 1rem;
}

.flash {
    border-radius: 14px;
    padding: 0.95rem 1rem;
    border: 1px solid transparent;
}

.flash-success { background: #edf7ef; border-color: #b8dbbf; }
.flash-error { background: #fceeed; border-color: #e7b5ad; }
.flash-warning { background: #fff6e8; border-color: #ecd2a3; }
.flash-info { background: #eef6fb; border-color: #b8d4e7; }

.card-grid,
.split-grid {
    display: grid;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.split-grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.reconciliation-grid {
    grid-template-columns: 1fr;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}

.entity-internal {
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 0.2em;
}

.company-report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.company-report-card {
    display: grid;
    gap: 0.45rem;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--surface-alt);
    color: var(--text);
}

.company-report-card.is-active {
    border-color: #7ab595;
    box-shadow: inset 0 0 0 1px rgba(31, 107, 82, 0.14);
}

.highlight-card {
    border-color: #97c6b0;
}

.stat-card strong {
    font-size: 2rem;
    display: block;
    margin: 0.4rem 0 0.3rem;
}

.eyebrow {
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.74rem;
    color: var(--muted);
}

.section-heading,
.reconcile-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.section-heading h2,
.reconcile-header h2 {
    margin: 0;
    font-size: 1.15rem;
}

.align-right {
    text-align: right;
}

.list-stack {
    display: grid;
    gap: 0.85rem;
}

.list-row {
    padding: 0.9rem;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--surface-alt);
}

.list-row p,
.helper-text,
.empty-state,
.info-strip span {
    color: var(--muted);
}

.table-wrap {
    overflow-x: auto;
}

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

th,
td {
    padding: 0.85rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

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

.actions-col {
    white-space: nowrap;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.form-grid label {
    display: grid;
    gap: 0.45rem;
}

.form-grid label.checkbox-field {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.form-grid label.checkbox-field input {
    width: auto;
    margin: 0;
}

.form-grid label.full,
.form-actions.full {
    grid-column: 1 / -1;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    padding: 0.78rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fbfcfa;
    color: var(--text);
}

textarea {
    resize: vertical;
}

.form-actions,
.inline-form {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    flex-wrap: wrap;
}

.compact-form {
    gap: 0.4rem;
}

.btn {
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0.7rem 1rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: var(--brand);
    color: #fff;
}

.btn-primary:hover {
    background: var(--brand-dark);
}

.btn-light {
    background: var(--surface-alt);
    color: var(--text);
    border-color: var(--line);
}

.btn-danger {
    background: #f9e9e6;
    color: var(--danger);
    border-color: #efc3bc;
}

.badge,
.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    font-size: 0.82rem;
}

.badge-success,
.pill-success { background: #e7f5eb; color: var(--success); }
.badge-info { background: #e9f2f7; color: var(--info); }
.badge-warning,
.pill-warning { background: #fbf2e2; color: var(--warning); }
.badge-danger,
.pill-danger { background: #faeae7; color: var(--danger); }
.badge-muted,
.pill-muted { background: #eef1ed; color: #66756a; }
.badge-alta { background: #faeae7; color: var(--danger); }
.badge-media { background: #fbf2e2; color: var(--warning); }
.badge-bassa { background: #eef6fb; color: var(--info); }

.pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-bottom: 1rem;
}

.info-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    padding: 0.9rem 1rem;
    background: var(--surface-alt);
    border-radius: 14px;
    border: 1px solid var(--line);
}

.row-ok td {
    background: rgba(45, 122, 79, 0.04);
}

.row-error td {
    background: rgba(183, 70, 54, 0.05);
}

.btn.is-selected {
    background: #17352c;
    color: #ffffff;
    border-color: #17352c;
}

.personal-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.95fr);
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.personal-hero-copy,
.personal-hero-panel {
    border-radius: 26px;
    padding: 1.4rem;
    border: 1px solid rgba(24, 54, 44, 0.1);
    box-shadow: var(--shadow);
}

.personal-hero-copy {
    color: #0f261f;
    background:
        radial-gradient(circle at top left, rgba(222, 173, 88, 0.24), transparent 28%),
        linear-gradient(135deg, #fbf4df 0%, #eef7ef 100%);
}

.personal-hero-copy h2 {
    margin: 0.4rem 0 0.8rem;
    font-family: Georgia, "Palatino Linotype", serif;
    font-size: clamp(1.9rem, 2.4vw, 3.15rem);
    line-height: 1.02;
    max-width: 16ch;
}

.personal-hero-copy p {
    max-width: 70ch;
}

.personal-hero-panel {
    background:
        radial-gradient(circle at top right, rgba(31, 107, 82, 0.16), transparent 24%),
        linear-gradient(180deg, #17352c 0%, #1f2b22 100%);
    color: #f5f6ef;
}

.personal-hero-panel .helper-text,
.personal-hero-panel code {
    color: rgba(245, 246, 239, 0.84);
}

.hero-chip-grid {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 0.85rem;
    margin-bottom: 1rem;
}

.hero-chip {
    padding: 1rem;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.hero-chip span,
.hero-chip small {
    display: block;
    color: rgba(255, 255, 255, 0.7);
}

.hero-chip strong {
    display: block;
    margin: 0.25rem 0 0.15rem;
    font-size: 1.5rem;
}

.personal-stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.personal-stat {
    position: relative;
    overflow: hidden;
}

.personal-stat::after {
    content: "";
    position: absolute;
    inset: auto -12% -35% auto;
    width: 140px;
    height: 140px;
    border-radius: 999px;
    background: radial-gradient(circle, rgba(31, 107, 82, 0.11), transparent 60%);
}

.personal-focus-card {
    background:
        linear-gradient(180deg, rgba(254, 246, 219, 0.9) 0%, rgba(255, 255, 255, 0.98) 100%);
}

.opportunity-stack {
    display: grid;
    gap: 0.85rem;
}

.opportunity-card {
    padding: 1rem;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.86);
}

.opportunity-card p,
.opportunity-card small {
    margin: 0.35rem 0 0;
    color: var(--muted);
}

.opportunity-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: baseline;
}

.opportunity-danger {
    border-color: rgba(183, 70, 54, 0.28);
    background: rgba(252, 238, 237, 0.8);
}

.opportunity-warning {
    border-color: rgba(163, 106, 23, 0.25);
    background: rgba(255, 246, 232, 0.86);
}

.opportunity-info {
    border-color: rgba(63, 109, 135, 0.25);
    background: rgba(238, 246, 251, 0.86);
}

.opportunity-success {
    border-color: rgba(45, 122, 79, 0.25);
    background: rgba(237, 247, 239, 0.86);
}

.monthly-bars {
    display: grid;
    gap: 0.75rem;
}

.monthly-row {
    display: grid;
    grid-template-columns: minmax(0, 150px) minmax(0, 1fr) minmax(0, 190px);
    gap: 0.8rem;
    align-items: center;
    padding: 0.85rem 0.95rem;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface-alt);
}

.monthly-meta strong,
.monthly-values span {
    display: block;
}

.monthly-meta small,
.monthly-values span:last-child {
    color: var(--muted);
}

.monthly-bar-track {
    height: 12px;
    border-radius: 999px;
    background: rgba(31, 43, 34, 0.08);
    overflow: hidden;
}

.monthly-bar-spend {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #1f6b52 0%, #ddb258 100%);
}

.monthly-values {
    text-align: right;
}

.compact-list .list-row,
.category-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
}

.audit-row {
    align-items: flex-start;
}

.audit-row small {
    display: block;
    margin-top: 0.35rem;
    color: var(--muted);
}

.table-wrap td p,
.table-wrap td .helper-text {
    margin: 0.28rem 0 0;
}

.price-watch-hero .personal-hero-copy {
    background:
        radial-gradient(circle at top left, rgba(100, 144, 201, 0.18), transparent 28%),
        linear-gradient(135deg, #eef4fb 0%, #f3f8ef 100%);
}

.strategy-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.9rem;
}

.strategy-card {
    padding: 1rem;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: var(--surface-alt);
}

.strategy-card p,
.strategy-card small {
    margin: 0.35rem 0 0;
    color: var(--muted);
}

.strategy-success {
    background: rgba(237, 247, 239, 0.86);
    border-color: rgba(45, 122, 79, 0.25);
}

.strategy-warning {
    background: rgba(255, 246, 232, 0.86);
    border-color: rgba(163, 106, 23, 0.25);
}

.strategy-info {
    background: rgba(238, 246, 251, 0.86);
    border-color: rgba(63, 109, 135, 0.25);
}

.strategy-danger {
    background: rgba(252, 238, 237, 0.8);
    border-color: rgba(183, 70, 54, 0.28);
}

.subscription-detail-stack {
    display: grid;
    gap: 1rem;
}

.subscription-detail-card {
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface-alt);
}

.subscription-detail-card h3 {
    margin: 0;
    font-size: 1.05rem;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.2rem;
}

.auth-shell {
    width: min(100%, 460px);
}

.auth-card {
    padding: 1.5rem;
    border-radius: 26px;
    border: 1px solid var(--line);
    background:
        radial-gradient(circle at top left, rgba(222, 173, 88, 0.2), transparent 30%),
        linear-gradient(180deg, #ffffff 0%, #f4f8f2 100%);
    box-shadow: var(--shadow);
}

.auth-card h1 {
    margin: 0.35rem 0 0.5rem;
    font-family: Georgia, "Palatino Linotype", serif;
}

.auth-form {
    display: grid;
    gap: 0.9rem;
    margin-top: 1rem;
}

.auth-form label {
    display: grid;
    gap: 0.35rem;
}

.auth-form button {
    margin-top: 0.4rem;
}

.auth-hint {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.auth-hint p {
    margin: 0.3rem 0 0;
    color: var(--muted);
}

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

    .sidebar {
        position: fixed;
        left: -100%;
        width: 290px;
        z-index: 20;
        transition: left 0.25s ease;
    }

    .sidebar.open {
        left: 0;
    }

    .menu-toggle {
        display: inline-flex;
    }

    .content {
        padding: 1rem;
    }

    .topbar {
        align-items: flex-start;
    }

    .personal-hero {
        grid-template-columns: 1fr;
    }

    .monthly-row {
        grid-template-columns: 1fr;
    }

    .monthly-values {
        text-align: left;
    }
}

@media (max-width: 640px) {
    .topbar h1 {
        font-size: 1.55rem;
    }

    .card {
        padding: 1rem;
    }

    .section-heading,
    .reconcile-header,
    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .btn,
    .inline-form,
    .compact-form {
        width: 100%;
    }
}
