:root {
    color-scheme: light;
    --bg: #f4f6f9;
    --card: #ffffff;
    --field: #ffffff;
    --hover: #f8fafc;
    --text: #1f2937;
    --text2: #6b7280;
    --text3: #9ca3af;
    --heading: #334155;
    --border: #e2e6ec;
    --border-hover: #94a3b8;
    --accent: #2563eb;
    --error: #b91c1c;
    --success: #15803d;
    --warning: #c2410c;
    --bar: #1e293b;
    --bar-hover: #334155;
    --bar-text: #cbd5e1;
    --bar-border: #475569;
    --profit: #15803d;
    --profit-bg: #dcfce7;
    --loss: #b91c1c;
    --loss-bg: #fee2e2;
    --exit-bg: #fef3c7;
    --series-1: #2a78d6;
    --series-2: #eb6834;
    --series-3: #1baf7a;
    --series-4: #eda100;
    --chart-grid: #e9edf2;
    --chart-axis: #c3c2b7;
    --chart-label: #6b7280;
}

/* Motyw ciemny: automatycznie wg systemu (gdy nie wybrano „jasny”) albo wybrany ręcznie */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #0f172a;
        --card: #1e293b;
        --field: #0f172a;
        --hover: #273449;
        --text: #e5e7eb;
        --text2: #9ca3af;
        --text3: #64748b;
        --heading: #cbd5e1;
        --border: #334155;
        --border-hover: #64748b;
        --accent: #3b82f6;
        --error: #f87171;
        --success: #4ade80;
        --warning: #fb923c;
        --bar: #020617;
        --bar-hover: #1e293b;
        --bar-text: #cbd5e1;
        --bar-border: #334155;
        --profit: #4ade80;
        --profit-bg: #14532d;
        --loss: #f87171;
        --loss-bg: #7f1d1d;
        --exit-bg: #713f12;
        --series-1: #3987e5;
        --series-2: #d95926;
        --series-3: #199e70;
        --series-4: #c98500;
        --chart-grid: #2a3649;
        --chart-axis: #475569;
        --chart-label: #94a3b8;
    }
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f172a;
    --card: #1e293b;
    --field: #0f172a;
    --hover: #273449;
    --text: #e5e7eb;
    --text2: #9ca3af;
    --text3: #64748b;
    --heading: #cbd5e1;
    --border: #334155;
    --border-hover: #64748b;
    --accent: #3b82f6;
    --error: #f87171;
    --success: #4ade80;
    --warning: #fb923c;
    --bar: #020617;
    --bar-hover: #1e293b;
    --bar-text: #cbd5e1;
    --bar-border: #334155;
    --profit: #4ade80;
    --profit-bg: #14532d;
    --loss: #f87171;
    --loss-bg: #7f1d1d;
    --exit-bg: #713f12;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --chart-grid: #2a3649;
    --chart-axis: #475569;
    --chart-label: #94a3b8;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: 14px;
}

h1:focus { outline: none; }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
a { color: var(--accent); }

