:root {
    --bg: #f3f1eb;
    --panel: #ffffff;
    --panel-soft: #f7f8f6;
    --text: #1f2a30;
    --muted: #6f7b82;
    --line: #d9ddd8;
    --primary: #0f766e;
    --primary-dark: #0a5a54;
    --accent: #cf7b34;
    --danger: #b9483b;
    --success: #287d57;
    --shadow: 0 18px 40px rgba(33, 45, 52, 0.08);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Trebuchet MS", "Segoe UI", Tahoma, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(15, 118, 110, 0.1), transparent 28%),
        radial-gradient(circle at bottom right, rgba(207, 123, 52, 0.12), transparent 24%),
        var(--bg);
}

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

code {
    background: #eef4f1;
    padding: 0.2rem 0.4rem;
    border-radius: 8px;
}

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

.sidebar {
    background: #172126;
    color: #f8fbfb;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    gap: 0.9rem;
    align-items: center;
}

.brand-mark {
    width: 54px;
    height: 54px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--accent), #f1b46f);
    color: #1a1c1e;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.brand-logo {
    width: 58px;
    height: 58px;
    object-fit: contain;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.94);
    padding: 0.35rem;
}

.brand h1,
.topbar h2,
.panel-header h3,
.metric-card h3,
.auth-card h1 {
    margin: 0;
    font-family: "Gill Sans", "Segoe UI", sans-serif;
}

.brand-kicker,
.eyebrow {
    margin: 0 0 0.25rem;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--muted);
}

.sidebar .eyebrow,
.sidebar .brand-kicker {
    color: rgba(255, 255, 255, 0.65);
}

.sidebar-nav {
    display: grid;
    gap: 0.45rem;
}

.sidebar-nav a {
    padding: 0.85rem 1rem;
    border-radius: 14px;
    color: rgba(255, 255, 255, 0.82);
    transition: 0.2s ease;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.sidebar-footer {
    margin-top: auto;
    padding: 1rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.06);
}

.sidebar-footer p,
.sidebar-footer span {
    margin: 0;
    color: rgba(255, 255, 255, 0.7);
}

