/* ==========================================================================
   DevFlow CRM — system wyglądu (wariant „Panel boczny”)
   Kolory to zmienne CSS; motyw przełącza atrybut data-theme na <html>,
   zwinięty panel boczny — atrybut data-sidebar="collapsed".
   Style komponentów są w warstwie "components", więc klasy Tailwinda
   (warstwa "utilities") zawsze mogą je nadpisać.
   ========================================================================== */

@layer theme, base, components, utilities;

/* ---------- Tokeny: motyw jasny ---------- */
:root {
    --font-sans: "Manrope", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-display: "Space Grotesk", "Manrope", ui-sans-serif, system-ui, sans-serif;

    --bg: #F4F4F7;
    --surface: #FFFFFF;
    --surface-2: #FAFAFC;
    --surface-3: #F1F1F6;
    --seg: #EFEFF4;
    --field: #FFFFFF;
    --raised: #FFFFFF;
    --line: #EEEEF3;
    --border: #E6E6EE;
    --line-strong: #DADAE4;
    --ink: #14131F;
    --ink-2: #4A4960;
    --ink-3: #6A6982;

    --btn: #14131F;
    --btn-hover: #2B2A3E;
    --btn-ink: #FFFFFF;
    --accent: #6A4DF4;
    --accent-soft: #F0ECFF;
    --accent-text: #5130D9;
    --accent-ring: rgba(106, 77, 244, .18);
    --lime: #C8F169;
    --lime-ink: #14131F;

    --pos: #0B7A54;
    --pos-ink: #FFFFFF;
    --pos-soft: #E2F5EC;
    --neg: #C4283E;
    --neg-soft: #FCEBEE;
    --warn: #955706;
    --warn-soft: #FFF1D8;

    --tile: #14131F;
    --tile-ink: #FFFFFF;
    --tile-ink-2: #ADABC6;
    --tile-track: rgba(255, 255, 255, .12);

    --side: #14131F;
    --side-ink: #F4F3FA;
    --side-ink-2: #A9A7C1;
    --side-hover: rgba(255, 255, 255, .06);
    --side-active: rgba(255, 255, 255, .10);

    --shadow-card: 0 1px 2px rgba(20, 19, 31, .04);
    --shadow-raised: 0 1px 3px rgba(20, 19, 31, .14);
    --shadow-pop: 0 20px 44px -14px rgba(20, 19, 31, .28), 0 2px 6px rgba(20, 19, 31, .06);
    --backdrop: rgba(12, 11, 20, .45);

    --side-w: 248px;
    color-scheme: light;
}

/* ---------- Tokeny: motyw ciemny ---------- */
:root[data-theme="dark"] {
    --bg: #101019;
    --surface: #171724;
    --surface-2: #1B1B29;
    --surface-3: #232334;
    --seg: #1F1F2E;
    --field: #1B1B29;
    --raised: #2C2C42;
    --line: #242434;
    --border: #262637;
    --line-strong: #30304A;
    --ink: #EFEFF7;
    --ink-2: #B8B7CE;
    --ink-3: #8E8DA8;

    --btn: #C8F169;
    --btn-hover: #D6F689;
    --btn-ink: #14131F;
    --accent: #9C84FF;
    --accent-soft: rgba(156, 132, 255, .15);
    --accent-text: #CBBEFF;
    --accent-ring: rgba(156, 132, 255, .24);

    --pos: #4AD6A0;
    --pos-ink: #06241A;
    --pos-soft: rgba(74, 214, 160, .13);
    --neg: #FF7D90;
    --neg-soft: rgba(255, 125, 144, .13);
    --warn: #F5BE5B;
    --warn-soft: rgba(245, 190, 91, .13);

    --tile: #201F36;
    --tile-ink: #FFFFFF;
    --tile-ink-2: #B0AECB;
    --tile-track: rgba(255, 255, 255, .10);

    --side: #0A0A11;
    --side-ink: #F4F3FA;
    --side-ink-2: #A19FBA;
    --side-hover: rgba(255, 255, 255, .05);
    --side-active: rgba(255, 255, 255, .09);

    --shadow-card: none;
    --shadow-raised: 0 1px 3px rgba(0, 0, 0, .45);
    --shadow-pop: 0 20px 48px -12px rgba(0, 0, 0, .7), 0 0 0 1px rgba(255, 255, 255, .04);
    --backdrop: rgba(0, 0, 0, .6);
    color-scheme: dark;
}

:root[data-sidebar="collapsed"] { --side-w: 78px; }

