*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f3f4f6;
    color: #111827;
}

a {
    color: #2563eb;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.container {
    max-width: 1120px;
    margin: 0 auto;
    padding: 16px;
}

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.auth-container {
    max-width: 420px;
    width: 100%;
}

.card {
    background: #ffffff;
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
    margin-bottom: 16px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.topbar-nav a {
    margin-left: 12px;
}

.field {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
}

.field label {
    font-size: 14px;
    margin-bottom: 4px;
}

.field input[type="text"],
.field input[type="password"],
.field input[type="email"],
.field input[type="date"],
.field input[type="url"],
.field input[type="file"],
.field select {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-size: 14px;
    background-color: #ffffff;
    color: #111827;
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 1px rgba(37,99,235,0.2);
}

.field.inline {
    flex-direction: row;
    align-items: center;
}

.field.inline label {
    margin-bottom: 0;
}

.actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

button,
.btn-link {
    border: none;
    border-radius: 999px;
    padding: 8px 16px;
    font-size: 14px;
    cursor: pointer;
    background: #2563eb;
    color: #ffffff;
    transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.1s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button.secondary {
    background: #6b7280;
    color: #f9fafb;
}

button.tertiary {
    background: #e5e7eb;
    color: #111827;
}

button.danger {
    background: #ef4444;
    color: #f9fafb;
}

button.small,
.btn-link {
    padding: 4px 10px;
    font-size: 13px;
}

.btn-link {
    text-decoration: none;
    background: #0f766e;
    color: #ecfeff;
}

.btn-link:hover {
    background: #115e59;
}

button:hover,
.btn-link:hover {
    text-decoration: none;
    box-shadow: 0 4px 10px rgba(37,99,235,0.3);
}

button:hover {
    background: #1d4ed8;
}

button.secondary:hover {
    background: #4b5563;
}

button.tertiary:hover {
    background: #d1d5db;
}

button.danger:hover {
    background: #b91c1c;
}

button:active,
.btn-link:active {
    transform: scale(0.98);
    box-shadow: none;
}

.message {
    margin-top: 8px;
    font-size: 14px;
}

.message.error {
    color: #b91c1c;
}

.message.success {
    color: #166534;
}

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

.form-card h2,
.list-card h2 {
    margin-top: 0;
    margin-bottom: 12px;
}

.date-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.date-row input[type="date"] {
    flex: 1;
}

.category-top-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 6px;
}

.label-small {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 4px;
}

.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chip {
    border-radius: 999px;
    padding: 4px 10px;
    border: 1px solid #d1d5db;
    background: #e5e7eb;
    font-size: 13px;
    cursor: pointer;
    color: #111827;
}

.chip.active {
    background: #2563eb;
    border-color: #1d4ed8;
    color: #ffffff;
}

.category-select-row {
    margin-bottom: 6px;
}

.category-new-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.category-new-row input {
    max-width: 260px;
}

.hint {
    font-size: 12px;
    color: #6b7280;
}

.expenses-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.expenses-table th,
.expenses-table td {
    border-bottom: 1px solid #e5e7eb;
    padding: 6px 4px;
}

.expenses-table th {
    text-align: left;
    font-weight: 600;
    background: #f9fafb;
}

.expenses-table td:nth-child(2) {
    text-align: right;
}

.expense-actions {
    display: flex;
    gap: 4px;
    flex-wrap: nowrap;
}

.report-filters {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 8px;
    flex-wrap: wrap;
}

.report-block {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.range-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.range-row label {
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chart-section h2 {
    margin-top: 0;
}

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

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

.stat-card {
    background: #f9fafb;
    border-radius: 10px;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
}

.stat-label {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 18px;
    font-weight: 600;
}

canvas {
    width: 100%;
    border-radius: 8px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
}

tr.editing-row {
    background: #eef2ff;
}

@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
    }
    .charts-grid {
        grid-template-columns: 1fr;
    }
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .report-filters {
        flex-direction: column;
        align-items: flex-start;
    }
    .topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}


/* BP extras */
.category-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}
.category-quick-btn {
    background: rgba(37, 99, 235, 0.08);
    color: #1e293b;
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 13px;
    border: 1px solid rgba(148, 163, 184, 0.6);
    cursor: pointer;
}
.category-quick-btn:hover {
    background: rgba(37, 99, 235, 0.16);
}

.table-actions {
    display: flex;
    gap: 6px;
}
.table-btn {
    padding: 4px 8px;
    border-radius: 999px;
    background: #e5e7eb;
    color: #111827;
    border: none;
    cursor: pointer;
}
.table-btn:hover {
    background: #d1d5db;
}

.chart-section h2 {
    margin-top: 0;
}
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}
.chart-card {
    display: flex;
    flex-direction: column;
    height: 260px;
}
.chart-card h3 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 14px;
}
.chart-wrapper {
    flex: 1;
    position: relative;
}
.chart-wrapper canvas {
    width: 100%;
    height: 100%;
    display: block;
}
@media (max-width: 768px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}
