/* Light (white) theme = default; dark theme overrides further below via [data-bs-theme="dark"]. */
:root {
    --crm-sidebar: #ffffff;
    --crm-sidebar-hover: #eef2ff;
    --crm-sidebar-text: #334155;
    --crm-sidebar-active-text: #3730a3;
    --crm-sidebar-brand: #111827;
    --crm-sidebar-border: #e5e7eb;
    --crm-accent: #4f46e5;
    --crm-bg: #f5f6fa;
    --crm-sidebar-width: 250px;
}

body { background: var(--crm-bg); font-size: .925rem; }
a { text-decoration: none; }

/* ---------- Layout ---------- */
.crm-sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--crm-sidebar-width); background: var(--crm-sidebar);
    color: var(--crm-sidebar-text); overflow-y: auto; z-index: 1040; transition: transform .2s ease;
    border-right: 1px solid var(--crm-sidebar-border);
}
.crm-sidebar .brand { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.25rem; color: var(--crm-sidebar-brand); font-weight: 700; font-size: 1.1rem; border-bottom: 1px solid var(--crm-sidebar-border); }
.crm-sidebar .brand .logo { color: #fff; }
.crm-sidebar .brand .logo { width: 32px; height: 32px; border-radius: 8px; background: var(--crm-accent); display: grid; place-items: center; }
.crm-sidebar .nav-section { padding: 1rem 1.25rem .35rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #64748b; }
.crm-sidebar .nav-link { color: var(--crm-sidebar-text); padding: .5rem 1.25rem; display: flex; align-items: center; gap: .65rem; border-left: 3px solid transparent; }
.crm-sidebar .nav-link:hover { background: var(--crm-sidebar-hover); color: var(--crm-sidebar-active-text); }
.crm-sidebar .nav-link.active { background: var(--crm-sidebar-hover); color: var(--crm-sidebar-active-text); border-left-color: var(--crm-accent); font-weight: 600; }
.crm-sidebar .nav-link .badge { margin-left: auto; }
.crm-main { margin-left: var(--crm-sidebar-width); min-height: 100vh; display: flex; flex-direction: column; }
.crm-topbar { background: #fff; border-bottom: 1px solid #e5e7eb; padding: .6rem 1.25rem; display: flex; align-items: center; gap: 1rem; position: sticky; top: 0; z-index: 1030; }
.crm-content { padding: 1.5rem; flex: 1; }
.crm-backdrop { display: none; }

@media (max-width: 991.98px) {
    .crm-sidebar { transform: translateX(-100%); }
    body.sidebar-open .crm-sidebar { transform: translateX(0); }
    body.sidebar-open .crm-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1035; }
    .crm-main { margin-left: 0; }
    .crm-content { padding: 1rem; }
}

/* ---------- Components ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-header h1 { font-size: 1.4rem; font-weight: 700; margin: 0; }
.page-header .subtitle { color: #6b7280; font-size: .875rem; }
.card { border: 1px solid #e5e7eb; border-radius: .75rem; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #fff; border-bottom: 1px solid #eef0f4; font-weight: 600; border-radius: .75rem .75rem 0 0 !important; }
.stat-card { padding: 1rem 1.1rem; height: 100%; }
.stat-card .label { color: #6b7280; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.stat-card .value { font-size: 1.65rem; font-weight: 700; line-height: 1.2; }
.stat-card .icon { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; font-size: 1.2rem; }
.stat-card .hint { font-size: .78rem; color: #6b7280; }
.table > :not(caption) > * > * { padding: .6rem .75rem; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: #6b7280; background: #f9fafb; white-space: nowrap; }
.table-card .table { margin-bottom: 0; }
.filter-bar { background: #fff; border: 1px solid #e5e7eb; border-radius: .75rem; padding: .85rem; margin-bottom: 1rem; }
.filter-bar .form-control, .filter-bar .form-select { font-size: .85rem; }
.empty-state { text-align: center; padding: 3rem 1rem; color: #6b7280; }
.empty-state i { font-size: 2.5rem; display: block; margin-bottom: .5rem; color: #cbd5e1; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 1rem 1.4rem; border-left: 2px solid #e5e7eb; margin-left: .4rem; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: .25rem; width: 10px; height: 10px; border-radius: 50%; background: var(--crm-accent); }
.timeline li:last-child { padding-bottom: 0; }
.timeline .meta { font-size: .78rem; color: #6b7280; }
.dl-grid { display: grid; grid-template-columns: 140px 1fr; gap: .4rem .75rem; margin: 0; }
.dl-grid dt { color: #6b7280; font-weight: 500; }
.dl-grid dd { margin: 0; word-break: break-word; }
.source-badge-manual { background: #e0e7ff; color: #3730a3; }
.source-badge-zadarma { background: #dcfce7; color: #166534; }
.source-badge-zadarma_simulated { background: #fef3c7; color: #92400e; border: 1px dashed #d97706; }
.secret-configured { font-family: monospace; letter-spacing: .15em; }
.notification-item.unread { background: #eef2ff; }
.attendance-cell { width: 30px; text-align: center; font-size: .72rem; padding: .35rem .1rem !important; }
.att-present { background: #dcfce7; } .att-late { background: #fef3c7; } .att-absent { background: #fee2e2; }
.att-on_leave { background: #e0f2fe; } .att-holiday { background: #ede9fe; } .att-incomplete { background: #ffedd5; }
.clock-widget .time { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.btn .spinner-border { width: 1rem; height: 1rem; border-width: .15em; }
.auth-wrapper { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #111827 0%, #312e81 100%); padding: 1rem; }
.auth-card { width: 100%; max-width: 420px; border-radius: 1rem; }
.mock-banner { background: repeating-linear-gradient(45deg, #fef3c7, #fef3c7 10px, #fde68a 10px, #fde68a 20px); border: 1px solid #f59e0b; }
.text-truncate-200 { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }
/* ---------- Caller screen protection (deterrent) ---------- */
.screen-protected .crm-content, .screen-protected .crm-topbar { -webkit-user-select: none; user-select: none; }
.screen-protected input, .screen-protected textarea, .screen-protected [contenteditable] { -webkit-user-select: text; user-select: text; }
.privacy-shield { display: none; position: fixed; inset: 0; z-index: 3000; background: #111827; color: #fff; text-align: center; align-items: center; justify-content: center; font-size: 1.1rem; cursor: pointer; }
.privacy-shield i { font-size: 3rem; display: block; margin-bottom: .5rem; }
body.shield-on .privacy-shield { display: flex; }
@media print { .screen-protected * { display: none !important; } .screen-protected::after { content: 'Printing is disabled for this account.'; display: block; } }

/* ---------- Dark mode (Bootstrap data-bs-theme="dark" + CRM overrides) ---------- */
[data-bs-theme="dark"] {
    --crm-bg: #0b1220; --crm-sidebar: #070d18; --crm-sidebar-hover: #142036; --crm-sidebar-text: #cbd5e1;
    --crm-sidebar-active-text: #ffffff; --crm-sidebar-brand: #ffffff; --crm-sidebar-border: #1b2742;
}
[data-bs-theme="dark"] body { background: var(--crm-bg); }
[data-bs-theme="dark"] .crm-topbar,
[data-bs-theme="dark"] .card-header,
[data-bs-theme="dark"] .filter-bar,
[data-bs-theme="dark"] footer.bg-white,
[data-bs-theme="dark"] .bg-white { background-color: #111a2e !important; border-color: #22304d !important; }
[data-bs-theme="dark"] .card, [data-bs-theme="dark"] .modal-content, [data-bs-theme="dark"] .dropdown-menu { background-color: #111a2e; border-color: #22304d; }
[data-bs-theme="dark"] .table > :not(caption) > * > * { background-color: transparent; border-color: #22304d; }
[data-bs-theme="dark"] .table thead th { background: #0e1729; color: #94a3b8; }
[data-bs-theme="dark"] .table-hover > tbody > tr:hover > * { background-color: #17223a; }
[data-bs-theme="dark"] .btn-light { background-color: #1b2742; border-color: #22304d; color: #e2e8f0; }
[data-bs-theme="dark"] .btn-light:hover { background-color: #22304d; color: #fff; }
[data-bs-theme="dark"] .stat-card .label, [data-bs-theme="dark"] .stat-card .hint, [data-bs-theme="dark"] .page-header .subtitle { color: #94a3b8; }
[data-bs-theme="dark"] .notification-item.unread { background: #1a2547; }
[data-bs-theme="dark"] .timeline li { border-left-color: #22304d; }
[data-bs-theme="dark"] .source-badge-manual { background: #1e2a5a; color: #c7d2fe; }
[data-bs-theme="dark"] .source-badge-zadarma { background: #133524; color: #bbf7d0; }
[data-bs-theme="dark"] .att-present { background: #12361f; } [data-bs-theme="dark"] .att-late { background: #3d3210; }
[data-bs-theme="dark"] .att-absent { background: #3f1515; } [data-bs-theme="dark"] .att-on_leave { background: #0f2f44; }
[data-bs-theme="dark"] .att-holiday { background: #2a1f4a; } [data-bs-theme="dark"] .att-incomplete { background: #3d2410; }
[data-bs-theme="dark"] .mock-banner { background: repeating-linear-gradient(45deg, #3d3210, #3d3210 10px, #4a3c12 10px, #4a3c12 20px); color: #fde68a; }
.world-clock .card-body { line-height: 1.2; }

pre.json { background: #0f172a; color: #e2e8f0; padding: .75rem; border-radius: .5rem; font-size: .78rem; max-height: 300px; overflow: auto; }