@layer components {

    /* ---------- Podstawy ---------- */
    [hidden] { display: none !important; }

    body {
        background: var(--bg);
        color: var(--ink);
        font-family: var(--font-sans);
        font-size: 14px;
        line-height: 1.5;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-rendering: optimizeLegibility;
    }
    ::selection { background: var(--accent-soft); color: var(--ink); }
    :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
    a { color: inherit; }

    .sr-only {
        position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
        overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
    }
    .t-muted { color: var(--ink-3); }
    .t-soft { color: var(--ink-2); }
    .t-pos { color: var(--pos); }
    .t-neg { color: var(--neg); }
    .t-accent { color: var(--accent-text); }
    .tnum { font-variant-numeric: tabular-nums; }
    .print-only { display: none; }

    /* ---------- Układ: panel boczny + treść ---------- */
    .app { display: block; min-height: 100vh; }
    @media (min-width: 900px) { .app { display: flex; } }
    .main { flex: 1; min-width: 0; }
    .shell { max-width: 1240px; margin: 0 auto; padding: 28px 20px 72px; }
    .shell-narrow { max-width: 780px; }
    @media (min-width: 900px) { .shell { padding: 30px 32px 80px; } }

    .brand-mark {
        width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
        display: grid; place-items: center;
        background: var(--lime); color: var(--lime-ink);
        font-family: var(--font-display); font-size: 15px; font-weight: 700;
    }
    .brand-name { font-family: var(--font-display); font-size: 18px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); }

    .sidebar {
        position: fixed; inset: 0 auto 0 0; z-index: 50;
        width: min(300px, 86vw); height: 100vh; height: 100dvh;
        display: flex; flex-direction: column; gap: 22px;
        padding: 18px 14px 16px;
        background: var(--side); color: var(--side-ink);
        overflow-y: auto; overflow-x: hidden;
        transform: translateX(-102%);
        transition: transform .22s ease, width .2s ease;
    }
    :root[data-drawer="open"] .sidebar { transform: none; box-shadow: var(--shadow-pop); }
    .side-backdrop { position: fixed; inset: 0; z-index: 45; background: var(--backdrop); }

    @media (min-width: 900px) {
        .sidebar {
            position: sticky; top: 0; flex-shrink: 0;
            width: var(--side-w); transform: none; box-shadow: none;
        }
        .side-backdrop, .mobilebar { display: none !important; }
    }

    .side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; }
    .side-brand { display: flex; align-items: center; gap: 11px; min-width: 0; padding-left: 4px; text-decoration: none; color: var(--side-ink); }
    .side-brand-text { display: flex; flex-direction: column; line-height: 1.15; white-space: nowrap; }
    .side-brand-text b { font-family: var(--font-display); font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
    .side-brand-text small { font-size: 12px; color: var(--side-ink-2); }

    .side-btn {
        display: inline-grid; place-items: center; flex-shrink: 0;
        width: 36px; height: 36px; padding: 0; border: 0; border-radius: 10px;
        background: transparent; color: var(--side-ink-2); cursor: pointer;
        transition: background-color .15s, color .15s;
    }
    .side-btn:hover { background: var(--side-hover); color: var(--side-ink); }
    .side-btn svg { width: 19px; height: 19px; }
    .side-collapse { display: none; }
    @media (min-width: 900px) {
        .side-collapse { display: inline-grid; }
        .side-close { display: none; }
    }

    .side-nav { display: flex; flex-direction: column; gap: 18px; }
    .side-group { display: flex; flex-direction: column; gap: 2px; }
    .side-group-title { padding: 0 12px 6px; font-size: 12px; font-weight: 700; color: var(--side-ink-2); white-space: nowrap; }
    .side-link {
        display: flex; align-items: center; gap: 12px;
        height: 44px; padding: 0 12px; border-radius: 12px;
        color: var(--side-ink-2); text-decoration: none;
        font-size: 14.5px; font-weight: 600; white-space: nowrap;
        transition: background-color .15s, color .15s;
    }
    .side-link svg { width: 19px; height: 19px; flex-shrink: 0; }
    .side-link:hover { background: var(--side-hover); color: var(--side-ink); }
    .side-link.is-active { background: var(--side-active); color: var(--side-ink); font-weight: 700; }
    .side-link.is-active svg { color: var(--lime); }

    .side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
    .side-theme { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 12px; background: rgba(255, 255, 255, .05); }
    .side-theme button {
        display: flex; align-items: center; justify-content: center; gap: 6px;
        height: 36px; border: 0; border-radius: 9px; background: transparent;
        color: var(--side-ink-2); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
    }
    .side-theme button svg { width: 16px; height: 16px; }
    .side-theme button[aria-pressed="true"] { background: rgba(255, 255, 255, .12); color: var(--side-ink); }
    .side-user { display: flex; align-items: center; gap: 10px; padding: 9px; border-radius: 14px; background: var(--side-active); }
    .side-user .avatar { width: 38px; height: 38px; border-radius: 11px; background: #6A4DF4; color: #FFFFFF; font-size: 15px; }
    .side-user-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; flex: 1; }
    .side-user-text b { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .side-user-text small { font-size: 12px; color: var(--side-ink-2); }

    /* Panel zwinięty: sam pasek ikon, podpisy zostają dla czytników ekranu */
    @media (min-width: 900px) {
        :root[data-sidebar="collapsed"] .sidebar { padding-left: 12px; padding-right: 12px; align-items: stretch; }
        :root[data-sidebar="collapsed"] .side-label {
            position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
            overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
        }
        :root[data-sidebar="collapsed"] .side-head { flex-direction: column; gap: 10px; }
        :root[data-sidebar="collapsed"] .side-brand { padding-left: 0; }
        :root[data-sidebar="collapsed"] .side-collapse svg { transform: scaleX(-1); }
        :root[data-sidebar="collapsed"] .side-link { justify-content: center; padding: 0; }
        :root[data-sidebar="collapsed"] .side-group { padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, .08); }
        :root[data-sidebar="collapsed"] .side-theme { grid-template-columns: 1fr; }
        :root[data-sidebar="collapsed"] .side-user { flex-direction: column; padding: 8px 4px; gap: 6px; }
    }

    .mobilebar {
        position: sticky; top: 0; z-index: 40;
        display: flex; align-items: center; justify-content: space-between; gap: 12px;
        height: 60px; padding: 0 12px;
        background: var(--side); color: var(--side-ink);
    }
    .mobilebar .side-brand { padding-left: 0; }
    .mobilebar .brand-mark { width: 34px; height: 34px; border-radius: 10px; font-size: 13px; }
    .mobilebar .side-brand-text b { font-size: 17px; }

    .theme-icon-dark { display: none; }
    :root[data-theme="dark"] .theme-icon-light { display: none; }
    :root[data-theme="dark"] .theme-icon-dark { display: inline; }

    /* ---------- Nagłówek strony ---------- */
    .page-head {
        display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
        gap: 16px 20px; margin-bottom: 24px;
    }
    .page-kicker { display: block; margin-bottom: 4px; font-size: 14px; font-weight: 600; color: var(--ink-3); }
    .page-title {
        font-family: var(--font-display);
        font-size: clamp(28px, 3.2vw, 38px); line-height: 1.05;
        font-weight: 700; letter-spacing: -0.035em; color: var(--ink);
    }
    .page-sub { margin-top: 8px; max-width: 64ch; font-size: 14.5px; color: var(--ink-3); }
    .page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
    .back-link {
        display: inline-flex; align-items: center; gap: 6px; margin-bottom: 14px;
        font-size: 13.5px; font-weight: 600; color: var(--ink-3); text-decoration: none;
    }
    .back-link svg { width: 15px; height: 15px; }
    .back-link:hover { color: var(--ink); }

    /* ---------- Karty ---------- */
    .panel {
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: 20px;
        box-shadow: var(--shadow-card);
        padding: 20px;
    }
    @media (min-width: 640px) { .panel { padding: 22px 24px; } }
    .panel-head {
        display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
        gap: 10px 14px; margin-bottom: 16px;
    }
    .panel-title {
        display: flex; align-items: center; gap: 10px;
        font-family: var(--font-display); font-size: 20px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink);
    }
    .panel-note { font-size: 13px; color: var(--ink-3); }
    .count {
        display: inline-grid; place-items: center;
        min-width: 26px; height: 26px; padding: 0 8px; border-radius: 8px;
        background: var(--surface-3); color: var(--ink-2);
        font-family: var(--font-sans); font-size: 12.5px; font-weight: 800; letter-spacing: 0; font-variant-numeric: tabular-nums;
    }

    /* Ciemny kafel (dzień, prywatne kwoty) */
    .tile-dark { background: var(--tile); color: var(--tile-ink); border-color: transparent; }
    .tile-dark .panel-note, .tile-dark .metric-label, .tile-dark .metric-foot { color: var(--tile-ink-2); }

    /* ---------- Formularze ---------- */
    .form-stack { display: grid; gap: 16px; }
    .field { display: grid; gap: 7px; min-width: 0; align-content: start; }
    .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
    .label {
        display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
        font-size: 13px; font-weight: 700; color: var(--ink-2);
    }
    .label-hint { font-size: 12.5px; font-weight: 500; color: var(--ink-3); }
    .help { font-size: 12.5px; line-height: 1.45; color: var(--ink-3); }
    .help.t-neg { color: var(--neg); }

    .input {
        width: 100%; height: 46px; padding: 0 13px;
        border: 1px solid var(--line-strong); border-radius: 12px;
        background-color: var(--field); color: var(--ink);
        font: inherit; font-size: 15px;
        transition: border-color .15s, box-shadow .15s;
    }
    .input::placeholder { color: var(--ink-3); opacity: 1; }
    .input:hover { border-color: color-mix(in srgb, var(--line-strong) 50%, var(--ink-3)); }
    .input:focus, .input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
    .input[readonly] { color: var(--ink-3); background-color: var(--surface-3); }
    textarea.input { height: auto; min-height: 84px; padding: 11px 13px; line-height: 1.5; resize: vertical; }
    select.input {
        appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 38px; font-weight: 600;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238E8DA8' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
        background-repeat: no-repeat; background-position: right 13px center;
    }
    .input-sm { height: 40px; padding: 0 11px; border-radius: 10px; font-size: 14px; }
    select.input-sm { padding-right: 34px; background-position: right 11px center; }
    .input-num { font-variant-numeric: tabular-nums; }
    .checkbox { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }
    .check-line { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; color: var(--ink-2); cursor: pointer; }

    .input-with-btn { position: relative; }
    .input-with-btn .input { padding-right: 46px; }
    .input-with-btn .icon-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 38px; height: 38px; border: 0; }

    /* ---------- Przyciski ---------- */
    .btn {
        display: inline-flex; align-items: center; justify-content: center; gap: 8px;
        height: 44px; padding: 0 16px;
        border: 1px solid transparent; border-radius: 12px;
        font: inherit; font-size: 14px; font-weight: 700; line-height: 1;
        white-space: nowrap; text-decoration: none; cursor: pointer; user-select: none;
        transition: background-color .15s, border-color .15s, color .15s, opacity .15s;
    }
    .btn svg { width: 17px; height: 17px; flex-shrink: 0; }
    .btn:disabled { opacity: .55; cursor: default; }
    .btn-primary { background: var(--btn); color: var(--btn-ink); }
    .btn-primary:hover { background: var(--btn-hover); }
    .btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
    .btn-secondary:hover { background: var(--surface-3); }
    .btn-ghost { background: transparent; color: var(--ink-2); }
    .btn-ghost:hover { background: var(--surface-3); color: var(--ink); }
    .btn-danger { background: transparent; color: var(--neg); }
    .btn-danger:hover { background: var(--neg-soft); }
    .btn-success { background: var(--pos); color: var(--pos-ink); }
    .btn-success:hover { filter: brightness(1.08); }
    .btn-sm { height: 38px; padding: 0 13px; gap: 7px; border-radius: 11px; font-size: 13.5px; }
    .btn-sm svg { width: 16px; height: 16px; }
    .btn-lg { height: 52px; border-radius: 13px; font-size: 15.5px; }
    .btn-block { width: 100%; }

    .icon-btn {
        display: inline-grid; place-items: center; flex-shrink: 0;
        width: 38px; height: 38px; padding: 0;
        border: 1px solid var(--border); border-radius: 11px;
        background: transparent; color: var(--ink-3); cursor: pointer;
        transition: background-color .15s, color .15s, border-color .15s;
    }
    .icon-btn svg { width: 18px; height: 18px; }
    .icon-btn:hover { background: var(--surface-3); color: var(--ink); }
    .icon-btn-sm { width: 34px; height: 34px; border-radius: 10px; }
    .icon-btn-sm svg { width: 16px; height: 16px; }
    .icon-btn.is-danger:hover { background: var(--neg-soft); border-color: transparent; color: var(--neg); }
    .icon-btn-plain { border-color: transparent; }

    /* ---------- Przełącznik segmentowy (radio) ---------- */
    .segmented {
        display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px;
        padding: 4px; border-radius: 13px; background: var(--seg);
    }
    .segmented label { position: relative; cursor: pointer; }
    .segmented input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
    .segmented span {
        display: flex; align-items: center; justify-content: center; gap: 7px;
        height: 40px; padding: 0 12px; border-radius: 10px;
        font-size: 14px; font-weight: 600; color: var(--ink-3); white-space: nowrap;
        transition: background-color .15s, color .15s, box-shadow .15s;
    }
    .segmented span svg { width: 16px; height: 16px; }
    .segmented label:hover span { color: var(--ink); }
    .segmented input:checked + span { background: var(--raised); color: var(--ink); font-weight: 700; box-shadow: var(--shadow-raised); }
    .segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
    .segmented-sm { display: inline-grid; padding: 3px; border-radius: 11px; }
    .segmented-sm span { height: 34px; padding: 0 12px; border-radius: 8px; font-size: 13px; }
    .segmented-sm input:checked + span { background: var(--btn); color: var(--btn-ink); box-shadow: none; }

    /* ---------- Zakładki ---------- */
    .tablist { display: flex; gap: 24px; margin: -8px 0 18px; border-bottom: 1px solid var(--line); }
    .tab {
        position: relative; height: 52px; padding: 0; border: 0; background: transparent;
        font-family: var(--font-display); font-size: 17px; font-weight: 600; color: var(--ink-3); cursor: pointer;
    }
    .tab:hover { color: var(--ink-2); }
    .tab[aria-selected="true"] { color: var(--ink); font-weight: 700; }
    .tab[aria-selected="true"]::after {
        content: ""; position: absolute; left: 0; right: 0; bottom: -1px;
        height: 2.5px; border-radius: 2px; background: var(--ink);
    }

    /* ---------- Chipy ---------- */
    .chips { display: flex; flex-wrap: wrap; gap: 7px; }
    .chip {
        display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px;
        border: 1px solid var(--line-strong); border-radius: 999px;
        background: transparent; color: var(--ink-2);
        font: inherit; font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums;
        text-decoration: none; white-space: nowrap; cursor: pointer;
        transition: background-color .15s, border-color .15s, color .15s;
    }
    .chip:hover { border-color: var(--ink-3); color: var(--ink); }
    .chip.is-on { background: var(--btn); border-color: var(--btn); color: var(--btn-ink); }

    /* ---------- Znaczniki ---------- */
    .tags { display: flex; flex-wrap: wrap; gap: 6px; }
    .tag {
        display: inline-flex; align-items: center; max-width: 100%;
        min-height: 26px; padding: 3px 9px; border-radius: 7px;
        background: var(--surface-3); color: var(--ink-2);
        font-size: 12.5px; font-weight: 600; line-height: 1.35;
    }
    .badge {
        display: inline-flex; align-items: center; gap: 6px;
        height: 28px; padding: 0 10px; border-radius: 8px;
        background: var(--surface-3); color: var(--ink-2);
        font-size: 12.5px; font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums;
    }
    .badge svg { width: 14px; height: 14px; }
    .badge-neg { background: var(--neg-soft); color: var(--neg); }
    .badge-warn { background: var(--warn-soft); color: var(--warn); }
    .badge-pos { background: var(--pos-soft); color: var(--pos); }
    .badge-accent { background: var(--accent-soft); color: var(--accent-text); }

    /* ---------- Komunikaty ---------- */
    .alert {
        display: flex; align-items: center; gap: 10px;
        margin-bottom: 20px; padding: 10px 10px 10px 14px;
        border: 1px solid transparent; border-radius: 14px;
        font-size: 14px; font-weight: 600;
    }
    .alert > svg { width: 18px; height: 18px; flex-shrink: 0; }
    .alert-ok { background: var(--pos-soft); color: var(--pos); border-color: color-mix(in srgb, var(--pos) 22%, transparent); }
    .alert-err { background: var(--neg-soft); color: var(--neg); border-color: color-mix(in srgb, var(--neg) 22%, transparent); }
    .alert-close {
        margin-left: auto; display: inline-grid; place-items: center;
        width: 30px; height: 30px; border: 0; border-radius: 8px;
        background: transparent; color: inherit; opacity: .7; cursor: pointer;
    }
    .alert-close:hover { opacity: 1; }
    .alert-close svg { width: 15px; height: 15px; }

    /* ---------- Kafelki (bento) ---------- */
    .bento { display: grid; gap: 16px; margin-bottom: 22px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .bento > * { min-width: 0; }
    .bento-wide { grid-column: 1 / -1; }
    .stat-num {
        display: block; font-family: var(--font-display); font-weight: 700;
        font-size: 40px; line-height: 1; letter-spacing: -0.03em; white-space: nowrap;
        font-variant-numeric: tabular-nums;
    }
    .stat-label { display: block; font-size: 13.5px; font-weight: 700; color: var(--ink-3); }
    .stat-foot { display: block; font-size: 12.5px; color: var(--ink-3); }
    .stat-icon {
        width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
        display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text);
    }
    .stat-icon svg { width: 19px; height: 19px; }
    .stat-tile { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
    .stat-tile > div { display: grid; gap: 6px; }
    .stat-alert { background: var(--neg-soft); border-color: transparent; }
    .stat-alert .stat-label, .stat-alert .stat-num { color: var(--neg); }
    .stat-alert .stat-icon { background: var(--surface); color: var(--neg); }

    /* Pierścień „dziś z 8 godzin” */
    .day-ring-tile { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
    .day-ring-tile .stat-label { align-self: flex-start; color: var(--tile-ink-2); }
    .day-ring { position: relative; width: 150px; height: 150px; }
    .day-ring svg { display: block; width: 150px; height: 150px; transform: rotate(-90deg); }
    .day-ring circle { fill: none; stroke-width: 13; }
    .day-ring .day-ring-track { stroke: var(--tile-track); }
    .day-ring .day-ring-value { stroke: var(--lime); stroke-linecap: round; }
    .day-ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
    .day-ring-center b { font-family: var(--font-display); font-size: 24px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
    .day-ring-center small { font-size: 12.5px; color: var(--tile-ink-2); }
    .day-ring-foot { font-size: 13px; color: var(--tile-ink-2); }

    /* Oś dnia w kolorach klientów */
    .dayline {
        display: flex; gap: 4px; height: 46px; padding: 5px;
        border-radius: 14px; background: var(--seg); overflow: hidden;
    }
    .dayline-seg { flex: none; height: 100%; min-width: 6px; border-radius: 10px; }
    .dayline-scale {
        display: flex; justify-content: space-between; margin-top: 8px; padding: 0 4px;
        font-size: 12px; font-weight: 600; color: var(--ink-3); font-variant-numeric: tabular-nums;
    }
    .dayline-legend { display: grid; gap: 7px; margin: 14px 0 0; padding: 0; list-style: none; font-size: 13.5px; }
    .dayline-legend li { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--ink-2); }
    .dayline-legend span.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .dayline-legend b { font-weight: 800; color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
    .dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
    .daystrip-empty { margin-top: 12px; font-size: 13.5px; color: var(--ink-3); }

    /* Kafelek firmy z inicjałami (kolor klienta w --c) */
    .ctile {
        width: 44px; height: 44px; border-radius: 13px; flex-shrink: 0;
        display: grid; place-items: center;
        background: color-mix(in srgb, var(--c, #6A4DF4) 15%, transparent);
        color: color-mix(in srgb, var(--c, #6A4DF4) 70%, var(--ink));
        font-family: var(--font-display); font-size: 14px; font-weight: 700; letter-spacing: .01em;
    }
    .ctile-sm { width: 36px; height: 36px; border-radius: 11px; font-size: 12.5px; }

    /* ---------- Listy wpisów ---------- */
    .rows { display: grid; margin: 0; padding: 0; list-style: none; }
    .row { display: flex; justify-content: space-between; gap: 14px; padding: 16px 0; border-top: 1px solid var(--line); }
    .row:first-child { padding-top: 4px; border-top: 0; }
    .row:last-child { padding-bottom: 4px; }
    .row-main { flex: 1; min-width: 0; }
    .row-title { font-size: 15.5px; font-weight: 800; letter-spacing: -0.01em; color: var(--ink); overflow-wrap: anywhere; }
    .row-desc { margin-top: 7px; font-size: 14px; color: var(--ink-2); white-space: pre-line; overflow-wrap: anywhere; }
    .row-meta { margin-top: 7px; font-size: 13px; color: var(--ink-3); }
    .row-meta b { font-weight: 700; color: var(--ink-2); }
    .row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
    .dur {
        font-family: var(--font-display); font-size: 19px; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em;
        font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink);
    }
    .actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 6px; }
    .actions form { display: contents; }

    /* Zadania w toku */
    .task-list { display: grid; }
    .task { display: grid; gap: 12px; padding: 18px 0; border-top: 1px solid var(--line); }
    .task:first-child { padding-top: 4px; border-top: 0; }
    .task:last-child { padding-bottom: 6px; }
    .task-grid { display: flex; gap: 14px; align-items: flex-start; }
    .task-body { flex: 1; min-width: 0; display: grid; gap: 8px; }
    .task-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 12px; }
    .task-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-top: 2px; }
    .task-foot .row-meta { margin-top: 0; }
    .task-body .row-desc { margin-top: 0; }
    .logtime { display: grid; gap: 12px; margin-left: 58px; padding: 14px; border-radius: 15px; background: var(--seg); }
    .logtime-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
    .logtime-grid .field:last-child { grid-column: 1 / -1; }
    @media (min-width: 640px) {
        .logtime-grid { grid-template-columns: 150px 100px 1fr; }
        .logtime-grid .field:last-child { grid-column: auto; }
    }
    @media (max-width: 639px) { .logtime { margin-left: 0; } }
    .logtime .input { background-color: var(--surface); }
    .logtime-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
    .logtime .segmented-sm { background: var(--surface); border: 1px solid var(--border); }

    /* Dzisiejsze wpisy z godziną po lewej */
    .timeline { display: grid; margin: 0; padding: 0; list-style: none; }
    .tl-item { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 14px; align-items: start; padding: 14px 0; border-top: 1px solid var(--line); }
    .tl-item:first-child { padding-top: 4px; border-top: 0; }
    .tl-time { padding-top: 1px; font-family: var(--font-display); font-size: 15px; font-weight: 600; color: var(--ink-3); font-variant-numeric: tabular-nums; }
    .tl-main { display: grid; gap: 7px; min-width: 0; }
    .tl-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 9px; }
    .tl-head .row-title { font-size: 15px; }
    .tl-who { font-size: 13px; color: var(--ink-3); }
    .tl-main .row-desc { margin-top: 0; font-size: 13.5px; }
    .tl-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
    .tl-side .actions { gap: 2px; }

    /* Lista dni pracy z paskiem obecności */
    .daytile {
        width: 52px; height: 52px; border-radius: 14px; background: var(--seg);
        display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1;
    }
    .daytile b { font-family: var(--font-display); font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
    .daytile small { margin-top: 4px; font-size: 11.5px; font-weight: 700; color: var(--ink-3); }
    .daytile.is-weekend { background: var(--accent-soft); }
    .daytile.is-weekend small { color: var(--accent-text); }
    .daybar { display: grid; gap: 6px; min-width: 150px; }
    .daybar-track { position: relative; height: 10px; border-radius: 999px; background: var(--seg); }
    .daybar-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 999px; background: var(--accent); }
    .daybar-fill.is-short { background: var(--ink-3); }
    .daybar-norm { position: absolute; top: -3px; bottom: -3px; width: 2px; border-radius: 2px; background: var(--ink); opacity: .55; }
    .daybar-label { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
    .daybar-label b { color: var(--ink); font-weight: 800; }
    .norm-key { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-3); }
    .norm-key::before { content: ""; width: 2px; height: 14px; border-radius: 2px; background: var(--ink); opacity: .55; }

    /* Karta, która podczas przewijania zostaje na ekranie (duże ekrany) */
    @media (min-width: 1280px) {
        .is-sticky { position: sticky; top: 24px; }
    }

    /* ---------- Rozwijana sekcja ---------- */
    .disclosure > summary {
        display: flex; align-items: center; justify-content: space-between; gap: 10px;
        list-style: none; cursor: pointer;
        font-size: 15px; font-weight: 800; color: var(--ink);
    }
    .disclosure > summary::-webkit-details-marker { display: none; }
    .disclosure > summary > span { display: flex; flex-direction: column; gap: 2px; }
    .disclosure > summary .chev {
        width: 38px; height: 38px; padding: 9px; flex-shrink: 0;
        border: 1px solid var(--border); border-radius: 11px; color: var(--ink-3); transition: transform .15s;
    }
    .disclosure[open] > summary { margin-bottom: 16px; }
    .disclosure[open] > summary .chev { transform: rotate(180deg); }
    .disclosure > summary small { font-size: 12.5px; font-weight: 500; color: var(--ink-3); }
    .panel-divider { margin-top: 4px; padding-top: 16px; border-top: 1px solid var(--line); }

    /* ---------- Metryki (raporty, statystyki, dosprzedaż) ---------- */
    .metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 22px; }
    .metric {
        min-width: 0; padding: 18px 20px 20px; display: grid; gap: 6px; align-content: start;
        border: 1px solid var(--border); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-card);
    }
    .metric-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 22px; font-size: 13.5px; font-weight: 700; color: var(--ink-3); }
    .metric-value {
        font-family: var(--font-display);
        font-size: clamp(24px, 2.4vw, 30px); line-height: 1.1;
        font-weight: 700; letter-spacing: -0.03em;
        font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap;
    }
    .metric-value small { margin-left: 2px; font-family: var(--font-sans); font-size: 15px; font-weight: 600; letter-spacing: 0; color: var(--ink-3); }
    .metric-value.is-pos { color: var(--pos); }
    .metric-value.is-neg { color: var(--neg); }
    .metric-value.is-accent { color: var(--accent-text); }
    .metric-value.is-text { font-family: var(--font-sans); font-size: 18px; font-weight: 800; line-height: 1.3; letter-spacing: -0.01em; white-space: normal; overflow-wrap: anywhere; }
    .metric-foot { font-size: 12.5px; color: var(--ink-3); }
    .metric-private { background: var(--tile); color: var(--tile-ink); border-color: transparent; }
    .metric-private .metric-label, .metric-private .metric-foot { color: var(--tile-ink-2); }
    .metric-private .metric-value { color: var(--lime); letter-spacing: .02em; }
    .metric-private .icon-btn { border: 0; background: rgba(255, 255, 255, .1); color: var(--tile-ink); }
    .metric-private .icon-btn:hover { background: rgba(255, 255, 255, .18); }

    .progress { height: 12px; border-radius: 999px; background: var(--seg); overflow: hidden; }
    .progress > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
    .progress-legend { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; font-size: 13px; color: var(--ink-3); }
    .progress-legend b { color: var(--ink); font-weight: 800; }

    /* ---------- Tabele ---------- */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table { width: 100%; border-collapse: collapse; font-size: 14px; }
    .table th {
        padding: 0 12px 10px; border-bottom: 1px solid var(--line);
        text-align: left; white-space: nowrap;
        font-size: 12.5px; font-weight: 700; color: var(--ink-3);
    }
    .table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--ink-2); }
    .table th:first-child, .table td:first-child { padding-left: 0; }
    .table th:last-child, .table td:last-child { padding-right: 0; }
    .table tbody tr:last-child td { border-bottom: 0; }
    .table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
    .table .strong { font-weight: 700; color: var(--ink); }
    .table .nowrap { white-space: nowrap; }
    .table .t-pos { color: var(--pos); }
    .table .t-neg { color: var(--neg); }
    .table .t-muted { color: var(--ink-3); }
    .table tfoot td { padding-top: 12px; border-top: 1px solid var(--line-strong); border-bottom: 0; font-weight: 800; color: var(--ink); }
    .table-empty { padding: 36px 0 !important; text-align: center; color: var(--ink-3) !important; }
    .cell-sub { display: block; margin-top: 3px; font-size: 12.5px; color: var(--ink-3); }
    .table-days td { vertical-align: middle; padding-top: 10px; padding-bottom: 10px; }

    /* ---------- Zestawienia z paskiem ---------- */
    .breakdown { display: grid; gap: 13px; }
    .breakdown-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: baseline; font-size: 14px; }
    .breakdown-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-weight: 600; }
    .breakdown-val { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink); }
    .breakdown-bar { grid-column: 1 / -1; height: 6px; overflow: hidden; border-radius: 6px; background: var(--seg); }
    .breakdown-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }

    /* ---------- Stan pusty ---------- */
    .empty {
        padding: 28px 18px; text-align: center; font-size: 14px; color: var(--ink-3);
        border: 1px dashed var(--line-strong); border-radius: 16px;
    }
    .empty strong { display: block; margin-bottom: 4px; font-weight: 800; color: var(--ink-2); }

    /* ---------- Okno dialogowe ---------- */
    .dialog {
        width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
        margin: auto; padding: 0; overflow: auto;
        border: 1px solid var(--border); border-radius: 22px;
        background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop);
    }
    .dialog::backdrop { background: var(--backdrop); }
    .dialog-body { padding: 24px; }
    .dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
    .dialog-foot { display: flex; justify-content: flex-end; gap: 8px; }

    /* ---------- Karty klientów ---------- */
    .client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
    .client-card {
        display: flex; flex-direction: column; gap: 14px; padding: 20px;
        border: 1px solid var(--border); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-card);
    }
    .client-name { font-size: 16px; font-weight: 800; line-height: 1.25; overflow-wrap: anywhere; }
    .client-url {
        display: inline-flex; align-items: center; gap: 5px; margin-top: 4px;
        font-size: 13.5px; font-weight: 600; color: var(--accent-text); text-decoration: none; overflow-wrap: anywhere;
    }
    .client-url svg { width: 13px; height: 13px; flex-shrink: 0; }
    .client-url:hover { text-decoration: underline; }
    .kv { display: grid; gap: 3px; }
    .kv dt { font-size: 12.5px; font-weight: 700; color: var(--ink-3); }
    .kv dd { margin: 0; font-size: 14px; color: var(--ink-2); white-space: pre-line; overflow-wrap: anywhere; }
    .client-card-foot { display: flex; gap: 6px; margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
    .client-card-foot > * { flex: 1; }
    .client-card-foot form { display: flex; }
    .client-card-foot form .btn { flex: 1; }

    .search-box { position: relative; width: min(340px, 100%); }
    .search-box svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--ink-3); pointer-events: none; }
    .search-box .input { padding-left: 38px; }

    /* ---------- Logowanie ---------- */
    .auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
    .auth-card { width: 100%; max-width: 420px; }
    .auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
    .auth-corner { position: fixed; top: 14px; right: 14px; }

    .avatar {
        display: inline-grid; place-items: center; flex-shrink: 0;
        width: 36px; height: 36px; border-radius: 11px;
        background: var(--accent); color: #FFFFFF; font-size: 14px; font-weight: 800;
    }

    /* ---------- Wykresy ---------- */
    .chart-box { position: relative; width: 100%; height: 300px; }

    /* ---------- To-do ---------- */
    .todo-check {
        display: inline-grid; place-items: center; flex-shrink: 0;
        width: 24px; height: 24px; margin-top: 1px;
        border: 1.5px solid var(--line-strong); border-radius: 8px;
        background: var(--surface); color: var(--pos-ink); cursor: pointer;
        transition: background-color .15s, border-color .15s;
    }
    .todo-check svg { width: 15px; height: 15px; opacity: 0; }
    .todo-check:hover { border-color: var(--pos); }
    .todo-check.is-done { background: var(--pos); border-color: var(--pos); }
    .todo-check.is-done svg { opacity: 1; }
    .is-done-text { text-decoration: line-through; color: var(--ink-3) !important; }
    .todo-client { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
    .todo-text { margin-top: 4px; font-size: 15px; line-height: 1.5; color: var(--ink); white-space: pre-line; overflow-wrap: anywhere; }

    .summary-line {
        display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
        margin-top: 16px; padding: 16px 20px; border-radius: 16px; background: var(--seg);
        font-size: 14.5px; font-weight: 700; color: var(--ink-2);
    }
    .summary-line b {
        font-family: var(--font-display); font-size: 28px; line-height: 1; font-weight: 700; letter-spacing: -0.03em;
        font-variant-numeric: tabular-nums; color: var(--ink);
    }
    .summary-line.is-neg { background: var(--neg-soft); }
    .summary-line.is-pos { background: var(--pos-soft); }
    .summary-line b.t-pos { color: var(--pos); }
    .summary-line b.t-neg { color: var(--neg); }
}

