/* ============================================================
   Visit Checker — визуален език
   Тъмно меню, светло съдържание, лилав акцент.
   ============================================================ */

:root {
    color-scheme: light;

    /* меню */
    --nav: #101528;
    --nav-2: #161C33;
    --nav-text: #8A93AD;
    --nav-text-hover: #CBD2E4;

    /* акцент */
    --accent: #6D4AFF;
    --accent-2: #8B5CF6;
    --accent-soft: #F1EDFF;
    --accent-line: #DDD2FF;

    /* основа */
    --ground: #F4F5FA;
    --card: #FFFFFF;
    --line: #ECEEF4;
    --line-2: #F5F6FA;
    --cal-line: #DFE3EC;

    /* текст */
    --ink: #141A2E;
    --ink-2: #5A6381;
    --ink-3: #919AB4;

    /* състояния */
    --blue: #4F6EF7;   --blue-bg: #EDF1FE;
    --green: #12B76A;  --green-bg: #E7F8F0;  --green-ink: #04734A;
    --amber: #F59E0B;  --amber-bg: #FEF5E6;  --amber-ink: #8A5A06;
    --red: #F04438;    --red-bg: #FEECEB;    --red-ink: #A8271C;
    --violet: #8B5CF6; --violet-bg: #F3EEFF;

    --shadow-sm: 0 1px 2px rgba(20, 26, 46, .04);
    --shadow: 0 1px 2px rgba(20, 26, 46, .04), 0 6px 20px -8px rgba(20, 26, 46, .10);
    --shadow-lg: 0 20px 60px -20px rgba(20, 26, 46, .30);

    --r: 16px;
    --r-md: 11px;
    --r-sm: 8px;

    --nav-w: 244px;
    --ease: 180ms cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--ground);
    color: var(--ink);
    font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system,
                 "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.015em; }
p { margin: 0; }
svg { flex: none; }
.muted { color: var(--ink-3); }
.center { text-align: center; }
.num, td, th { font-variant-numeric: tabular-nums; }

::selection { background: var(--accent-soft); }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ── Каркас ────────────────────────────────────────────── */

.app {
    display: grid;
    grid-template-columns: var(--nav-w) minmax(0, 1fr);
    min-height: 100vh;
    max-width: 100%;
    overflow-x: clip;
}

.shell { display: flex; flex-direction: column; min-width: 0; }

/* ── Меню ──────────────────────────────────────────────── */

.nav {
    background: var(--nav);
    display: flex;
    flex-direction: column;
    padding: 22px 0 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

/* ── Снимка за фон на менюто (по избор) ────────────────────
   Слага се в static/img/sidebar.jpg и се хваща автоматично.
   Отгоре ляга плътна завеса, за да остане менюто четимо;
   към дъното тя изсветлява и снимката се показва.          */

.nav.has-photo { position: sticky; }

.nav.has-photo::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: var(--nav-photo);
    background-size: cover;
    background-position: center bottom;
    z-index: 0;
}

.nav.has-photo::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        rgba(13, 17, 34, .96) 0%,
        rgba(13, 17, 34, .94) 27%,
        rgba(13, 17, 34, .78) 40%,
        rgba(13, 17, 34, .48) 55%,
        rgba(13, 17, 34, .24) 74%,
        rgba(13, 17, 34, .14) 100%);
    z-index: 1;
    pointer-events: none;
}

/* Съдържанието стои над завесата */
.nav.has-photo > * { position: relative; z-index: 2; }

/* Менюто получава лека собствена сянка, за да не се слива със снимката */
.nav.has-photo .nav-item { text-shadow: 0 1px 2px rgba(0, 0, 0, .5); }
.nav.has-photo .brand-text b { text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
.nav.has-photo .nav-item:hover { background: rgba(32, 40, 66, .85); }
/* Долният надпис ляга върху най-светлата част на снимката —
   получава собствена завеса, за да остане четим. */
.nav.has-photo .nav-foot {
    margin-top: auto;
    padding-top: 26px;
    padding-bottom: 20px;
    color: #A8B2CC;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .85);
    background: linear-gradient(180deg,
        rgba(13, 17, 34, 0) 0%,
        rgba(13, 17, 34, .72) 55%,
        rgba(13, 17, 34, .88) 100%);
}

/* Тънка линия, която отделя менюто от снимката */
.nav.has-photo .nav-list { padding-bottom: 20px; }

.brand { display: flex; align-items: center; gap: 11px; padding: 0 22px 26px; }

.mark {
    width: 34px; height: 34px; border-radius: 9px; flex: none;
    background: linear-gradient(145deg, var(--accent), var(--accent-2));
    display: grid; place-items: center;
}

.brand-text b { color: #fff; font-size: 16.5px; display: block; line-height: 1.2; }
.brand-text > span {
    color: var(--nav-text); font-size: 9.5px;
    letter-spacing: .14em; text-transform: uppercase;
}

.nav-list { display: flex; flex-direction: column; gap: 3px; padding: 0 12px; }

.nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px; border-radius: 9px;
    color: var(--nav-text); text-decoration: none;
    font-size: 14px; font-weight: 500;
    transition: background var(--ease), color var(--ease);
}

.nav-item svg { width: 17px; height: 17px; opacity: .9; }
.nav-item:hover { background: var(--nav-2); color: var(--nav-text-hover); }

.nav-item.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    box-shadow: 0 6px 16px -6px rgba(109, 74, 255, .7);
}

