/* =====================================================================
   Personal Finance Control - Stylesheet
   Font: Poppins only. No purple.
   Theme: light + dark via [data-theme]
   ===================================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #f4f6fa;
    --surface: #ffffff;
    --surface-2: #f9fbfd;
    --text: #1a2235;
    --text-muted: #61708a;
    --border: #e3e8ef;
    --primary: #0d7c66;          /* teal green - no purple */
    --primary-hover: #0a6353;
    --accent: #f08a24;           /* warm orange */
    --danger: #d64545;
    --success: #2e9d63;
    --warning: #d4a017;
    --info: #2c7be5;
    --shadow: 0 4px 14px rgba(20, 30, 60, 0.06);
    --radius: 14px;
    --radius-sm: 8px;
}

[data-theme="dark"] {
    --bg: #0f1622;
    --surface: #182233;
    --surface-2: #1f2b3f;
    --text: #e9edf5;
    --text-muted: #93a1bb;
    --border: #2a3853;
    --primary: #14a589;
    --primary-hover: #1ec0a2;
    --accent: #ffa64d;
    --danger: #ef6b6b;
    --success: #4cc88a;
    --shadow: 0 6px 22px rgba(0, 0, 0, 0.4);
}

html, body {
    font-family: 'Poppins', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100%;
    line-height: 1.55;
    font-weight: 400;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* ----------------- Top Bar ----------------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 26px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: sticky; top: 0; z-index: 50;
    flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.brand a { color: var(--text); font-size: 18px; }
.brand-logo {
    width: 34px; height: 34px;
    border-radius: 50%;
    flex-shrink: 0;
}
.nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nav a {
    padding: 8px 14px; border-radius: 999px;
    color: var(--text-muted); font-weight: 500; font-size: 14px;
    transition: 0.2s;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active {
    background: var(--primary); color: #fff;
}
.nav a.logout { color: var(--danger); }
.nav a.logout:hover { background: rgba(214,69,69,0.1); }

.theme-btn {
    background: var(--surface-2); border: 1px solid var(--border);
    width: 38px; height: 38px; border-radius: 50%;
    cursor: pointer; color: var(--text); font-size: 16px;
    display: inline-flex; align-items: center; justify-content: center;
}
[data-theme="light"] .t-dark { display: none; }
[data-theme="dark"] .t-light { display: none; }

.menu-toggle {
    display: none;
    background: none; border: none; color: var(--text);
    font-size: 26px; cursor: pointer;
}

/* ----------------- Layout ----------------- */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 28px 22px 60px;
}
.page-title {
    font-size: 26px; font-weight: 600; margin-bottom: 6px;
}
.page-sub { color: var(--text-muted); margin-bottom: 22px; font-size: 14px; }

/* ----------------- Cards ----------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    margin-bottom: 22px;
}
.card h3 {
    font-size: 16px; font-weight: 600; margin-bottom: 14px;
    display: flex; justify-content: space-between; align-items: center;
}

/* ----------------- Stat tiles ----------------- */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}
.stat::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0;
    width: 4px; background: var(--primary);
}
.stat.expense::before { background: var(--danger); }
.stat.savings::before { background: var(--success); }
.stat.accent::before  { background: var(--accent); }
.stat .label { color: var(--text-muted); font-size: 13px; font-weight: 500; }
.stat .value { font-size: 26px; font-weight: 600; margin-top: 4px; }
.stat .sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ----------------- Forms ----------------- */
form .row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 14px;
}
label { font-size: 13px; color: var(--text-muted); font-weight: 500; display:block; margin-bottom:4px; }
input, select, textarea, button {
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
}
input[type="text"], input[type="number"], input[type="password"],
input[type="date"], input[type="month"], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    border-radius: var(--radius-sm);
    outline: none;
    transition: 0.2s;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    background: var(--surface);
}

