/* Wartości przeniesione z wersji desktopowej (MainWindow.xaml) */
:root {
    --bg: #F1F5F9;
    --card: #FFFFFF;
    --border: #E2E8F0;
    --text: #1E293B;
    --text-strong: #0F172A;
    --label: #475569;
    --muted: #64748B;
    --faint: #94A3B8;
    --primary: #0EA5E9;
    --dark: #111827;
    --good: #059669;
    --bad: #DC2626;
    --radius: 10px;
    --radius-sm: 8px;
    --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: Consolas, "Cascadia Mono", "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.35;
}

.page { max-width: 1400px; margin: 0 auto; padding: 16px; }

h1 { font-size: 20px; margin: 0 0 8px; }
h2 { font-size: 16px; margin: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 12px 0; }
code { font-family: var(--mono); font-size: 0.95em; background: #F8FAFC; padding: 0 3px; border-radius: 3px; }

.muted { color: var(--muted); }
.small { font-size: 11px; }
.mono { font-family: var(--mono); }
.grow { flex: 1 1 auto; min-width: 0; }
.hint { font-size: 11px; color: var(--faint); margin: 6px 0 0; }
.row-gap { display: flex; gap: 6px; align-items: center; }

/* Karta */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    box-shadow: 0 1px 8px rgba(15, 23, 42, 0.06);
}
.card.narrow { max-width: 560px; margin: 40px auto; }
.card-title { font-size: 13px; font-weight: 700; margin: 0 0 10px; }