.nav-art { margin-top: auto; padding: 18px; }
.nav-art svg { display: block; border-radius: 12px; }
.nav-foot { padding: 0 22px 20px; color: #4E5670; font-size: 11px; line-height: 1.6; }

/* ── Горна лента ───────────────────────────────────────── */

.top {
    display: flex; align-items: center; gap: 14px;
    padding: 18px 26px;
    position: sticky; top: 0; z-index: 40;
    background: var(--ground);
}

.hamburger {
    display: none;
    width: 38px; height: 38px; border-radius: var(--r-md);
    background: var(--card); border: 1px solid var(--line);
    flex-direction: column; justify-content: center; align-items: center; gap: 4px;
    cursor: pointer; padding: 0;
}
.hamburger span {
    display: block; width: 16px; height: 1.8px; border-radius: 2px;
    background: var(--ink-2); transition: transform var(--ease), opacity var(--ease);
}
.hamburger.active span:nth-child(1) { transform: translateY(5.8px) rotate(45deg); }
.hamburger.active span:nth-child(2) { opacity: 0; }
.hamburger.active span:nth-child(3) { transform: translateY(-5.8px) rotate(-45deg); }

/* Падащо меню със служители в горната лента */
.picker {
    flex: 1; max-width: 320px;
    display: flex; align-items: center; gap: 9px;
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--r-md); padding: 8px 12px; color: var(--ink-3);
    transition: border-color var(--ease), box-shadow var(--ease);
    cursor: pointer;
}
.picker:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(109, 74, 255, .12);
}
.picker select {
    border: 0; outline: 0; background: transparent; flex: 1; min-width: 0;
    font: inherit; font-weight: 550; color: var(--ink); cursor: pointer;
}
.picker select:disabled { color: var(--ink-3); cursor: default; }

/* Стрелки за бързо местене на периода */
.period-step {
    width: 26px; height: 26px; flex: none;
    display: grid; place-items: center;
    background: transparent; border: 1px solid transparent;
    border-radius: 7px; color: var(--ink-2); cursor: pointer; padding: 0;
    transition: background var(--ease), color var(--ease);
}
.period-step svg { width: 15px; height: 15px; }
.period-step:hover:not(:disabled) { background: var(--ground); color: var(--ink); }
.period-step:disabled { color: #CBD2E0; cursor: default; }
.period-step:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.kbd {
    font-size: 11px; color: var(--ink-3); background: var(--ground);
    border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; white-space: nowrap;
}

.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.period {
    display: flex; align-items: center; gap: 6px;
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--r-md); padding: 7px 11px; color: var(--ink-2);
}
.period select {
    border: 0; outline: 0; background: transparent; font: inherit;
    font-weight: 550; color: var(--ink); cursor: pointer; padding: 2px 2px;
    max-width: 120px;
}

/* ── Бутони ────────────────────────────────────────────── */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    border: 1px solid transparent; border-radius: var(--r-md);
    padding: 9px 15px; font: inherit; font-weight: 600; font-size: 13.5px;
    cursor: pointer; white-space: nowrap;
    transition: background var(--ease), border-color var(--ease), color var(--ease),
                box-shadow var(--ease), transform var(--ease);
}
.btn:active { transform: translateY(1px); }

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff; box-shadow: 0 6px 16px -8px rgba(109, 74, 255, .9);
}
.btn-primary:hover { filter: brightness(1.06); }

.btn-secondary { background: var(--card); border-color: var(--line); color: var(--ink-2); }
.btn-secondary:hover { border-color: #D9DEE9; color: var(--ink); }

.btn-danger { background: var(--card); border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }

.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }

/* ── Съдържание ────────────────────────────────────────── */

.main { padding: 0 26px 34px; display: flex; flex-direction: column; gap: 18px; }

.page { display: flex; flex-direction: column; gap: 18px; }

.page-head h1 { font-size: 22px; letter-spacing: -.025em; }
.page-head p { color: var(--ink-3); font-size: 13.5px; margin-top: 2px; }

/* ── Карти ─────────────────────────────────────────────── */

.card {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--r); box-shadow: var(--shadow);
}

.card-head {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.card-head h2 {
    font-size: 15.5px; display: flex; align-items: center; gap: 9px;
}
.card-head h2 svg { width: 17px; height: 17px; }

.card-body { padding: 18px 20px; }
.chart-box { height: 290px; position: relative; }
.chart-box canvas { max-height: 100%; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 18px; align-items: start; }

/* ── KPI ───────────────────────────────────────────────── */

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }

.kpi {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--r); box-shadow: var(--shadow);
    padding: 16px 17px; display: flex; flex-direction: column; gap: 11px;
}

.kpi-top { display: flex; align-items: flex-start; gap: 11px; }

.tile {
    width: 40px; height: 40px; border-radius: var(--r-md);
    display: grid; place-items: center; flex: none;
}
.tile svg { width: 19px; height: 19px; }
.tile-blue   { background: var(--blue-bg);   color: var(--blue); }
.tile-green  { background: var(--green-bg);  color: var(--green); }
.tile-amber  { background: var(--amber-bg);  color: var(--amber); }
.tile-red    { background: var(--red-bg);    color: var(--red); }
.tile-violet { background: var(--violet-bg); color: var(--violet); }

