:root {
    --sidebar-width: 280px;
    --sidebar-collapsed: 88px;
    --bg: #eef4f7;
    --surface: rgba(255, 255, 255, .86);
    --surface-solid: #ffffff;
    --ink: #122033;
    --muted: #657488;
    --line: rgba(24, 39, 56, .1);
    --brand: #0d6b5a;
    --brand-2: #1f89a8;
    --accent: #f0b429;
    --danger: #d84d4d;
    --sidebar: #0b1624;
    --sidebar-2: #102a43;
    --shadow: 0 22px 60px rgba(15, 23, 42, .12);
}

[data-theme="dark"] {
    --bg: #08111f;
    --surface: rgba(15, 25, 42, .86);
    --surface-solid: #111d31;
    --ink: #e7edf6;
    --muted: #99a8ba;
    --line: rgba(226, 232, 240, .12);
    --sidebar: #040914;
    --sidebar-2: #0b1628;
    --shadow: 0 22px 60px rgba(0, 0, 0, .35);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
    overflow-x: hidden;
}

body {
    color: var(--ink);
    font-family: 'Plus Jakarta Sans', sans-serif;
    background:
        radial-gradient(circle at 4% 0%, rgba(31, 137, 168, .18), transparent 30%),
        radial-gradient(circle at 100% 12%, rgba(13, 107, 90, .2), transparent 26%),
        linear-gradient(135deg, var(--bg), #f8fbfc 45%, var(--bg));
}

[data-theme="dark"] body {
    background:
        radial-gradient(circle at 8% 0%, rgba(31, 137, 168, .22), transparent 30%),
        radial-gradient(circle at 100% 12%, rgba(13, 107, 90, .2), transparent 26%),
        var(--bg);
}

button,
a {
    font: inherit;
}

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

.app-shell {
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    color: #d7e2ef;
    background:
        linear-gradient(180deg, rgba(16, 42, 67, .78), rgba(11, 22, 36, .98)),
        radial-gradient(circle at top left, rgba(31, 137, 168, .35), transparent 32%);
    border-right: 1px solid rgba(255, 255, 255, .08);
    transition: transform .25s ease, width .25s ease;
    overflow: hidden;
}

.sidebar-brand {
    min-height: 82px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand-mark {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    color: #ffffff;
    font: 800 13px/1 'Instrument Sans', sans-serif;
    background: linear-gradient(145deg, var(--brand), var(--brand-2));
    box-shadow: 0 14px 26px rgba(13, 107, 90, .35);
}

.brand-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.brand-copy strong {
    font: 800 18px/1 'Instrument Sans', sans-serif;
    letter-spacing: -.03em;
}

.brand-copy span {
    color: #93a7bd;
    font-size: 12px;
}

.sidebar-nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 12px 24px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .22) transparent;
}

.nav-section {
    margin: 18px 12px 8px;
    color: #7890a8;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.nav-item {
    width: 100%;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 11px;
    margin: 3px 0;
    padding: 11px 13px;
    border: 0;
    border-radius: 16px;
    color: #aabacf;
    background: transparent;
    cursor: pointer;
    text-align: left;
    transition: background .18s ease, color .18s ease, transform .18s ease;
}

.nav-item:hover,
.nav-item.active {
    color: #ffffff;
    background: rgba(255, 255, 255, .09);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(13, 107, 90, .45), rgba(31, 137, 168, .24));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
}

.nav-icon {
    width: 24px;
    flex: 0 0 24px;
    text-align: center;
    color: #9fd7cc;
}

.nav-item span:nth-child(2) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chevron {
    margin-left: auto;
    color: #8ea2b9;
    transition: transform .18s ease;
}

.nav-toggle.is-open .chevron {
    transform: rotate(180deg);
}

.nav-submenu {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-4px);
    transition: max-height .24s ease, opacity .18s ease, transform .18s ease;
}

