:root {
    --bg: #ffffff;
    --panel: #ffffff;
    --border: #e2e5eb;
    --text: #1c1f26;
    --muted: #6b7280;
    --green: #1a9c62;
    --red: #d64545;
    --accent: #3366e0;
    --row-hover: #f7f8fa;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-text-size-adjust: 100%;
}

.container { max-width: 900px; margin: 0 auto; padding: 20px 16px 60px; }

.topnav {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 20px; background: #fff; border-bottom: 1px solid var(--border);
    flex-wrap: wrap; gap: 10px; position: sticky; top: 0; z-index: 10;
}
.topnav .brand { font-weight: 700; }
.topnav .links { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.topnav .links a { color: var(--muted); text-decoration: none; font-size: 14px; padding: 4px 0; }
.topnav .links a:hover { color: var(--text); }

.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.auth-box {
    background: #fff; border: 1px solid var(--border); border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    padding: 32px; width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 14px;
}
.auth-box h1 { font-size: 20px; margin: 0 0 6px; }
.auth-box label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }

input, select, button {
    font: inherit; padding: 10px 12px; border-radius: 6px; border: 1px solid var(--border);
    background: #fff; color: var(--text); width: 100%;
}
select { max-width: 100%; }
button { cursor: pointer; background: var(--accent); border: none; color: #fff; font-weight: 600; width: auto; }
button:hover { opacity: 0.9; }

.month-switch { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.month-switch a { color: var(--accent); text-decoration: none; font-size: 14px; }
.month-switch h2 { margin: 0; font-size: 20px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 24px; }
.card {
    background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 16px;
    display: flex; flex-direction: column; gap: 6px;
}
.card span { color: var(--muted); font-size: 13px; }
.card strong { font-size: 22px; }
.card small { color: var(--muted); font-size: 12px; }
.card.in strong { color: var(--green); }
.card.out strong { color: var(--red); }

h3 { font-size: 16px; margin: 24px 0 10px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; margin-top: 4px; min-width: 480px; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 14px; white-space: nowrap; }
.table th { color: var(--muted); font-weight: 600; }
.table td.in { color: var(--green); }
.table td.out { color: var(--red); }

.badge {
    display: inline-block; padding: 2px 8px; border-radius: 100px;
    background: #eef1f7; color: var(--text); font-size: 12px; font-weight: 600;
}

.entry-form { display: flex; flex-direction: column; gap: 14px; max-width: 420px; }
.entry-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.entry-form button { width: 100%; padding: 12px; }

.inline-filter { margin-bottom: 14px; display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.inline-filter label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.inline-filter input, .inline-filter select { width: auto; min-width: 150px; }

.link-btn { background: none; border: none; color: var(--red); padding: 0; font-size: 13px; width: auto; }

.bars { display: flex; flex-direction: column; gap: 12px; margin-bottom: 8px; }
.bar-row { display: flex; flex-direction: column; gap: 4px; }
.bar-label { display: flex; justify-content: space-between; font-size: 13px; gap: 8px; }
.bar-track { background: #f1f2f5; border-radius: 6px; height: 10px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; }
.bar-fill.out { background: var(--red); }
.bar-fill.in { background: var(--green); }

.muted { color: var(--muted); }
.error { color: var(--red); }
.success { color: var(--green); }

@media (max-width: 640px) {
    .container { padding: 16px 12px 48px; }
    .topnav { padding: 12px 14px; }
    .topnav .links { gap: 4px 12px; font-size: 13px; }
    .cards { grid-template-columns: 1fr; }
    .month-switch h2 { font-size: 18px; order: -1; width: 100%; text-align: center; }
    .month-switch { justify-content: space-between; }
    .inline-filter { flex-direction: column; align-items: stretch; }
    .inline-filter input, .inline-filter select { min-width: 0; width: 100%; }
}
