:root {
    --bg: #eceef4;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --text: #14161c;
    --muted: #8b8fa3;
    --accent: #2f6fed;
    --accent-soft: #eaf0fe;
    --black: #0f1115;
    --danger: #e6484f;
    --green: #22a35c;
    --orange: #f2994a;
    --border: #e8eaf1;
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 14px rgba(20, 22, 28, 0.06);
    --sidebar-w: 220px;
    --topbar-h: 76px;
}
* { box-sizing: border-box; }
html, body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    z-index: 10;
}
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px 28px 8px;
}
.sidebar-logo .mark {
    width: 34px; height: 34px;
    border-radius: 9px;
    background: var(--black);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800;
    font-size: 17px;
    flex-shrink: 0;
}
.sidebar-logo .wordmark {
    font-weight: 800;
    font-size: 13px;
    letter-spacing: 0.06em;
    line-height: 1.25;
    text-transform: uppercase;
}
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    transition: background .15s ease, color .15s ease;
}
.nav-item:hover { background: #f4f5f9; text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item svg { width: 19px; height: 19px; flex-shrink: 0; }
.sidebar-bottom {
    border-top: 1px solid var(--border);
    padding-top: 10px;
    margin-top: 10px;
}

/* ---------- Topbar ---------- */
.topbar {
    position: fixed;
    top: 0; right: 0;
    left: var(--sidebar-w);
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    z-index: 9;
}
.topbar-user { display: flex; align-items: center; gap: 12px; }
.topbar-avatar {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800;
    font-size: 15px;
    text-transform: uppercase;
}
.topbar-user-name { font-weight: 800; font-size: 15px; line-height: 1.2; }
.topbar-user-sub { font-size: 12px; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-actions a {
    width: 38px; height: 38px;
    border-radius: 11px;
    background: var(--black);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px;
    font-weight: 700;
}
.topbar-actions a:hover { opacity: 0.85; text-decoration: none; }

/* ---------- Layout ---------- */
.content {
    margin-left: var(--sidebar-w);
    margin-top: var(--topbar-h);
    padding: 28px;
    max-width: 920px;
}
.page-title {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin: 0 0 16px 4px;
    color: var(--text);
}

/* ---------- Cards ---------- */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px 26px;
    margin-bottom: 20px;
}
.card h2 {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin: 0 0 16px 0;
    color: var(--text);
}
.muted { color: var(--muted); }
.counts { color: var(--muted); font-size: 14px; }
.counts strong { color: var(--text); }

/* ---------- Icon grid (obszary pracy) ---------- */
.tile-grid {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 32px;
}
.tile {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    width: 128px;
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
    transition: transform .15s ease, box-shadow .15s ease;
}
.tile:hover {
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(20, 22, 28, 0.1);
}
.tile .tile-icon {
    width: 48px; height: 48px;
    border-radius: 13px;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
}
.tile .tile-icon svg { width: 24px; height: 24px; }
.tile .tile-label { font-size: 13px; font-weight: 700; color: var(--text); }
.tile .tile-count { font-size: 13px; color: var(--muted); }

/* ---------- Form ---------- */
.generate-form { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.generate-form label,
.field label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}
.generate-form input,
.field input {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    width: 200px;
    background: #fbfbfd;
}
.generate-form input:focus,
.field input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

button, .btn {
    background: var(--black);
    color: #fff;
    border: none;
    padding: 13px 22px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    transition: opacity .15s ease, transform .15s ease;
}
button:hover, .btn:hover { opacity: 0.88; text-decoration: none; }
button:active, .btn:active { transform: scale(0.97); }

/* ---------- Day/tab pill selector ---------- */
.day-tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.day-tab {
    padding: 9px 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}
.day-tab.active { background: var(--black); color: #fff; border-color: var(--black); }

/* ---------- Macro summary bar ---------- */
.macro-bar {
    background: var(--black);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 22px;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.macro-bar .dot {
    display: inline-block;
    width: 9px; height: 9px;
    border-radius: 50%;
    margin-right: 6px;
}
.macro-bar .dot.b { background: var(--green); }
.macro-bar .dot.t { background: var(--danger); }
.macro-bar .dot.w { background: var(--orange); }
.macro-bar .kcal-total { margin-left: auto; color: #fff; }

/* ---------- Meal rows ---------- */
.meal {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 0;
    border-top: 1px solid var(--border);
}
.meal:first-of-type { border-top: none; padding-top: 4px; }
.meal-thumb {
    width: 52px; height: 52px;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.meal-thumb svg { width: 24px; height: 24px; }
.meal-body { flex: 1; min-width: 0; }
.meal-body h3 { margin: 0 0 4px 0; font-size: 15px; font-weight: 700; }
.meal-slot {
    display: inline-block;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--accent);
    background: var(--accent-soft);
    padding: 2px 8px;
    border-radius: 999px;
    margin-bottom: 6px;
}
.macros { margin: 0 0 6px 0; color: var(--text); font-size: 13px; }
.macros .muted { font-size: 12px; }
.meal-error { color: var(--danger); font-weight: 600; }
.meal-swap { margin-left: auto; flex-shrink: 0; }
.meal-swap button {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    padding: 7px 14px;
    font-size: 11px;
}
.meal-swap button:hover { background: #f4f5f9; opacity: 1; }
.ingredients { margin: 8px 0; padding-left: 20px; font-size: 13px; }
.instructions { white-space: pre-line; color: var(--text); font-size: 13px; }
.total { text-align: right; font-size: 14px; font-weight: 700; padding-top: 10px; }
details summary { cursor: pointer; color: var(--accent); font-weight: 700; font-size: 13px; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "▸ "; }
details[open] summary::before { content: "▾ "; }

/* ---------- Status badges (historia) ---------- */
.badge-pill {
    display: inline-block;
    font-size: 11px;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
}

/* ---------- Login page ---------- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
}
.login-box {
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 40px 40px;
    width: 340px;
}
.login-box .mark {
    width: 40px; height: 40px;
    border-radius: 11px;
    background: var(--black);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800;
    font-size: 19px;
    margin-bottom: 18px;
}
.login-box h1 { font-size: 19px; margin: 0 0 4px 0; font-weight: 800; }
.subtitle { color: var(--muted); margin: 0 0 22px 0; font-size: 13px; }
.login-box label {
    display: block; font-size: 12px; font-weight: 700; color: var(--muted);
    text-transform: uppercase; letter-spacing: 0.04em; margin: 14px 0 6px;
}
.login-box input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    background: #fbfbfd;
}
.login-box button { width: 100%; margin-top: 20px; }
.error {
    color: var(--danger);
    font-size: 13px;
    background: #fdecec;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
}

@media (max-width: 760px) {
    :root { --sidebar-w: 72px; }
    .sidebar-logo .wordmark, .nav-item span.label { display: none; }
    .sidebar-logo { justify-content: center; padding: 0 0 20px 0; }
    .nav-item { justify-content: center; }
    .content { padding: 20px 16px; }
}