.nav-submenu.is-open {
    max-height: 220px;
    opacity: 1;
    transform: translateY(0);
}

.nav-submenu a {
    display: block;
    margin: 2px 0 2px 48px;
    padding: 8px 10px;
    border-radius: 12px;
    color: #8ea2b9;
    font-size: 13px;
}

.nav-submenu a:hover,
.nav-submenu a.active {
    color: #ffffff;
    background: rgba(255, 255, 255, .07);
}

.main-area {
    min-width: 0;
    margin-left: var(--sidebar-width);
    transition: margin-left .25s ease;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 82px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 18px 28px;
    border-bottom: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface-solid) 76%, transparent);
    backdrop-filter: blur(18px);
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--brand-2);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1,
h2,
h3 {
    font-family: 'Instrument Sans', sans-serif;
    letter-spacing: -.04em;
}

h1 {
    margin-bottom: 0;
    font-size: 24px;
}

.icon-button,
.theme-button,
.profile-button,
.primary-link {
    border: 1px solid var(--line);
    color: var(--ink);
    background: var(--surface-solid);
    box-shadow: 0 10px 28px rgba(15, 23, 42, .06);
}

.icon-button {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    cursor: pointer;
}

.theme-button,
.profile-button,
.primary-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 14px;
    border-radius: 999px;
    font-weight: 700;
    cursor: pointer;
}

.avatar {
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    color: #ffffff;
    background: linear-gradient(145deg, var(--brand), var(--brand-2));
    font-size: 12px;
}

.profile-menu {
    position: relative;
}

.profile-chevron {
    color: var(--muted);
    font-size: 13px;
    transition: transform .18s ease;
}

.profile-menu.is-open .profile-chevron {
    transform: rotate(180deg);
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    z-index: 40;
    width: 220px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: var(--surface-solid);
    box-shadow: var(--shadow);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px) scale(.98);
    transform-origin: top right;
    transition: opacity .18s ease, visibility .18s ease, transform .18s ease;
}

.profile-menu.is-open .profile-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.profile-dropdown-head {
    display: grid;
    gap: 2px;
    padding: 10px 12px 12px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 6px;
}

.profile-dropdown-head span {
    color: var(--muted);
    font-size: 12px;
}

.profile-dropdown a {
    display: flex;
    align-items: center;
    min-height: 38px;
    padding: 0 12px;
    border-radius: 12px;
    color: var(--ink);
    font-size: 14px;
    font-weight: 700;
}

.profile-dropdown a:hover {
    background: color-mix(in srgb, var(--brand) 10%, transparent);
}

.profile-dropdown .danger-link {
    color: var(--danger);
}

.content-grid {
    display: grid;
    gap: 18px;
    padding: 24px 28px 34px;
}

.page-view {
    display: none;
}

.page-view.is-active {
    display: grid;
}

.hero-card,
.metric-card,
.panel-card {
    border: 1px solid var(--line);
    border-radius: 28px;
    background: var(--surface);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.hero-card {
    position: relative;
    overflow: hidden;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 22px;
    align-items: end;
    padding: 28px;
    background:
        radial-gradient(circle at 88% 8%, rgba(240, 180, 41, .28), transparent 24%),
        radial-gradient(circle at 8% 100%, rgba(31, 137, 168, .22), transparent 30%),
        var(--surface);
}

.hero-card::after {
    content: '';
    position: absolute;
    right: 26%;
    top: -70px;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    border: 1px solid var(--line);
}

.hero-kicker {
    display: inline-flex;
    margin-bottom: 12px;
    padding: 8px 12px;
    border-radius: 999px;
    color: var(--brand);
    background: rgba(13, 107, 90, .1);
    font-size: 12px;
    font-weight: 800;
}

.hero-card h2 {
    max-width: 680px;
    margin-bottom: 12px;
    font-size: clamp(30px, 4vw, 54px);
    line-height: .98;
}

.hero-card p:not(.hero-kicker) {
    max-width: 720px;
    margin-bottom: 0;
    color: var(--muted);
    line-height: 1.7;
}

.hero-status {
    min-width: 190px;
    display: grid;
    gap: 5px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: color-mix(in srgb, var(--surface-solid) 74%, transparent);
}

.pulse {
    width: 11px;
    height: 11px;
    border-radius: 999px;
    background: #23c282;
    box-shadow: 0 0 0 0 rgba(35, 194, 130, .45);
    animation: pulse 1.7s infinite;
}

.hero-status small,
.metric-card small,
.activity-item small {
    color: var(--muted);
}

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

.metric-card {
    padding: 20px;
    transition: transform .2s ease, border-color .2s ease;
}

.metric-card:hover {
    transform: translateY(-4px);
    border-color: rgba(13, 107, 90, .28);
}

.metric-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    margin-bottom: 18px;
    border-radius: 16px;
    color: var(--brand);
    background: rgba(13, 107, 90, .1);
    font-weight: 800;
}

