:root {
    color-scheme: light;
    --ink: #172b27;
    --muted: #526560;
    --background: #f5f7f5;
    --line: #dce5df;
    --surface: #fff;
    --green: #17694f;
    --green-dark: #114d3c;
    --sidebar: #112b27;
    --side-line: #2a4941;
    --radius: 15px;
    font: 16px/1.5 "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    background: var(--background);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
a { color: inherit; }
button, input, select { font: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #2e9976; outline-offset: 3px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.8rem, 3.3vw, 2.55rem); line-height: 1.14; letter-spacing: -.042em; font-weight: 740; }
h2 { font-size: 1.18rem; line-height: 1.3; letter-spacing: -.018em; }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.text-positive { color: var(--green); }
.sr-only, .skip-link:not(:focus) {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.skip-link:focus { position: absolute; margin: 8px; z-index: 4; color: var(--ink); background: #fff; padding: 10px; }

.app-shell { display: grid; grid-template-columns: 238px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
    position: sticky; top: 0; height: 100dvh; min-height: 440px; display: flex; flex-direction: column;
    padding: 29px 18px 20px; overflow: hidden auto; color: #e4f2ec; background: var(--sidebar);
}
.brand {
    display: inline-flex; gap: 12px; align-items: center; align-self: flex-start; margin: 0 0 35px 10px;
    text-decoration: none; color: #f5fbf7; font-size: 1.55rem; font-weight: 760; letter-spacing: -.05em; line-height: 1;
}
.brand small { display: block; color: #b8d1c8; font-size: .60rem; line-height: 1; letter-spacing: .06em; white-space: nowrap; margin-top: 7px; font-weight: 650; }
.brand-mark {
    width: 38px; height: 38px; flex: 0 0 38px; display: inline-flex; gap: 3px; justify-content: center; align-items: flex-end;
    padding-bottom: 10px; background: #bfeecb; color: #173f34; border-radius: 11px;
}
.brand-mark i { display: block; width: 4px; background: currentColor; border-radius: 4px; }
.brand-mark i:nth-child(1) { height: 8px; }
.brand-mark i:nth-child(2) { height: 16px; }
.brand-mark i:nth-child(3) { height: 12px; }
.workspace-switcher { margin: 0 0 28px; }
.workspace-switcher label { display: block; margin: 0 7px 9px; font-size: .69rem; letter-spacing: .11em; font-weight: 700; color: #b8d1c8; }
.workspace-control { position: relative; display: flex; gap: 7px; align-items: center; }
.workspace-control select {
    min-width: 0; width: 100%; height: 49px; padding: 0 30px 0 44px; border: 1px solid #3a594f;
    border-radius: 10px; color: #f2f8f5; background-color: #1d3a33; font-size: .88rem; font-weight: 650; text-overflow: ellipsis;
}
.workspace-avatar, .avatar {
    display: grid; place-items: center; width: 31px; height: 31px; border-radius: 8px; background: #345b4d;
    color: #def3e4; font-size: .72rem; font-weight: 750; flex: 0 0 auto; letter-spacing: .025em;
}
.workspace-avatar { position: absolute; left: 9px; pointer-events: none; }
.switch-submit { padding: 6px; border-radius: 6px; border: 1px solid var(--line); font-size: .84rem; color: var(--ink); background: #fff; }
.nav { display: grid; gap: 5px; }
.nav a {
    display: flex; gap: 12px; align-items: center; padding: 11px 12px; min-height: 44px;
    border: 1px solid transparent; border-radius: 9px; text-decoration: none; color: #c4d9d1; font-size: .94rem;
}
.nav a:hover { background: #24463d; color: white; }
.nav a[aria-current="page"] { background: #2b5043; color: #effbf0; font-weight: 700; border-color: #365e4f; }
.nav a[aria-current="page"] .icon { color: #bfeecb; }
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--side-line); padding: 15px 1px 0; display: flex; justify-content: space-between; gap: 6px; }
.profile { min-width: 0; display: flex; align-items: center; gap: 8px; }
.profile > span:last-child { min-width: 0; }
.profile strong, .profile small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile strong { font-size: .82rem; color: #e7f4ed; }
.profile small { font-size: .75rem; color: #b8d1c8; }
.avatar { border-radius: 50%; }
.logout { display: inline-grid; place-items: center; padding: 7px; height: 36px; border: 0; border-radius: 7px; background: none; color: #c4d9d1; }
.logout:hover { color: white; background: #274d41; }
.logout span:not(.icon) { display: none; }

.main-column { min-width: 0; }
.topbar {
    height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 0 clamp(20px, 3vw, 46px); border-bottom: 1px solid var(--line); background: var(--surface);
    color: var(--muted); font-size: .875rem;
}
.breadcrumbs, .today { display: flex; align-items: center; gap: 10px; min-width: 0; }
.breadcrumbs span:first-child { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.breadcrumbs strong { color: var(--ink); }
.crumb-divider { color: #778b84; }
.today { white-space: nowrap; }
.content { max-width: 1640px; margin: auto; padding: 33px clamp(20px, 3vw, 46px) 46px; }
.page-heading { display: flex; justify-content: space-between; align-items: end; flex-wrap: wrap; gap: 18px; margin-bottom: 25px; }
.page-subtitle { margin-top: 7px; font-size: .96rem; }
.heading-actions, .form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.period-control { display: flex; gap: 6px; align-items: center; }
.period-control input { width: auto; background: #fff; font-size: .87rem; min-height: 43px; }
.button {
    display: inline-flex; gap: 8px; align-items: center; justify-content: center;
    min-height: 43px; padding: 8px 15px; border: 1px solid transparent; border-radius: 9px;
    text-decoration: none; font-size: .875rem; font-weight: 700; line-height: 1.2; text-align: center;
}
.button.primary { background: var(--green); color: white; }
.button.primary:hover { background: var(--green-dark); }
.button.secondary { color: var(--ink); border-color: #d6e2db; background: var(--surface); }
.button.secondary:hover { background: #edf4ee; border-color: #a8c9b8; }
.button.small { min-height: 36px; padding: 6px 11px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 2px 3px #112b2705; min-width: 0; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 19px; }
.metrics.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.metric { display: flex; flex-direction: column; gap: 10px; padding: 15px 16px; min-height: 137px; }
.metric p { font-size: .86rem; font-weight: 650; color: var(--muted); }
.metric strong { display: block; font-weight: 760; font-size: clamp(1.2rem, 2.05vw, 1.89rem); line-height: 1.22; letter-spacing: -.042em; margin: 2px 0 5px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.metric small { display: block; font-size: .77rem; line-height: 1.35; color: var(--muted); }
.metric-link { text-decoration: none; }
.metric-link:hover { border-color: #9ebfae; background: #fbfdfb; }
.balance-card { background: #164d3e; color: white; border-color: #164d3e; }
.balance-card p, .balance-card small { color: #c6e7dd; }
.tile-icon, .item-icon, .transaction-icon { width: 34px; height: 34px; border-radius: 9px; display: inline-grid; place-items: center; flex-shrink: 0; }
.balance-card .tile-icon { background: #2d6957; color: #e6f7eb; }
.income-tile, .positive { background: #e5f4ec; color: #17694f; }
.expense-tile, .negative { background: #eaf0f7; color: #3d587e; }
.alert-tile { background: #f9efde; color: #805213; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(255px, 1fr); gap: 17px; align-items: start; margin-bottom: 19px; }
.dashboard-grid > .card { min-height: 100%; }
.card-heading { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 17px 18px 14px; }
.card-heading p { font-size: .83rem; margin-top: 3px; }
.legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px 12px; color: var(--muted); font-size: .75rem; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; border-radius: 3px; background: #268164; }
.legend span:last-child i { background: #879ebb; }
.cash-chart { display: block; width: calc(100% - 36px); height: 180px; margin: 0 18px; }
.chart-data { padding: 5px 18px 13px; color: var(--muted); font-size: .79rem; }
.chart-data summary { cursor: pointer; width: max-content; max-width: 100%; }
.chart-data table { margin-top: 6px; }
.chart-data th, .chart-data td { padding: 6px 8px; }
.alerts-card { display: flex; flex-direction: column; }
.alert-list { list-style: none; padding: 0 17px; margin: 0; }
.alert-list li { display: grid; gap: 8px; align-items: center; grid-template-columns: auto minmax(0, 1fr) auto; border-bottom: 1px solid #ecf0ec; padding: 9px 0; min-height: 50px; }
.item-icon { width: 30px; height: 30px; background: #eff3ef; color: #536b61; }
.alert-list strong { display: block; font-size: .84rem; line-height: 1.23; overflow-wrap: anywhere; }
.alert-list small, .table-note { display: block; color: var(--muted); font-size: .74rem; margin-top: 2px; overflow-wrap: anywhere; }
.section-link { color: var(--green-dark); font-weight: 700; text-decoration: none; font-size: .83rem; width: fit-content; }
.section-link:hover { text-decoration: underline; }
.alerts-card > .section-link { margin: auto 17px 0; padding-block: 11px; }
.badge { display: inline-block; padding: 3px 7px; width: fit-content; border-radius: 7px; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.healthy { color: #1b614b; background: #e5f2e9; }
.warning { color: #70470e; background: #fbefd9; }
.critical { color: #8d342c; background: #f9e9e4; }
.neutral { color: #4f5e5b; background: #edf0ef; }
.empty, .empty-compact { margin: 0; color: var(--muted); padding: 21px 18px; font-size: .91rem; }
.empty { border-top: 1px solid var(--line); text-align: center; }
.empty-compact { padding: 15px 17px; }

.table-scroll { overflow: auto; }
.table-card { overflow: hidden; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .85rem; }
th { color: var(--muted); background: #f5f8f5; font-weight: 700; font-size: .79rem; white-space: nowrap; }
th, td { padding: 11px 13px; border-top: 1px solid #ecf0ec; }
th:first-child, td:first-child { padding-left: 18px; }
th:last-child, td:last-child { padding-right: 18px; }
td strong { color: var(--ink); font-weight: 700; overflow-wrap: anywhere; }
.table-identity { display: flex; align-items: center; gap: 9px; }
.transaction-icon { width: 29px; height: 29px; }
.row-actions { display: flex; justify-content: flex-end; gap: 10px; white-space: nowrap; }
.row-actions a, .text-button { color: var(--green-dark); font-size: .82rem; font-weight: 700; text-decoration: none; }
.row-actions a:hover, .text-button:hover { text-decoration: underline; }
.text-button { min-height: auto; padding: 0; border: 0; background: transparent; }
.text-button.danger { color: #963c36; }
.section-gap { margin-top: 19px; }
.pagination { border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 18px; font-size: .85rem; color: var(--muted); }

.form-card { padding: 19px 18px; margin-bottom: 18px; max-width: 920px; }
.form-card > .muted { margin-top: 4px; }
.fields { display: grid; gap: 15px; margin-top: 16px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px 16px; }
.fields label, .filters label { display: grid; gap: 5px; font-size: .87rem; font-weight: 650; color: var(--ink); }
input:not([type="hidden"]), select {
    min-height: 42px; min-width: 0; width: 100%; border: 1px solid #cbdad1; border-radius: 8px; padding: 8px 10px;
    color: var(--ink); background-color: #fff;
}
select {
    appearance: none; padding-right: 25px;
    background-image: linear-gradient(45deg, transparent 50%, #5a7168 50%), linear-gradient(135deg, #5a7168 50%, transparent 50%);
    background-position: calc(100% - 15px) 51%, calc(100% - 10px) 51%;
    background-size: 5px 5px; background-repeat: no-repeat;
}
.workspace-control select { background-color: #1d3a33; background-image: linear-gradient(45deg, transparent 50%, #c4d9d1 50%), linear-gradient(135deg, #c4d9d1 50%, transparent 50%); }
.period-control input { min-height: 43px; }
input::placeholder { color: #64756f; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 0 18px 15px; }
.filters input, .filters select { min-width: 153px; }
.field-note { font-size: .86rem; }
.flash { border: 1px solid #b9dcc7; background: #e8f5ed; color: #1b5b43; border-radius: 10px; padding: 9px 13px; margin: 0 0 17px; overflow-wrap: anywhere; }
.flash.error { border-color: #ebc3b8; background: #faeee9; color: #8f382d; }
.business-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.business-card { padding: 16px; display: flex; flex-direction: column; gap: 15px; overflow-wrap: anywhere; }
.business-card .form-actions { margin-top: auto; }
.business-card-top { display: flex; align-items: start; justify-content: space-between; gap: 8px; }
.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 16px; background: radial-gradient(ellipse at 70% 5%, #dcece2, transparent 65%), #f2f6f3; }
.login-card { width: min(100%, 420px); padding: clamp(22px, 5vw, 36px); box-shadow: 0 10px 35px #112b2710; }
.login-card h1 { font-size: 2.05rem; margin-bottom: 9px; }
.login-card .muted { margin-bottom: 16px; }
.login-brand { color: var(--ink); margin: 0 0 24px; }
.login-brand small { color: var(--muted); }
.login-card .fields { gap: 13px; }
.login-card .button { margin-top: 3px; }

.icon { display: inline-block; width: 17px; height: 17px; position: relative; flex: 0 0 17px; vertical-align: middle; }
.icon::before, .icon::after { content: ""; position: absolute; }
.icon-panel::before { inset: 1px; border: 1.5px solid; border-radius: 4px; }
.icon-panel::after { inset: 2px auto 2px 6px; border-left: 1.5px solid; }
.icon-cash::before { inset: 3px 0 2px; border: 1.5px solid; border-radius: 3px; }
.icon-cash::after { width: 5px; height: 5px; top: 6px; left: 6px; border: 1.5px solid; border-radius: 50%; }
.icon-box::before { width: 12px; height: 13px; inset: 2px auto auto 2.5px; border: 1.5px solid; border-radius: 3px; }
.icon-box::after { width: 11px; left: 3px; top: 6px; border-top: 1.5px solid; }
.icon-store::before { width: 12px; height: 10px; border: 1.5px solid; left: 2.5px; bottom: 1px; border-radius: 1px; }
.icon-store::after { width: 16px; height: 5px; border: 1.5px solid; left: .5px; top: 2px; border-radius: 2px; background: var(--store-fill, transparent); }
.business-card .icon-store { --store-fill: #e5f4ec; }
.icon-user::before { inset: 1px 5px auto; height: 7px; border: 1.5px solid; border-radius: 50%; }
.icon-user::after { inset: auto 2px 1px; height: 7px; border: 1.5px solid; border-radius: 6px 6px 2px 2px; }
.icon-calendar::before { inset: 3px 1px 1px; border: 1.5px solid; border-radius: 3px; }
.icon-calendar::after { width: 7px; height: 6px; left: 5px; top: 1px; border: solid; border-width: 0 1.5px 1.5px; }
.icon-logout::before { inset: 2px 7px 2px 1px; border: 1.5px solid; border-right: 0; border-radius: 3px 0 0 3px; }
.icon-logout::after { width: 6px; height: 6px; top: 5px; right: 2px; transform: rotate(45deg); border: solid; border-width: 1.5px 1.5px 0 0; }
.icon-plus::before, .icon-plus::after { border-radius: 2px; background: currentColor; }
.icon-plus::before { width: 12px; height: 1.5px; top: 8px; left: 2.5px; }
.icon-plus::after { width: 1.5px; height: 12px; left: 8px; top: 2.5px; }
.icon-alert::before { inset: 1px; border: 1.5px solid; border-radius: 50%; }
.icon-alert::after { content: "!"; inset: -1px 0 0; text-align: center; font: 750 13px/18px Arial, sans-serif; }
.icon-up::before, .icon-down::before, .icon-in::before, .icon-out::before { width: 8px; height: 8px; border-style: solid; border-width: 1.5px 1.5px 0 0; top: 3px; left: 5px; }
.icon-up::before, .icon-out::before { transform: rotate(-45deg); }
.icon-down::before, .icon-in::before { top: 6px; transform: rotate(135deg); }
.icon-up::after, .icon-down::after, .icon-in::after, .icon-out::after { height: 10px; border-left: 1.5px solid; top: 4px; left: 8px; }
.icon-in { transform: rotate(45deg) scale(.86); }
.icon-out { transform: rotate(45deg) scale(.86); }
.icon-download::before { height: 5px; width: 13px; left: 2px; bottom: 1px; border: solid; border-width: 0 1.5px 1.5px; border-radius: 0 0 2px 2px; }
.icon-download::after { width: 7px; height: 7px; border: solid; border-width: 0 1.5px 1.5px 0; top: 3px; left: 5px; transform: rotate(45deg); }

@media (max-width: 1080px) {
    .app-shell { grid-template-columns: 200px minmax(0, 1fr); }
    .sidebar { padding-inline: 13px; }
    .sidebar .brand small { white-space: normal; }
    .dashboard-grid { grid-template-columns: minmax(0, 1.6fr) minmax(235px, 1fr); gap: 13px; }
    .legend { justify-content: flex-start; }
}
@media (max-width: 870px) {
    .metrics, .metrics.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .business-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 660px) {
    .app-shell { display: block; }
    .sidebar { position: static; min-height: auto; height: auto; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 13px 8px; padding: 13px 13px 0; }
    .brand { margin: 0; font-size: 1.35rem; }
    .brand small { font-size: .58rem; }
    .brand-mark { width: 35px; height: 35px; flex-basis: 35px; padding-bottom: 8px; }
    .sidebar-footer { grid-row: 1; grid-column: 2; margin: 0; padding: 0; border: 0; align-items: center; }
    .profile { display: none; }
    .workspace-switcher { grid-column: 1 / -1; margin: 0; }
    .workspace-switcher label { margin: 0 0 5px; }
    .workspace-control select { height: 44px; }
    .nav { display: flex; flex-wrap: wrap; gap: 2px; grid-column: 1 / -1; }
    .nav a { padding: 8px; gap: 4px; font-size: .82rem; min-height: 40px; }
    .topbar { height: 48px; padding-inline: 13px; }
    .today { display: none; }
    .content { padding: 20px 13px 27px; }
    .page-heading { gap: 12px; margin-bottom: 15px; }
    .metrics, .metrics.three { gap: 8px; margin-bottom: 13px; }
    .metric { min-height: 120px; padding: 12px 10px; gap: 7px; }
    .card-heading { padding: 13px; flex-wrap: wrap; }
    .table-card th:first-child, .table-card td:first-child { padding-left: 13px; }
    .form-card { padding: 14px 12px; }
    .cash-chart { width: calc(100% - 26px); margin-inline: 13px; height: 157px; }
    .filters { padding-inline: 13px; }
    .filters label { flex: 1 1 144px; }
    .field-grid, .business-grid { grid-template-columns: 1fr; }
}