/* ==========================================================================
   Tom Select (wyszukiwalne listy) — poza warstwami, jak CSS biblioteki
   ========================================================================== */
.ts-wrapper { width: 100%; }
.ts-wrapper .ts-control,
.ts-wrapper.single .ts-control,
.ts-wrapper.single.input-active .ts-control {
    min-height: 46px;
    padding: 9px 38px 9px 13px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    background: var(--field);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.5;
    box-shadow: none;
    cursor: pointer;
}
.ts-wrapper.multi .ts-control { padding: 6px 38px 6px 6px; }
.ts-wrapper.multi.has-items .ts-control { padding-left: 6px; }
.ts-wrapper.focus .ts-control { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.ts-wrapper .ts-control > input,
.ts-wrapper .ts-control input { color: var(--ink); font-family: var(--font-sans); font-size: 15px; font-weight: 500; }
.ts-wrapper.multi .ts-control > input { padding-left: 7px !important; }
.ts-wrapper .ts-control > input::placeholder { color: var(--ink-3); opacity: 1; }
.ts-wrapper.single .ts-control .item { color: var(--ink); }
.ts-wrapper.single .ts-control:not(.rtl)::after,
.ts-wrapper.multi .ts-control:not(.rtl)::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 15px;
    display: block;
    width: 7px;
    height: 7px;
    margin: 0;
    border: solid var(--ink-3);
    border-width: 0 1.8px 1.8px 0;
    transform: translateY(-70%) rotate(45deg);
    pointer-events: none;
}
.ts-wrapper.single.dropdown-active .ts-control:not(.rtl)::after,
.ts-wrapper.multi.dropdown-active .ts-control:not(.rtl)::after {
    margin: 0;
    border-color: var(--ink-3);
    border-width: 0 1.8px 1.8px 0;
    transform: translateY(-25%) rotate(225deg);
}
.ts-wrapper.multi .ts-control > .item {
    display: inline-flex;
    align-items: center;
    margin: 0 6px 0 0;
    padding: 4px 3px 4px 10px;
    border: 0;
    border-radius: 9px;
    background: var(--accent-soft);
    color: var(--accent-text);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.5;
}
.ts-wrapper.multi .ts-control > .item.active { background: var(--accent); color: #FFFFFF; }
.ts-wrapper.plugin-remove_button .item .remove {
    margin-left: 3px;
    padding: 0 6px;
    border: 0 !important;
    border-radius: 0 8px 8px 0;
    color: inherit;
    font-size: 16px;
    line-height: 1;
    opacity: .65;
    text-decoration: none;
}
.ts-wrapper.plugin-remove_button .item .remove:hover { background: transparent; opacity: 1; }
.ts-dropdown {
    z-index: 60;
    margin-top: 6px;
    padding: 5px;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-pop);
    font-family: var(--font-sans);
}
.ts-dropdown .ts-dropdown-content { max-height: 330px; }
.ts-dropdown .optgroup-header { padding: 10px 10px 4px; background: transparent; color: var(--ink-3); font-size: 12px; font-weight: 700; }
.ts-dropdown .optgroup:first-child .optgroup-header { padding-top: 6px; }
.ts-dropdown .option,
.ts-dropdown [data-selectable].option {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: 9px;
    color: var(--ink);
    font-size: 14px;
    font-weight: 500;
}
.ts-dropdown .active,
.ts-dropdown .option.active { background: var(--surface-3); color: var(--ink); }
.ts-dropdown .option.selected { color: var(--accent-text); font-weight: 700; }
.ts-dropdown .option input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); flex-shrink: 0; }
.ts-dropdown .no-results { padding: 9px 10px; color: var(--ink-3); }
.ts-wrapper .ts-control .clear-button { color: var(--ink-3); }
/* Czerwona ramka dopiero po próbie wysłania formularza, nie od razu po wejściu na stronę */
.was-validated .ts-wrapper.invalid .ts-control { border-color: var(--neg); }
.was-validated .ts-wrapper.invalid.focus .ts-control { box-shadow: 0 0 0 4px color-mix(in srgb, var(--neg) 22%, transparent); }

