:root {
    --bg: #070b12;
    --bg-alt: #0d1320;
    --panel: rgba(17, 25, 40, 0.68);
    --panel-2: rgba(20, 29, 46, 0.74);
    --text: #e8eef8;
    --muted: #9fb0c7;
    --line: rgba(255,255,255,0.08);
    --accent: #5ea6ff;
    --accent-2: #6ff2d7;
    --danger: #ff6d89;
    --warning: #ffbd66;
    --success: #4ee29b;
    --shadow: 0 20px 60px rgba(0,0,0,0.32);
    --radius: 22px;
    --blur: 22px;
    --max-width: 1320px;
    --input-bg: rgba(255,255,255,0.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    background:
        radial-gradient(circle at 10% 20%, rgba(94,166,255,0.16), transparent 28%),
        radial-gradient(circle at 90% 10%, rgba(111,242,215,0.12), transparent 24%),
        linear-gradient(160deg, var(--bg), var(--bg-alt));
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

a { color: var(--text); text-decoration: none; }
img { max-width: 100%; display: block; }

.bg-orb {
    position: fixed;
    inset: auto;
    border-radius: 999px;
    filter: blur(90px);
    pointer-events: none;
    opacity: .35;
    z-index: 0;
}
.bg-orb-a {
    width: 280px; height: 280px; left: 5%; top: 6%;
    background: rgba(94,166,255,.35);
}
.bg-orb-b {
    width: 280px; height: 280px; right: 6%; top: 22%;
    background: rgba(111,242,215,.24);
}

.glass {
    background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.04));
    backdrop-filter: blur(var(--blur));
    -webkit-backdrop-filter: blur(var(--blur));
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    width: min(calc(100% - 32px), var(--max-width));
    margin: 18px auto 0;
    padding: 14px 18px;
    border-radius: 26px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo {
    width: 44px; height: 44px; border-radius: 14px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, rgba(94,166,255,.22), rgba(111,242,215,.18));
    border: 1px solid rgba(255,255,255,.12);
    font-size: 22px;
}
.brand small { color: var(--muted); display: block; }

.top-nav { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.top-nav a {
    padding: 10px 14px;
    border-radius: 14px;
    color: var(--muted);
    transition: .2s ease;
}
.top-nav a:hover, .top-nav a.active {
    background: rgba(255,255,255,.07);
    color: var(--text);
}
.danger-link:hover { color: #fff; background: rgba(255,109,137,.12) !important; }

.page-shell {
    position: relative;
    z-index: 1;
    width: min(calc(100% - 32px), var(--max-width));
    margin: 22px auto 60px;
}

.hero-card, .card {
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 18px;
}

.hero-card {
    display: grid;
    grid-template-columns: 1.3fr .8fr;
    gap: 18px;
}
.hero-title { font-size: clamp(28px, 4vw, 42px); margin: 0 0 8px; }
.hero-sub { color: var(--muted); max-width: 70ch; }

.card-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 18px;
}
.span-12 { grid-column: span 12; }
.span-8 { grid-column: span 8; }
.span-6 { grid-column: span 6; }
.span-4 { grid-column: span 4; }
.span-3 { grid-column: span 3; }

.card h2, .card h3 { margin-top: 0; }
.section-title {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    margin-bottom: 12px;
}

.muted { color: var(--muted); }
.kpi {
    display: flex; flex-direction: column; gap: 8px;
    padding: 16px;
    border-radius: 18px;
    background: rgba(255,255,255,.04);
    border: 1px solid rgba(255,255,255,.06);
}
.kpi strong { font-size: 28px; }

.progress-wrap { display: grid; gap: 14px; }
.progress {
    height: 12px; background: rgba(255,255,255,.06); border-radius: 999px; overflow: hidden;
}
.progress > span {
    display: block; height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    border-radius: 999px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 16px;
}
.field { grid-column: span 12; display: flex; flex-direction: column; gap: 8px; }
.field.span-6 { grid-column: span 6; }
.field.span-4 { grid-column: span 4; }
.field.span-3 { grid-column: span 3; }
.field label { color: var(--muted); font-size: 14px; }

input, select, textarea, button {
    font: inherit;
}
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"], select, textarea {
    width: 100%;
    background: var(--input-bg);
    color: var(--text);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 16px;
    padding: 14px 16px;
    outline: none;
    transition: .2s ease;
}
input:focus, select:focus, textarea:focus {
    border-color: rgba(94,166,255,.5);
    box-shadow: 0 0 0 4px rgba(94,166,255,.12);
}

.btn, button, .button-link {
    appearance: none;
    border: 1px solid rgba(255,255,255,.12);
    background: linear-gradient(135deg, rgba(94,166,255,.18), rgba(111,242,215,.12));
    color: var(--text);
    border-radius: 16px;
    padding: 12px 16px;
    cursor: pointer;
    transition: transform .18s ease, box-shadow .2s ease, background .2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.btn:hover, button:hover, .button-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 30px rgba(0,0,0,.22);
}
.btn-secondary {
    background: rgba(255,255,255,.05);
}
.btn-danger {
    background: linear-gradient(135deg, rgba(255,109,137,.2), rgba(255,109,137,.08));
}

.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    text-align: left;
    padding: 14px 10px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
th { color: var(--muted); font-weight: 600; }

.badge {
    display: inline-flex;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255,255,255,.06);
    color: var(--muted);
    font-size: 12px;
}
.alert {
    padding: 14px 18px;
    border-radius: 18px;
    margin-bottom: 16px;
}
.alert-success { border-color: rgba(78,226,155,.2); }
.alert-error { border-color: rgba(255,109,137,.2); }
.alert-warning { border-color: rgba(255,189,102,.2); }

.split {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}
.justify-between { justify-content: space-between; }
.right { text-align: right; }

.auth-shell {
    max-width: 520px;
    margin: 7vh auto 40px;
}
.auth-shell .card { padding: 28px; }

.stat-line {
    display: flex; justify-content: space-between; gap: 14px;
    padding: 8px 0;
    border-bottom: 1px dashed rgba(255,255,255,.08);
}
.stat-line:last-child { border-bottom: 0; }

.meal-list, .favorite-list {
    display: grid;
    gap: 12px;
}
.meal-item {
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(255,255,255,.04);
    border: 1px solid rgba(255,255,255,.06);
}

.chart-box {
    position: relative;
    min-height: 280px;
    padding: 10px;
    border-radius: 18px;
    background: rgba(255,255,255,.03);
}

.inline-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: end;
}
.inline-form .field { margin: 0; min-width: 140px; }

.search-results {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}
.search-result {
    padding: 14px;
    border-radius: 16px;
    background: rgba(255,255,255,.04);
    border: 1px solid rgba(255,255,255,.06);
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}
.search-result .meta { color: var(--muted); font-size: 14px; }

.empty {
    padding: 18px;
    border-radius: 18px;
    color: var(--muted);
    background: rgba(255,255,255,.03);
    border: 1px dashed rgba(255,255,255,.08);
}

.footer-note { color: var(--muted); font-size: 13px; }

canvas { width: 100% !important; height: auto !important; }

@media (max-width: 980px) {
    .hero-card { grid-template-columns: 1fr; }
    .span-8, .span-6, .span-4, .span-3, .field.span-6, .field.span-4, .field.span-3 { grid-column: span 12; }
    .site-header { align-items: flex-start; flex-direction: column; }
    .top-nav { justify-content: flex-start; }
}
