/* dark theme */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #0b1120;
    color: #e2e8f0;
    font-family: "Segoe UI", Arial, sans-serif;
}

.navbar {
    padding: 16px 32px;
    border-bottom: 1px solid #1e293b;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 24px;
}

.logo {
    color: #38bdf8;
    font-size: 20px;
    font-weight: bold;
    text-decoration: none;
}

.nav-links {
    display: flex;
    gap: 16px;
}

.nav-link {
    color: #94a3b8;
    text-decoration: none;
    padding: 4px 0;
    border-bottom: 2px solid transparent;
}

.nav-link:hover {
    color: #e2e8f0;
}

/* right side of the nav bar: Register, or who is logged in */
.nav-account {
    margin-left: auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
}

.nav-user {
    color: #94a3b8;
    font-size: 14px;
}

.btn-small {
    padding: 5px 12px;
    font-size: 14px;
}

/* a line of text under a form, like "No account yet?" */
.form-note {
    color: #94a3b8;
    font-size: 14px;
    margin: 16px 0 0 0;
    text-align: center;
}

.form-note a {
    color: #38bdf8;
}

/* the page you are on */
.nav-link.active {
    color: #e2e8f0;
    border-bottom-color: #38bdf8;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px;
}

h1 {
    margin-bottom: 5px;
}

h2 {
    font-size: 18px;
    margin-top: 0;
}

.subtitle {
    color: #94a3b8;
    margin-top: 0;
    margin-bottom: 30px;
}

.card {
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 20px;
}

/* a page with one form (log in, register, edit expense): everything on it,
   messages too, is one column in the middle */
.container.form-page {
    max-width: 560px;
}

/* filters on the left, add form on the right */
.top {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

/* two cards side by side, same width (dashboard quick add) */
.top.even {
    grid-template-columns: 1fr 1fr;
}

.charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* ---------- dashboard ---------- */

.month-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

/* forecast: expected spending, income and balance in one row */
.forecast-totals {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 32px;
    margin: 12px 0;
}

.forecast-totals p {
    margin: 0;
}

/* to the far right of a row, like Download PDF */
.push-right {
    margin-left: auto;
}

.month-nav h1 {
    margin: 0;
    min-width: 220px;
    text-align: center;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.stat h2 {
    margin: 0 0 8px 0;
    font-size: 15px;
    color: #94a3b8;
}

.stat-value {
    margin: 0;
    font-size: 28px;
    font-weight: bold;
}

/* money in, and a balance below zero */
.income {
    color: #4ade80;
}

.negative {
    color: #f87171;
}

/* budget progress on the dashboard */
.budget-row {
    margin-bottom: 16px;
}

.budget-head {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 14px;
}

.progress {
    height: 10px;
    background: #1e293b;
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #38bdf8;
}

.progress-fill.over {
    background: #f87171;
}

.budget-note {
    margin: 4px 0 0 0;
    font-size: 13px;
    color: #94a3b8;
}

/* .negative has to win over the grey of .budget-note */
.budget-note.negative {
    color: #f87171;
}

/* ---------- forms ---------- */

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}

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

.filters .field {
    margin-bottom: 0;
}

.grow {
    flex: 1;
    min-width: 150px;
}

.row {
    display: flex;
    gap: 12px;
}

.row .field {
    flex: 1;
}

/* a password field, with its Show / Hide button inside on the right */
.password-box {
    position: relative;
    display: flex;
}

.password-box input {
    flex: 1;
    min-width: 0;
    padding-right: 64px; /* so the text never goes under the button */
}

.password-toggle {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 60px;
    background: none;
    border: none;
    border-radius: 10px;
    color: #94a3b8;
    font-size: 13px;
    cursor: pointer;
}

.password-toggle[hidden] {
    display: none;
}

.password-toggle:hover {
    color: #e2e8f0;
}

.password-toggle:focus-visible {
    outline: 2px solid #38bdf8;
    outline-offset: -2px;
}

/* Edge has its own eye button, one is enough */
.password-box input::-ms-reveal {
    display: none;
}

/* a short help text under a form field */
.hint {
    color: #94a3b8;
    font-size: 12px;
    margin-top: 4px;
}

label {
    font-size: 14px;
    color: #cbd5e1;
    margin-bottom: 6px;
}

input,
select {
    background: #111827;
    color: #e2e8f0;
    border: 1px solid #1f2a3d;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    color-scheme: dark; /* makes the calendar icon light */
}

input:focus,
select:focus {
    outline: none;
    border-color: #38bdf8;
}

.btn {
    background: #1e293b;
    color: #e2e8f0;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 10px 18px;
    font-size: 15px;
    cursor: pointer;
    text-decoration: none;
}

.btn:hover {
    background: #273449;
}

.btn-blue {
    background: #0c4a6e;
    border-color: #0284c7;
    color: #7dd3fc;
}

.btn-blue:hover {
    background: #075985;
}

.full {
    width: 100%;
}

.btn-edit {
    background: #1d4ed8;
    border-color: #60a5fa;
    color: #dbeafe;
    padding: 5px 12px;
}

.btn-edit:hover {
    background: #1e40af;
}

.row-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
}

.btn-delete {
    background: transparent;
    color: #f87171;
    border: 1px solid #7f1d1d;
    border-radius: 8px;
    padding: 5px 12px;
    cursor: pointer;
}

.btn-delete:hover {
    background: #450a0a;
}

.error {
    background: #450a0a;
    border: 1px solid #b91c1c;
    color: #fecaca;
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.success {
    background: #052e16;
    border: 1px solid #15803d;
    color: #bbf7d0;
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 20px;
}

/* ---------- total ---------- */

.total-row {
    color: #cbd5e1;
    margin: 20px 0 10px 0;
}

.pill {
    background: #1e293b;
    border-radius: 10px;
    padding: 6px 12px;
    font-weight: bold;
    color: #fff;
}

.pill.big {
    font-size: 18px;
}

.small-link {
    color: #94a3b8;
    font-size: 13px;
}

/* ---------- table ---------- */

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

th {
    text-align: left;
    background: #111c30;
    padding: 12px;
    font-size: 14px;
}

td {
    padding: 12px;
    border-bottom: 1px solid #1e293b;
}

.right {
    text-align: right;
}

.empty {
    color: #64748b;
    text-align: center;
    padding: 30px;
}

/* a small form inside a table cell, like a budget's limit */
.inline-form {
    display: flex;
    gap: 8px;
    margin: 0;
}

.inline-form input {
    width: 140px;
}

/* category colour, same as in the pie chart */
.dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
}

/* label only for screen readers */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

/* ---------- charts ---------- */

/* chart.js needs a box with fixed height, otherwise canvas grows forever */
.chart-box {
    position: relative;
    height: 320px;
}

/* phone / small screen */
@media (max-width: 800px) {
    .top,
    .top.even,
    .stats,
    .charts {
        grid-template-columns: 1fr;
    }
}
