:root {
    --vg-green: #1e6b3a;
    --vg-green-soft: #e7f1ea;
    --vg-gold: #c89237;
    --vg-blue: #3e668e;
    --charcoal: #222a2e;
    --grey: #555e64;
    --grey-light: #f6f6f3;
    --grey-line: #e5e5e0;
    --white: #ffffff;
    --danger: #b23a3a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    background: var(--grey-light);
    color: var(--charcoal);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

header.top {
    background: var(--vg-green);
    color: var(--white);
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

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

header.top .brand .brand-mark { flex-shrink: 0; }

header.top .brand .brand-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

header.top .brand .company {
    font-size: 11px;
    letter-spacing: 1.5px;
    opacity: 0.85;
    text-transform: uppercase;
}

header.top .brand .app {
    font-size: 20px;
    font-weight: 700;
}

header.top .brand .brand-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

header.top .who {
    text-align: right;
    font-size: 13px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

header.top .who a {
    color: #fff;
    opacity: 0.9;
    text-decoration: none;
}
header.top .who a:hover { opacity: 1; text-decoration: underline; }

header.top .who .whoami {
    line-height: 1.2;
    max-width: 220px;
    text-align: right;
    word-break: break-word;
}

button.signout-btn {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}
button.signout-btn:hover { background: rgba(255, 255, 255, 0.22); }

@media (max-width: 560px) {
    header.top { flex-direction: column; align-items: flex-start; padding: 14px 18px; }
    header.top .who {
        text-align: left;
        justify-content: flex-start;
        width: 100%;
        border-top: 1px solid rgba(255,255,255,0.15);
        padding-top: 10px;
    }
    header.top .who .whoami { text-align: left; max-width: none; }
    main { padding: 20px 16px; }
    section { padding: 16px 18px; }
    h1 { font-size: 22px; }
}

main {
    padding: 28px 24px;
    max-width: 1100px;
    margin: 0 auto;
}

h1 {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--charcoal);
}

h1 + p.sub {
    color: var(--grey);
    font-size: 14px;
    margin-bottom: 24px;
}

section {
    background: var(--white);
    border: 1px solid var(--grey-line);
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 20px;
}

section h2 {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--vg-green);
    margin-bottom: 14px;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

section h2 .sub {
    color: var(--grey);
    font-size: 11px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
}

/* summary tiles */
.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

.tile {
    padding: 16px 18px;
    border-radius: 10px;
    background: var(--grey-light);
    border: 1px solid var(--grey-line);
}

.tile .label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--grey);
    margin-bottom: 6px;
}

.tile .value {
    font-size: 24px;
    font-weight: 700;
    color: var(--charcoal);
    line-height: 1.1;
}

.tile .value.big {
    font-size: 30px;
    color: var(--vg-green);
}

.tile.accent {
    background: var(--vg-green-soft);
    border-color: var(--vg-green-soft);
}

/* Hero primary tile — one glance = one answer */
.hero-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 14px;
}
@media (max-width: 640px) { .hero-row { grid-template-columns: 1fr; } }

.tile.hero-primary {
    background: var(--vg-green-soft);
    border-color: var(--vg-green-soft);
    padding: 22px 26px;
}
.tile.hero-primary .label {
    font-size: 12px;
    color: var(--vg-green);
    font-weight: 700;
}
.tile.hero-primary .value.hero {
    font-size: 44px;
    font-weight: 800;
    color: var(--vg-green);
    line-height: 1.05;
    margin-bottom: 14px;
    font-variant-numeric: tabular-nums;
}
.hero-breakdown {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px 18px;
    border-top: 1px solid rgba(30, 107, 58, 0.15);
    padding-top: 12px;
}
.hero-breakdown .lane { display: flex; flex-direction: column; gap: 2px; }
.hero-breakdown .lane .k {
    font-size: 10px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--vg-green);
    opacity: 0.8;
    font-weight: 600;
}
.hero-breakdown .lane .v {
    font-size: 15px;
    font-weight: 700;
    color: var(--charcoal);
    font-variant-numeric: tabular-nums;
}
@media (max-width: 480px) {
    .tile.hero-primary .value.hero { font-size: 34px; }
    .hero-breakdown { grid-template-columns: 1fr; gap: 6px; }
    .hero-breakdown .lane { flex-direction: row; justify-content: space-between; }
}