.metric-card.warning .metric-icon {
    color: var(--danger);
    background: rgba(216, 77, 77, .11);
}

.metric-card p {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 14px;
}

.metric-card strong {
    display: block;
    margin-bottom: 8px;
    font: 800 clamp(24px, 3vw, 34px)/1 'Instrument Sans', sans-serif;
    letter-spacing: -.04em;
}

.dashboard-panels {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, .8fr);
    gap: 18px;
}

.panel-card {
    overflow: hidden;
}

.form-panel {
    display: grid;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    padding: 20px 22px;
    border-bottom: 1px solid var(--line);
}

.panel-head h3 {
    margin-bottom: 0;
    font-size: 20px;
}

.chip {
    display: inline-flex;
    padding: 8px 12px;
    border-radius: 999px;
    color: var(--brand);
    background: rgba(13, 107, 90, .1);
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.form-layout {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    padding: 20px 22px;
}

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

.form-layout label:nth-child(4) {
    grid-column: 1 / -1;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    color: var(--ink);
    background: var(--surface-solid);
    font: inherit;
}

input,
select {
    min-height: 42px;
    padding: 0 12px;
}

textarea {
    min-height: 82px;
    padding: 12px;
    resize: vertical;
}

.primary-action {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 14px;
    padding: 0 14px;
    color: #ffffff;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 12px 26px rgba(13, 107, 90, .2);
}

.summary-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
    padding: 18px 22px 22px;
    color: var(--muted);
    border-top: 1px solid var(--line);
}

.summary-row strong {
    color: var(--ink);
}

.compact table {
    min-width: 620px;
}

.two-col {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chart-wrap {
    height: 280px;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 10px;
    align-items: end;
    padding: 24px;
}

.chart-wrap div {
    border-radius: 999px 999px 12px 12px;
    background: linear-gradient(180deg, var(--brand-2), var(--brand));
    box-shadow: 0 12px 24px rgba(13, 107, 90, .16);
    animation: growBar .8s both ease-out;
}

.chart-wrap div:nth-child(2n) {
    background: linear-gradient(180deg, var(--accent), #e09416);
}

.activity-list {
    display: grid;
    gap: 12px;
    padding: 18px;
}

.activity-item {
    display: grid;
    grid-template-columns: 12px 1fr;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: color-mix(in srgb, var(--surface-solid) 64%, transparent);
}

.activity-item > span {
    width: 10px;
    height: 10px;
    margin-top: 6px;
    border-radius: 999px;
    background: var(--brand);
}

.activity-item p {
    margin: 4px 0;
    color: var(--muted);
    font-size: 14px;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
}

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

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

th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .09em;
    text-transform: uppercase;
    background: color-mix(in srgb, var(--surface-solid) 54%, transparent);
}

td {
    color: color-mix(in srgb, var(--ink) 92%, var(--muted));
    font-size: 14px;
}

td small {
    display: inline-block;
    margin-top: 4px;
    color: var(--muted);
    line-height: 1.45;
}

.invoice-code {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--ink);
    font-weight: 800;
}