/* Pola i przyciski */
.label { display: block; font-size: 11px; font-weight: 500; color: var(--label); margin: 0 0 2px; }
.input {
    width: 100%;
    padding: 6px 8px;
    font: inherit;
    color: var(--text);
    background: #fff;
    border: 1px solid #CBD5E1;
    border-radius: 4px;
}
.input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
.input.mono { font-family: var(--mono); font-size: 13px; }
.input-green { background: #F0FDF4; border-color: #86EFAC; }
.input-orange { background: #FFF7ED; border-color: #FDBA74; }
.field-error { color: var(--bad); font-size: 12px; margin-top: 6px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    padding: 6px 12px;
    font: inherit;
    color: var(--text);
    background: #F8FAFC;
    border: 1px solid #CBD5E1;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { background: #EEF2F7; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn-primary:hover { background: #0284C7; }
.btn-dark { background: var(--dark); border-color: var(--dark); color: #fff; }
.btn-dark:hover { background: #1F2937; }
.btn-light { background: #F8FAFC; }
.btn-soft-blue { background: #EFF6FF; border-color: #93C5FD; }
.btn-icon { width: 36px; padding: 6px 0; font-size: 16px; line-height: 1; }
.btn-block { width: 100%; margin-top: 14px; }

/* Nagłówek */
.header { display: flex; align-items: flex-end; gap: 24px; margin-bottom: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 12px; align-self: center; }
.brand-icon {
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--primary); display: grid; place-items: center; font-size: 22px;
}
.brand-name { font-size: 16px; font-weight: 700; }
.brand-sub { font-size: 11px; color: var(--muted); }
.profile-fields { display: flex; gap: 8px; flex: 1 1 520px; flex-wrap: wrap; }
.profile-fields .field { flex: 1 1 140px; }
.profile-fields .field-num { flex: 0 1 110px; }
.header-actions { display: flex; gap: 6px; }
.header-actions form { margin: 0; }

/* Komunikat */
.toast {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 8px 12px; margin-bottom: 12px; border-radius: var(--radius-sm); border: 1px solid;
}
.toast-ok { background: #ECFDF5; border-color: #A7F3D0; color: #065F46; }
.toast-error { background: #FEF2F2; border-color: #FECACA; color: #991B1B; }
.toast-close { background: none; border: 0; cursor: pointer; color: inherit; font-size: 14px; }

/* Układ główny */
.main-grid { display: grid; grid-template-columns: 2.1fr 0.9fr; gap: 12px; align-items: start; }
.side { display: flex; flex-direction: column; gap: 12px; }

.month-nav { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; }
.month-label { font-size: 18px; font-weight: 700; text-align: center; }
.formula-bar {
    display: flex; align-items: center; gap: 8px;
    background: #F8FAFC; border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 8px; margin: 10px 0;
}
.formula-label { font-size: 11px; font-weight: 600; white-space: nowrap; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.tab {
    padding: 6px 14px; font: inherit; font-size: 12px; font-weight: 600;
    background: none; border: 1px solid transparent; border-bottom: 0;
    border-radius: 6px 6px 0 0; cursor: pointer; color: var(--muted); margin-bottom: -1px;
}
.tab.active { background: #fff; border-color: var(--border); color: var(--text); }

/* Kalendarz */
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); height: 28px; align-items: center; }
.cal-head span { text-align: center; font-size: 11px; font-weight: 600; color: var(--muted); }
.cal-head span.we { color: #E11D48; }
.calendar {
    display: grid; grid-template-columns: repeat(7, 1fr);
    border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: #fff;
}
.day {
    min-height: 84px; padding: 4px 5px 3px;
    display: flex; flex-direction: column; align-items: center; gap: 1px;
    background: #fff; border: 0; box-shadow: inset 0 0 0 0.5px var(--border);
    font: inherit; color: inherit; cursor: pointer; text-align: center;
}
.day:hover:not(:disabled) { filter: brightness(0.97); }
.day:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.day:disabled { cursor: default; }
.day.out { background: #F8FAFC; }
.day.weekend { background: #F1F5F9; }
.day.has-plan { background: #F0FDF4; }
.day.has-plan.weekend { background: #DCFCE7; }
.day.has-actual { background: #FEF2F2; }
.day.has-actual.weekend { background: #FEE2E2; }
.day.is-today { background: #DBEAFE; }
.day.selected { box-shadow: inset 0 0 0 2px var(--primary); }
.day-top { width: 100%; display: flex; justify-content: space-between; align-items: flex-start; }
.day-num { font-size: 12px; font-weight: 600; color: var(--text-strong); }
.day.out .day-num { color: #CBD5E1; }
.day-num.today { color: #1D4ED8; font-weight: 700; }
.we-dot { width: 6px; height: 6px; border-radius: 3px; background: #FECACA; }
.day-weight { font-size: 13px; font-weight: 700; margin-top: 2px; position: relative; }
.day-weight.actual { color: #BE123C; }
.day-weight.planned { color: #16652D; }
.fx { position: absolute; left: 100%; bottom: 0; margin-left: 4px; font-size: 8px; font-weight: 400; color: var(--faint); }
.day-sub { font-size: 10px; color: #718096; }
.day-delta { font-size: 10px; font-weight: 600; }
.day-delta.zero { color: #718096; }
.day-delta.up { color: #BE123C; }
.day-delta.down { color: #0E7A4A; }
.day-empty { font-size: 11px; color: #CBD5E1; margin-top: 6px; }

/* Wykres */
.legend-line { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; font-size: 11px; color: var(--label); margin: 2px 0 6px; }
.legend-line .hypo { color: #92400E; }
.swatch { display: inline-block; width: 18px; height: 3px; border-radius: 1px; vertical-align: middle; margin-right: 6px; }
.chart-box { border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; padding: 6px; }
.chart { width: 100%; height: auto; display: block; }
.axis-label { font-size: 10px; fill: var(--muted); font-family: var(--font); }
.axis-label.italic { font-style: italic; }
.chart-empty { min-height: 300px; display: grid; place-items: center; text-align: center; color: var(--faint); font-size: 12px; }
.chart-info { font-size: 10px; color: var(--faint); text-align: center; margin-top: 6px; }

/* Panel boczny */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.stat { font-size: 18px; font-weight: 700; color: var(--text-strong); }
.stat-sm { font-size: 15px; font-weight: 700; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.days-box { background: #EFF6FF; border: 1px solid #BFDBFE; border-radius: var(--radius-sm); padding: 10px; margin-top: 12px; }
.days-num { font-size: 22px; font-weight: 700; color: #1D4ED8; }
.days-unit { color: #3B82F6; }
.progress { height: 6px; background: #DBEAFE; border-radius: 3px; margin: 6px 0 4px; overflow: hidden; }
.progress-fill { height: 100%; background: #3B82F6; }
.legend-box { background: #FEFCE8; border: 1px solid #FDE68A; border-radius: var(--radius-sm); padding: 8px; margin-top: 10px; }
.legend-title { font-size: 11px; font-weight: 600; color: #92400E; }
.legend-items { display: flex; gap: 12px; font-size: 10px; margin-top: 4px; }
.sq { display: inline-block; width: 12px; height: 12px; border-radius: 2px; border: 1px solid; vertical-align: middle; margin-right: 4px; }
.sq-today { background: #DBEAFE; border-color: #93C5FD; }
.sq-plan { background: #F0FDF4; border-color: #86EFAC; }
.sq-actual { background: #FEF2F2; border-color: #FECACA; }
.selected-date { margin: -6px 0 8px; }
.side .input { margin-bottom: 6px; }
.side .row-gap .input { margin-bottom: 0; }
.actions { margin-top: 14px; }
.actions .btn { min-width: 90px; }

.footer { font-size: 10px; color: var(--faint); text-align: center; margin-top: 12px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* Okna dialogowe */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.35); z-index: 10; }
.modal {
    position: fixed; z-index: 11; left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: min(460px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto;
    background: #fff; border-radius: var(--radius); padding: 16px; box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
}
.modal .input { margin-bottom: 8px; }
.modal-wide { width: min(900px, calc(100vw - 24px)); }
.modal-head { margin-bottom: 10px; }
.modal-head p { margin: 4px 0 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.modal-actions .btn { min-width: 90px; }

/* Kreator formuł */
.validation { font-size: 11px; margin: 4px 0 0 2px; }
.validation.ok { color: var(--good); }
.validation.err { color: var(--bad); }
.preview-line { background: #F8FAFC; border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; margin: 8px 0; font-size: 13px; }
.fb-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fb-group { margin-bottom: 10px; }
.fb-head { font-weight: 600; font-size: 12px; color: #374151; margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
    min-width: 40px; padding: 4px 8px; font-family: var(--mono); font-size: 12px;
    background: #F9FAFB; border: 1px solid #D1D5DB; border-radius: 4px; cursor: pointer;
}
.chip:hover { background: #F3F4F6; }
.chip-blue { background: #EFF6FF; border-color: #93C5FD; }
.chip-amber { background: #FEF3C7; border-color: #FCD34D; }
.fb-box { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px; margin-bottom: 10px; }
.examples { list-style: none; margin: 4px 0 0; padding: 0; max-height: 220px; overflow: auto; }
.example {
    display: block; width: 100%; text-align: left; padding: 4px 6px; font-size: 12px;
    background: none; border: 0; border-radius: 4px; cursor: pointer; color: var(--text);
}
.example:hover { background: #EFF6FF; }
.table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 4px; }
.table th, .table td { padding: 3px 6px; border-bottom: 1px solid #F1F5F9; text-align: left; }
.table th { color: var(--muted); font-weight: 600; }
.table .num { text-align: right; }

/* Logowanie */
.login-wrap { min-height: 80vh; display: grid; place-items: center; }
.login-card { width: min(360px, 100%); padding: 24px; }
.login-card .brand { margin-bottom: 18px; }
.alert { padding: 10px; border-radius: var(--radius-sm); font-size: 12px; }
.alert-error { background: #FEF2F2; border: 1px solid #FECACA; color: #991B1B; }

#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; width: 100%; z-index: 1000;
    background: #FEF3C7; padding: 8px 16px; box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.15);
}
#blazor-error-ui .reload { margin-left: 8px; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 12px; top: 8px; }

/* Wąskie ekrany (telefon) */
@media (max-width: 1000px) {
    .main-grid { grid-template-columns: 1fr; }
    .fb-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .page { padding: 8px; }
    .month-nav { grid-template-columns: auto 1fr; }
    .month-nav > .btn-light { grid-column: 1 / -1; }
    .formula-bar { flex-wrap: wrap; }
    .formula-bar .btn { width: 100%; }
    .day { min-height: 64px; padding: 2px; }
    .day-weight { font-size: 12px; }
    .day-sub, .day-delta { font-size: 9px; }
    .fx { display: none; }
    .header-actions { width: 100%; flex-wrap: wrap; }
}
