:root {
    --bg: #f6f7f9;
    --ink: #18202a;
    --muted: #6d7784;
    --line: #dde3ea;
    --panel: #ffffff;
    --brand: #0f766e;
    --brand-dark: #0b5d56;
    --accent: #eab308;
    --danger: #dc2626;
    --good: #16803c;
    --soft: #edf7f6;
    --shadow: 0 16px 40px rgba(24, 32, 42, .08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--bg);
}
a { color: inherit; text-decoration: none; }
input, select, textarea, button { font: inherit; }

.setup-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(15,118,110,.92), rgba(24,32,42,.88)),
        url("https://images.unsplash.com/photo-1554224155-6726b3ff858f?auto=format&fit=crop&w=1600&q=80") center/cover;
}
.setup-shell {
    width: min(1080px, 100%);
    display: grid;
    grid-template-columns: 1fr 1.1fr;
    gap: 26px;
    align-items: stretch;
}
.setup-hero {
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: end;
    min-height: 540px;
    padding: 34px;
}
.setup-hero h1 { font-size: clamp(34px, 5vw, 62px); line-height: 1; margin: 18px 0; letter-spacing: 0; }
.setup-hero p { max-width: 520px; color: rgba(255,255,255,.86); font-size: 18px; line-height: 1.6; }
.brand-mark {
    width: 58px; height: 58px; display: grid; place-items: center;
    border: 1px solid rgba(255,255,255,.46); border-radius: 8px; font-weight: 800;
}
.setup-card, .login-card {
    background: rgba(255,255,255,.96);
    border: 1px solid rgba(255,255,255,.55);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 28px;
}
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.full { grid-column: 1 / -1; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 700; }
input, select, textarea {
    width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 12px 13px;
    background: #fff; color: var(--ink); outline: none;
}
textarea { min-height: 94px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15,118,110,.14); }
.btn {
    border: 0; border-radius: 8px; min-height: 42px; padding: 10px 15px;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    cursor: pointer; font-weight: 800; background: #e9eef3; color: var(--ink);
}
.btn.primary { background: var(--brand); color: white; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { background: #fee2e2; color: #991b1b; }
.btn.wide { width: 100%; grid-column: 1 / -1; }
.notice { padding: 13px 14px; border-radius: 8px; margin-bottom: 16px; font-weight: 700; }
.notice.success { background: #dcfce7; color: #166534; }
.notice.danger { background: #fee2e2; color: #991b1b; }

.app {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 270px 1fr;
}
.sidebar {
    background: #111827;
    color: white;
    padding: 22px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar .brand { display: flex; align-items: center; gap: 12px; font-size: 19px; font-weight: 900; margin-bottom: 22px; }
.nav { display: grid; gap: 6px; }
.nav a {
    display: flex; align-items: center; gap: 10px; padding: 11px 12px;
    border-radius: 8px; color: rgba(255,255,255,.78); font-weight: 700;
}
.nav a.active, .nav a:hover { background: rgba(255,255,255,.11); color: white; }
.content { padding: 24px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; gap: 14px; align-items: center; margin-bottom: 22px; }
.topbar h1 { margin: 0; font-size: 28px; letter-spacing: 0; }
.topbar p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.metric {
    background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
    padding: 18px; box-shadow: 0 8px 24px rgba(24,32,42,.04);
}
.metric span { color: var(--muted); font-size: 13px; font-weight: 800; }
.metric strong { display: block; margin-top: 8px; font-size: 24px; }
.metric.good strong { color: var(--good); }
.metric.bad strong { color: var(--danger); }
.section-grid { display: grid; grid-template-columns: 1.4fr .8fr; gap: 16px; align-items: start; }
.panel {
    background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
    padding: 18px; box-shadow: 0 8px 24px rgba(24,32,42,.04);
}
.panel h2 { margin: 0 0 14px; font-size: 18px; letter-spacing: 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; background: white; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; background: #fafbfc; }
tr:last-child td { border-bottom: 0; }
.badge { display: inline-flex; border-radius: 999px; padding: 5px 9px; font-size: 12px; font-weight: 900; background: #e5e7eb; color: #374151; }
.badge.income, .badge.paid, .badge.closed { background: #dcfce7; color: #166534; }
.badge.expense, .badge.overdue { background: #fee2e2; color: #991b1b; }
.badge.business { background: #e0f2fe; color: #075985; }
.badge.home { background: #fef3c7; color: #92400e; }
.empty { color: var(--muted); padding: 22px; text-align: center; }
.form-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.form-actions { display: flex; justify-content: end; gap: 10px; margin-top: 14px; }
.login-page {
    min-height: 100vh; display: grid; place-items: center; padding: 22px;
    background: linear-gradient(140deg, #111827 0%, #0f766e 100%);
}
.login-card { width: min(430px, 100%); }
.login-card h1 { margin: 0 0 6px; }
.login-card p { margin: 0 0 18px; color: var(--muted); }
.quick-list { display: grid; gap: 10px; }
.quick-item { display: flex; justify-content: space-between; gap: 12px; padding: 12px; background: #fafafa; border: 1px solid var(--line); border-radius: 8px; }
.quick-item small { color: var(--muted); display: block; margin-top: 3px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filters > * { width: auto; min-width: 150px; }

@media (max-width: 980px) {
    .setup-shell, .app, .section-grid { grid-template-columns: 1fr; }
    .setup-hero { min-height: 320px; padding: 22px; }
    .sidebar { position: static; height: auto; }
    .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .content { padding: 16px; }
    .grid-form, .form-row, .metric-grid { grid-template-columns: 1fr; }
    .topbar { align-items: stretch; flex-direction: column; }
    .nav { grid-template-columns: 1fr; }
    .filters > * { width: 100%; }
}
