:root {
    --green: #0a5c40;
    --green-mid: #0e7a56;
    --green-pale: #e8f5ef;
    --gold: #f0a500;
    --gold-pale: #fff8e6;
    --text: #111c17;
    --muted: #5a7268;
    --border: #dce8e2;
    --surface: #ffffff;
    --bg: #f5f8f6;
    --radius: 14px;
    --radius-lg: 20px;
    --font-head: 'Syne', sans-serif;
    --font-body: 'DM Sans', sans-serif;
    --nav-h: 64px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}

.app {
    max-width: 520px;
    margin: auto;
    padding: 18px 14px 24px;
}

/* Topbar */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.brand {
    font-family: var(--font-head);
    font-size: 21px;
    font-weight: 800;
    color: var(--green);
}

.offline {
    font-size: 12px;
    background: var(--green-pale);
    color: var(--green);
    padding: 7px 10px;
    border-radius: 20px;
    font-weight: 700;
}

.offline.is-online {
    background: var(--gold-pale);
    color: #8a6100;
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 14px;
    box-shadow: 0 4px 18px rgba(10, 92, 64, .06);
}

h1 {
    font-family: var(--font-head);
    font-size: 21px;
    margin: 0 0 16px;
}

.note-card p {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
    margin: 8px 0 0;
}

/* Hero */
.hero {
    background: linear-gradient(135deg, var(--green) 0%, var(--green-mid) 100%);
    border-radius: var(--radius-lg);
    padding: 22px 20px;
    color: #fff;
    margin-bottom: 18px;
    box-shadow: 0 10px 24px rgba(10, 92, 64, .18);
}

.hero-label {
    font-family: var(--font-head);
    font-size: 19px;
    font-weight: 800;
    margin-bottom: 4px;
}

.hero-date {
    font-size: 13px;
    opacity: .85;
}

.formula-badge {
    display: inline-block;
    margin-top: 10px;
    font-size: 12px;
    background: rgba(255, 255, 255, .16);
    border: 1px solid rgba(255, 255, 255, .22);
    padding: 7px 11px;
    border-radius: 20px;
    line-height: 1.4;
}

/* Section label */
.section-label {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    margin: 4px 2px 10px;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 15px;
    box-shadow: 0 3px 12px rgba(10, 92, 64, .05);
}

.stat.full {
    grid-column: span 2;
}

.stat-icon {
    font-size: 18px;
    margin-bottom: 6px;
}

.label {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 5px;
}

.value {
    font-size: 20px;
    font-weight: 800;
    color: var(--green);
}

/* Quick actions */
.quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.qa {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 10px;
    color: var(--text);
    font-weight: 700;
    font-size: 13px;
    box-shadow: 0 3px 12px rgba(10, 92, 64, .05);
}

.qa-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--green-pale);
    color: var(--green);
    font-size: 18px;
}

/* Fields */
.field {
    margin: 13px 0;
}

label {
    display: block;
    font-weight: 700;
    margin-bottom: 7px;
    font-size: 14px;
}

input {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-body);
    font-size: 17px;
    outline: 0;
    background: var(--surface);
    color: var(--text);
}

input:focus {
    border-color: var(--green-mid);
    box-shadow: 0 0 0 3px var(--green-pale);
}

.readonly {
    background: var(--bg);
}

.grid2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* Buttons */
.btn {
    width: 100%;
    border: 0;
    border-radius: var(--radius);
    padding: 15px;
    font-family: var(--font-body);
    font-size: 16px;
    font-weight: 800;
    background: var(--green);
    color: #fff;
    cursor: pointer;
    margin-top: 7px;
}

.btn:active {
    transform: scale(.99);
}

.btn.secondary {
    background: var(--green-mid);
}

.btn.gold {
    background: var(--gold);
    color: var(--text);
}

.btn.danger {
    background: #c62828;
}

.msg {
    min-height: 22px;
    margin-top: 9px;
    font-weight: 700;
    font-size: 14px;
}

.msg.success {
    color: var(--green);
}

.msg.error {
    color: #c62828;
}

.note {
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    margin-top: 15px;
}

/* Bottom nav */
.nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-h);
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: center;
    z-index: 20;
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-inner {
    width: 100%;
    max-width: 520px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
}

.nav a {
    text-decoration: none;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 10.5px;
    font-weight: 700;
    gap: 3px;
}

.nav a.active {
    color: var(--green);
}

.icon {
    font-size: 19px;
}

/* Search / list rows */
.search {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 16px;
    outline: 0;
    margin: 14px 0 10px;
}

.actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.row {
    border-top: 1px solid var(--border);
    padding: 14px 0;
}

.row:first-child {
    border-top: 0;
}

.account {
    font-weight: 800;
    font-size: 15px;
    color: var(--green);
}

.muted {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

.amount {
    font-weight: 800;
    margin-top: 8px;
    color: var(--green);
}

.balances {
    font-size: 13px;
    color: var(--muted);
    margin-top: 5px;
}

.empty {
    text-align: center;
    color: var(--muted);
    padding: 25px 10px;
}

.item {
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.item:last-child {
    border-bottom: 0;
}

/* Commission stat rows */
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    font-size: 14px;
}

.stat-row span {
    color: var(--muted);
}

.stat-row strong {
    color: var(--text);
    font-weight: 800;
    white-space: nowrap;
}

.stat-row.total {
    padding-top: 14px;
}

.stat-row.total span {
    color: var(--text);
    font-weight: 800;
}

.stat-row.total strong {
    color: var(--green);
    font-size: 18px;
}

hr {
    border: 0;
    border-top: 1px dashed var(--border);
    margin: 4px 0;
}

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

    .stat.full {
        grid-column: span 1;
    }
}
