:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #172033;
    --muted: #6b7280;
    --line: #e5e7eb;
    --primary: #2563eb;
    --accent: #16a34a;
    --danger: #dc2626;
    --warn: #f59e0b;
}

[data-theme="dark"] {
    --bg: #10131a;
    --panel: #171b24;
    --text: #f8fafc;
    --muted: #9ca3af;
    --line: #2a3140;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { text-decoration: none; }
label { display: block; margin-top: 14px; margin-bottom: 6px; color: var(--muted); font-size: .86rem; font-weight: 700; }
.form-control, .form-select { border-color: var(--line); border-radius: 8px; min-height: 42px; background: var(--panel); color: var(--text); }
.btn { border-radius: 8px; font-weight: 700; }

.app-shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 22px 16px; background: #0f172a; color: #fff; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; font-weight: 900; font-size: 1.3rem; margin-bottom: 24px; }
.brand-icon, .brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 8px; background: #2563eb; color: #fff; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar a:not(.brand) { display: flex; align-items: center; gap: 11px; padding: 11px 12px; color: #cbd5e1; border-radius: 8px; transition: .2s ease; }
.sidebar a.active, .sidebar a:hover { background: rgba(255,255,255,.11); color: #fff; transform: translateX(3px); }
.sidebar i { width: 20px; text-align: center; }
.main-panel { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 3; display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 16px 24px; background: color-mix(in srgb, var(--bg) 84%, transparent); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.search-bar { flex: 1; max-width: 680px; display: flex; align-items: center; gap: 10px; padding: 0 14px; min-height: 44px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.search-bar input { border: 0; outline: 0; width: 100%; background: transparent; color: var(--text); }
.user-menu { display: flex; align-items: center; gap: 10px; }
.avatar-link { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 900; }
.avatar-link img { width: 100%; height: 100%; object-fit: cover; }
.icon-button { border: 0; width: 38px; height: 38px; border-radius: 8px; background: color-mix(in srgb, var(--primary) 10%, var(--panel)); color: var(--primary); display: inline-grid; place-items: center; }
.content { padding: 24px; }
.page-title { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 20px; }
.page-title span { color: var(--primary); font-weight: 900; text-transform: uppercase; font-size: .75rem; letter-spacing: .08em; }
.page-title h1 { margin: 0; font-size: 2rem; font-weight: 900; letter-spacing: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px; box-shadow: 0 12px 30px rgba(15,23,42,.06); }
.panel h2 { font-size: 1.05rem; font-weight: 900; margin: 0 0 14px; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.metric strong { display: block; font-size: 1.65rem; line-height: 1.1; }
.metric span { color: var(--muted); font-weight: 700; }
.metric i { font-size: 1.35rem; color: var(--primary); }
.table { color: var(--text); }
.table td, .table th { vertical-align: middle; }
.badge-soft { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 999px; background: color-mix(in srgb, var(--primary) 10%, transparent); color: var(--primary); font-weight: 800; font-size: .78rem; }
.budget-alert { margin: 16px 24px 0; padding: 13px 16px; border-radius: 8px; color: #fff; background: var(--danger); font-weight: 800; }
.budget-alert.reminder-alert { background: var(--warn); }
.suggestion-card { padding: 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); }
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(150px, 1fr)); gap: 12px; }
.day-card { min-height: 200px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.day-card h3 { font-size: .95rem; font-weight: 900; margin-bottom: 10px; }
.meal-chip { display: block; padding: 9px; border-radius: 8px; background: color-mix(in srgb, var(--accent) 10%, var(--panel)); margin-bottom: 8px; border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line)); }
.purchase-line { display: grid; grid-template-columns: 1.3fr .7fr .8fr .8fr 42px; gap: 8px; margin-bottom: 8px; }
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 20% 20%, #dbeafe, transparent 34%), #f8fafc; }
.auth-card { display: grid; grid-template-columns: 1fr 410px; width: min(900px, 100%); background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; box-shadow: 0 30px 80px rgba(15,23,42,.16); }
.auth-copy { padding: 46px; background: #0f172a; color: #fff; display: flex; flex-direction: column; justify-content: center; }
.auth-copy h1 { font-size: 3rem; font-weight: 900; margin: 18px 0 8px; }
.login-panel { padding: 42px; }
.login-panel h2 { font-weight: 900; }

@media (max-width: 980px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .sidebar nav { grid-template-columns: repeat(2, 1fr); }
    .grid.two, .grid.three, .grid.four, .week-grid { grid-template-columns: 1fr; }
    .purchase-line { grid-template-columns: 1fr; }
    .auth-card { grid-template-columns: 1fr; }
}