.invoice-code i {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--brand);
}

.status {
    display: inline-flex;
    padding: 7px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.status.success {
    color: #0d7c57;
    background: rgba(35, 194, 130, .12);
}

.status.warning {
    color: #a16207;
    background: rgba(240, 180, 41, .18);
}

.status.danger {
    color: #b42318;
    background: rgba(216, 77, 77, .14);
}

.mobile-only {
    display: none;
}

body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed);
}

body.sidebar-collapsed .main-area {
    margin-left: var(--sidebar-collapsed);
}

body.sidebar-collapsed .brand-copy,
body.sidebar-collapsed .nav-section,
body.sidebar-collapsed .nav-item span:nth-child(2),
body.sidebar-collapsed .chevron,
body.sidebar-collapsed .nav-submenu {
    display: none;
}

body.sidebar-collapsed .sidebar-brand,
body.sidebar-collapsed .nav-item {
    justify-content: center;
}

.reveal {
    opacity: 0;
    transform: translateY(12px);
    animation: reveal .55s forwards ease;
}

.reveal:nth-child(2) { animation-delay: .04s; }
.reveal:nth-child(3) { animation-delay: .08s; }
.reveal:nth-child(4) { animation-delay: .12s; }

@keyframes reveal {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes growBar {
    from {
        transform: scaleY(.2);
        transform-origin: bottom;
    }
}

@keyframes pulse {
    70% {
        box-shadow: 0 0 0 12px rgba(35, 194, 130, 0);
    }
}

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

    .dashboard-panels .revenue-panel,
    .dashboard-panels .activity-panel {
        grid-column: span 2;
    }
}

@media (max-width: 860px) {
    .desktop-only {
        display: none;
    }

    .mobile-only {
        display: inline-grid;
    }

    .sidebar {
        transform: translateX(-100%);
        width: min(86vw, 320px);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .mobile-backdrop {
        position: fixed;
        inset: 0;
        z-index: 25;
        pointer-events: none;
        background: rgba(4, 9, 20, .48);
        opacity: 0;
        transition: opacity .2s ease;
    }

    body.sidebar-open .mobile-backdrop {
        pointer-events: auto;
        opacity: 1;
    }

    .main-area,
    body.sidebar-collapsed .main-area {
        margin-left: 0;
    }

    body.sidebar-collapsed .sidebar {
        width: min(86vw, 320px);
    }

    body.sidebar-collapsed .brand-copy {
        display: grid;
    }

    body.sidebar-collapsed .nav-section {
        display: block;
    }

    body.sidebar-collapsed .nav-item span:nth-child(2),
    body.sidebar-collapsed .chevron {
        display: inline;
    }

    body.sidebar-collapsed .nav-submenu {
        display: grid;
    }

    .topbar {
        padding: 14px 16px;
    }

    .profile-button span:last-child,
    .theme-button {
        display: none;
    }

    .content-grid {
        padding: 16px;
    }

    .hero-card,
    .metric-grid,
    .dashboard-panels,
    .form-layout {
        grid-template-columns: 1fr;
    }

    .form-layout label:nth-child(4) {
        grid-column: auto;
    }

    .dashboard-panels .revenue-panel,
    .dashboard-panels .activity-panel {
        grid-column: auto;
    }

    .hero-status {
        min-width: 0;
    }
}

@media (max-width: 560px) {
    .metric-grid {
        grid-template-columns: 1fr;
    }

    .hero-card,
    .metric-card,
    .panel-card {
        border-radius: 22px;
    }

    .hero-card,
    .panel-head {
        padding: 18px;
    }

    .chart-wrap {
        height: 220px;
        gap: 6px;
        padding: 18px;
    }

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

    .primary-action,
    .filter-row,
    .filter-row select {
        width: 100%;
    }
}
