/* ============================================================
   SKYLIGNER CRM v7 — Premium Design
   Brand: #D3EDE4 · #313237 · #F4F4F4 · #BEBEC0 · #FFFFFF
   Danger: #E74C3C · Accent-green: #2E7D5E
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Figtree:wght@300..900&display=swap');

:root {
    --mint: #d3ede4;
    --mint-light: rgba(211, 237, 228, 0.12);
    --mint-hover: #c5e7dc;
    --mint-dark: #b0d8c8;
    --dark: #313237;
    --dark-hover: #404145;
    --bg: #f4f4f4;
    --gray: #bebec0;
    --gray-mid: #aaa;
    --gray-light: #e0e0e2;
    --white: #ffffff;
    --red: #e74c3c;
    --red-light: rgba(231, 76, 60, 0.1);
    --green: #2e7d5e;
    --green-light: rgba(46, 125, 94, 0.08);
    --orange: #f0a030;
    --orange-light: rgba(240, 160, 48, 0.12);
    --font: "Figtree", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --shadow-card: 0 1px 3px rgba(49, 50, 55, 0.06), 0 1px 2px rgba(49, 50, 55, 0.04);
    --shadow-hover: 0 8px 25px rgba(49, 50, 55, 0.08), 0 2px 6px rgba(49, 50, 55, 0.04);
    --shadow-elevated: 0 20px 60px rgba(49, 50, 55, 0.12), 0 4px 12px rgba(49, 50, 55, 0.06);
    --text-body: #313237;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text-body);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray); }

/* ===== SIDEBAR ===== */
.sidebar {
    position: fixed; top: 0; left: 0; width: 240px; height: 100vh;
    background: linear-gradient(180deg, #313237 0%, #27282c 100%);
    z-index: 100; overflow-y: auto;
    display: flex; flex-direction: column;
}

.sidebar-logo { text-align: center; padding: 24px 16px 8px; }
.sidebar-logo-img { width: 82px; height: 82px; object-fit: contain; filter: none; }
.sidebar-title { font-size: 18px; font-weight: 800; text-align: center; color: #fff; letter-spacing: -0.3px; }
.sidebar-subtitle { font-size: 9px; text-align: center; color: rgba(255,255,255,0.4); text-transform: uppercase; letter-spacing: 2.5px; margin-top: 2px; }
.sidebar-version { font-size: 9px; text-align: center; color: var(--mint); padding-bottom: 20px; letter-spacing: 1px; }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    margin: 2px 10px; padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.55); text-decoration: none;
    font-size: 14px; font-weight: 500;
    transition: all var(--transition);
}
.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-link.active { background: var(--mint); color: var(--dark) !important; font-weight: 600; }

.nav-link .nav-icon { flex-shrink: 0; width: 20px; height: 20px; opacity: 0.7; transition: opacity var(--transition); }
.nav-link:hover .nav-icon { opacity: 1; }
.nav-link.active .nav-icon { opacity: 1; color: var(--dark); }