.btn {
    display: inline-block;
    padding: 10px 18px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: 0.2s;
    text-decoration: none;
}
.btn:hover { background: var(--primary-hover); color: #fff; }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.secondary:hover { background: var(--border); color: var(--text); }
.btn.danger  { background: var(--danger); }
.btn.danger:hover { background: #b53939; }
.btn.small { padding: 6px 12px; font-size: 12px; }

/* ----------------- Tables ----------------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table {
    width: 100%; border-collapse: collapse;
    background: var(--surface);
}
th, td {
    padding: 12px 14px; text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
th {
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface-2);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
tbody tr:hover { background: var(--surface-2); }
.amount { font-weight: 600; }
.amount.expense { color: var(--danger); }
.amount.income  { color: var(--success); }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    background: var(--surface-2);
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.badge.recurring { background: rgba(13,124,102,0.12); color: var(--primary); border-color: transparent; }

/* ----------------- Alerts ----------------- */
.alert {
    padding: 12px 16px; border-radius: var(--radius-sm);
    margin-bottom: 18px; font-size: 14px;
    border: 1px solid var(--border);
}
.alert.ok  { background: rgba(46,157,99,0.12);  color: var(--success); border-color: rgba(46,157,99,0.3); }
.alert.err { background: rgba(214,69,69,0.12);  color: var(--danger);  border-color: rgba(214,69,69,0.3); }

/* ----------------- Login ----------------- */
.login-wrap {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--bg), var(--surface-2));
}
.login-card {
    width: 100%; max-width: 400px;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 36px 32px;
    box-shadow: var(--shadow);
}
.login-card h1 {
    font-size: 22px; font-weight: 600; margin-bottom: 6px;
    text-align: center;
}
.login-card .sub { text-align: center; color: var(--text-muted); margin-bottom: 22px; font-size: 13px; }
.login-card form .row { grid-template-columns: 1fr; }
.login-card .btn { width: 100%; padding: 12px; }

/* ----------------- Two-column layouts ----------------- */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 22px;
}
.grid-3 {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr 0.9fr;
    gap: 22px;
}
/* Chart scroll wrapper — prevents page-level overflow on small screens */
.chart-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}
.chart-scroll .chart-box {
    min-width: 320px;
}
.chart-box { position: relative; height: 280px; }

.list-clean { list-style: none; }
.list-clean li {
    display: flex; justify-content: space-between;
    padding: 10px 0; border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.list-clean li:last-child { border-bottom: none; }
.rank {
    display: inline-block; width: 22px; height: 22px;
    border-radius: 50%; background: var(--primary); color: #fff;
    text-align: center; line-height: 22px; font-size: 11px; font-weight: 600;
    margin-right: 8px;
}
.rank.r2 { background: var(--accent); }
.rank.r3 { background: var(--info); }
.rank.r4 { background: var(--warning); }

/* ----------------- Footer ----------------- */
.footer {
    text-align: center; padding: 24px;
    color: var(--text-muted); font-size: 13px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}
img.brand-logo{width:36px !important;}
/* ----------------- Responsive ----------------- */
@media (max-width: 900px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
    .menu-toggle { display: inline-block; }
    .nav {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        margin-top: 12px;
    }
    .nav.open { display: flex; }
    .nav a, .nav .theme-btn { width: 100%; text-align: left; border-radius: var(--radius-sm); }
    .nav .theme-btn { width: 38px; }
    .topbar { padding: 12px 16px; }
    .container { padding: 18px 14px 50px; }
    .stat .value { font-size: 22px; }
    th, td { padding: 10px; font-size: 13px; }
}
@media (max-width: 420px) {
    .page-title { font-size: 22px; }
}

/* ----------------- Misc ----------------- */
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar {
    display: flex; flex-wrap: wrap; gap: 12px; align-items: end;
    margin-bottom: 18px;
}
.toolbar > * { min-width: 160px; }
hr.sep { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.empty { text-align: center; padding: 30px; color: var(--text-muted); }