/* ---------- pasek nawigacji ---------- */
.topbar {
    display: flex; align-items: center; gap: 2rem;
    background: var(--bar); color: #fff; padding: .6rem 1.5rem;
    position: sticky; top: 0; z-index: 50;
}
.topbar .logo { color: #fff; font-weight: 600; font-size: 1.1rem; text-decoration: none; white-space: nowrap; }
.topbar nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.topbar nav a { color: var(--bar-text); text-decoration: none; padding: .35rem .8rem; border-radius: 6px; }
.topbar nav a:hover { background: var(--bar-hover); color: #fff; }
.topbar nav a.active { background: var(--accent); color: #fff; }

.content { padding: 1.25rem 1.5rem 3rem; max-width: 1600px; margin: 0 auto; }

.card {
    background: var(--card); border: 1px solid var(--border); border-radius: 10px;
    padding: 1rem 1.25rem; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.stack { display: flex; flex-direction: column; gap: 1rem; }

button {
    font: inherit; cursor: pointer; border: 1px solid var(--border); background: var(--field);
    border-radius: 6px; padding: .35rem .8rem; color: var(--text);
}
button:hover:not(:disabled) { border-color: var(--border-hover); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--error); }
button.small { padding: .1rem .45rem; font-size: .85rem; }
button.link { border: none; background: transparent; padding: 0; color: var(--accent); }
a.button {
    display: inline-flex; align-items: center; gap: .3rem; text-decoration: none; color: var(--text);
    border: 1px solid var(--border); background: var(--field); border-radius: 6px; padding: .35rem .8rem;
}
a.button:hover { border-color: var(--border-hover); }

input, select, textarea {
    font: inherit; border: 1px solid var(--border); border-radius: 6px; padding: .3rem .5rem; background: var(--field); color: var(--text);
}
input[type=number] { text-align: right; font-variant-numeric: tabular-nums; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(37,99,235,.35); border-color: var(--accent); }
label { color: var(--text2); font-size: .85rem; }

.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.column { display: flex; flex-direction: column; gap: .25rem; }
.spacer { flex: 1; }
.muted { color: var(--text2); }
.small-text { font-size: .82rem; }
.error { color: var(--error); }
.success { color: var(--success); }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.profit { color: var(--profit); }
.loss { color: var(--loss); }
.check { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; color: var(--text); font-size: .9rem; }

.page-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .75rem; }
.toolbar input[type=search] { min-width: 14rem; }

/* przełącznik (segmenty) */
.segments { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--field); }
.segments button { border: none; border-radius: 0; background: transparent; padding: .3rem .75rem; color: var(--text2); }
.segments button + button { border-left: 1px solid var(--border); }
.segments button.active { background: var(--accent); color: #fff; }

/* ---------- kafelki podsumowania ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.tile { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: .75rem 1rem; }
.tile .label { font-size: .78rem; color: var(--text2); text-transform: uppercase; letter-spacing: .03em; }
.tile .value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: .15rem; }
.tile .sub { font-size: .82rem; color: var(--text2); font-variant-numeric: tabular-nums; }
.tile.profit-tile { border-left: 4px solid var(--profit); }
.tile.loss-tile { border-left: 4px solid var(--loss); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 1rem; align-items: start; }
@media (max-width: 1100px) { .grid-2, .grid-main { grid-template-columns: 1fr; } }

/* ---------- tabele ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
table.table th { text-align: left; font-size: .8rem; color: var(--text2); font-weight: 600; padding: .4rem .5rem; border-bottom: 2px solid var(--border); white-space: nowrap; }
table.table td { padding: .4rem .5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.table td.num, table.table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.table tr:hover td { background: var(--hover); }
table.table tr.clickable { cursor: pointer; }
table.table tr.closed td { color: var(--text2); }
table.table tfoot td { font-weight: 700; border-top: 2px solid var(--border); border-bottom: none; }
table.table .actions { white-space: nowrap; text-align: right; }
table.table .actions button { margin-left: .2rem; }

.asset-cell { display: flex; flex-direction: column; }
.asset-cell .symbol { font-weight: 600; }
.asset-cell .name { font-size: .78rem; color: var(--text2); max-width: 18rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge { display: inline-block; border-radius: 999px; padding: .05rem .55rem; font-size: .75rem; font-weight: 600; background: var(--border); color: var(--text); white-space: nowrap; }
.badge.ok { background: var(--profit-bg); color: var(--profit); }
.badge.warn { background: var(--exit-bg); color: var(--warning); }
.badge.bad { background: var(--loss-bg); color: var(--loss); }
.badge.info { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.swatch { width: .8rem; height: .8rem; border-radius: 3px; display: inline-block; flex: none; border: 1px solid rgba(0,0,0,.15); vertical-align: middle; }

.empty { text-align: center; padding: 2rem 1rem; color: var(--text2); }
.empty .big { font-size: 2.2rem; }

/* ---------- okna dialogowe ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 100; }
.dialog { background: var(--card); border-radius: 12px; padding: 1.25rem 1.5rem; width: min(620px, 94vw); max-height: 92vh; overflow: auto; box-shadow: 0 20px 40px rgba(0,0,0,.25); }
.dialog.wide { width: min(900px, 96vw); }
.dialog h2 { margin-bottom: 1rem; }
.dialog .footer { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.field input, .field select, .field textarea { width: 100%; }
.field input[type=checkbox], .field input[type=radio] { width: auto; }
.field label.check { align-self: flex-start; }
.field .hint { font-size: .75rem; color: var(--text3); }
.preview { background: var(--hover); border: 1px dashed var(--border); border-radius: 8px; padding: .6rem .8rem; font-size: .88rem; line-height: 1.45; }

.toast { position: fixed; bottom: 2.25rem; right: 1.25rem; background: #1e293b; color: #fff; padding: .7rem 1rem; border-radius: 8px; z-index: 200; box-shadow: 0 8px 20px rgba(0,0,0,.25); max-width: 420px; }
.toast.error { background: #b91c1c; color: #fff; }

#blazor-error-ui {
    background: lightyellow; color: #111827; bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); display: none;
    left: 0; padding: .6rem 1.25rem .7rem; position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "Wystąpił błąd."; }

/* ---------- użytkownik / logowanie ---------- */
.user { display: flex; align-items: center; gap: .75rem; white-space: nowrap; }
.user a { color: var(--bar-text); text-decoration: none; }
.user a:hover { color: #fff; }
button.logout { background: transparent; color: var(--bar-text); border-color: var(--bar-border); padding: .25rem .7rem; }
button.logout:hover { color: #fff; border-color: #94a3b8; }

.login-bg {
    min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem 1rem 2.5rem;
    background: linear-gradient(135deg, #1e293b 0%, #334155 55%, #15803d 140%);
}
.login-box {
    background: var(--card); border-radius: 14px; padding: 2rem 2.25rem; width: min(400px, 100%);
    box-shadow: 0 25px 50px rgba(0,0,0,.35); text-align: center;
}
.login-box form { text-align: left; margin-top: 1.25rem; }
.login-logo { font-size: 2.6rem; line-height: 1; }
.login-box h1 { margin: .4rem 0 .25rem; font-size: 1.6rem; }
.login-box p { margin: 0; }
.login-field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .9rem; }
.login-field input { padding: .55rem .7rem; font-size: 1rem; width: 100%; }
.remember { color: var(--text2); font-size: .9rem; margin-bottom: 1rem; display: flex; }
button.wide { width: 100%; padding: .65rem; font-size: 1rem; font-weight: 600; }
.separator { display: flex; align-items: center; gap: .6rem; color: var(--text3); font-size: .8rem; margin: 1rem 0; }
.separator::before, .separator::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.login-info { background: var(--hover); border: 1px solid var(--border); border-radius: 8px; padding: .6rem .8rem; margin-top: .8rem !important; font-size: .88rem; }
.switch-mode { margin: 1rem 0 0 !important; font-size: .9rem; color: var(--text2); }
.switch-mode a { color: var(--accent); font-weight: 600; }
.fine { font-size: .8rem; margin-top: .5rem !important; }

/* ---------- przełącznik motywu ---------- */
.theme { display: inline-flex; border: 1px solid var(--bar-border); border-radius: 8px; overflow: hidden; }
.theme button {
    background: transparent; border: none; border-radius: 0; padding: .2rem .5rem; font-size: .95rem;
    color: var(--bar-text); opacity: .55; line-height: 1.2;
}
.theme button + button { border-left: 1px solid var(--bar-border); }
.theme button:hover { opacity: 1; background: var(--bar-hover); }
html:not([data-theme-choice]) .theme button[data-m="system"],
html[data-theme-choice="system"] .theme button[data-m="system"],
html[data-theme-choice="light"] .theme button[data-m="light"],
html[data-theme-choice="dark"] .theme button[data-m="dark"] { opacity: 1; background: var(--accent); color: #fff; }
.login-theme { position: fixed; top: 1rem; right: 1rem; }
.login-theme .theme { border-color: rgba(255,255,255,.25); }

/* ---------- menu rozwijane w pasku ---------- */
.dropdown { position: relative; }
.dropdown-button {
    background: transparent; border: none; color: var(--bar-text); padding: .35rem .8rem; border-radius: 6px;
    display: inline-flex; align-items: center; gap: .3rem;
}
.dropdown-button:hover:not(:disabled) { background: var(--bar-hover); color: #fff; }
.dropdown-button.active { background: var(--accent); color: #fff; }
.dropdown-button .arrow { font-size: .75rem; transition: transform .15s; }
.dropdown.open .arrow { transform: rotate(180deg); }
.dropdown-backdrop { position: fixed; inset: 0; z-index: 60; }
.dropdown-list {
    position: absolute; top: calc(100% + .35rem); left: 0; z-index: 61; min-width: 11rem;
    background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: .3rem;
    box-shadow: 0 10px 25px rgba(0,0,0,.2); display: flex; flex-direction: column;
}
.topbar nav .dropdown-list a { color: var(--text); padding: .45rem .7rem; border-radius: 6px; }
.topbar nav .dropdown-list a:hover { background: var(--hover); color: var(--text); }
.topbar nav .dropdown-list a.active { background: var(--accent); color: #fff; }

/* ---------- stan synchronizacji ---------- */
.sync-state {
    display: inline-flex; align-items: center; gap: .4rem; background: transparent; border: 1px solid var(--bar-border);
    color: var(--bar-text); border-radius: 999px; padding: .2rem .65rem; font-size: .8rem; white-space: nowrap;
}
.sync-state:hover:not(:disabled) { border-color: var(--border-hover); color: #fff; }
.sync-dot { width: .55rem; height: .55rem; border-radius: 50%; background: #94a3b8; flex: none; }
.sync-state.ok .sync-dot { background: #22c55e; }
.sync-state.busy .sync-dot { background: #facc15; }
.sync-state.offline .sync-dot { background: #94a3b8; box-shadow: 0 0 0 2px rgba(148,163,184,.35); }
.sync-state.guest .sync-dot { background: #a78bfa; }
.sync-state.failed .sync-dot { background: #ef4444; }
.warning-banner { background: #fef3c7; color: #78350f; padding: .55rem 1.5rem; font-size: .9rem; border-bottom: 1px solid #fcd34d; }
.warning-banner a { color: #92400e; font-weight: 700; }

/* ---------- ładowanie aplikacji ---------- */
.loading { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem; color: var(--text2); }
.loading-logo { font-size: 3rem; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.12); opacity: .7; } }
@media (prefers-reduced-motion: reduce) { .loading-logo { animation: none; } }

/* ---------- stopka: wersja i kompilacja ---------- */
.version-footer {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    display: flex; flex-wrap: nowrap; justify-content: center; gap: .9rem; overflow: hidden; white-space: nowrap;
    height: 1.5rem; align-items: center; padding: 0 1rem;
    font-size: .72rem; color: var(--text3); font-variant-numeric: tabular-nums;
    background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(3px);
    border-top: 1px solid var(--border);
}
.content { padding-bottom: calc(1.5rem + 1.5rem); }
.version-footer .other-version { color: var(--warning); font-weight: 600; cursor: help; }
.version-footer.on-bg { color: rgba(255,255,255,.6); background: transparent; backdrop-filter: none; border-top: none; }
.version-footer.on-bg .other-version { color: #fcd34d; }
.version-footer .about-link { all: unset; cursor: pointer; color: inherit; font: inherit; padding: 0 .25rem; border-radius: 4px; }
.version-footer .about-link:hover { color: var(--accent); text-decoration: underline; }
.version-footer.on-bg .about-link:hover { color: #fff; }
.version-footer .about-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.about { width: min(520px, 94vw); color: var(--text); }
.about h2 { margin: 0; }
.about-header { display: flex; gap: .8rem; align-items: center; margin-bottom: .6rem; }
.about-logo { font-size: 2.4rem; }
.about-data { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 1rem 0 0; font-size: .9rem; }
.about-data dt { color: var(--text2); }
.about-data dd { margin: 0; overflow-wrap: anywhere; }

/* ---------- kalendarz ---------- */
.month-nav { display: flex; align-items: center; gap: .25rem; }
.month-nav .month-title { font-size: 1.5rem; font-weight: 700; min-width: 13rem; text-align: center; text-transform: capitalize; }
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.month-grid .dow { font-size: .75rem; color: var(--text2); font-weight: 600; text-align: center; padding: .2rem 0; }
.day {
    min-height: 6.2rem; border: 1px solid var(--border); border-radius: 8px; padding: .3rem .4rem;
    background: var(--card); cursor: pointer; display: flex; flex-direction: column; gap: .1rem;
    font-size: .76rem; font-variant-numeric: tabular-nums; position: relative; overflow: hidden;
}
.day:hover { border-color: var(--border-hover); }
.day.other { opacity: .45; }
.day.future { background: var(--hover); }
.day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.day.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--card)); }
.day.weekend .day-number { color: var(--error); }
.day .day-number { font-weight: 700; font-size: .9rem; display: flex; justify-content: space-between; align-items: center; }
.day .day-value { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day .day-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day .exit-mark { background: var(--exit-bg); color: var(--warning); border-radius: 4px; padding: 0 .3rem; font-size: .7rem; font-weight: 700; }
.day.up { border-left: 3px solid var(--profit); }
.day.down { border-left: 3px solid var(--loss); }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .8rem; color: var(--text2); margin-top: .6rem; }

.detail-list { list-style: none; margin: 0; padding: 0; }
.detail-list li { padding: .45rem 0; border-bottom: 1px dashed var(--border); display: grid; grid-template-columns: 1fr auto; gap: .1rem .6rem; font-size: .88rem; }
.detail-list li .sub { grid-column: 1 / -1; font-size: .78rem; color: var(--text2); }

/* ---------- wykresy ---------- */
.chart { margin: 0; }
.chart figcaption { display: flex; flex-direction: column; gap: .1rem; margin-bottom: .5rem; }
.chart-title { font-weight: 600; font-size: 1rem; color: var(--text); }
.chart-subtitle { font-size: .8rem; color: var(--text2); }
.chart-legend { list-style: none; margin: 0 0 .4rem; padding: 0; display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: .8rem; color: var(--text2); }
.chart-legend li { display: inline-flex; align-items: center; gap: .35rem; }
.chart-swatch { width: .9rem; height: 3px; border-radius: 2px; display: inline-block; flex: none; }
.chart-area { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-grid { stroke: var(--chart-grid); stroke-width: 1; }
.chart-axis { stroke: var(--chart-axis); stroke-width: 1; }
.chart-label { fill: var(--chart-label); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.chart-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-fill { opacity: .12; }
.chart-cursor { stroke: var(--border-hover); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-point { stroke: var(--card); stroke-width: 2; }
.chart-tooltip {
    position: absolute; top: 0; transform: translateX(12px); pointer-events: none; z-index: 5;
    background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: .45rem .6rem;
    box-shadow: 0 8px 20px rgba(0,0,0,.18); font-size: .8rem; min-width: 10rem; color: var(--text);
}
.chart-tooltip.left { transform: translateX(calc(-100% - 12px)); }
.chart-tooltip-title { font-weight: 700; margin-bottom: .25rem; }
.chart-tooltip-row { display: grid; grid-template-columns: .9rem 1fr auto; align-items: center; gap: .4rem; padding: .08rem 0; color: var(--text2); }
.chart-tooltip-row b { color: var(--text); font-variant-numeric: tabular-nums; }
.stats { display: flex; gap: 1.5rem; flex-wrap: wrap; font-size: .85rem; color: var(--text2); margin-top: .6rem; }
.stats b { color: var(--text); font-variant-numeric: tabular-nums; }

.donut-wrap { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.donut { width: 170px; height: 170px; flex: none; }
.donut-legend { list-style: none; margin: 0; padding: 0; font-size: .82rem; display: flex; flex-direction: column; gap: .2rem; min-width: 12rem; flex: 1; }
.donut-legend li { display: grid; grid-template-columns: .8rem 1fr auto; gap: .45rem; align-items: center; }

/* ---------- widok mobilny ---------- */
@media (max-width: 820px) {
    .topbar { flex-wrap: wrap; gap: .4rem .75rem; padding: .5rem .75rem; }
    .topbar nav { order: 3; width: 100%; gap: .15rem; }
    .topbar nav a, .dropdown-button { padding: .3rem .55rem; font-size: .92rem; }
    .user { gap: .5rem; }
    .user .user-name { display: none; }
    button.logout { padding: .2rem .55rem; }
    .sync-state .sync-text { display: none; }
    .sync-state { padding: .35rem; }
    .warning-banner { padding: .5rem .75rem; }

    .content { padding: .75rem .6rem 3rem; }
    h1 { font-size: 1.25rem; }
    .card { padding: .75rem .8rem; }
    .form-grid { grid-template-columns: 1fr; }
    .dialog { padding: 1rem; }
    .toast { left: .75rem; right: .75rem; bottom: 2rem; max-width: none; }
    .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tile .value { font-size: 1.1rem; }
    .day { min-height: 3.6rem; font-size: .68rem; padding: .2rem .25rem; }
    .day .day-line { display: none; }
    .month-nav .month-title { min-width: 0; font-size: 1.2rem; }
    .chart-tooltip { min-width: 8rem; font-size: .75rem; }
}

@media print {
    .topbar, .toolbar, button, .overlay, .warning-banner, .toast, .version-footer, #blazor-error-ui { display: none !important; }
}