.main-panel {
    padding: 1.25rem;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.topbar-title {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.topbar-logo {
    width: 50px;
    height: 50px;
    object-fit: contain;
    border-radius: 14px;
    background: #fff;
    padding: 0.3rem;
    box-shadow: var(--shadow);
}

.content {
    display: grid;
    gap: 1.25rem;
}

.panel,
.metric-card,
.auth-card {
    background: var(--panel);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel {
    padding: 1.2rem;
}

.panel-soft {
    background: var(--panel-soft);
    border: 1px solid var(--line);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.panel-header h3 {
    font-size: 1.25rem;
}

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

.metric-card {
    padding: 1.25rem;
    border: 1px solid rgba(15, 118, 110, 0.08);
}

.metric-card p,
.muted {
    margin: 0;
    color: var(--muted);
}

.metric-card h3 {
    margin-top: 0.5rem;
    font-size: 1.65rem;
}

.metric-card.metric-positive h3 {
    color: var(--success);
}

.metric-card.metric-negative h3 {
    color: var(--danger);
}

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

.bar-chart {
    display: flex;
    gap: 1rem;
    align-items: end;
    min-height: 220px;
    padding-top: 1rem;
}

.bar-group {
    flex: 1;
    text-align: center;
}

.bar-row {
    display: flex;
    gap: 0.35rem;
    justify-content: center;
    align-items: end;
    min-height: 180px;
}

.bar {
    width: 18px;
    border-radius: 999px 999px 0 0;
    display: inline-block;
}

.bar.income {
    background: linear-gradient(180deg, #2bb7a8, var(--primary));
}

.bar.expense {
    background: linear-gradient(180deg, #f4a35d, var(--accent));
}

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

.table {
    width: 100%;
    border-collapse: collapse;
}

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

.table th {
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.table-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn {
    border: 0;
    border-radius: 14px;
    padding: 0.85rem 1.1rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: 0.2s ease;
}

.btn-small {
    padding: 0.55rem 0.8rem;
    border-radius: 12px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
}

.btn-secondary {
    background: #e7ece9;
    color: var(--text);
}

.btn-ghost {
    background: rgba(23, 33, 38, 0.06);
    color: var(--text);
}

.btn-danger {
    background: rgba(185, 72, 59, 0.12);
    color: var(--danger);
}

.btn:hover {
    transform: translateY(-1px);
}

.badge {
    display: inline-flex;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    background: rgba(15, 118, 110, 0.1);
    color: var(--primary-dark);
    font-size: 0.82rem;
}

.alert {
    padding: 0.95rem 1rem;
    border-radius: 14px;
    margin-bottom: 1rem;
}

.alert-success {
    background: rgba(40, 125, 87, 0.12);
    color: var(--success);
}

.alert-danger {
    background: rgba(185, 72, 59, 0.12);
    color: var(--danger);
}

.stack {
    display: grid;
    gap: 1rem;
}

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

.field {
    display: grid;
    gap: 0.45rem;
}

.field-full {
    grid-column: 1 / -1;
}

.field input,
.field select,
.field textarea,
.inline-form input,
.inline-form select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 0.85rem 0.95rem;
    background: #fff;
    color: var(--text);
    font: inherit;
}

.field input[disabled] {
    background: #f2f4f3;
}

.field textarea {
    resize: vertical;
}

.error-text {
    color: var(--danger);
    font-size: 0.84rem;
}

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

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

.auth-logo-wrap {
    margin-bottom: -0.5rem;
}

.auth-logo {
    width: 92px;
    height: 92px;
    object-fit: contain;
    border-radius: 22px;
    background: #fff;
    padding: 0.55rem;
    box-shadow: var(--shadow);
}

.auth-card {
    width: min(480px, 100%);
    padding: 2rem;
}

.auth-help {
    margin-top: 1.5rem;
    padding: 1rem;
    border-radius: 14px;
    background: var(--panel-soft);
    display: grid;
    gap: 0.3rem;
}

.invoice-items input {
    min-width: 120px;
}

.invoice-summary {
    margin-top: 1rem;
    margin-left: auto;
    width: min(340px, 100%);
    display: grid;
    gap: 0.5rem;
}

.invoice-summary div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.65rem 0.8rem;
    background: #fff;
    border-radius: 12px;
}

.invoice-summary-wide {
    width: min(460px, 100%);
}

.grand-total {
    background: #edf7f5 !important;
}

.invoice-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.invoice-logo {
    width: 96px;
    height: 96px;
    object-fit: contain;
    border-radius: 18px;
    background: #fff;
    padding: 0.45rem;
    box-shadow: var(--shadow);
    margin-bottom: 0.75rem;
}

.logo-preview-card {
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 1rem;
    background: var(--panel-soft);
    display: inline-flex;
}

.settings-logo-preview {
    width: 140px;
    height: 140px;
    object-fit: contain;
}

.checkbox-field {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--muted);
}

.checkbox-field input {
    width: auto;
}

.invoice-view p {
    margin: 0.2rem 0;
}

.link {
    color: var(--primary);
}

.sidebar-toggle {
    display: none;
    border: 0;
    border-radius: 12px;
    padding: 0.8rem 0.95rem;
    background: rgba(23, 33, 38, 0.08);
    font-weight: 700;
}

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

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 20;
    }

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

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

@media (max-width: 720px) {
    .panel-header,
    .topbar,
    .actions-row,
    .inline-form {
        flex-direction: column;
        align-items: stretch;
    }

    .main-panel {
        padding: 1rem;
    }
}

@media print {
    .sidebar,
    .topbar,
    .btn,
    .alert {
        display: none !important;
    }

    .app-shell,
    .main-panel,
    .content {
        display: block;
        padding: 0;
        box-shadow: none;
    }
}