/* ==========================================================================
   Druk — zawsze jasno, bez nawigacji i formularzy
   ========================================================================== */
@media print {
    :root,
    :root[data-theme="dark"] {
        --bg: #FFFFFF; --surface: #FFFFFF; --surface-2: #F7F7FA; --surface-3: #F0F0F5; --seg: #F0F0F5; --raised: #FFFFFF;
        --line: #E4E4EC; --border: #E4E4EC; --line-strong: #CFCFDB;
        --ink: #111019; --ink-2: #3E3D52; --ink-3: #66657C;
        --accent: #6A4DF4; --accent-soft: #F0ECFF; --accent-text: #5130D9;
        --pos: #0B7A54; --pos-soft: #E2F5EC; --neg: #C4283E; --neg-soft: #FCEBEE; --warn: #955706; --warn-soft: #FFF1D8;
        --tile: #FFFFFF; --tile-ink: #111019; --tile-ink-2: #66657C;
        color-scheme: light;
    }
    .no-print, .sidebar, .mobilebar, .side-backdrop { display: none !important; }
    .print-only { display: block !important; }
    .app { display: block; }
    body { background: #FFFFFF; font-size: 12px; }
    .shell { max-width: none; padding: 0; }
    .panel, .metric, .client-card { break-inside: avoid; box-shadow: none; }
    .panel { padding: 14px 0; border: 0; border-radius: 0; }
    .metric { padding: 10px 12px; }
    .table-wrap { overflow: visible; }
    .is-sticky { position: static; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}

/* ---------- Dashboard: układ kafelków ---------- */
@layer components {
    .bento-dash { grid-template-columns: minmax(0, 1fr); }
    .bento-stack { display: grid; gap: 16px; }
    .bento-stack > .panel { padding: 18px 20px; }
    @media (min-width: 640px) {
        .bento-dash { grid-template-columns: repeat(2, minmax(0, 1fr)); }
        .bento-dash .bento-day { grid-column: 1 / -1; order: 3; }
    }
    @media (min-width: 1100px) {
        .bento-dash { grid-template-columns: minmax(230px, 3fr) minmax(0, 6fr) minmax(210px, 3fr); }
        .bento-dash .bento-day { grid-column: auto; order: 0; }
    }
    .bento-day .panel-head { margin-bottom: 14px; }
}

/* ---------- Czas pracy: kafelki, przełącznik miesiąca, karta przyklejona ---------- */
@layer components {
    .bento-att { grid-template-columns: minmax(0, 1fr); }
    .bento-att > .panel { display: flex; flex-direction: column; gap: 10px; padding: 20px 22px; }
    @media (min-width: 640px) {
        .bento-att { grid-template-columns: repeat(2, minmax(0, 1fr)); }
        .bento-att .att-balance { grid-column: 1 / -1; }
    }
    @media (min-width: 1280px) {
        .bento-att { grid-template-columns: minmax(0, 5fr) minmax(170px, 2.3fr) minmax(150px, 2fr) minmax(0, 3.2fr); }
        .bento-att .att-balance { grid-column: auto; }
    }
    .stat-xl { font-size: clamp(40px, 4.2vw, 52px); letter-spacing: -0.04em; }
    .stat-md { font-size: 28px; }
    .stat-num.t-pos { color: var(--pos); }
    .stat-num.t-neg { color: var(--neg); }
    .att-small .stat-foot, .att-pay .stat-foot { margin-top: auto; }
    .att-pay .stat-label, .att-pay .stat-foot { color: var(--tile-ink-2); }
    .att-pay-value { color: var(--lime); letter-spacing: .02em; }
    .att-pay .icon-btn { border: 0; background: rgba(255, 255, 255, .1); color: var(--tile-ink); }
    .att-pay .icon-btn:hover { background: rgba(255, 255, 255, .18); }

    .month-switch {
        display: flex; align-items: center; gap: 2px; height: 46px; padding: 0 3px;
        border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface);
    }
    .month-switch form { display: flex; }
    .month-input {
        width: 150px; height: 38px; padding: 0 6px; border: 0; border-radius: 8px;
        background: transparent; color: var(--ink);
        font: inherit; font-size: 14.5px; font-weight: 700; text-align: center;
    }
    .month-input:focus-visible { outline: 2px solid var(--accent); }

    .duration-preview { font-family: var(--font-display); font-size: 15px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
    .duration-preview.t-neg { font-family: var(--font-sans); font-size: 12.5px; color: var(--neg); }

    @media (min-width: 1280px) {
        .is-sticky { max-height: calc(100vh - 48px); overflow-y: auto; overscroll-behavior: contain; }
    }
}