.kpi-l { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.kpi-v {
    font-size: 27px; font-weight: 700; letter-spacing: -.03em;
    line-height: 1.15; margin-top: 1px; font-variant-numeric: tabular-nums;
}
.kpi-n { font-size: 11.5px; color: var(--ink-3); min-height: 17px; }
.kpi-n b { font-weight: 600; color: var(--ink-2); }

.bar { height: 4px; border-radius: 99px; background: var(--line-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; width: 0; transition: width 420ms var(--ease); }

/* ── Таблици ───────────────────────────────────────────── */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -20px; padding: 0 20px; }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.table th {
    text-align: left; font-size: 11px; font-weight: 600; color: var(--ink-3);
    text-transform: uppercase; letter-spacing: .07em;
    padding: 0 14px 11px; white-space: nowrap;
    border-bottom: 1px solid var(--line);
}

.table td {
    padding: 11px 14px; border-bottom: 1px solid var(--line-2);
    vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--ground); }
.table td.strong { font-weight: 650; }

.table tfoot td {
    padding: 13px 14px; border-top: 2px solid var(--line);
    background: var(--ground); font-weight: 650;
}

/* ── Значки ────────────────────────────────────────────── */

.badge {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11.5px; font-weight: 600; padding: 3px 9px;
    border-radius: 99px; white-space: nowrap;
}
.badge-green  { background: var(--green-bg);  color: var(--green-ink); }
.badge-amber  { background: var(--amber-bg);  color: var(--amber-ink); }
.badge-red    { background: var(--red-bg);    color: var(--red-ink); }
.badge-blue   { background: var(--blue-bg);   color: #2B49C9; }
.badge-grey   { background: var(--ground);    color: var(--ink-3); }
.badge-violet { background: var(--violet-bg); color: #5B36C9; }

.dot { width: 7px; height: 7px; border-radius: 99px; flex: none; display: inline-block; }
.dot-green { background: var(--green); }
.dot-amber { background: var(--amber); }
.dot-red   { background: var(--red); }
.dot-grey  { background: #D4D9E6; }

/* ── Инициали ──────────────────────────────────────────── */

.ini {
    width: 36px; height: 36px; border-radius: 10px; flex: none;
    display: grid; place-items: center;
    background: var(--accent-soft); color: var(--accent);
    font-size: 12.5px; font-weight: 650;
}
.ini-lg { width: 54px; height: 54px; border-radius: 14px; font-size: 17px; }

/* ── Служители ─────────────────────────────────────────── */

.employees-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(236px, 1fr)); gap: 14px;
}

.emp-card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
    box-shadow: var(--shadow); padding: 18px; cursor: pointer;
    transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease);
}
.emp-card:hover {
    border-color: var(--accent-line);
    box-shadow: 0 10px 28px -12px rgba(109, 74, 255, .3);
    transform: translateY(-2px);
}
.emp-head { display: flex; align-items: center; gap: 12px; margin-bottom: 15px; }
.emp-name { font-size: 14.5px; font-weight: 650; line-height: 1.3; }
.emp-code { font-size: 11.5px; color: var(--ink-3); }
.emp-stats {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
    padding-top: 14px; border-top: 1px solid var(--line-2);
}
.emp-stat { text-align: center; }
.emp-stat b { display: block; font-size: 16px; font-weight: 700; letter-spacing: -.02em; }
.emp-stat span { font-size: 10.5px; color: var(--ink-3); }

/* ── Активност ─────────────────────────────────────────── */

.activity-list { display: flex; flex-direction: column; max-height: 290px; overflow-y: auto; }
.activity-item {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 0; border-bottom: 1px solid var(--line-2);
}
.activity-item:last-child { border-bottom: 0; }
.activity-name { font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.activity-detail { font-size: 11.5px; color: var(--ink-3); }
.activity-time { margin-left: auto; text-align: right; font-size: 12.5px; font-weight: 600; }
.activity-time span { display: block; font-size: 10.5px; color: var(--ink-3); font-weight: 400; }

/* ── Сегменти и табове ─────────────────────────────────── */

.seg {
    display: inline-flex; background: var(--card); border: 1px solid var(--line);
    border-radius: var(--r-md); padding: 3px; gap: 2px; align-self: flex-start;
}
.seg .tab {
    border: 0; background: transparent; font: inherit; font-size: 13px; font-weight: 550;
    color: var(--ink-2); padding: 7px 15px; border-radius: var(--r-sm); cursor: pointer;
    transition: background var(--ease), color var(--ease);
}
.seg .tab:hover { color: var(--ink); }
.seg .tab.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff; box-shadow: 0 4px 12px -6px rgba(109, 74, 255, .8);
}

/* ── Ленти с филтри ────────────────────────────────────── */