/* CRM-раздел: светлая оболочка по рабочему образцу staff CRM */
body.crm-shell { background: #f3f7f5; }
.crm-shell .main-area, .crm-shell .content { min-width: 0; }
.crm-shell .sidebar {
    background: #fff;
    border-right: 1px solid #dfe7e4;
    box-shadow: 2px 0 12px rgba(35, 67, 56, 0.035);
}
.crm-shell .sidebar-logo-img { filter: none; }
.crm-shell .sidebar-title { color: #283a34; }
.crm-shell .sidebar-subtitle { color: #8b9994; }
.crm-shell .sidebar-version { color: #5d7a70; }
.crm-shell .sidebar hr { border-color: #dfe7e4; opacity: 1 !important; }
.crm-shell .sidebar .nav-link { color: #68766f; padding: 7px 12px; gap: 9px; }
.crm-shell .sidebar .nav-link:hover { background: #f0f5f3; color: #293c35; }
.crm-shell .sidebar .nav-link.active {
    background: #def1ea;
    color: #263b34 !important;
    box-shadow: inset 3px 0 0 #70bda2;
}
.crm-shell .sidebar .nav-icon {
    width: 28px;
    height: 28px;
    padding: 5px;
    box-sizing: border-box;
    border-radius: 9px;
    opacity: 1;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
}
.crm-shell .sidebar .nav-link:hover .nav-icon { transform: translateY(-1px) scale(1.04); }
.crm-shell .sidebar .nav-link.active .nav-icon { box-shadow: 0 2px 7px rgba(43, 80, 67, .13); }

/* Цветовая навигация: оттенок закреплён за разделом и не меняется между экранами. */
.crm-shell .sidebar .nav-link[href^="/crm"] .nav-icon { color: #d85e69; background: #fdebed; }
.crm-shell .sidebar .nav-link[href^="/tasks"] .nav-icon { color: #7965c5; background: #f0edfb; }
.crm-shell .sidebar .nav-link[href^="/schedule"] .nav-icon { color: #3e88c9; background: #e9f3fb; }
.crm-shell .sidebar .nav-link[href^="/dashboard"] .nav-icon { color: #5c70c7; background: #edf0fc; }
.crm-shell .sidebar .nav-link[href^="/finance"] .nav-icon { color: #27865f; background: #e5f4ed; }
.crm-shell .sidebar .nav-link[href^="/patients"] .nav-icon { color: #df7b3f; background: #fff0e7; }
.crm-shell .sidebar .nav-link[href^="/inventory"] .nav-icon { color: #b57b22; background: #fff4df; }
.crm-shell .sidebar .nav-link[href="/directories"] .nav-icon { color: #358e99; background: #e8f5f6; }
.crm-shell .sidebar .nav-link[href^="/directories/egisz"] .nav-icon { color: #d25570; background: #fcebf0; }
.crm-shell .sidebar .nav-link[href^="/archive"] .nav-icon { color: #8a6739; background: #f7efe3; }
.crm-shell .sidebar .nav-link[href^="/services"] .nav-icon { color: #258f80; background: #e5f5f1; }
.crm-shell .sidebar .nav-link[href^="/salary"] .nav-icon { color: #8a62b8; background: #f3ecfa; }
.crm-shell .sidebar .nav-link[href^="/reports"] .nav-icon { color: #427fb3; background: #eaf2f8; }
.crm-shell .sidebar .nav-link[href^="/admin"] .nav-icon { color: #715da9; background: #f0edf8; }
.crm-shell .sidebar .nav-link[href^="/marketing"] .nav-icon { color: #c95b91; background: #fbeaf3; }
.crm-shell .sidebar .nav-link[href^="/audit"] .nav-icon { color: #597a91; background: #eaf1f5; }
.crm-back-link {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 14px;
    color: #66766f;
    font-size: 13px;
    font-weight: 650;
    text-decoration: none;
}
.crm-back-link:hover { color: var(--dark); }
.crm-back-link svg { width: 17px; height: 17px; }

/* ===== TOPBAR ===== */
.main-area { margin-left: 240px; min-height: 100vh; display: flex; flex-direction: column; transition: margin-left var(--transition); }

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    height: 64px; padding: 0 36px; flex-shrink: 0;
    background: var(--white); border-bottom: 1px solid var(--gray-light);
    position: sticky; top: 0; z-index: 90;
}
.topbar-clinic { font-size: 14px; font-weight: 600; color: var(--dark); }
.topbar-back { width: 34px; height: 34px; border: 1px solid var(--gray-light); border-radius: 9px; background: #fff; color: var(--gray-mid); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: all var(--transition); }
.topbar-back:hover { color: var(--dark); background: var(--mint-light); border-color: var(--mint); }
.finance-patient-picker { position: relative; }
.cash-patient-results { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 3px); background: #fff; border: 1px solid var(--gray-light); border-radius: 8px; box-shadow: 0 8px 24px rgba(30,50,40,.12); max-height: 240px; overflow-y: auto; }
.cash-patient-result { width: 100%; border: 0; border-bottom: 1px solid #eef2ef; background: #fff; padding: 8px 10px; text-align: left; display: flex; flex-direction: column; gap: 2px; }
.cash-patient-result:hover { background: var(--mint-light); }
.cash-patient-result span { font-weight: 600; font-size: 13px; }
.cash-patient-result small { color: var(--gray-mid); font-size: 11px; }
.topbar-right { display: flex; align-items: center; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.topbar-avatar {
    width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
    background: var(--mint); color: var(--dark);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px;
}
.topbar-user-name { font-size: 13px; font-weight: 600; color: var(--dark); line-height: 1.3; }
.topbar-user-role { font-size: 11px; color: var(--gray-mid); line-height: 1.3; }
.topbar-logout {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: var(--radius-sm);
    color: var(--gray-mid); margin-left: 20px; transition: all var(--transition);
}
.topbar-logout:hover { background: var(--red-light); color: var(--red); }

/* ===== CONTENT ===== */
.content { padding: 32px 36px; flex: 1; }

/* ===== PAGE TRANSITION ===== */
@keyframes pageEnter {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
.content { animation: pageEnter 0.35s ease-out; }

/* ===== CARDS ===== */
.card {
    background: var(--white);
    border: 1px solid var(--gray-light);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-card);
    transition: all var(--transition);
}
.card:hover { box-shadow: var(--shadow-hover); }

.card-header-line {
    border-bottom: 1px solid var(--gray-light);
    padding-bottom: 16px;
    margin-bottom: 16px;
}

/* ===== STAT CARDS ===== */
.stat-card {
    background: var(--white);
    border: 1px solid var(--gray-light);
    border-radius: var(--radius);
    padding: 22px 16px 18px;
    text-align: center;
    box-shadow: var(--shadow-card);
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
    cursor: default;
}
.stat-card::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: var(--mint);
    opacity: 0;
    transition: opacity var(--transition);
}
.stat-card:hover { border-color: var(--mint); box-shadow: var(--shadow-hover); transform: translateY(-3px); }
.stat-card:hover::before { opacity: 1; }

.stat-icon { width: 32px; height: 32px; margin: 0 auto 8px; display: block; color: var(--dark); opacity: 0.6; }
.stat-value { font-size: 28px; font-weight: 800; margin: 8px 0 4px; color: var(--dark); letter-spacing: -0.5px; }
.stat-label { font-size: 11px; color: var(--gray); font-weight: 600; text-transform: uppercase; letter-spacing: 1px; }

.stat-card-income .stat-icon { color: var(--green); opacity: 1; }
.stat-card-expense .stat-icon { color: var(--red); opacity: 1; }
.stat-card-balance .stat-icon { color: var(--dark); opacity: 1; }

/* ===== SKELETON LOADING ===== */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.skeleton {
    background: linear-gradient(90deg, var(--gray-light) 25%, #f0f0f2 50%, var(--gray-light) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-xs);
}
.skeleton-text { height: 14px; margin-bottom: 8px; width: 80%; }
.skeleton-text-sm { height: 10px; margin-bottom: 6px; width: 60%; }
.skeleton-card { height: 120px; border-radius: var(--radius); }

/* ===== FORMS ===== */
.form-control, .form-select {
    background: var(--white);
    border: 1.5px solid var(--gray-light);
    border-radius: var(--radius-sm);
    color: var(--dark);
    padding: 10px 14px;
    font-size: 14px;
    min-height: 40px;
    transition: all var(--transition);
    width: 100%;
}
.form-control:hover, .form-select:hover { border-color: var(--gray-mid); }
.form-control:focus, .form-select:focus {
    border-color: var(--mint-dark);
    box-shadow: 0 0 0 4px rgba(211, 237, 228, 0.25);
    outline: none;
}
.form-control-sm { padding: 6px 10px; font-size: 13px; min-height: 32px; }
.form-select-sm { padding: 6px 10px; font-size: 13px; min-height: 32px; }
.form-label { font-size: 13px; font-weight: 600; color: var(--dark); margin-bottom: 6px; display: block; }

/* ===== COMPACT FINANCE ENTRY ===== */
.finance-entry-card { padding: 18px 20px; }
.finance-expense-presets {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 2px;
}
.finance-expense-presets .btn { flex: 0 0 auto; }
.finance-entry-form {
    display: grid;
    grid-template-columns: 190px minmax(220px, 1fr) 130px 155px 150px;
    gap: 8px 10px;
    align-items: end;
}
.finance-entry-field { min-width: 0; }
.finance-entry-field .form-label {
    margin-bottom: 3px;
    color: #708078;
    font-size: 11px;
    line-height: 1.2;
}
.finance-entry-type .btn-group { display: flex; width: 100%; }
.finance-entry-type .btn { flex: 1 1 50%; padding-left: 8px; padding-right: 8px; }
.finance-entry-description { grid-column: 3 / span 2; }
.finance-entry-submit .btn { width: 100%; min-height: 32px; }
.finance-operation-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}
.finance-operation-panel {
    border: 1px solid #dfe7e4;
    border-radius: 14px;
    padding: 16px;
    background: #fff;
}
.finance-operation-income { border-top: 4px solid #299766; }
.finance-operation-expense { border-top: 4px solid #d65c5c; }
.finance-operation-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}
.finance-operation-heading h6 { margin: 0 0 2px; }
.finance-operation-heading small { color: #708078; }
.finance-operation-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    font-size: 22px;
    font-weight: 700;
    background: #edf8f2;
    color: #237d56;
}
.finance-operation-expense .finance-operation-icon {
    background: #fff0f0;
    color: #b84242;
}
.finance-operation-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.finance-operation-form label { min-width: 0; }
.finance-operation-form label > span {
    display: block;
    margin-bottom: 4px;
    color: #56645d;
    font-size: 11px;
    font-weight: 600;
}
.finance-operation-comment { grid-column: 1 / -1; }
.finance-operation-form > .btn {
    grid-column: 1 / -1;
    min-height: 36px;
}

@media (max-width: 1199px) {
    .finance-entry-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .finance-entry-description { grid-column: auto; }
}

@media (max-width: 900px) {
    .finance-operation-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .finance-entry-card { padding: 16px; }
    .finance-entry-form { grid-template-columns: 1fr; }
    .finance-operation-form { grid-template-columns: 1fr; }
    .finance-operation-comment { grid-column: auto; }
    .finance-operation-form > .btn { grid-column: auto; }
}

/* ===== FINANCIAL CENTER ===== */
.finance-center-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}
.finance-period-card { padding: 14px 18px; }
.finance-period-form {
    display: grid;
    grid-template-columns: 160px 180px 180px auto 1fr;
    align-items: end;
    gap: 10px;
}
.finance-period-form .form-label { margin-bottom: 3px; font-size: 11px; color: #708078; }
.finance-period-note { align-self: center; justify-self: end; color: #708078; font-size: 12px; }
.finance-kpi-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
}
.finance-kpi {
    min-width: 0;
    padding: 14px 16px;
    border: 1px solid #dfe7e4;
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--shadow-card);
}
.finance-kpi span { display: block; color: #708078; font-size: 11px; margin-bottom: 3px; }
.finance-kpi strong { display: block; color: var(--dark); font-size: 19px; line-height: 1.2; white-space: nowrap; }
.finance-center-tabs { gap: 6px; }
.finance-center-tabs .nav-link {
    border: 1px solid #dfe7e4;
    border-radius: 10px;
    background: #fff;
    color: #617169;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 650;
}
.finance-center-tabs .nav-link.active {
    background: #d8eee6;
    border-color: #b7dbcf;
    color: #263b34;
}
.finance-report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}
.finance-two-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.finance-compact-card { padding: 16px 18px; }
.finance-compact-card h5 { margin: 0 0 10px; font-size: 15px; }
.finance-line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 7px 0;
    border-bottom: 1px solid #edf1ef;
    font-size: 13px;
}
.finance-line span { min-width: 0; }
.finance-line b { flex: 0 0 auto; white-space: nowrap; }
.finance-line.finance-total { margin-top: 3px; border-bottom: 0; font-size: 14px; font-weight: 700; }
.finance-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.finance-card-heading h5 { margin: 0; }
.finance-card-heading > span { color: #7a8882; font-size: 11px; white-space: nowrap; }
.cash-operation-card {
    position: relative;
    overflow: visible;
    border: 2px solid #47a979;
    background: linear-gradient(135deg, #f1fbf6 0%, #ffffff 58%);
    box-shadow: 0 8px 24px rgba(38, 125, 88, .13);
    transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
.cash-operation-card::before {
    content: '';
    position: absolute;
    top: -2px;
    bottom: -2px;
    left: -2px;
    width: 7px;
    border-radius: 12px 0 0 12px;
    background: #267d58;
}
.cash-operation-card.is-expense {
    border-color: #dc7470;
    background: linear-gradient(135deg, #fff5f4 0%, #ffffff 58%);
    box-shadow: 0 8px 24px rgba(190, 66, 57, .11);
}
.cash-operation-card.is-expense::before { background: #c74d47; }
.cash-operation-heading { padding-bottom: 12px; border-bottom: 1px solid rgba(38, 125, 88, .16); }
.cash-operation-card.is-expense .cash-operation-heading { border-bottom-color: rgba(199, 77, 71, .18); }
.cash-operation-title { display: flex; align-items: center; gap: 10px; min-width: 250px; }
.cash-operation-icon {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 11px;
    color: #fff;
    background: #267d58;
    font-size: 21px;
    font-weight: 800;
    box-shadow: 0 4px 10px rgba(38, 125, 88, .22);
}
.cash-operation-card.is-expense .cash-operation-icon { background: #c74d47; box-shadow: 0 4px 10px rgba(199, 77, 71, .2); }
.cash-operation-eyebrow { margin-bottom: 1px; color: #267d58; font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.cash-operation-card.is-expense .cash-operation-eyebrow { color: #b43e38; }
.cash-operation-title h5 { font-size: 17px; }
.cash-operation-controls { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.cash-operation-controls > span { color: #61716a; font-size: 11px; max-width: 260px; line-height: 1.25; }
.cash-operation-card .finance-payment-form { padding-top: 4px; }
.cash-operation-card .finance-payment-form .form-control,
.cash-operation-card .finance-payment-form .form-select { background-color: #fff; border-color: #c9d9d2; }
.cash-operation-card .finance-payment-form .btn { min-height: 34px; font-weight: 750; }
.finance-table-scroll { max-height: 430px; overflow: auto; }
.finance-table-scroll .table thead { position: sticky; top: 0; z-index: 1; }
.finance-operation-type { display: inline-flex; padding: 2px 7px; border-radius: 12px; font-size: 11px; font-weight: 650; }
.finance-operation-type.is-income { color: #257052; background: #e5f3ed; }
.finance-operation-type.is-expense { color: #bc3f35; background: #fdebe9; }
.finance-operation-type.is-transfer { color: #5f6e68; background: #eef2f0; }
.finance-close-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}
.finance-close-form label { color: #708078; font-size: 11px; }
.finance-close-form label input { margin-top: 3px; }
.finance-close-note { grid-column: 1 / -1; }
.finance-close-form .btn { grid-column: 1 / -1; }
.finance-encashment-form {
    display: grid;
    grid-template-columns: 150px minmax(180px, .8fr) minmax(240px, 1.4fr) auto;
    gap: 8px;
}
.finance-payment-form {
    display: grid;
    grid-template-columns: minmax(150px, 1.1fr) minmax(170px, 1.3fr) 110px 135px 135px;
    gap: 8px;
}
.finance-payment-form > * { min-width: 0; }
.finance-payment-form input[name="description"] { grid-column: 1 / 5; }
.finance-payment-form .btn { grid-column: 5; }
.finance-discrepancy { margin-top: 10px; border-radius: 8px; padding: 8px 10px; font-size: 12px; }
.finance-discrepancy.is-ok { color: #257052; background: #e5f3ed; }
.finance-discrepancy.has-difference { color: #9b6718; background: #fff4dd; }

@media (max-width: 1199px) {
    .finance-period-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .finance-period-note { justify-self: start; }
    .finance-kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .finance-encashment-form,
    .finance-payment-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .finance-payment-form input[name="description"],
    .finance-payment-form .btn { grid-column: auto; }
}

@media (max-width: 768px) {
    .finance-center-header { flex-direction: column; }
    .finance-period-form, .finance-kpi-grid, .finance-two-columns,
    .finance-encashment-form, .finance-payment-form { grid-template-columns: 1fr; }
    .finance-kpi strong { font-size: 17px; }
    .cash-operation-heading, .cash-operation-controls { align-items: stretch; flex-direction: column; }
    .cash-operation-controls { justify-content: flex-start; }
    .cash-operation-controls > span { max-width: none; }
}

/* ===== EXECUTIVE DASHBOARD ===== */
.executive-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}
.executive-header-actions {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}
.executive-period-form {
    display: flex;
    align-items: flex-end;
    gap: 7px;
}
.executive-period-form label {
    color: #708078;
    font-size: 11px;
    padding-bottom: 8px;
}
.executive-period-form input { width: 155px; }
.executive-kpi-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
}
.executive-kpi {
    min-width: 0;
    padding: 15px 16px;
    border: 1px solid #dfe7e4;
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--shadow-card);
}
.executive-kpi span,
.executive-kpi small { display: block; color: #74837c; }
.executive-kpi span { margin-bottom: 4px; font-size: 11px; }
.executive-kpi strong {
    display: block;
    color: var(--dark);
    font-size: 20px;
    line-height: 1.2;
    white-space: nowrap;
}
.executive-kpi small {
    margin-top: 5px;
    overflow: hidden;
    font-size: 10px;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.executive-kpi.is-revenue { border-left: 4px solid #76bea4; }
.executive-kpi.is-profit { border-left: 4px solid var(--green); }
.executive-kpi.is-loss { border-left: 4px solid var(--red); }
.executive-patient-card,
.executive-chart-card,
.executive-compact-card { padding: 16px 18px; }
.executive-card-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.executive-card-heading h5 { margin: 0; font-size: 15px; }
.executive-card-heading span { color: #74837c; font-size: 11px; }
.executive-patient-counts {
    display: flex;
    align-items: baseline;
    gap: 6px;
    color: #74837c;
    font-size: 11px;
}
.executive-patient-counts b { color: var(--dark); font-size: 16px; }
.executive-patient-bar {
    display: flex;
    height: 8px;
    overflow: hidden;
    border-radius: 10px;
    background: #edf1ef;
}
.executive-patient-bar > div { min-width: 0; }
.executive-patient-bar .is-active { background: #8fcdb7; }
.executive-patient-bar .is-completed { background: #aebbb6; }
.executive-chart-grid,
.executive-table-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.executive-chart { height: 250px; }
.executive-chart.is-empty {
    display: grid;
    place-items: center;
    color: #7a8882;
    font-size: 12px;
    background: #f8faf9;
    border: 1px dashed #dfe7e4;
    border-radius: 10px;
}
.executive-compact-card { min-width: 0; }
.executive-compact-card .table-container { box-shadow: none; }
.executive-table-scroll { max-height: 360px; overflow: auto; }
.executive-table-scroll .table thead { position: sticky; top: 0; z-index: 1; }

@media (max-width: 1199px) {
    .executive-kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
    .executive-header { flex-direction: column; }
    .executive-header-actions,
    .executive-period-form { width: 100%; }
    .executive-period-form input { flex: 1 1 auto; width: auto; }
    .executive-kpi-grid,
    .executive-chart-grid,
    .executive-table-grid { grid-template-columns: 1fr; }
    .executive-kpi strong { font-size: 18px; }
    .executive-card-heading { align-items: flex-start; flex-direction: column; }
}

/* ===== INPUT GROUP ===== */
.input-group .btn { border-radius: var(--radius-sm); }
.input-group .form-control:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group .btn:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }

/* ===== MODALS ===== */
.modal-content {
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-elevated);
}
.modal-header {
    border-bottom: 1px solid var(--gray-light);
    padding: 20px 24px 16px;
}
.modal-header .modal-title { font-size: 17px; font-weight: 700; }
.modal-body { padding: 20px 24px; }
.modal-footer {
    border-top: 1px solid var(--gray-light);
    padding: 16px 24px 20px;
    gap: 8px;
}
.modal .btn-close {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    transition: background var(--transition);
    opacity: 0.5;
}
.modal .btn-close:hover { background: var(--mint-light); opacity: 1; }

/* ===== TABLES ===== */
.table { width: 100%; color: var(--dark); border-collapse: separate; border-spacing: 0; }

.table thead th {
    background: var(--mint);
    color: var(--dark);
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.8px;
    padding: 14px 16px; text-align: left;
    border-bottom: 2px solid rgba(49,50,55,0.08);
}
.table thead th:first-child { border-radius: 10px 0 0 0; }
.table thead th:last-child { border-radius: 0 10px 0 0; }

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-light);
    font-size: 14px;
    transition: background var(--transition);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: var(--mint-light); }
.table tbody tr:active td { background: rgba(211,237,228,0.2); }

.table tbody tr { transition: background var(--transition); }

.table-container {
    background: var(--white);
    border: 1px solid var(--gray-light);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.table-actions { display: flex; gap: 4px; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border-radius: var(--radius-sm);
    padding: 10px 20px; font-size: 14px; font-weight: 600;
    line-height: 1; cursor: pointer;
    transition: all var(--transition);
    border: none; text-decoration: none; white-space: nowrap;
}
.btn:active { transform: scale(0.96); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-xs { padding: 4px 10px; font-size: 12px; border-radius: var(--radius-xs); }

.btn-primary { background: var(--mint); color: var(--dark); }
.btn-primary:hover { background: var(--mint-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(211,237,228,0.4); }
.btn-outline-primary { background: transparent; border: 1.5px solid var(--mint); color: var(--dark); }
.btn-outline-primary:hover { background: var(--mint); transform: translateY(-1px); }

.btn-outline-secondary { background: transparent; border: 1.5px solid var(--gray-light); color: var(--gray); }
.btn-outline-secondary:hover { border-color: var(--mint); color: var(--dark); }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(231,76,60,0.3); }
.btn-outline-danger { border: 1.5px solid var(--red); color: var(--red); background: transparent; }
.btn-outline-danger:hover { background: var(--red-light); }

.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #256a50; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(46,125,94,0.3); }
.btn-outline-success { border: 1.5px solid var(--green); color: var(--green); background: transparent; }
.btn-outline-success:hover { background: var(--green-light); color: var(--green); }

.btn-warning { background: var(--orange); color: #fff; }
.btn-warning:hover { background: #d8902a; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(240,160,48,0.3); }

.btn-icon {
    width: 36px; height: 36px; padding: 0;
    border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
}
.btn-icon.btn-sm { width: 30px; height: 30px; }

/* ===== BADGES ===== */
.badge { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; padding: 3px 10px; border-radius: 20px; font-size: 12px; line-height: 1.4; }
.badge-income { background: var(--mint-light); color: var(--dark); padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-expense { background: var(--red-light); color: var(--red); padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.bg-primary { background: var(--mint) !important; color: var(--dark) !important; }
.bg-success { background: var(--green) !important; color: #fff !important; }
.bg-danger { background: var(--red) !important; color: #fff !important; }
.bg-warning { background: var(--orange) !important; color: #fff !important; }
.bg-secondary { background: var(--gray-light) !important; color: var(--dark) !important; }
.bg-info { background: var(--mint-light) !important; color: var(--dark) !important; }

/* ===== PROGRESS ===== */
.progress { background: var(--gray-light); border-radius: 8px; height: 10px; overflow: hidden; }
.progress-bar { border-radius: 8px; background: var(--mint) !important; transition: width 0.5s ease; }

/* ===== ALERTS ===== */
.alert { border-radius: var(--radius); border: none; padding: 16px 20px; font-size: 14px; }
.alert-danger { background: var(--red-light); color: var(--red); }
.alert-warning { background: var(--orange-light); color: #8a5e1a; }
.alert-info { background: var(--mint-light); color: var(--dark); }
.alert-success { background: var(--green-light); color: var(--green); }

.alert-icon { width: 24px; height: 24px; flex-shrink: 0; }

/* ===== TYPOGRAPHY ===== */
h1, h2, h3, h4, h5 { font-weight: 700; color: var(--dark); letter-spacing: -0.3px; margin-top: 0; line-height: 1.3; }
.h3, h1.h3 { font-size: 22px; }
h5 { font-size: 15px; }
h5.mb-3 { margin-bottom: 16px; }
.text-secondary { color: var(--gray); }
.text-muted { color: var(--gray-mid); }
.text-success { color: var(--green) !important; }
.text-danger { color: var(--red) !important; }
.text-primary { color: var(--dark) !important; }
.text-warning { color: var(--orange) !important; }
.fw-bold { font-weight: 700; }
.small { font-size: 12px; line-height: 1.5; }

a { color: var(--dark); transition: color var(--transition); text-decoration: none; }
a:hover { color: var(--mint-dark); }

hr { border: none; border-top: 1px solid var(--gray-light); margin: 16px 0; }

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 24px;
}
.page-header h1 { font-size: 22px; font-weight: 700; margin: 0; }
.page-header p { color: var(--gray); font-size: 13px; margin: 4px 0 0; }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center; padding: 48px 24px; color: var(--gray);
}
.empty-state-icon { width: 48px; height: 48px; margin: 0 auto 12px; opacity: 0.3; }
.empty-state-title { font-size: 16px; font-weight: 600; color: var(--gray-mid); margin-bottom: 4px; }
.empty-state-text { font-size: 13px; }

/* ===== INSIGHT CARDS ===== */
.insight-card {
    background: var(--white);
    border: 1px solid var(--gray-light);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow-card);
    transition: all var(--transition);
    display: flex; align-items: flex-start; gap: 12px;
}
.insight-card:hover { border-color: var(--mint); box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.insight-card-icon { width: 28px; height: 28px; flex-shrink: 0; margin-top: 2px; }

/* ===== FILTER BUTTON GROUP ===== */
.filter-group { display: flex; gap: 4px; flex-wrap: wrap; }

/* ===== TOOLTIP CUSTOM ===== */
.tooltip-inner { font-family: var(--font); font-size: 12px; border-radius: var(--radius-xs); padding: 6px 12px; }

/* ===== NAV TABS ===== */
.nav-tabs { border-bottom: 1px solid var(--gray-light); gap: 0; }
.nav-tabs .nav-link {
    border: none; color: var(--gray); padding: 10px 20px;
    font-weight: 600; font-size: 13px;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all var(--transition);
    background: transparent;
}
.nav-tabs .nav-link:hover { color: var(--dark); }
.nav-tabs .nav-link.active { color: var(--dark); border-bottom-color: var(--dark); background: transparent; }

/* ===== BOOTSTRAP OVERRIDES ===== */
.dropdown-menu { border: 1px solid var(--gray-light); border-radius: var(--radius-sm); box-shadow: var(--shadow-hover); padding: 6px; }
.dropdown-item { border-radius: var(--radius-xs); padding: 8px 12px; font-size: 13px; transition: background var(--transition); }
.dropdown-item:hover { background: var(--mint-light); }
.dropdown-item:active { background: var(--mint); }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.stat-card { animation: fadeIn 0.3s ease forwards; }
.stat-card:nth-child(2) { animation-delay: 0.05s; }
.stat-card:nth-child(3) { animation-delay: 0.1s; }
.stat-card:nth-child(4) { animation-delay: 0.15s; }
.stat-card:nth-child(5) { animation-delay: 0.2s; }
.stat-card:nth-child(6) { animation-delay: 0.25s; }
.stat-card:nth-child(7) { animation-delay: 0.3s; }
.stat-card:nth-child(8) { animation-delay: 0.35s; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar .nav-text, .sidebar .sidebar-title, .sidebar .sidebar-subtitle, .sidebar .sidebar-version { display: none; }
    .sidebar .nav-link { justify-content: center; padding: 11px 0; margin: 2px 6px; }
    .sidebar .nav-link .nav-icon { margin: 0; }
    .main-area { margin-left: 60px; }
    .topbar { padding: 0 16px; }
    .topbar-clinic { display: none; }
    .topbar-user-name, .topbar-user-role { display: none; }
    .content { padding: 16px; }
    .stat-value { font-size: 22px; }
    .page-header { flex-direction: column; gap: 12px; }
}
@media (min-width: 769px) and (max-width: 1199px) {
    .sidebar { width: 200px; }
    .main-area { margin-left: 200px; }
}

/* ===== PRINT ===== */
@media print {
    @page { margin: 15mm; }
    body { background: white !important; }
    .sidebar { display: none !important; }
    .main-area { margin-left: 0 !important; }
    .topbar { display: none !important; }
    .content { padding: 0 !important; animation: none !important; }
    .card { border: 1px solid #ddd !important; box-shadow: none !important; border-radius: 4px !important; break-inside: avoid; }
    .btn, .btn-group { display: none !important; }
    .badge { border: 1px solid #ccc !important; }
    .table-container { border: 1px solid #ddd !important; border-radius: 4px !important; }
    .print-hide { display: none !important; }
}
body.print-mode .sidebar { display: none !important; }
body.print-mode .main-area { margin-left: 0 !important; }
body.print-mode .topbar { display: none !important; }
body.print-mode .content { animation: none !important; }
body.print-mode .btn { display: none !important; }
body.print-mode .print-hide { display: none !important; }

/* Bootstrap по умолчанию скрывает .toast (display:none), пока не добавлен класс .show —
   showToast() в skyligner.js работает без Bootstrap Toast API, поэтому явно включаем показ. */
.toast-container-fixed {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.toast-container-fixed .toast {
    display: block;
    min-width: 240px;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    color: #fff;
    background: #333;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: opacity 0.3s, transform 0.3s;
}
.toast-container-fixed .toast-info { background: #0d6efd; }
.toast-container-fixed .toast-danger { background: #dc3545; }
.toast-container-fixed .toast-success { background: #198754; }

/* ===== INCOMING CALL ===== */
.incoming-call {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 2500;
    width: min(430px, calc(100vw - 32px));
    display: flex;
    gap: 14px;
    padding: 18px;
    border: 1px solid #cfe4dc;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 22px 70px rgba(31, 68, 55, .24);
    opacity: 0;
    visibility: hidden;
    transform: translateY(24px) scale(.97);
    transition: opacity .2s ease, transform .2s ease, visibility .2s;
}
.incoming-call.is-visible { opacity: 1; visibility: visible; transform: none; }
.incoming-call__pulse {
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #2e7d5e;
    color: #fff;
    font-size: 23px;
    box-shadow: 0 0 0 0 rgba(46,125,94,.35);
    animation: incoming-ring 1.4s infinite;
}
@keyframes incoming-ring {
    0% { box-shadow: 0 0 0 0 rgba(46,125,94,.35); transform: rotate(-5deg); }
    55% { box-shadow: 0 0 0 12px rgba(46,125,94,0); transform: rotate(7deg); }
    100% { box-shadow: 0 0 0 0 rgba(46,125,94,0); transform: rotate(-5deg); }
}
.incoming-call__body { min-width: 0; flex: 1; }
.incoming-call__top { display: flex; justify-content: space-between; gap: 12px; }
.incoming-call__eyebrow {
    margin-bottom: 2px;
    color: #2e7d5e;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.incoming-call h3 { margin: 0; font-size: 20px; line-height: 1.25; }
.incoming-call__close {
    width: 30px; height: 30px; border: 0; border-radius: 8px;
    background: #f2f5f4; color: #66736e; font-size: 22px; line-height: 1;
}
.incoming-call__phone {
    display: inline-block; margin-top: 7px; color: #263b34;
    font-size: 18px; font-weight: 750; text-decoration: none;
}
.incoming-call__meta { margin-top: 3px; color: #71817b; font-size: 12px; }
.incoming-call__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.incoming-call__primary, .incoming-call__secondary, .incoming-call__save {
    border: 0; border-radius: 9px; padding: 9px 12px;
    font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
}
.incoming-call__primary, .incoming-call__save { background: #2e7d5e; color: #fff; }
.incoming-call__secondary { background: #eef5f2; color: #36594d; }
.incoming-call__form { margin-top: 14px; padding-top: 13px; border-top: 1px solid #e7eeeb; }
.incoming-call__form-title { margin-bottom: 9px; font-size: 13px; font-weight: 800; }
.incoming-call__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.incoming-call__form input, .incoming-call__form select, .incoming-call__form textarea {
    width: 100%; border: 1px solid #d8e2de; border-radius: 9px;
    padding: 9px 10px; background: #fff; color: #313237; font: inherit;
}
.incoming-call__form textarea { resize: vertical; margin-bottom: 8px; }
.incoming-call__save { width: 100%; }
.incoming-call__save:disabled { opacity: .6; cursor: wait; }
.incoming-call__history {
    max-height: 190px; overflow: auto; margin-top: 12px; padding: 10px;
    border-radius: 10px; background: #f7faf9;
}
.incoming-call__history-title { margin-bottom: 7px; font-size: 12px; font-weight: 800; }
.incoming-call__history-row {
    display: grid; grid-template-columns: 1fr auto auto; gap: 8px;
    padding: 7px 0; border-bottom: 1px solid #e4ece9; font-size: 12px;
}
.incoming-call__history-row:last-child { border-bottom: 0; }
.incoming-call__history-row small, .incoming-call__empty, .incoming-call__loading { color: #71817b; }
@media (max-width: 600px) {
    .incoming-call { right: 16px; bottom: 16px; padding: 14px; }
    .incoming-call__pulse { width: 40px; height: 40px; flex-basis: 40px; }
    .incoming-call__grid { grid-template-columns: 1fr; }
}
