* { box-sizing: border-box; }

:root {
  --bg: #f5f6fa;
  --card-bg: #fff;
  --text: #1a1d29;
  --text-muted: #6b7280;
  --border: #f0f1f4;
  --table-head-bg: #f9fafb;
  --input-border: #d1d5db;
}
html.dark, body.dark {
  --bg: #0f1420;
  --card-bg: #171d2b;
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --border: #232a3b;
  --table-head-bg: #1c2333;
  --input-border: #2d3448;
}

body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); transition: background .2s, color .2s; }
a { color: inherit; }
.wrap { max-width: 1150px; margin: 0 auto; padding: 20px; }

.topbar { display: flex; justify-content: space-between; align-items: center; background: #14213d; color: #fff; padding: 14px 20px; }
.topbar h1 { font-size: 18px; margin: 0; font-weight: 600; }
.topbar a.logout { color: #cbd5e1; text-decoration: none; font-size: 13px; }
.topbar a.logout:hover { color: #fff; }

.banner-warn { background: #fef3cd; color: #92400e; border: 1px solid #f5c542; padding: 12px 16px; border-radius: 10px; font-size: 13px; margin-bottom: 16px; }
.banner-warn a { color: #92400e; text-decoration: underline; font-weight: 600; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin: 20px 0; }
.card { background: var(--card-bg); border-radius: 12px; padding: 18px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); border-left: 4px solid #2563eb; }
.card.debt { border-left-color: #dc2626; }
.card.paid { border-left-color: #16a34a; }
.card.monthly { border-left-color: #d97706; }
.card.interest { border-left-color: #0891b2; }
.card.target { border-left-color: #7c3aed; }
.card .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
.card .value { font-size: 22px; font-weight: 700; }
.card .sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.section-header { display: flex; justify-content: space-between; align-items: center; margin: 28px 0 12px; flex-wrap: wrap; gap: 8px; }
.section-header h2 { font-size: 16px; margin: 0; }
.btn { display: inline-block; padding: 9px 16px; border-radius: 8px; border: none; background: #2563eb; color: #fff; text-decoration: none; font-size: 14px; cursor: pointer; }
.btn:hover { background: #1d4ed8; }
.btn.secondary { background: #e5e7eb; color: #111827; }
html.dark .btn.secondary, body.dark .btn.secondary { background: #2d3448; color: #e5e7eb; }
.btn.secondary:hover { background: #d1d5db; }
.btn.danger { background: #dc2626; }
.btn.small { padding: 5px 10px; font-size: 12px; }

.table-wrap { background: var(--card-bg); border-radius: 12px; overflow-x: auto; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th, td { text-align: left; padding: 12px 14px; font-size: 13px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: var(--table-head-bg); color: var(--text-muted); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }
.tag { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.tag.bank { background: #dbeafe; color: #1d4ed8; }
.tag.nbfc { background: #e0e7ff; color: #4338ca; }
.tag.cc { background: #fee2e2; color: #b91c1c; }
.tag.person { background: #dcfce7; color: #15803d; }
.tag.other { background: #f3f4f6; color: #374151; }
.due-soon { color: #dc2626; font-weight: 700; }
.actions a { margin-right: 8px; font-size: 12px; text-decoration: none; color: #2563eb; }
.actions a.del { color: #dc2626; }
.empty { padding: 30px; text-align: center; color: var(--text-muted); }

.form-card { background: var(--card-bg); border-radius: 12px; padding: 24px; max-width: 560px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.form-row { margin-bottom: 16px; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); }
input[type=text], input[type=number], input[type=date], input[type=password], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--input-border); border-radius: 8px; font-size: 14px;
  background: var(--card-bg); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #2563eb; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--bg); }
.login-box { background: var(--card-bg); padding: 34px; border-radius: 14px; width: 100%; max-width: 380px; box-shadow: 0 4px 20px rgba(0,0,0,0.08); }
.login-box h1 { font-size: 20px; margin: 0 0 6px; }
.login-box p.sub { color: var(--text-muted); font-size: 13px; margin: 0 0 22px; }
.error-msg { background: #fee2e2; color: #b91c1c; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.success-msg { background: #dcfce7; color: #15803d; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }

.progress-bar { width: 100%; background: var(--border); border-radius: 999px; height: 6px; overflow: hidden; margin-top: 4px; }
.progress-fill { height: 100%; background: #16a34a; }

footer.note { text-align: center; color: var(--text-muted); font-size: 12px; margin: 30px 0 10px; }
footer.note a { color: #2563eb; text-decoration: none; }

@media (max-width: 640px) {
  .topbar h1 { font-size: 15px; }
  .card .value { font-size: 19px; }
}