.report-toolbar, .calendar-toolbar {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--r-md); padding: 11px 15px;
}
.filter-group { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.filter-group label { font-size: 12.5px; color: var(--ink-2); font-weight: 550; }

.filter-group select, .filter-group input[type="date"], .input {
    font: inherit; font-size: 13.5px; color: var(--ink);
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--r-sm); padding: 7px 10px; outline: 0;
    transition: border-color var(--ease), box-shadow var(--ease);
}
.filter-group select:focus, .filter-group input:focus, .input:focus {
    border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109, 74, 255, .12);
}
.toolbar-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.filter-chip {
    display: flex; align-items: center; gap: 11px; margin-left: auto;
    font-size: 13px; color: var(--ink-2);
}
.filter-chip strong { color: var(--ink); }
.filter-chip button {
    background: var(--card); border: 1px solid var(--accent); color: var(--accent);
    border-radius: var(--r-sm); padding: 5px 11px; font: inherit;
    font-size: 12px; font-weight: 600; cursor: pointer;
}
.filter-chip button:hover { background: var(--accent); color: #fff; }

/* ── Форми ─────────────────────────────────────────────── */

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12.5px; font-weight: 550; color: var(--ink-2); }
.form-group small { font-size: 11.5px; color: var(--ink-3); }
.form-group .input { max-width: 220px; }
#settingsResult:not(:empty), #syncResult:not(:empty) { margin: 16px 0; }
#saveSettingsBtn { margin-top: 18px; }

/* ── Модали ────────────────────────────────────────────── */

.modal-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(16, 21, 40, .45); backdrop-filter: blur(3px);
    display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.active { display: flex; }

.modal {
    background: var(--card); border-radius: 18px; box-shadow: var(--shadow-lg);
    width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
    animation: pop 200ms cubic-bezier(.2, .9, .3, 1.2);
}
.modal-lg { max-width: 940px; }

@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.98); } }
@media (prefers-reduced-motion: reduce) { .modal { animation: none; } }

.modal-header {
    display: flex; align-items: center; gap: 14px;
    padding: 18px 22px; border-bottom: 1px solid var(--line);
    position: sticky; top: 0; background: var(--card); z-index: 1;
    border-radius: 18px 18px 0 0;
}
.modal-header h2 { font-size: 16.5px; }
.modal-close {
    margin-left: auto; width: 32px; height: 32px; border-radius: var(--r-sm);
    border: 1px solid var(--line); background: var(--card);
    color: var(--ink-3); font-size: 20px; line-height: 1; cursor: pointer;
}
.modal-close:hover { background: var(--ground); color: var(--ink); }
.modal-body { padding: 20px 22px 24px; }

/* ── Качване ───────────────────────────────────────────── */

.dropzone {
    border: 2px dashed var(--line); border-radius: var(--r);
    padding: 36px 20px; text-align: center; cursor: pointer;
    transition: border-color var(--ease), background var(--ease);
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone-icon {
    width: 52px; height: 52px; border-radius: 14px; margin: 0 auto 14px;
    display: grid; place-items: center; background: var(--accent-soft); color: var(--accent);
}
.dropzone-title { font-size: 15px; font-weight: 650; }
.dropzone-sub { font-size: 13px; color: var(--ink-2); margin-top: 3px; }
.dropzone-hint { font-size: 11.5px; color: var(--ink-3); margin-top: 10px; }

.progress-bar { height: 7px; border-radius: 99px; background: var(--line-2); overflow: hidden; }
.progress-fill {
    height: 100%; width: 0; border-radius: 99px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    transition: width 200ms var(--ease);
}
.upload-status { text-align: center; font-size: 13px; color: var(--ink-2); margin-top: 12px; }

.upload-summary, .upload-error { text-align: center; }
.result-icon {
    width: 50px; height: 50px; border-radius: 99px; margin: 0 auto 14px;
    display: grid; place-items: center;
}
.result-icon.ok { background: var(--green-bg); color: var(--green); }
.result-icon.bad { background: var(--red-bg); color: var(--red); }
.upload-summary h3, .upload-error h3 { font-size: 16px; margin-bottom: 16px; }
.upload-error p { color: var(--ink-2); font-size: 13.5px; margin-bottom: 18px; }

.summary-stats {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
    margin-bottom: 20px; text-align: left;
}
.summary-stat { background: var(--ground); border-radius: var(--r-md); padding: 11px 13px; }
.summary-stat-label { font-size: 11.5px; color: var(--ink-3); }
.summary-stat-value { font-size: 17px; font-weight: 700; letter-spacing: -.02em; }

/* ── Обобщаващи карти ──────────────────────────────────── */

.summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.summary-card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
    box-shadow: var(--shadow-sm); padding: 15px 17px;
}
.summary-card-value { font-size: 22px; font-weight: 700; letter-spacing: -.025em; }
.summary-card-label { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }

/* ── Сесии в детайла за ден ────────────────────────────── */

.session-row > td { background: var(--ground) !important; padding: 0 !important; }
.session-list { padding: 12px 16px 12px 42px; display: flex; flex-direction: column; }
.session-item {
    display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 12px;
    padding: 7px 0; font-size: 13px; border-bottom: 1px solid var(--line);
}
.session-item:last-child { border-bottom: 0; }
.session-index { font-size: 11px; color: var(--ink-3); text-align: center; }
.session-times { font-variant-numeric: tabular-nums; }
.session-times em { color: var(--ink-3); font-style: normal; font-size: 11.5px; }
.session-duration { font-variant-numeric: tabular-nums; font-weight: 650; }
.session-total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 9px; font-weight: 650; }
.session-total .session-times { color: var(--ink-2); }
.session-orphan .session-times { color: var(--amber-ink); }
.session-orphan .session-times em { color: var(--amber-ink); font-weight: 700; opacity: .7; }
.session-orphan .session-index { color: var(--amber-ink); }
.session-note {
    margin-top: 9px; font-size: 12px; color: var(--ink-3); line-height: 1.5;
}