.tile.paid-side {
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.tile.paid-side .label { color: var(--grey); }
.tile.paid-side .value { color: var(--grey); font-size: 20px; }
.tile.paid-side .value.err { color: var(--danger); }

/* Skeleton loaders */
@keyframes skel-shimmer {
    0%   { background-position: -200px 0; }
    100% { background-position: calc(200px + 100%) 0; }
}
.skel {
    background: linear-gradient(90deg, #eeece7 0%, #f6f6f3 40%, #eeece7 80%);
    background-size: 200px 100%;
    background-repeat: no-repeat;
    animation: skel-shimmer 1.4s ease-in-out infinite;
    border-radius: 4px;
    color: transparent !important;
    display: inline-block;
    min-width: 60px;
}
.skel-line { display: block; height: 12px; margin: 6px 0; }
.skel-line.w-30 { width: 30%; }
.skel-line.w-50 { width: 50%; }
.skel-line.w-70 { width: 70%; }
.skel-line.w-90 { width: 90%; }
.skel-block { height: 44px; width: 60%; margin: 4px 0; }

/* Month tier progress */
.tier-bar {
    display: flex;
    gap: 4px;
    margin-top: 8px;
}
.tier-seg {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: var(--grey-line);
}
.tier-seg.active-t2 { background: var(--vg-gold); }
.tier-seg.active-t3 { background: var(--vg-green); }

.tier-legend {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--grey);
    margin-top: 6px;
    letter-spacing: 0.3px;
}

/* tables */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

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

th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--grey);
    font-weight: 600;
}

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.tag { font-size: 11px; }

.pill {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}
.pill.paid { background: var(--vg-green-soft); color: var(--vg-green); }
.pill.payment-outstanding { background: #fdf1de; color: var(--vg-gold); }
.pill.pending { background: var(--grey-light); color: var(--grey); }

.empty {
    color: var(--grey);
    font-style: italic;
    padding: 12px 0;
    font-size: 13px;
}

.status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px dashed var(--grey-line);
}
.status-row:last-child { border-bottom: none; }
.status-row .label { color: var(--grey); font-size: 13px; }
.status-row .value { font-weight: 600; }

/* Mobile: turn wide tables into stacked cards (data-label attr on td) */
@media (max-width: 600px) {
    table.responsive thead { display: none; }
    table.responsive, table.responsive tbody, table.responsive tr, table.responsive td {
        display: block;
        width: 100%;
    }
    table.responsive tr {
        border: 1px solid var(--grey-line);
        border-radius: 10px;
        margin-bottom: 12px;
        padding: 12px 14px;
        background: var(--white);
    }
    table.responsive tr:empty { display: none; }
    table.responsive td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        padding: 8px 0;
        border: none;
        border-bottom: 1px dashed var(--grey-line);
        text-align: right;
    }
    table.responsive td:last-child { border-bottom: none; }
    table.responsive td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--grey);
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        text-align: left;
        flex-shrink: 0;
    }
    table.responsive td.num { text-align: right; }
    table.responsive td button.mp-btn { margin-left: auto; }
}

footer.bottom {
    text-align: center;
    color: var(--grey);
    font-size: 11px;
    padding: 20px;
}

.warn-banner {
    background: #fef4e6;
    border: 1px solid #f5d9a5;
    color: #7a4d0c;
    padding: 10px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 13px;
}

.warn-banner strong { color: #7a4d0c; }

button.mp-btn {
    background: var(--vg-green);
    color: white;
    border: none;
    border-radius: 5px;
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
button.mp-btn:hover { background: #17552e; }
button.mp-btn:disabled { background: var(--grey); cursor: not-allowed; }
