:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --text: #1a1d23;
    --text-muted: #5c6470;
    --border: #dde1e6;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --green: #16a34a;
    --red: #dc2626;
    --yellow-bg: #fef9c3;
    --yellow-text: #713f12;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14161a;
        --surface: #1e2127;
        --text: #e7e9ec;
        --text-muted: #9aa2ad;
        --border: #2e333b;
        --accent: #3b82f6;
        --accent-hover: #60a5fa;
        --green: #4ade80;
        --red: #f87171;
        --yellow-bg: #422006;
        --yellow-text: #fde68a;
        --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Noto Sans Thai", "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
}

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.nav-brand { font-weight: 700; font-size: 1.1rem; }

.nav-links a {
    margin-left: 20px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.95rem;
}

.nav-links a:hover { color: var(--accent); }

.banner-warning {
    background: var(--yellow-bg);
    color: var(--yellow-text);
    padding: 10px 24px;
    font-size: 0.9rem;
    text-align: center;
}

.container {
    max-width: 1100px;
    margin: 24px auto;
    padding: 0 20px;
}

h1, h2, h3 { margin-top: 0; }

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

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px;
    box-shadow: var(--shadow);
}

.card .label { font-size: 0.85rem; color: var(--text-muted); }
.card .value { font-size: 1.5rem; font-weight: 700; margin-top: 4px; }
.card .value.positive { color: var(--green); }
.card .value.negative { color: var(--red); }

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

th, td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 0.9rem;
}

th { background: var(--bg); color: var(--text-muted); font-weight: 600; }

tr:last-child td { border-bottom: none; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}

.badge.deposit { background: #dcfce7; color: #166534; }
.badge.withdraw { background: #fee2e2; color: #991b1b; }

@media (prefers-color-scheme: dark) {
    .badge.deposit { background: #14532d; color: #bbf7d0; }
    .badge.withdraw { background: #7f1d1d; color: #fecaca; }
}

.confidence-high { color: var(--green); font-weight: 600; }
.confidence-mid { color: #ca8a04; font-weight: 600; }
.confidence-low { color: var(--red); font-weight: 600; }

form.inline { display: inline; }

input, select, textarea, button {
    font-family: inherit;
    font-size: 0.9rem;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}

button {
    background: var(--accent);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 600;
}

button:hover { background: var(--accent-hover); }

button.danger { background: var(--red); }
button.secondary { background: var(--text-muted); }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.form-row label {
    display: block;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.upload-zone {
    background: var(--surface);
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 24px;
}

.upload-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

.upload-card.saved { color: var(--green); font-weight: 600; }
.upload-card.error { color: var(--red); font-weight: 600; }

.year-select-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.login-box {
    max-width: 360px;
    margin: 80px auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.error-text { color: var(--red); font-size: 0.9rem; margin-bottom: 12px; }

.tax-steps td, .tax-steps th { font-size: 0.88rem; }
.tax-steps .total-row td { font-weight: 700; border-top: 2px solid var(--border); }