/* ── Детайл за служител ────────────────────────────────── */

.emp-detail-head { display: flex; align-items: center; gap: 15px; margin-bottom: 20px; flex-wrap: wrap; }
.emp-detail-head h3 { font-size: 18px; }
.emp-detail-stats {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px; margin-bottom: 20px;
}
.detail-stat { background: var(--ground); border-radius: var(--r-md); padding: 13px 15px; }
.detail-stat b { display: block; font-size: 20px; font-weight: 700; letter-spacing: -.025em; }
.detail-stat span { font-size: 11.5px; color: var(--ink-3); }

/* ── Работен календар в настройки ──────────────────────── */

.workdays-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 11px; }
.workday-card {
    background: var(--ground); border-radius: var(--r-md); padding: 13px; text-align: center;
}
.workday-card h4 { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.workday-value { font-size: 21px; font-weight: 700; letter-spacing: -.025em; margin: 3px 0 1px; }
.workday-hours { font-size: 11px; color: var(--ink-3); }

/* ── Лента за данните ──────────────────────────────────── */

.data-banner {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--r-md); padding: 11px 16px; font-size: 13px;
}
.data-banner[hidden] { display: none !important; }
.data-banner.loaded { background: var(--green-bg); border-color: #B7E8CE; }
.data-banner.idle { background: var(--amber-bg); border-color: #F7DFB0; }
.data-banner-icon { display: grid; place-items: center; }
.data-banner-text strong { font-weight: 650; }
.data-banner-hint { color: var(--ink-3); font-size: 11.5px; }
.data-banner-actions { margin-left: auto; display: flex; gap: 8px; }
.data-banner button {
    background: var(--card); border: 1px solid var(--line); color: var(--ink-2);
    border-radius: var(--r-sm); padding: 5px 11px; font: inherit;
    font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.data-banner button:hover { border-color: #D9DEE9; color: var(--ink); }
.data-banner button.danger { border-color: var(--red); color: var(--red); }
.data-banner button.danger:hover { background: var(--red); color: #fff; }

/* ── Съобщения ─────────────────────────────────────────── */

.sync-note { border-radius: var(--r-md); padding: 14px 17px; font-size: 13px; border: 1px solid transparent; }
.sync-note p { margin: 0 0 10px; }
.sync-note p:last-child { margin-bottom: 0; }
.sync-ok { background: var(--green-bg); border-color: #B7E8CE; color: var(--green-ink); }
.sync-warn { background: var(--amber-bg); border-color: #F7DFB0; color: var(--ink); }
.sync-error { background: var(--red-bg); border-color: #F8C9C4; color: var(--red-ink); }
.sync-note .table { margin-top: 12px; }

/* ── Празни състояния ──────────────────────────────────── */

.empty-state { text-align: center; padding: 40px 20px; }
.empty-icon {
    width: 54px; height: 54px; border-radius: 16px; margin: 0 auto 14px;
    display: grid; place-items: center; background: var(--ground); color: var(--ink-3);
}
.empty-state h3 { font-size: 15.5px; color: var(--ink-2); margin-bottom: 5px; }
.empty-state p { font-size: 13px; color: var(--ink-3); line-height: 1.6; }
.empty-state .btn { margin-top: 16px; }

/* ── Въртележка ────────────────────────────────────────── */

.spinner {
    width: 26px; height: 26px; margin: 34px auto; border-radius: 99px;
    border: 2.5px solid var(--line); border-top-color: var(--accent);
    animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }

/* ── Завеса за менюто на телефон ───────────────────────── */

.nav-overlay {
    display: none; position: fixed; inset: 0; z-index: 90;
    background: rgba(16, 21, 40, .4);
}
.nav-overlay.active { display: block; }

/* ── Отзивчивост ───────────────────────────────────────── */

@media (max-width: 1180px) {
    .grid-2 { grid-template-columns: minmax(0, 1fr); }
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 920px) {
    .app { grid-template-columns: minmax(0, 1fr); }
    /* горната лента се пренарежда, вместо да избутва страницата */
    .top { flex-wrap: wrap; }
    .picker { order: 3; flex-basis: 100%; max-width: none; min-width: 0; }
    .top-right { margin-left: auto; min-width: 0; }
    .period { min-width: 0; }
    .period select { min-width: 0; }
    .nav {
        position: fixed; top: 0; left: 0; bottom: 0; width: var(--nav-w);
        z-index: 100; transform: translateX(-100%);
        transition: transform 240ms var(--ease);
    }
    .nav.open { transform: none; }
    .hamburger { display: flex; }
    .picker { max-width: none; }
    .kbd { display: none; }
    .top { padding: 14px 16px; gap: 10px; }
    .main { padding: 0 16px 28px; }
    .btn-label { display: none; }
    .top-right .btn { padding: 9px 11px; }
    .period select { max-width: 92px; font-size: 13px; }
}

@media (max-width: 560px) {
    .kpis { grid-template-columns: minmax(0, 1fr); }
    .table-wrap { margin: 0 -16px; padding: 0 16px; }
    .card-body { padding: 15px 16px; }
    .card-head { padding: 14px 16px; }
    .toolbar-actions { margin-left: 0; width: 100%; }
    .data-banner-actions { margin-left: 0; width: 100%; }
    .data-banner-hint { display: none; }
    .summary-stats { grid-template-columns: 1fr; }
    .filter-chip { margin-left: 0; width: 100%; justify-content: space-between; }
}

/* ── Печат ─────────────────────────────────────────────── */

@media print {
    .nav, .top, .seg, .report-toolbar, .calendar-toolbar, .data-banner,
    .page-head p, .nav-overlay, .toolbar-actions { display: none !important; }
    .app { grid-template-columns: 1fr; }
    .main { padding: 0; }
    .card { border: 0; box-shadow: none; }
    .table { font-size: 10pt; }
    body { background: #fff; }
}

/* Номерът на деня — горе вляво, както в макета */
.fc .fc-daygrid-day-top { flex-direction: row; }
.fc .fc-daygrid-day-top a { margin-right: auto; }

/* ── Разбивка по месец в детайла за служител ───────────── */

.month-row .month-cell { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.month-caret { color: var(--ink-3); display: grid; place-items: center; transition: transform var(--ease); }
.month-row.open .month-caret { transform: rotate(90deg); color: var(--accent); }
.month-row.open > td { background: var(--accent-soft); }
.month-row.open > td:first-child { border-radius: 8px 0 0 0; }

.month-detail > td { background: var(--ground) !important; padding: 0 !important; }
.month-detail-box { padding: 14px 16px 16px; }

.month-detail-head {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    margin-bottom: 10px; font-size: 13px;
}
.month-detail-head strong { font-size: 14px; }
.month-detail-head .btn { margin-left: auto; padding: 5px 11px; font-size: 12px; }

.table-compact { font-size: 12.5px; background: var(--card); border-radius: var(--r-md); }
.table-compact th { padding: 9px 11px; background: var(--card); }
.table-compact td { padding: 7px 11px; }
.table-compact tbody tr.is-weekend td { background: #F7F8FC; }
.table-compact .day-date { font-weight: 600; white-space: nowrap; }

.month-detail-note {
    display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
    margin-top: 11px; font-size: 12px; color: var(--amber-ink);
}

/* ── Списък с качените файлове ─────────────────────────── */

.upload-files {
    display: flex; flex-direction: column; gap: 6px;
    margin-bottom: 16px; text-align: left;
}
.upload-file {
    display: flex; align-items: center; gap: 10px;
    background: var(--green-bg); border: 1px solid #B7E8CE;
    border-radius: var(--r-sm); padding: 8px 11px; font-size: 12.5px;
}
.upload-file.bad { background: var(--red-bg); border-color: #F8C9C4; }
.upload-file-name {
    font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.upload-file-info { margin-left: auto; color: var(--ink-2); white-space: nowrap; }
.upload-file.bad .upload-file-info { color: var(--red-ink); }

/* Контейнерът вече носи собствена подредба — списък с файлове,
   после мрежата с числата. */
#uploadSummaryStats { display: block; }

.summary-stats-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; text-align: left;
}
@media (max-width: 560px) { .summary-stats-grid { grid-template-columns: 1fr; } }

/* ════════════════════════════════════════════════════════
   ЕКРАН „КАЛЕНДАР“ — премиум подредба
   ════════════════════════════════════════════════════════ */

.cal-page { gap: 16px; }

/* ── Заглавие и превключвател на изгледа ───────────────── */

.cal-head {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 16px; flex-wrap: wrap;
}
.cal-head h1 { font-size: 22px; letter-spacing: -.025em; }
.cal-head p { color: var(--ink-3); font-size: 13.5px; margin-top: 2px; }
.cal-views[hidden] { display: none !important; }

/* ── Лента с филтър и навигация ────────────────────────── */

.calendar-toolbar {
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--r); box-shadow: var(--shadow);
    padding: 12px 16px;
}

.cal-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cal-who label {
    font-size: 11px; font-weight: 650; color: var(--ink-3);
    text-transform: uppercase; letter-spacing: .08em; white-space: nowrap;
}
.cal-who select {
    font: inherit; font-size: 13.5px; font-weight: 550; color: var(--ink);
    background: var(--ground); border: 1px solid var(--line);
    border-radius: var(--r-sm); padding: 8px 11px; outline: 0; cursor: pointer;
    min-width: 190px;
    transition: border-color var(--ease), box-shadow var(--ease);
}
.cal-who select:focus {
    border-color: var(--accent); box-shadow: 0 0 0 3px rgba(109, 74, 255, .12);
}

.cal-nav {
    margin-left: auto; display: flex; align-items: center; gap: 6px;
}
.cal-step {
    width: 32px; height: 32px; flex: none; display: grid; place-items: center;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm);
    color: var(--ink-2); cursor: pointer; padding: 0;
    transition: background var(--ease), border-color var(--ease), color var(--ease);
}
.cal-step svg { width: 15px; height: 15px; }
.cal-step:hover { background: var(--ground); color: var(--ink); border-color: #D9DEE9; }

.cal-title {
    min-width: 150px; text-align: center;
    font-size: 15px; font-weight: 650; letter-spacing: -.015em;
    white-space: nowrap;
}

.cal-today {
    margin-left: 6px; background: var(--card); border: 1px solid var(--line);
    border-radius: var(--r-sm); padding: 7px 13px; font: inherit;
    font-size: 12.5px; font-weight: 600; color: var(--ink-2); cursor: pointer;
    transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.cal-today:hover { background: var(--ground); color: var(--ink); border-color: #D9DEE9; }

/* активният филтър оцветява цялата лента */
.calendar-toolbar.filtered { border-color: var(--accent-line); background: var(--accent-soft); }
.calendar-toolbar.filtered .cal-who select { background: var(--card); }

/* ── Обобщаваща редица ─────────────────────────────────── */

.stats-strip {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden;
}
.stats-strip.empty {
    padding: 18px 20px; color: var(--ink-3); font-size: 13.5px; text-align: center;
}

.stat-lead {
    display: flex; align-items: center; gap: 14px;
    padding: 16px 20px; border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, #FBFBFE 0%, var(--card) 100%);
}
.stat-lead-name { font-size: 16px; font-weight: 650; letter-spacing: -.015em; }
.stat-lead-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 1px; }
.stat-lead-icon {
    width: 40px; height: 40px; border-radius: var(--r-md); flex: none;
    display: grid; place-items: center;
    background: var(--accent-soft); color: var(--accent);
}
.stat-lead-icon svg { width: 20px; height: 20px; }

/* кръгъл индикатор за изпълнението */
.ring {
    margin-left: auto; width: 54px; height: 54px; flex: none; border-radius: 99px;
    display: grid; place-items: center; position: relative;
    background: conic-gradient(var(--ring-col) calc(var(--pct) * 1%), var(--line-2) 0);
}
.ring::before {
    content: ""; position: absolute; inset: 5px; border-radius: 99px; background: var(--card);
}
.ring span {
    position: relative; font-size: 14px; font-weight: 700; letter-spacing: -.03em;
    color: var(--ring-col); font-variant-numeric: tabular-nums;
}
.ring span small { font-size: 9px; font-weight: 600; }
.ring-ok   { --ring-col: var(--green); }
.ring-warn { --ring-col: var(--amber); }
.ring-low  { --ring-col: var(--red); }

.stat-cells {
    display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 1px; background: var(--line);
}
.stat-cell {
    background: var(--card); padding: 14px 18px;
    display: flex; flex-direction: column; gap: 2px;
}
.stat-cell .sv {
    font-size: 19px; font-weight: 700; letter-spacing: -.028em;
    font-variant-numeric: tabular-nums; line-height: 1.2;
}
.stat-cell .sv small { font-size: 13px; font-weight: 600; color: var(--ink-3); }
.stat-cell .sv.good { color: var(--green); }
.stat-cell .sv.bad  { color: var(--red); }
.stat-cell .sv.warn { color: var(--amber); }
.stat-cell .sk { font-size: 11.5px; color: var(--ink-3); }

.stat-foot {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 12px 20px; border-top: 1px solid var(--line); background: #FCFCFE;
    font-size: 12.5px;
}
.stat-warn { display: flex; align-items: center; gap: 7px; color: var(--amber-ink); }
.stat-clean { color: var(--green-ink); }
.stat-hint { color: var(--ink-3); }
.stat-foot .btn { margin-left: auto; padding: 6px 13px; font-size: 12.5px; }

/* ── Календарът ────────────────────────────────────────── */

.cal-card { overflow: hidden; }
.cal-body { padding: 18px 18px 6px; }

.fc .fc-col-header-cell { border: 0; padding: 0 0 10px; }
.fc .fc-col-header-cell-cushion {
    font-size: 10.5px; font-weight: 700; color: var(--ink-3);
    text-transform: uppercase; letter-spacing: .09em; padding: 0 8px;
}

/* всеки ден е отделна плочка */
.fc .fc-daygrid-body .fc-scrollgrid-sync-table { border-collapse: separate; border-spacing: 7px; }
.fc .fc-daygrid-body .fc-scrollgrid-sync-table td {
    border: 1px solid var(--cal-line);
    border-radius: 12px;
    background: var(--card);
    transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease);
}
.fc .fc-daygrid-day:hover {
    border-color: #BFC8DC;
    box-shadow: 0 6px 18px -8px rgba(20, 26, 46, .28);
    transform: translateY(-1px);
    cursor: pointer;
}

.fc .fc-daygrid-day-frame { padding: 9px 10px; min-height: 0 !important; height: 112px; overflow: hidden; }
.fc .fc-daygrid-day-top { flex-direction: row; }
.fc .fc-daygrid-day-top a { margin-right: auto; }
.fc .fc-daygrid-day-number {
    font-size: 13px; font-weight: 650; color: var(--ink); padding: 0;
    font-variant-numeric: tabular-nums;
}

.fc .fc-day-other { background: #FAFBFD !important; }
.fc .fc-day-other .fc-daygrid-day-number { color: #BFC6D6; }
.fc .fc-day-sat, .fc .fc-day-sun { background: #F8F9FC; }
.fc .fc-day-sat .fc-daygrid-day-number,
.fc .fc-day-sun .fc-daygrid-day-number { color: var(--ink-3); }

.fc .fc-day-today {
    background: var(--accent-soft) !important;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 1px var(--accent) inset;
}
.fc .fc-day-today .fc-daygrid-day-number { color: var(--accent); font-weight: 750; }

.fc .fc-daygrid-day.day-flagged {
    border-color: #F1A79D !important;
    background: #FFF7F6 !important;
}
.fc .fc-daygrid-day.day-flagged .fc-daygrid-day-number { color: var(--red-ink); }

/* ── Съдържание на клетката ────────────────────────────── */

.cal-summary, .cal-single { display: flex; flex-direction: column; gap: 6px; cursor: pointer; }
.cal-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.cal-chips { display: flex; flex-wrap: wrap; gap: 3px; }

.cal-count {
    display: inline-flex; align-items: center; gap: 3.5px;
    font-size: 10.5px; font-weight: 700; padding: 2px 6px; border-radius: 99px;
    font-variant-numeric: tabular-nums; line-height: 1.45;
}
.cal-count::before { content: ""; width: 4.5px; height: 4.5px; border-radius: 99px; background: currentColor; }
.cal-count-green  { background: var(--green-bg); color: var(--green-ink); }
.cal-count-yellow { background: var(--amber-bg); color: var(--amber-ink); }
.cal-count-red    { background: var(--red-bg);   color: var(--red-ink); }

.cal-flag {
    display: inline-flex; align-items: center; gap: 3px;
    font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 99px;
    font-variant-numeric: tabular-nums; line-height: 1.45;
    border: 1px solid transparent;
}
.cal-flag svg { width: 9px; height: 9px; }
.cal-flag-warn { background: var(--amber-bg); color: var(--amber-ink); border-color: #F0D49A; }
.cal-flag-bad  { background: var(--red-bg);   color: var(--red-ink);   border-color: #F3BDB6; }

/* тънка лента под чиповете */
/* Лентата стои веднага след чиповете — «margin-top: auto» я
   изтласкваше в празнината, която FullCalendar пази в клетката. */
.cal-bar {
    display: flex; height: 4px; border-radius: 99px;
    background: var(--line-2); overflow: hidden;
}
.cal-bar i { display: block; height: 100%; }
.cal-bar-green  { background: var(--green); border-radius: 99px; }
.cal-bar-yellow { background: var(--amber); border-radius: 99px; }
.cal-bar-red    { background: var(--red);   border-radius: 99px; }
.cal-bar-split .seg-green { background: var(--green); }
.cal-bar-split .seg-amber { background: var(--amber); }
.cal-bar-split .seg-red   { background: var(--red); }

/* един служител */
.cal-hours {
    font-size: 15px; font-weight: 700; letter-spacing: -.025em;
    font-variant-numeric: tabular-nums; line-height: 1.2;
}
.cal-hours-green  { color: var(--green-ink); }
.cal-hours-yellow { color: var(--amber-ink); }
.cal-hours-red    { color: var(--red-ink); }

.cal-absent {
    font-size: 10.5px; font-weight: 600; padding: 3px 8px; border-radius: 99px;
    background: #F3F5F9; color: var(--ink-3); border: 1px dashed #D4DAE6;
    display: inline-block; cursor: pointer; align-self: flex-start;
}

/* ── Легенда ───────────────────────────────────────────── */

.cal-legend {
    display: flex; flex-wrap: wrap; gap: 10px 8px;
    padding: 14px 18px; border-top: 1px solid var(--line); background: #FCFCFE;
}
.cal-legend .leg {
    display: inline-flex; align-items: center; gap: 7px;
    font-size: 11.5px; font-weight: 550; color: var(--ink-2);
    background: var(--card); border: 1px solid var(--line);
    border-radius: 99px; padding: 4px 11px 4px 9px;
}
.leg-dot { width: 7px; height: 7px; border-radius: 99px; flex: none; }
.leg-green { background: var(--green); }
.leg-amber { background: var(--amber); }
.leg-red   { background: var(--red); }
.leg-grey  { background: #C8CFDE; }
.leg-warn  { color: var(--amber); display: grid; place-items: center; }
.leg-warn svg { width: 11px; height: 11px; }

/* ── Отзивчивост ───────────────────────────────────────── */

@media (max-width: 1180px) {
    .stat-cells { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 920px) {
    .calendar-toolbar { gap: 12px; }
    .cal-who { width: 100%; }
    .cal-who select { flex: 1; min-width: 0; }
    .cal-nav { margin-left: 0; width: 100%; }
    .cal-title { flex: 1; min-width: 0; }
    .cal-head { align-items: flex-start; }
    .filter-chip { width: 100%; justify-content: space-between; margin-left: 0; }
}

@media (max-width: 560px) {
    .stat-cells { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat-lead { padding: 14px 16px; }
    .stat-cell { padding: 12px 14px; }
    .cal-body { padding: 14px 12px 4px; }
    .cal-legend { padding: 12px 14px; }
}

/* Знакът за липсващ бадж е само икона — текстът е в подсказката */
.cal-flag-icon { padding: 3px 5px; }
