:root {
    --red: #c2000a;
    --red-hover: #e0000d;
    --red-soft: rgba(194, 0, 10, 0.08);
    --black: #0d0d0f;
    --ink: #1a1a1f;
    --muted: #6c6c78;
    --line: #e8e8ee;
    --line-strong: #d8d8e0;
    --bg: #f4f5f8;
    --card: #ffffff;
    --green: #1f9d55;
    --green-soft: #e6f6ec;
    --yellow: #c47a00;
    --yellow-soft: #fff3dc;
    --blue: #0e6cd9;
    --blue-soft: #e3efff;
    --gray-soft: #ececf1;
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(20, 20, 30, 0.05);
    --shadow: 0 6px 24px rgba(20, 20, 30, 0.07);
    --shadow-lg: 0 14px 40px rgba(20, 20, 30, 0.10);
    --transition: 0.2s ease;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
    font-family: 'Inter', system-ui, -apple-system, Segoe UI, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; outline: none; }
img { max-width: 100%; display: block; }

.app {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--black);
    color: #fff;
    padding: 22px 16px;
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column; gap: 8px;
    transition: transform 0.3s ease;
    z-index: 50;
}
.sidebar-close {
    display: none;
    position: absolute;
    top: 10px; right: 10px;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    color: #fff;
    align-items: center; justify-content: center;
    transition: background var(--transition);
}
.sidebar-close:hover { background: rgba(255,255,255,0.18); }
.sidebar-backdrop {
    position: fixed; inset: 0;
    background: rgba(13,13,15,0.55);
    backdrop-filter: blur(2px);
    z-index: 40;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.sidebar-backdrop.is-visible { opacity: 1; }
body.no-scroll { overflow: hidden; }

.brand {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 8px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 12px;
}
.brand img { height: 28px; width: auto; }
.brand .brand-icon { display: none; height: 32px; }
.brand-name { font-family: 'Chakra Petch', sans-serif; font-size: 18px; font-weight: 700; letter-spacing: 0.04em; }
.brand-name em { color: var(--red); font-style: normal; }

.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: rgba(255,255,255,0.78);
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
    position: relative;
    min-height: 40px;
}
.nav-link:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav-link.active { background: var(--red); color: #fff; }
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-badge {
    margin-left: auto;
    min-width: 22px;
    height: 22px;
    padding: 0 7px;
    border-radius: 11px;
    background: var(--red);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-shadow: 0 0 0 2px rgba(194, 0, 10, 0.18);
    font-feature-settings: 'tnum';
}
.nav-badge[hidden] { display: none; }
.nav-link.active .nav-badge { background: #fff; color: var(--red); box-shadow: none; }

.sidebar-footer {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 12px;
    color: rgba(255,255,255,0.55);
}
.sidebar-user { padding: 10px 12px; }
.sidebar-user .name { color: #fff; font-weight: 600; }
.sidebar-user .role { color: rgba(255,255,255,0.5); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; }

.main { padding: 0; }

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 28px;
    background: var(--card);
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 20;
    min-width: 0;
}
.topbar-left {
    display: flex; align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1 1 auto;
}
.topbar-titles {
    min-width: 0;
    overflow: hidden;
    flex: 1 1 auto;
}
.topbar h1 {
    font-family: 'Chakra Petch', sans-serif;
    font-size: 22px; margin: 0; letter-spacing: 0.02em;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar .crumbs {
    font-size: 12px; color: var(--muted); margin-top: 4px;
    text-transform: uppercase; letter-spacing: 0.1em;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-actions {
    display: flex; gap: 10px; align-items: center;
    justify-content: flex-end;
    flex-shrink: 0;
}
.topbar-actions:empty { display: none; }
.hamburger {
    display: none;
    width: 40px; height: 40px;
    border-radius: var(--radius);
    background: var(--gray-soft);
    color: var(--ink);
    align-items: center; justify-content: center;
    flex-shrink: 0;
    border: 1px solid var(--line);
    transition: background var(--transition);
}
.hamburger:hover { background: var(--line-strong); }
.hamburger:active { transform: scale(0.96); }
.topbar-logo {
    display: none;
    align-items: center;
    flex-shrink: 0;
}

.topbar-logo .logo-icon,
.topbar-logo .logo-wide { display: none; }

.topbar-divider { display: none; }

.content { padding: 24px 28px 80px; min-width: 0; }

.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 16px;
    border-radius: var(--radius);
    font-size: 13px; font-weight: 600;
    transition: background var(--transition), color var(--transition), box-shadow var(--transition);
    border: 1px solid transparent;
    white-space: nowrap;
}
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-hover); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--gray-soft); }
.btn-dark { background: var(--black); color: #fff; }
.btn-dark:hover { background: #1f1f25; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card-head h2 { font-size: 16px; margin: 0; font-weight: 700; }
.card-body { padding: 18px 20px; }

.table-wrap { overflow-x: auto; }
table.data {
    width: 100%; border-collapse: collapse;
    font-size: 13px;
}
table.data th, table.data td {
    text-align: left; padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
    white-space: nowrap;
}
table.data thead th {
    background: #fafbfc; font-weight: 600; color: var(--muted);
    text-transform: uppercase; font-size: 11px; letter-spacing: 0.08em;
}
table.data tbody tr { transition: background var(--transition); }
table.data tbody tr:hover { background: #fafbfc; cursor: pointer; }
table.data .id-col { color: var(--red); font-weight: 600; font-feature-settings: 'tnum'; }
table.data .id-col .src-icon { margin-left: 6px; opacity: 0.65; font-size: 11px; }

table.data tbody tr.is-unread { background: rgba(194, 0, 10, 0.05); }
table.data tbody tr.is-unread:hover { background: rgba(194, 0, 10, 0.10); }
table.data tbody tr.is-unread td { font-weight: 700; }
table.data tbody tr.is-unread td:first-child {
    box-shadow: inset 3px 0 0 0 var(--red);
}
table.data tbody tr.is-unread .id-col::before {
    content: '';
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--red);
    margin-right: 8px;
    vertical-align: middle;
    box-shadow: 0 0 0 3px rgba(194, 0, 10, 0.20);
}

.pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px; font-weight: 600;
    letter-spacing: 0.02em;
    background: var(--gray-soft);
    color: var(--ink);
    border: 1px solid transparent;
}
.pill.dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.pill.s-nowy           { background: #eaf3ff; color: #0a4ea6; }
.pill.s-w_kontakcie    { background: #eef2f7; color: #354156; }
.pill.s-nie_odpowiada  { background: #1a1a1f; color: #fff; }
.pill.s-zainteresowany_pozniej { background: #eaf3ff; color: #0a4ea6; }
.pill.s-zainteresowany_teraz   { background: var(--green-soft); color: #0c6c34; }
.pill.s-niezainteresowany      { background: #fdecec; color: #a31818; }
.pill.s-nieprawidlowy          { background: #fdecec; color: #a31818; }
.pill.s-zamkniety_wygrany      { background: var(--green-soft); color: #0c6c34; }
.pill.s-zamkniety_przegrany    { background: #efeff3; color: #555562; }
.pill.role-admin     { background: #fff0f0; color: #a31818; }
.pill.role-wlasciciel{ background: #f3e8ff; color: #6a1a8a; }
.pill.role-manager   { background: #fff7e6; color: #8a4d00; }
.pill.role-handlowiec{ background: #eef6ff; color: #0a4ea6; }
.pill.role-marketing { background: #e6f7f2; color: #0b6b52; }

/* ===== Panel marketingowy ===== */
.src-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.src-chips .pill { background: #eef2f7; color: #354156; }
.pill.src-facebook   { background: #eaf3ff; color: #0a4ea6; }
.pill.src-instagram  { background: #fdeef7; color: #a1206b; }
.pill.src-google_ads { background: #fff7e6; color: #8a4d00; }
.pill.src-www        { background: var(--green-soft); color: #0c6c34; }
.pill.src-telefon    { background: #eef2f7; color: #354156; }
.pill.src-manualny   { background: #f3e8ff; color: #6a1a8a; }
.pill.src-inny       { background: var(--gray-soft); color: #555562; }
.btn.is-range.active { background: var(--black); color: #fff; border-color: var(--black); }
.kpi.accent .muted, .kpi.red .muted { color: rgba(255,255,255,0.72); }
.kpi .text-sm { line-height: 1.35; }

/* Panel marketingowy - desktop: cala tresc mieści się w oknie,
   bez poziomego paska przewijania (mobile ma wlasny uklad kart). */
@media (min-width: 901px) {
    body[data-active="marketing"] .main { min-width: 0; }
    body[data-active="marketing"] .content { max-width: 100%; overflow-x: hidden; }
    body[data-active="marketing"] .card-body-chart { padding: 16px 14px 12px; }
    body[data-active="marketing"] #chart { display: block; width: 100%; max-width: 100%; }
    /* Tabela miesięczna: chipy źródeł zawijają się zamiast rozpychać tabelę. */
    body[data-active="marketing"] #months td { white-space: normal; }
    body[data-active="marketing"] #months th,
    body[data-active="marketing"] #months td:first-child,
    body[data-active="marketing"] #months td:last-child { white-space: nowrap; }
    body[data-active="marketing"] #months td:first-child,
    body[data-active="marketing"] #months td:last-child { width: 1%; }
    body[data-active="marketing"] #months .src-chips { max-width: 100%; }
}
@media (min-width: 1101px) {
    body[data-active="marketing"] .lead-grid { grid-template-columns: 1fr 1fr; }
}

/* Panel marketingowy nie ma dzwonka powiadomień, więc w górnym pasku
   po prawej stronie logo nie ma nic, co równoważyłoby hamburgera.
   Niewidoczna przeciwwaga o szerokości hamburgera ustawia logo
   dokładnie na środku ekranu (sam hamburger zostaje na swoim miejscu). */
@media (max-width: 900px) {
    body[data-active="marketing"] .topbar::after {
        content: '';
        order: 3;
        flex: 0 0 40px;
        height: 1px;
    }
}
.src-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; }
.field[hidden], [data-src-block][hidden], [data-leads-block][hidden] { display: none !important; }
@media (max-width: 520px) { .src-picker { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.input, .select, textarea {
    width: 100%; padding: 10px 12px;
    border: 1px solid var(--line-strong); border-radius: var(--radius);
    background: #fff; font-size: 14px; color: var(--ink);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.input:focus, .select:focus, textarea:focus {
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(194,0,10,0.12);
}
textarea { min-height: 90px; resize: vertical; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--red); }

.form-grid { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }

.filters {
    display: grid; gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    background: #fff; padding: 14px 16px;
    border: 1px solid var(--line); border-radius: var(--radius-lg);
    margin-bottom: 18px;
    box-shadow: var(--shadow-sm);
}
.filters .field { margin: 0; }
.filters .field label { font-size: 11px; }

.kpis {
    display: grid; gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    margin-bottom: 22px;
}
.kpi {
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg);
    padding: 18px; box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; gap: 6px;
}
.kpi .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.kpi .value { font-family: 'Chakra Petch', sans-serif; font-size: 28px; font-weight: 700; color: var(--ink); }
.kpi.accent { background: var(--black); color: #fff; border-color: var(--black); }
.kpi.accent .label { color: rgba(255,255,255,0.6); }
.kpi.accent .value { color: #fff; }
.kpi.red { background: var(--red); color: #fff; border-color: var(--red); }
.kpi.red .label { color: rgba(255,255,255,0.7); }
.kpi.red .value { color: #fff; }

.lead-grid {
    display: grid; gap: 18px;
    grid-template-columns: 1fr 380px;
}
@media (max-width: 1100px) { .lead-grid { grid-template-columns: 1fr; } }

.detail-row { display: grid; grid-template-columns: 200px 1fr; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: center; }
.detail-row:last-child { border-bottom: 0; }
.detail-row .key { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.detail-row .val { font-weight: 500; }

.timeline { display: flex; flex-direction: column; gap: 10px; }
.timeline-item {
    background: #fafbfc; border: 1px solid var(--line);
    border-radius: var(--radius); padding: 10px 12px;
}
.timeline-item .meta { font-size: 11px; color: var(--muted); margin-bottom: 4px; }

.login-page {
    min-height: 100vh; display: grid; place-items: center;
    background: linear-gradient(135deg, #0d0d0f 0%, #1a1a1f 100%);
    color: #fff;
    padding: 24px;
}
.login-card {
    width: 100%; max-width: 400px;
    background: #fff; color: var(--ink);
    border-radius: var(--radius-lg);
    padding: 36px;
    box-shadow: var(--shadow-lg);
}
.login-card .brand { border: 0; padding: 0 0 22px; justify-content: center; flex-direction: column; }
.login-card h1 { font-family: 'Chakra Petch', sans-serif; font-size: 22px; margin: 0 0 4px; text-align: center; }
.login-card .lead { color: var(--muted); text-align: center; font-size: 13px; margin-bottom: 26px; }
.login-card .field { margin-bottom: 16px; }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 12px; font-size: 14px; }
.login-foot { text-align: center; margin-top: 16px; color: var(--muted); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; }

.toast-container {
    position: fixed; top: 16px; right: 16px; z-index: 9999;
    display: flex; flex-direction: column; gap: 8px;
}
.toast {
    background: var(--ink); color: #fff;
    padding: 10px 14px; border-radius: var(--radius); font-size: 13px;
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    border-left: 4px solid var(--red);
    animation: slideIn 0.25s ease;
}
.toast.ok { border-left-color: var(--green); }
.toast.warn { border-left-color: var(--yellow); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

.pager {
    display: flex; gap: 4px; justify-content: center; padding: 16px;
    align-items: center; flex-wrap: wrap;
}
.pager button {
    min-width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line); background: #fff;
    font-size: 13px; color: var(--ink);
    transition: background var(--transition);
}
.pager button:hover:not(:disabled) { background: var(--gray-soft); }
.pager button.active { background: var(--green-soft); color: #0c6c34; border-color: #c8eed5; font-weight: 600; }
.pager button:disabled { opacity: 0.4; cursor: not-allowed; }

.modal-backdrop {
    position: fixed; inset: 0; background: rgba(13,13,15,0.55);
    display: grid; place-items: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}
.modal {
    background: #fff; border-radius: var(--radius-lg);
    width: 100%; max-width: 540px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px 22px; max-height: 70vh; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }

.empty {
    text-align: center; padding: 60px 20px; color: var(--muted);
}
.spinner {
    width: 18px; height: 18px;
    border: 2px solid var(--line);
    border-top-color: var(--red);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.flex { display: flex; gap: 10px; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.mt-12 { margin-top: 12px; } .mt-20 { margin-top: 20px; } .mb-12 { margin-bottom: 12px; }
.hidden { display: none !important; }
.text-sm { font-size: 12px; }
.tnum { font-feature-settings: 'tnum'; }

.searates-cta {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 16px;
    padding: 14px 18px;
    background: linear-gradient(135deg, #fff6f6 0%, #ffeaea 100%);
    border: 1px solid #f5c0c0;
    border-radius: var(--radius);
    color: var(--ink);
    text-decoration: none;
    transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
.searates-cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(163, 24, 24, 0.12);
    border-color: var(--red);
    color: var(--ink);
}
.searates-cta > svg:first-child {
    flex-shrink: 0;
    color: var(--red);
}
.searates-cta > svg:last-child {
    flex-shrink: 0;
    color: var(--red);
    opacity: 0.75;
}
.searates-cta-text {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.searates-cta-title {
    font-weight: 700;
    font-size: 14px;
    line-height: 1.3;
}
.searates-cta-sub {
    font-size: 12px;
    color: var(--muted);
}
@media (max-width: 480px) {
    .searates-cta { padding: 12px 14px; gap: 10px; }
    .searates-cta-title { font-size: 13px; }
}

.cal-toolbar {
    display: flex; gap: 12px; align-items: center; justify-content: space-between;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.cal-toolbar .left, .cal-toolbar .right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cal-title {
    font-family: 'Chakra Petch', sans-serif;
    font-size: 22px; font-weight: 700;
    text-transform: capitalize;
    min-width: 180px;
}
.cal-grid-wrap {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.cal-headrow {
    display: grid; grid-template-columns: repeat(7, 1fr);
    background: #fafbfc;
    border-bottom: 1px solid var(--line);
}
.cal-headrow > div {
    padding: 10px 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    text-align: left;
    font-weight: 600;
}
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: minmax(110px, auto);
}
.cal-day {
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    padding: 8px;
    cursor: pointer;
    transition: background var(--transition);
    overflow: hidden;
    position: relative;
}
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day:hover { background: #fafbfc; }
.cal-day.outside { background: #fafbfc; opacity: 0.55; }
.cal-day.today { background: var(--red-soft); }
.cal-day.today .cal-day-num { color: var(--red); font-weight: 800; }
.cal-day.weekend { background: #fafbfc; }
.cal-day-num {
    font-size: 13px; font-weight: 600;
    color: var(--ink);
    margin-bottom: 6px;
    display: inline-block;
}
.cal-day-add {
    position: absolute; top: 6px; right: 8px;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--red);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    display: none;
    align-items: center; justify-content: center;
    line-height: 1;
}
.cal-day:hover .cal-day-add { display: inline-flex; }
.cal-task {
    display: block;
    background: var(--blue-soft);
    color: var(--blue);
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 11px;
    margin-bottom: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    border-left: 3px solid var(--blue);
}
.cal-task:hover { filter: brightness(0.96); }
.cal-task.done {
    background: var(--green-soft);
    color: #0c6c34;
    border-left-color: var(--green);
    text-decoration: line-through;
    opacity: 0.7;
}
.cal-task.overdue {
    background: #fdecec;
    color: #a31818;
    border-left-color: var(--red);
}
.cal-task .cal-task-time {
    font-weight: 700;
    margin-right: 4px;
    font-feature-settings: 'tnum';
}
.cal-more {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
    cursor: pointer;
}
.cal-more:hover { color: var(--ink); }

@media (max-width: 720px) {
    .cal-grid { grid-auto-rows: minmax(80px, auto); }
    .cal-day { padding: 4px; }
    .cal-day-num { font-size: 11px; }
    .cal-task { font-size: 10px; padding: 2px 4px; }

    .cal-day-cell { min-height: 64px; padding: 4px; }
    .cal-day-cell .cal-task {
        font-size: 14px;
        font-weight: 600;
        padding: 8px 10px;
        margin-bottom: 5px;
        white-space: normal;
        line-height: 1.3;
        border-left-width: 5px;
        border-radius: 6px;
        min-height: 34px;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 4px 6px;
    }
    .cal-day-cell .cal-task .cal-task-time {
        display: inline-block;
        font-size: 12px;
        font-weight: 700;
    }

    .cal-week-cell { min-height: 52px; padding: 3px; }
    .cal-week-cell .cal-task {
        font-size: 12px;
        font-weight: 600;
        padding: 5px 7px;
        margin-bottom: 3px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.25;
        border-left-width: 4px;
        border-radius: 5px;
        display: block;
    }
    .cal-week-cell .cal-task .cal-task-time {
        display: inline;
        font-size: 11px;
        font-weight: 700;
        margin-right: 4px;
    }
}

.collapse-card .card-head {
    cursor: pointer;
    user-select: none;
}
.collapse-card .card-head:hover { background: #fafbfc; }
.collapse-card .card-head .chev {
    transition: transform var(--transition);
    color: var(--muted);
}
.collapse-card.is-open .card-head .chev { transform: rotate(180deg); }
.collapse-card .card-body { display: none; }
.collapse-card.is-open .card-body { display: block; }

.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}
.kpi-row .kpi { padding: 12px 14px; }
.kpi-row .kpi .label { font-size: 10px; }
.kpi-row .kpi .value { font-size: 18px; }

.dropzone {
    border: 2px dashed var(--line-strong);
    border-radius: var(--radius-lg);
    padding: 22px;
    text-align: center;
    color: var(--muted);
    background: #fafbfc;
    cursor: pointer;
    transition: all var(--transition);
}
.dropzone:hover, .dropzone.is-drag {
    border-color: var(--red);
    background: var(--red-soft);
    color: var(--ink);
}
.dropzone svg { color: var(--red); }
.dropzone .dz-title { font-weight: 600; font-size: 14px; margin: 6px 0 2px; color: var(--ink); }
.dropzone .dz-sub { font-size: 12px; }
.dropzone input[type=file] { display: none; }

.file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 14px;
}
.file-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    overflow: hidden;
    position: relative;
    transition: box-shadow var(--transition), transform var(--transition);
    cursor: pointer;
}
.file-card:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.file-card .thumb {
    width: 100%; aspect-ratio: 4/3;
    display: flex; align-items: center; justify-content: center;
    background: #f4f5f8; color: var(--muted);
}
.file-card .thumb img {
    width: 100%; height: 100%; object-fit: cover; display: block;
}
.file-card .meta {
    padding: 8px 10px;
    font-size: 11px;
}
.file-card .meta .nm {
    color: var(--ink); font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block;
}
.file-card .meta .sub { color: var(--muted); font-size: 10px; }
.file-card .del {
    position: absolute; top: 6px; right: 6px;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: #a31818;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700;
    opacity: 0; transition: opacity var(--transition);
}
.file-card:hover .del { opacity: 1; }
.file-card .del:hover { background: #a31818; color: #fff; }

.cat-tabs {
    display: flex; gap: 6px; flex-wrap: wrap;
    margin-bottom: 4px;
}
.cat-tabs .cat-tab {
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    font-size: 12px;
    color: var(--ink);
    cursor: pointer;
    transition: all var(--transition);
    display: inline-flex; align-items: center; gap: 6px;
}
.cat-tabs .cat-tab:hover { border-color: var(--line-strong); }
.cat-tabs .cat-tab.active {
    background: var(--ink); color: #fff; border-color: var(--ink);
}
.cat-tabs .cat-tab .count {
    background: rgba(0,0,0,0.1);
    border-radius: 999px;
    padding: 0 6px;
    font-size: 10px; font-weight: 700;
}
.cat-tabs .cat-tab.active .count { background: rgba(255,255,255,0.2); }

.cal-task.auction {
    background: #fff3dc;
    color: #8a4d00;
    border-left-color: var(--yellow);
    font-weight: 600;
}
.cal-task.auction:hover { background: #ffe9c2; }

.phone-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: inherit;
    font-feature-settings: 'tnum';
    text-decoration: none;
    border-bottom: 1px dotted rgba(194, 0, 10, 0.35);
    padding-bottom: 1px;
    white-space: nowrap;
    transition: color var(--transition), border-color var(--transition);
}
.phone-link .phone-icon {
    color: var(--red);
    flex-shrink: 0;
    transition: transform var(--transition);
}
.phone-link:hover {
    color: var(--red);
    border-bottom-color: var(--red);
}
.phone-link:hover .phone-icon { transform: rotate(-12deg); }
.phone-link.muted { color: var(--muted); }
.phone-link.muted .phone-icon { color: var(--muted); }

.pill .icon {
    width: 12px;
    height: 12px;
    margin-right: 4px;
    vertical-align: -2px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.cal-lead-row:hover { background: #fafbfc; }
.cal-lead-row.selected { background: rgba(194, 0, 10, 0.08) !important; }
.cal-lead-row.selected:hover { background: rgba(194, 0, 10, 0.12) !important; }
.cal-lead-row:last-child { border-bottom: 0 !important; }

.skip-link { position: absolute; left: -9999px; top: 0; background: #000; color: #fff; padding: 8px 12px; }
.skip-link:focus { left: 8px; top: 8px; z-index: 9999; }

.vehicle-tabs {
    display: flex; flex-wrap: wrap; gap: 6px;
    padding: 12px 22px 0;
    border-bottom: 1px solid var(--line);
    margin-bottom: 4px;
}
.vehicle-tabs .vt,
.vehicle-tabs .vt-add {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    border-radius: 8px 8px 0 0;
    border-bottom: none;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    position: relative;
    top: 1px;
}
.vehicle-tabs .vt:hover { background: #fafbfc; }
.vehicle-tabs .vt.active {
    background: #fff;
    color: var(--red);
    font-weight: 700;
    border-bottom: 1px solid #fff;
    box-shadow: inset 0 3px 0 var(--red);
}
.vehicle-tabs .vt.lost {
    color: var(--muted);
    text-decoration: line-through;
}
.vehicle-tabs .vt.lost.active {
    text-decoration: none;
    color: #a31818;
    box-shadow: inset 0 3px 0 #a31818;
}
.vehicle-tabs .vt-add {
    background: var(--bg);
    color: var(--muted);
    border-style: dashed;
}
.vehicle-tabs .vt-add:hover { background: #fff; color: var(--red); border-color: var(--red); }

.pipeline-stepper {
    display: flex; align-items: flex-start;
    gap: 0;
    overflow-x: auto;
    padding: 12px 0 6px;
}
.pipeline-stepper .ps-step {
    flex: 1 1 0;
    min-width: 90px;
    display: flex; flex-direction: column; align-items: center;
    cursor: pointer;
    position: relative;
    padding: 0 4px;
    text-align: center;
}
.pipeline-stepper .ps-step + .ps-step::before {
    content: '';
    position: absolute;
    left: -50%;
    top: 16px;
    width: 100%;
    height: 2px;
    background: var(--line);
    z-index: 0;
}
.pipeline-stepper .ps-step.past + .ps-step.past::before,
.pipeline-stepper .ps-step.past + .ps-step.current::before {
    background: #2bb673;
}
.pipeline-stepper .ps-circle {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: #f4f4f7;
    border: 2px solid var(--line);
    color: var(--muted);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700;
    position: relative;
    z-index: 1;
    transition: all var(--transition);
}
.pipeline-stepper .ps-step.past .ps-circle {
    background: #2bb673;
    border-color: #2bb673;
    color: #fff;
}
.pipeline-stepper .ps-step.current .ps-circle {
    background: var(--red);
    border-color: var(--red);
    color: #fff;
    box-shadow: 0 0 0 4px rgba(194, 0, 10, 0.15);
}
.pipeline-stepper .ps-label {
    margin-top: 6px;
    font-size: 11px;
    line-height: 1.25;
    color: var(--ink);
    font-weight: 500;
    max-width: 110px;
}
.pipeline-stepper .ps-step.past .ps-label  { color: #0c6c34; }
.pipeline-stepper .ps-step.current .ps-label { color: var(--red); font-weight: 700; }
.pipeline-stepper .ps-step.future .ps-label { color: var(--muted); }
.pipeline-stepper .ps-step:hover .ps-circle {
    transform: scale(1.08);
    border-color: var(--red);
}
.pipeline-stepper .ps-step:focus { outline: none; }
.pipeline-stepper .ps-step:focus .ps-circle {
    box-shadow: 0 0 0 4px rgba(194, 0, 10, 0.25);
}

.notif-card-head {
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}
.notif-mass-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}
@media (max-width: 720px) {
    .notif-card-head { gap: 10px; }
    .notif-mass-actions { width: 100%; justify-content: stretch; }
    .notif-mass-actions .btn { flex: 1 1 100%; justify-content: center; }
}
.notif-tabs { display: flex; gap: 4px; }
.notif-tab {
    padding: 8px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
    display: inline-flex; align-items: center; gap: 8px;
}
.notif-tab:hover { background: var(--gray-soft); }
.notif-tab.active {
    background: var(--ink);
    color: #fff;
    border-color: var(--ink);
}
.notif-tab .tab-count {
    background: rgba(255,255,255,0.18);
    border-radius: 999px;
    padding: 1px 8px;
    font-size: 11px;
    font-weight: 700;
}
.notif-tab:not(.active) .tab-count {
    background: var(--gray-soft);
    color: var(--ink);
}

.notif-list { display: flex; flex-direction: column; }
.notif-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--line);
    transition: background var(--transition);
    align-items: flex-start;
}
.notif-row:hover { background: #fafbfc; }
.notif-row.unread {
    background: rgba(194, 0, 10, 0.04);
    box-shadow: inset 4px 0 0 0 var(--red);
}
.notif-row.unread .notif-title { font-weight: 700; }
.notif-row.trashed {
    background: #fafbfc;
    opacity: 0.85;
}
.notif-row.trashed .notif-title {
    text-decoration: line-through;
    text-decoration-color: rgba(0,0,0,0.25);
    color: var(--muted);
}
.notif-row .notif-meta {
    display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
    font-size: 12px;
    margin-bottom: 6px;
}
.notif-row .notif-title {
    font-size: 14px;
    line-height: 1.4;
    color: var(--ink);
    margin-bottom: 4px;
}
.notif-row .notif-title a { color: inherit; }
.notif-row .notif-title a:hover { color: var(--red); }
.notif-row .notif-body {
    font-size: 12.5px;
    color: var(--muted);
    line-height: 1.45;
    white-space: pre-wrap;
}
.notif-row .notif-actions {
    display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap;
    justify-content: flex-end;
}
.notif-row.sev-alert .notif-title::before {
    content: '';
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--red);
    margin-right: 6px;
    vertical-align: middle;
}
.notif-row.sev-success .notif-title::before {
    content: '';
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--green);
    margin-right: 6px;
    vertical-align: middle;
}

@media (max-width: 720px) {
    .notif-row { grid-template-columns: 1fr; }
    .notif-row .notif-actions { justify-content: flex-start; }
}

.bell-wrap { position: relative; }
.bell-btn {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--gray-soft);
    color: var(--ink);
    display: inline-flex; align-items: center; justify-content: center;
    position: relative;
    transition: background var(--transition), transform var(--transition);
}
.bell-btn:hover { background: var(--line-strong); }
.bell-btn:active { transform: scale(0.96); }
.bell-badge {
    position: absolute;
    top: -2px; right: -2px;
    min-width: 18px; height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--red);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center; justify-content: center;
    line-height: 1;
    box-shadow: 0 0 0 2px #fff;
    font-feature-settings: 'tnum';
}
.bell-badge[hidden] { display: none; }
.bell-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 360px;
    max-height: 480px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.bell-dropdown[hidden] { display: none; }
.bell-head {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.bell-list {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 80px;
}
.bell-item {
    display: flex;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
    align-items: flex-start;
    transition: background var(--transition);
}
.bell-item:hover { background: var(--gray-soft); }
.bell-item:last-child { border-bottom: 0; }
.bell-item-body { flex: 1 1 auto; min-width: 0; }
.bell-item-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.bell-item-meta {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
}
.sev-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--blue);
    margin-top: 6px;
    flex-shrink: 0;
}
.sev-dot.sev-info    { background: var(--blue); }
.sev-dot.sev-alert   { background: var(--red); }
.sev-dot.sev-success { background: var(--green); }
.bell-foot {
    padding: 10px 14px;
    border-top: 1px solid var(--line);
    background: #fafbfc;
}

.settings-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--line);
}
.settings-tab {
    padding: 10px 18px;
    background: transparent;
    color: var(--muted);
    font-weight: 600;
    font-size: 13px;
    border-bottom: 3px solid transparent;
    transition: color var(--transition), border-color var(--transition);
}
.settings-tab:hover { color: var(--ink); }
.settings-tab.active {
    color: var(--red);
    border-bottom-color: var(--red);
}
.settings-pane { display: none; }
.settings-pane.is-active { display: block; }

table.prefs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.prefs-table th,
table.prefs-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}
table.prefs-table thead th {
    background: #fafbfc;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.08em;
}
table.prefs-table tr.cat-row td {
    background: #f4f5f8;
    font-weight: 700;
    color: var(--ink);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.08em;
    padding: 8px 14px;
}
table.prefs-table td.ch-col,
table.prefs-table th.ch-col { text-align: center; }
table.prefs-table td.center,
table.prefs-table th.center { text-align: center; }

table.prefs-table tr.is-forced td { background: var(--red-soft); }
table.prefs-table tr.is-forced td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.forced-badge {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--red);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    vertical-align: 1px;
}
.input.input-narrow { width: 80px; padding: 6px 8px; }
table.prefs-global td .select { padding: 6px 10px; font-size: 12px; }

.pipeline-pill {
    background: #eef2f7;
    color: #2a3a55;
}
.pipeline-pill.pipeline-umowa_podpisana   { background: #fff7e6; color: #8a4d00; }
.pipeline-pill.pipeline-szukanie_auta     { background: #e7f0ff; color: #0a4ea6; }
.pipeline-pill.pipeline-licytacja_wygrana { background: #e6f7ea; color: #0c6c34; }
.pipeline-pill.pipeline-transport_usa     { background: #ecf3ff; color: #1a4a8e; }
.pipeline-pill.pipeline-port_fracht       { background: #e0f4f8; color: #0a5870; }
.pipeline-pill.pipeline-odprawa_celna     { background: #f7e6f9; color: #6a1a8a; }
.pipeline-pill.pipeline-transport_pl      { background: #fde7e9; color: #a31818; }
.pipeline-pill.pipeline-naprawa_wydanie   { background: #d8ebd1; color: #2c5a1a; font-weight: 700; }

@media (max-width: 1100px) {
    .app { grid-template-columns: 200px 1fr; }
    .content { padding: 20px 20px 60px; }
    .topbar { padding: 12px 20px; }
}

@media (max-width: 900px) {

    html, body { overflow-x: hidden; max-width: 100vw; }
    .app {
        grid-template-columns: 1fr;
        overflow-x: hidden;
        max-width: 100vw;
    }
    .main {
        overflow-x: hidden;
        min-width: 0;
        max-width: 100vw;
    }

    .sidebar {
        position: fixed;
        top: 0; left: 0;
        width: 280px;
        max-width: 86vw;
        height: 100dvh;
        transform: translateX(-100%);
        overflow-y: auto;
        padding-top: 60px;
        box-shadow: 6px 0 24px rgba(0,0,0,0.25);
        z-index: 60;
    }
    .sidebar.is-open { transform: translateX(0); }
    .sidebar-close { display: inline-flex; }
    .sidebar-backdrop { z-index: 55; }

    .topbar {
        flex-wrap: wrap;
        padding: 14px 14px 16px;
        gap: 10px;
        height: auto;
        min-height: 0;
    }

    .hamburger {
        display: inline-flex;
        order: 1;
        flex: 0 0 auto;
    }
    .topbar-logo {
        display: inline-flex;
        order: 2;
        flex: 1 1 auto;
        justify-content: center;
        width: auto;
        height: 28px;
        min-width: 0;
    }
    .topbar-logo .logo-icon { display: none; }
    .topbar-logo .logo-wide {
        display: block;
        height: 100%;
        max-height: 28px;
        width: auto;
        object-fit: contain;
    }
    .bell-wrap {
        order: 3;
        flex: 0 0 auto;
    }

    .topbar-divider {
        display: block;
        order: 4;
        flex: 1 1 100%;
        min-width: 100%;
        height: 1px;
        background: var(--line);
        margin: 8px -14px 4px;
    }

    .topbar-titles {
        order: 5;
        flex: 1 1 auto;
        min-width: 0;
        padding: 0;
    }
    .topbar h1 { font-size: 24px; }
    .topbar .crumbs { font-size: 12px; margin-top: 2px; }

    .topbar-actions {
        order: 6;
        flex: 0 0 auto;
        align-self: center;
        gap: 6px;
        justify-content: flex-end;
        flex-wrap: wrap;
    }
    .topbar-actions:empty { display: none; }
    .topbar-actions .btn {
        padding: 9px 14px;
        font-size: 13px;
        max-width: 100%;
    }

    body[data-active="powiadomienia"] .topbar-titles { flex: 1 1 100%; min-width: 100%; }
    body[data-active="powiadomienia"] .topbar-actions {
        flex: 1 1 100%;
        min-width: 100%;
        justify-content: flex-start;
    }
    body[data-active="powiadomienia"] .topbar-actions .btn { flex: 1 1 auto; justify-content: center; }

    .bell-wrap { position: relative; }
    .bell-dropdown {
        position: fixed !important;
        top: 60px !important;
        right: 8px !important;
        left: 8px !important;
        width: auto !important;
        max-height: 70dvh;
    }

    .content { padding: 16px 14px 60px; }

    .card { max-width: 100% !important; width: 100%; min-width: 0; }
    .card-body { min-width: 0; overflow-x: hidden; }

    .kpis {
        gap: 10px;
        grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
    }
    .kpis > .kpi { min-width: 0; }
    .kpi .label,
    .kpi .value { min-width: 0; overflow-wrap: break-word; }

    .lead-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
    .lead-grid > * { min-width: 0; max-width: 100%; }

    .filters {
        padding: 12px 14px;
        gap: 8px;
        grid-template-columns: 1fr 1fr;
    }

    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }
    table.data { min-width: 0; }

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

@media (max-width: 720px) {

    .topbar { padding: 12px 12px 14px; }
    .topbar h1 { font-size: 22px; }
    .topbar-divider { margin-left: -12px; margin-right: -12px; }

    .content { padding: 14px 12px 60px; }

    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .kpi { padding: 12px; }
    .kpi .value { font-size: 22px; }
    .kpi .label { font-size: 10px; }

    .filters { grid-template-columns: 1fr; gap: 8px; padding: 10px 12px; }

    .form-grid { grid-template-columns: 1fr; }

    .detail-row {
        grid-template-columns: 1fr;
        gap: 2px;
        padding: 8px 0;
    }
    .detail-row .key { font-size: 11px; }
    .detail-row .val { font-size: 14px; }

    .card-head {
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px 14px;
    }
    .card-head h2 { font-size: 15px; }
    .card-body { padding: 14px; }

    .card-body-chart { padding: 10px 6px 12px; }

    .modal-backdrop { padding: 8px; }
    .modal {
        max-width: 100%;
        width: 100%;
        max-height: calc(100dvh - 16px);
        display: flex;
        flex-direction: column;
    }
    .modal-body { flex: 1 1 auto; overflow-y: auto; padding: 16px; max-height: none; }
    .modal-head { padding: 14px 16px; }
    .modal-foot {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: stretch;
    }
    .modal-foot .btn {
        flex: 1 1 calc(50% - 4px);
        justify-content: center;
        min-width: 100px;
    }

    .notif-row { grid-template-columns: 1fr; padding: 12px 14px; gap: 8px; }
    .notif-row .notif-actions { justify-content: stretch; gap: 6px; }
    .notif-row .notif-actions .btn { flex: 1 1 calc(50% - 4px); justify-content: center; }

    .btn { min-height: 38px; }
    .btn-sm { min-height: 32px; }
    .input, .select, textarea { padding: 11px 12px; font-size: 14px; }

    .settings-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
    }
    .settings-tab { flex-shrink: 0; padding: 10px 14px; }

    .notif-tabs {
        flex-wrap: nowrap;
        gap: 4px;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .notif-tab {
        flex: 1 1 0;
        min-width: 0;
        justify-content: center;
        padding: 8px 8px;
        font-size: 12px;
        white-space: nowrap;
    }
    .notif-tab .tab-count {
        padding: 1px 6px;
        font-size: 10px;
        min-width: 18px;
    }

    .pipeline-stepper {
        padding: 6px 0;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
    }
    .pipeline-stepper .ps-step { flex: 0 0 auto; min-width: 80px; }
    .pipeline-stepper .ps-label { font-size: 10px; max-width: 76px; }

    .vehicle-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        padding: 8px 14px 0;
    }
    .vehicle-tabs .vt, .vehicle-tabs .vt-add { flex-shrink: 0; }

    table.prefs-table { font-size: 12px; }
    table.prefs-table th, table.prefs-table td { padding: 8px 6px; }

    #myPrefsBox,
    #globalBox,
    #escalationsBox {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    #escalationsBox table.prefs-table { min-width: 760px; }
    #globalBox table.prefs-global { min-width: 900px; }
    #escalationsBox .input.input-narrow { width: 64px; }
    #escalationsBox td.right { white-space: nowrap; }
    #escalationsBox td.right .btn { padding: 6px 10px; }

    .pager { gap: 4px; padding: 10px; flex-wrap: wrap; }
    .pager button { min-width: 32px; height: 32px; font-size: 12px; }
}

@media (max-width: 480px) {
    .topbar { padding: 10px 10px 12px; gap: 8px; }
    .topbar h1 { font-size: 20px; }
    .topbar-logo { height: 24px; }
    .topbar-logo .logo-wide { max-height: 24px; }
    .topbar-divider { margin-left: -10px; margin-right: -10px; }
    .hamburger { width: 38px; height: 38px; }
    .topbar-actions .btn {
        padding: 9px 12px;
        font-size: 12px;
    }

    .content { padding: 12px 10px 60px; }
    .kpis { grid-template-columns: 1fr; }
    .card-body { padding: 12px; }
    .card-head { padding: 10px 12px; }
    .login-card { padding: 22px 18px; margin: 12px; }
    .bell-btn { width: 36px; height: 36px; }
}

@media (max-width: 720px) {
    .cal-toolbar { display: grid; grid-template-columns: 1fr; gap: 8px; }
    .cal-toolbar .left,
    .cal-toolbar .right { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
    .cal-toolbar .left .cal-title { flex: 1 1 100%; order: 99; font-size: 16px; }
    .cal-toolbar .right .cal-viewswitch { width: 100%; display: flex; }
    .cal-toolbar .right .cal-viewswitch .cal-view-btn { flex: 1 1 33%; min-width: 0; }
    .cal-toolbar .right #calScope,
    .cal-toolbar .right select {
        flex: 1 1 100%;
        width: 100% !important;
        min-width: 0 !important;
    }
    .cal-toolbar .right #calNewTask { flex: 1 1 100%; justify-content: center; }

    .cal-headrow > div { font-size: 9px; padding: 6px 4px; }
    .cal-grid { grid-auto-rows: minmax(60px, auto); }
    .cal-day { padding: 4px 3px; }
    .cal-day-num { font-size: 11px; }
    .cal-task { font-size: 9px; padding: 1px 3px; }
    .cal-task .cal-task-time { display: none; }

    .cal-day-cell { min-height: 60px; padding: 4px; }
    .cal-day-cell .cal-task {
        font-size: 13px;
        font-weight: 600;
        padding: 7px 9px;
        margin-bottom: 4px;
        white-space: normal;
        line-height: 1.3;
        border-left-width: 4px;
        border-radius: 6px;
        min-height: 32px;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 4px 6px;
    }
    .cal-day-cell .cal-task .cal-task-time {
        display: inline-block;
        font-size: 11px;
        font-weight: 700;
    }

    .cal-week-cell { min-height: 48px; padding: 3px; }
    .cal-week-cell .cal-task {
        font-size: 11px;
        font-weight: 600;
        padding: 4px 6px;
        margin-bottom: 3px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.25;
        border-left-width: 3px;
        border-radius: 4px;
        display: block;
    }
    .cal-week-cell .cal-task .cal-task-time {
        display: inline;
        font-size: 10px;
        font-weight: 700;
        margin-right: 4px;
    }

    .cal-week-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .cal-week-grid { min-width: 640px; }
}

@media (max-width: 720px) {
    #changeStatus { width: 100% !important; padding: 10px 12px !important; }
    .lead-grid > div { min-width: 0; width: 100%; }
    #btnConvertCustomer, #btnRevertLead { width: 100%; justify-content: center; }
}

.filters-toggle,
.filters-toggle .ft-label,
.filters-toggle .ft-icon,
.filters-toggle .ft-count,
.filters-toggle .ft-chev {
    display: none !important;
}

@media (max-width: 720px) {
    .filters-toggle {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        width: 100%;
        padding: 12px 16px;
        background: var(--card);
        border: 1px solid var(--line);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-sm);
        margin-bottom: 12px;
        font-size: 14px;
        font-weight: 600;
        color: var(--ink);
        cursor: pointer;
        transition: background var(--transition), border-color var(--transition);
    }
    .filters-toggle:hover,
    .filters-toggle:active { background: var(--gray-soft); }
    .filters-toggle .ft-label {
        display: inline-flex !important;
        align-items: center;
        gap: 10px;
    }
    .filters-toggle .ft-icon {
        display: inline-block !important;
        width: 18px; height: 18px;
        color: var(--red);
        flex-shrink: 0;
    }
    .filters-toggle .ft-count {
        display: inline-flex !important;
        background: var(--red);
        color: #fff;
        font-size: 11px;
        font-weight: 700;
        padding: 2px 8px;
        border-radius: 999px;
        min-width: 22px;
        text-align: center;
    }
    .filters-toggle .ft-count[hidden] { display: none !important; }
    .filters-toggle .ft-chev {
        display: inline-block !important;
        width: 16px; height: 16px;
        color: var(--muted);
        transition: transform 0.2s ease;
        flex-shrink: 0;
    }
    .filters-toggle[aria-expanded="true"] .ft-chev { transform: rotate(180deg); }
    .filters-toggle[aria-expanded="true"] {
        border-color: var(--red);
        color: var(--red);
    }

    .filters[data-filters-content] {
        display: none;
        margin-top: -4px;
        margin-bottom: 12px;
        animation: filtersSlide 0.2s ease;
    }
    .filters[data-filters-content].is-open { display: grid; }
}

@keyframes filtersSlide {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (hover: none) and (pointer: coarse) {
    .input,
    .select,
    textarea,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"],
    input[type="search"],
    input[type="number"],
    input[type="date"],
    input[type="time"],
    input[type="datetime-local"],
    input[type="url"],
    select {
        font-size: 16px !important;
    }
}

