:root {
    /* Color Palette */
    --primary-color: #4f46e5;
    /* Indigo 600 */
    --primary-hover: #4338ca;
    /* Indigo 700 */
    --primary-light: #e0e7ff;
    /* Indigo 100 */

    --secondary-color: #64748b;
    /* Slate 500 */
    --secondary-hover: #475569;
    /* Slate 600 */
    --secondary-light: #f8fafc;
    /* Slate 50 */

    --success-color: #10b981;
    /* Emerald 500 */
    --success-bg: #ecfdf5;
    /* Emerald 50 */

    --warning-color: #f59e0b;
    /* Amber 500 */
    --warning-bg: #fffbeb;
    /* Amber 50 */

    --danger-color: #ef4444;
    /* Red 500 */
    --danger-bg: #fef2f2;
    /* Red 50 */

    --bg-app: #f1f5f9;
    /* Slate 100 - Main App Background */
    --bg-surface: #ffffff;
    /* White - Cards, Table, Sidebar */

    --text-main: #0f172a;
    /* Slate 900 */
    --text-muted: #64748b;
    /* Slate 500 */
    --text-light: #94a3b8;
    /* Slate 400 */

    --border-color: #e2e8f0;
    /* Slate 200 */

    /* Shadows & Radii */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);

    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    --radius-full: 9999px;

    --transition: all 0.2s ease-in-out;

    --sidebar-width: 260px;
    --sidebar-width-collapsed: 80px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
}

/* Utilities */
.text-indigo {
    color: var(--primary-color);
}

.text-red {
    color: var(--danger-color);
}

.text-emerald {
    color: var(--success-color);
}

.bg-indigo-light {
    background-color: var(--primary-light);
}

.bg-red-light {
    background-color: var(--danger-bg);
}

.bg-emerald-light {
    background-color: var(--success-bg);
}

.text-right {
    text-align: right;
}

/* Dashboard Layout */
.dashboard-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    z-index: 10;
}

.sidebar.collapsed {
    width: var(--sidebar-width-collapsed);
}

.sidebar-header {
    height: 70px;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
}

.sidebar.collapsed .logo span {
    display: none;
}

.toggle-sidebar-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.25rem;
    padding: 0.25rem;
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: var(--transition);
}

.nav-item i {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

.nav-item:hover {
    background-color: var(--secondary-light);
    color: var(--text-main);
}

.nav-item.active {
    background-color: var(--primary-light);
    color: var(--primary-color);
}

.badge {
    margin-left: auto;
    background-color: var(--primary-color);
    color: white;
    font-size: 0.75rem;
    padding: 0.1rem 0.6rem;
    border-radius: var(--radius-full);
}

.sidebar.collapsed .nav-text,
.sidebar.collapsed .badge {
    display: none;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Main Wrapper & Topbar */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: 70px;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.search-container {
    position: relative;
    width: 300px;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-input {
    width: 100%;
    padding: 0.6rem 1rem 0.6rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    background-color: var(--bg-app);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
}

.search-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
    background-color: var(--bg-surface);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.action-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
}

/* Notification Bell */
.notification-wrapper {
    position: relative;
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--danger-color, #ef4444);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-surface, #fff);
    line-height: 1;
}

.notification-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: -40px;
    width: 380px;
    max-height: 440px;
    background: var(--bg-surface, #fff);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15), 0 2px 10px rgba(0, 0, 0, 0.08);
    z-index: 1000;
    overflow: hidden;
    border: 1px solid var(--border-color, #e2e8f0);
}

.notification-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    background: var(--bg-surface, #fff);
}

.notification-dropdown-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary, #1e293b);
}

.notification-mark-all {
    background: none;
    border: none;
    font-size: 0.75rem;
    color: var(--primary-color, #6366f1);
    cursor: pointer;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.15s;
}

.notification-mark-all:hover {
    background: rgba(99, 102, 241, 0.1);
}

.notification-list {
    max-height: 370px;
    overflow-y: auto;
}

.notification-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.8rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    transition: background 0.15s;
}

.notification-item:last-child {
    border-bottom: none;
}

.notification-item:hover {
    background: rgba(99, 102, 241, 0.04);
}

.notification-item.unread {
    background: rgba(99, 102, 241, 0.06);
}

.notification-item.unread:hover {
    background: rgba(99, 102, 241, 0.1);
}

.notification-item-icon {
    font-size: 1.4rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.notification-item-content {
    flex: 1;
    min-width: 0;
}

.notification-item-title {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-primary, #1e293b);
    margin-bottom: 2px;
}

.notification-item-body {
    font-size: 0.78rem;
    color: var(--text-muted, #64748b);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.notification-item-time {
    font-size: 0.7rem;
    color: var(--text-muted, #94a3b8);
    margin-top: 4px;
}

.notification-empty {
    padding: 2rem;
    text-align: center;
    color: var(--text-muted, #94a3b8);
    font-size: 0.85rem;
}

.notification-empty i {
    display: block;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

/* Mobile notification dropdown */
@media (max-width: 768px) {
    .notification-dropdown {
        width: calc(100vw - 2rem);
        right: -80px;
        max-height: 50vh;
    }
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.avatar {
    width: 40px;
    height: 40px;
    background-color: var(--primary-color);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-weight: 600;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Content Area */
.content-area {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: white;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--secondary-light);
}

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background-color: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    border: 1px solid var(--border-color);
}

.kpi-card[onclick] {
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.kpi-card[onclick]:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.15);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.25rem;
}

.kpi-details {
    display: flex;
    flex-direction: column;
}

.kpi-title {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
    margin: 0.25rem 0;
}

.kpi-trend {
    font-size: 0.8rem;
    font-weight: 500;
}

.kpi-trend.positive {
    color: var(--success-color);
}

.kpi-trend.negative {
    color: var(--danger-color);
}

.kpi-trend.neutral {
    color: var(--text-muted);
}

/* Data Section & Table */
.data-section {
    background-color: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.data-section-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.data-section-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
}

.filter-bar {
    display: flex;
    gap: 1rem;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.filter-group label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.filter-select {
    padding: 0.4rem 2rem 0.4rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: white;
    font-size: 0.85rem;
    color: var(--text-main);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1rem;
    cursor: pointer;
    outline: none;
}

.filter-select:focus {
    border-color: var(--primary-color);
}

.table-container {
    overflow-x: auto;
}

.crm-table {
    width: 100%;
    border-collapse: collapse;
}

.crm-table th {
    background-color: var(--bg-app);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.crm-table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.95rem;
    vertical-align: middle;
}

.crm-table tbody tr {
    transition: var(--transition);
}

.crm-table tbody tr:hover {
    background-color: var(--bg-app);
}

.patient-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.patient-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--primary-light);
    color: var(--primary-color);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 600;
    font-size: 0.8rem;
}

.patient-name {
    font-weight: 600;
    color: var(--text-main);
}

.patient-id {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
}

/* Status Pills */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.6rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.status-pill.success {
    background-color: var(--success-bg);
    color: var(--success-color);
}

.status-pill.warning {
    background-color: var(--warning-bg);
    color: var(--warning-color);
}

.status-pill.danger {
    background-color: var(--danger-bg);
    color: var(--danger-color);
}

.status-pill.neutral {
    background-color: var(--secondary-light);
    color: var(--secondary-hover);
}

.table-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.btn-icon {
    width: 32px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    background-color: white;
    border-color: var(--border-color);
    color: var(--primary-color);
}

.btn-icon.active {
    background-color: var(--primary-color);
    color: white;
}

.btn-icon[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Pagination */
.pagination {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: white;
}

.pagination-info {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.pagination-ellipsis {
    color: var(--text-muted);
    padding: 0 0.5rem;
}

/* Clickable table rows */
.crm-table tbody tr {
    cursor: pointer;
}

/* ===== Patient Detail Slide-out Panel ===== */
.detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 90;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.detail-overlay.active {
    opacity: 1;
    visibility: visible;
}

.detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 480px;
    max-width: 90vw;
    height: 100vh;     /* fallback для старых браузеров */
    height: 100dvh;    /* учитывает таскбар Windows */
    background: var(--bg-surface);
    box-shadow: -8px 0 30px rgba(0, 0, 0, 0.12);
    z-index: 100;
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.detail-panel.active {
    transform: translateX(0);
}

.detail-panel-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    color: white;
    flex-shrink: 0;
}

.detail-panel-header .dp-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.detail-panel-header .dp-close:hover {
    background: rgba(255, 255, 255, 0.35);
}

.dp-patient-name {
    font-size: 1.15rem;
    font-weight: 700;
}

.dp-patient-sub {
    font-size: 0.8rem;
    opacity: 0.85;
    margin-top: 2px;
}

.detail-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem 1.5rem;
}

/* Term hero card */
.dp-term-card {
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}
.dp-term-card.dp-term-error {
    background: linear-gradient(135deg, #fef2f2 0%, #fecaca 100%);
    border: 2px solid #ef4444;
}
.dp-term-error .dp-term-big {
    color: #dc2626;
}

.dp-term-big {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary-color);
    line-height: 1;
}

.dp-term-big small {
    font-size: 1rem;
    font-weight: 600;
    opacity: 0.7;
}

.dp-term-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.85rem;
    color: #3730a3;
}

/* Section blocks */
.dp-section {
    margin-bottom: 1rem;
}

.dp-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border-color);
}

.dp-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 1rem;
}

.dp-field {
    display: flex;
    flex-direction: column;
}

.dp-field-label {
    font-size: 0.7rem;
    color: var(--text-light);
    font-weight: 500;
}

.dp-field-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

.dp-field-value.highlight-danger {
    color: var(--danger-color);
}

.dp-field-value.highlight-warning {
    color: var(--warning-color);
}

.dp-field.full-width {
    grid-column: 1 / -1;
}

/* Badges row */
.dp-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.dp-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 700;
}

.dp-badge.red {
    background: #fef2f2;
    color: #dc2626;
}

.dp-badge.orange {
    background: #fff7ed;
    color: #ea580c;
}

.dp-badge.yellow {
    background: #fefce8;
    color: #a16207;
}

.dp-badge.indigo {
    background: #e0e7ff;
    color: #4338ca;
}

.dp-badge.slate {
    background: #f1f5f9;
    color: #475569;
}

.dp-badge.green {
    background: #ecfdf5;
    color: #059669;
}

/* Check/cross indicators */
.dp-check {
    color: var(--danger-color);
    font-weight: 700;
}

.dp-ok {
    color: var(--success-color);
}

/* Actions footer */
.detail-panel-footer {
    padding: 0.6rem 0.75rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
    background: var(--bg-app);
}

.detail-panel-footer .btn {
    flex: 1;
    justify-content: center;
    font-size: 0.75rem;
    padding: 0.5rem 0.25rem;
    white-space: nowrap;
}

/* ==========================================================================
   Login Screen Styles
   ========================================================================== */
.login-container {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-color);
    background-image: radial-gradient(circle at top, #eef2ff 0%, #f8fafc 100%);
    padding: 1rem;
}

.login-card {
    background: white;
    padding: 3rem 2rem;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    width: 100%;
    max-width: 440px;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.login-header h2 {
    color: var(--text-main);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.input-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 0.5rem;
    text-align: left;
}

.input-group input {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}

.input-group input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.mt-4 {
    margin-top: 1rem;
}

.mt-6 {
    margin-top: 1.5rem;
}

.login-error {
    background-color: #fef2f2;
    color: #ef4444;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    margin-top: 1rem;
    font-size: 0.9rem;
    text-align: center;
    border: 1px solid #fca5a5;
    animation: fadeIn 0.3s ease;
}

.login-footer {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-light);
    font-size: 0.8rem;
    line-height: 1.5;
}

/* Helper class used in JS for full width buttons */
.full-width {
    width: 100%;
}

/* ==========================================================================
   Stub Sections (In Development)
   ========================================================================== */
.stub-section {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}
.stub-content {
    text-align: center;
    padding: 3rem;
}
.stub-content i {
    font-size: 4rem;
    color: var(--primary);
    opacity: 0.3;
    margin-bottom: 1.5rem;
    display: block;
}
.stub-content h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.75rem;
}
.stub-content p {
    font-size: 1rem;
    color: var(--text-muted);
    max-width: 400px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ==========================================================================
   Inline Edit Mode (Patient Detail Panel)
   ========================================================================== */
.dp-field-input {
    width: 100%;
    padding: 0.4rem 0.5rem;
    border: 1.5px solid var(--primary);
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: inherit;
    background: #f0f4ff;
    color: var(--text-main);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.dp-field-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.dp-field-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}
.dp-edit-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}
.dp-edit-actions .btn {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
}

/* ===== Search Result Cards ===== */
.search-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
    padding: 0.5rem 0;
}

.search-result-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.25rem;
    cursor: pointer;
    transition: box-shadow 0.2s ease, transform 0.15s ease, border-color 0.2s ease;
    position: relative;
    overflow: hidden;
}

.search-result-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary-color);
    opacity: 0;
    transition: opacity 0.2s;
}

.search-result-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--primary-light);
}

.search-result-card:hover::before {
    opacity: 1;
}

.search-result-card.src-danger::before {
    background: var(--danger-color);
    opacity: 1;
}

.search-result-card.src-warning::before {
    background: var(--warning-color);
    opacity: 1;
}

/* Card header: avatar + name */
.src-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 0.75rem;
}

.src-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-light), #c7d2fe);
    color: var(--primary-color);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
}

.src-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-main);
    line-height: 1.3;
}

.src-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 1px;
}

/* Term block */
.src-term-row {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 0.6rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-app);
    border-radius: var(--radius-md);
}

.src-term {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-main);
}

.src-term small {
    font-weight: 500;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.src-pdr {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.src-pdr i {
    color: var(--primary-color);
    margin-right: 3px;
}

/* Badges row */
.src-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 0.5rem;
}

/* Empty state */
.search-cards-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.search-cards-empty i {
    font-size: 2.5rem;
    color: var(--text-light);
    margin-bottom: 0.75rem;
    display: block;
}

/* Search info bar */
.search-info-bar {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.search-info-bar strong {
    color: var(--text-main);
}

/* ===== Mobile-Only Elements (hidden on desktop, shown via @media) ===== */
.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-main);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
}
.mobile-menu-btn:hover {
    background: var(--primary-light);
    color: var(--primary-color);
}
.mobile-menu-btn:active {
    transform: scale(0.92);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}
.sidebar-overlay.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.search-close-btn {
    display: none;
    align-items: center;
    justify-content: center;
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: all 0.15s;
    z-index: 2;
}
.search-close-btn:hover {
    color: var(--danger-color);
    background: var(--danger-bg);
}

.filter-toggle-btn {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background: var(--bg-app);
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    justify-content: center;
}
.filter-toggle-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}
.filter-toggle-icon {
    transition: transform 0.3s;
    font-size: 0.7rem;
}
.filter-toggle-btn.open .filter-toggle-icon {
    transform: rotate(180deg);
}

/* ==========================================================================
   Mobile Responsiveness
   ========================================================================== */
@media (max-width: 768px) {

    /* Main Layout */
    .dashboard-layout {
        position: relative;
    }

    /* ===== Sidebar — fixed overlay with transform (Audit Risk #1 fix) ===== */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px !important;
        height: 100vh;
        box-shadow: 4px 0 15px rgba(0, 0, 0, 0.15);
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    /* On mobile, JS .collapsed class = sidebar VISIBLE (inverted logic) */
    .sidebar.collapsed {
        transform: translateX(0);
        width: 280px !important;
    }

    /* Show text when sidebar is open on mobile */
    .sidebar.collapsed .logo span,
    .sidebar.collapsed .nav-text,
    .sidebar.collapsed .badge {
        display: block;
    }

    /* ===== Topbar — compact mobile layout ===== */
    .topbar {
        padding: 0 0.5rem;
        height: 56px;
        position: relative;
    }

    /* Show mobile hamburger */
    .mobile-menu-btn {
        display: flex;
        margin-right: 0.35rem;
    }

    /* Hide original sidebar toggle on mobile */
    .toggle-sidebar-btn {
        display: none !important;
    }

    /* ===== Expandable Search ===== */
    .search-container {
        width: 40px;
        max-width: 40px;
        min-width: 40px;
        height: 40px;
        overflow: hidden;
        border-radius: 10px;
        cursor: pointer;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        flex-shrink: 0;
    }

    .search-container .search-input {
        opacity: 0;
        pointer-events: none;
        padding: 0.45rem 0.75rem 0.45rem 2.2rem;
        font-size: 0.9rem;
    }

    .search-container.expanded {
        position: absolute;
        left: 0.5rem;
        right: 0.5rem;
        width: auto;
        max-width: none;
        min-width: 0;
        z-index: 1001;
        background: white;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
        border-radius: var(--radius-md);
    }

    .search-container.expanded .search-input {
        opacity: 1;
        pointer-events: auto;
        padding-right: 2.5rem;
    }

    .search-container.expanded .search-close-btn {
        display: flex;
    }

    /* Hide profile text — keep only avatar */
    .topbar-actions {
        gap: 0.35rem;
    }

    .user-profile .user-info {
        display: none;
    }

    .user-profile .avatar {
        width: 32px;
        height: 32px;
    }

    /* Hide button text, keep icons only */
    .merge-btn-text,
    .sync-btn-text {
        display: none;
    }

    /* Compact action buttons */
    .btn-sync-header {
        padding: 0.35rem 0.5rem;
        font-size: 0.8rem;
        margin-left: 0;
    }

    .btn-merge-header {
        padding: 0.35rem 0.5rem;
        font-size: 0.8rem;
    }

    .btn-logout-header {
        padding: 0.35rem 0.5rem;
        font-size: 0.8rem;
    }

    /* ===== Content Area ===== */
    .content-area {
        padding: 0.75rem;
        width: 100vw;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .page-header h1 {
        font-size: 1.25rem;
    }

    .page-header p {
        font-size: 0.85rem;
    }

    .header-actions {
        width: 100%;
    }

    .header-actions .btn {
        flex: 1;
        justify-content: center;
        min-height: 44px;
    }

    /* ===== KPIs — stacked, compact ===== */
    .kpi-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }

    .kpi-card {
        padding: 1rem;
    }

    /* ===== Alerts / Widgets Grid ===== */
    .alerts-grid {
        grid-template-columns: 1fr;
    }

    .alerts-container {
        padding: 1rem;
    }

    .dashboard-widgets-grid-layout {
        grid-template-columns: 1fr;
    }

    /* ===== Table Section ===== */
    .data-section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 1rem;
    }

    .filter-bar {
        flex-wrap: wrap;
        width: 100%;
        gap: 0.5rem;
    }

    .filter-group {
        flex: 1 1 calc(50% - 0.5rem);
        min-width: 0;
    }

    .filter-group label {
        display: none;
    }

    .filter-select {
        width: 100%;
        font-size: 0.8rem;
        padding: 0.5rem 2rem 0.5rem 0.75rem;
    }

    /* ===== Collapsible Filters (mobile) ===== */
    .filter-toggle-btn {
        display: flex;
    }

    .filter-bar {
        display: none !important;
    }

    .filter-bar.open {
        display: flex !important;
    }

    /* ===== Detail Panel — full screen (Audit Risk #2: strict media scope) ===== */
    .detail-panel {
        width: 100% !important;
        max-width: 100% !important;
    }

    .detail-panel-body {
        padding: 1rem;
    }

    .dp-grid {
        grid-template-columns: 1fr;
    }

    .dp-term-card {
        padding: 1rem;
        gap: 1rem;
    }

    .dp-term-big {
        font-size: 2rem;
    }

    /* Footer buttons — touch-friendly 44px min */
    .detail-panel-footer {
        padding: 0.75rem;
        gap: 0.5rem;
        flex-wrap: wrap;
    }

    .detail-panel-footer .btn {
        min-height: 44px;
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem;
    }

    /* ===== Pagination ===== */
    .pagination {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.75rem;
    }


    /* ===== Search Cards Mobile ===== */
    .search-cards-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .src-avatar {
        width: 38px;
        height: 38px;
        font-size: 13px;
    }

    .src-term {
        font-size: 1.05rem;
    }

    /* ===== Table Card Layout for Mobile ===== */
    .table-container {
        border: none;
        background: transparent;
        padding: 0;
    }

    .crm-table,
    .crm-table tbody,
    .crm-table tr,
    .crm-table td {
        display: block;
        width: 100%;
    }

    .crm-table thead {
        display: none;
    }

    .crm-table tr {
        background-color: var(--bg-surface);
        border: 1px solid var(--border-color);
        border-radius: var(--radius-lg);
        margin-bottom: 1rem;
        padding: 0.75rem;
        box-shadow: var(--shadow-sm);
        position: relative;
    }

    .crm-table td {
        padding: 0.5rem 0;
        border-bottom: 1px dashed var(--border-color);
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
    }

    .crm-table td:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

    /* Auto-generated Labels for Card Rows */
    .crm-table td::before {
        font-weight: 600;
        font-size: 0.7rem;
        color: var(--text-muted);
        text-transform: uppercase;
        text-align: left;
        margin-right: 0.75rem;
        letter-spacing: 0.05em;
    }

    .crm-table td:nth-child(1)::before {
        content: "ID Пациента";
    }

    .crm-table td:nth-child(2) {
        justify-content: flex-start;
        background-color: var(--bg-app);
        margin: -0.75rem -0.75rem 0.75rem -0.75rem;
        padding: 0.75rem;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        border-bottom: 1px solid var(--border-color);
    }

    .crm-table td:nth-child(2)::before {
        display: none;
    }

    .crm-table td:nth-child(3)::before {
        content: "Срок Беременности";
    }

    .crm-table td:nth-child(4)::before {
        content: "ПДР";
    }

    .crm-table td:nth-child(5) {
        align-items: flex-start;
    }

    .crm-table td:nth-child(5)::before {
        content: "Риски / Особенности";
        margin-top: 4px;
    }

    .crm-table td:nth-child(5)>div {
        justify-content: flex-end;
    }

    .crm-table td:nth-child(6)::before {
        content: "Текущий Статус";
    }

    .crm-table td:nth-child(7) {
        justify-content: flex-end;
        padding-top: 0.75rem;
        gap: 0.5rem;
    }

    .crm-table td:nth-child(7)::before {
        content: "Действия";
        margin-right: auto;
    }

    /* ===== Schedule slots ===== */
    .schedule-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .schedule-slots-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    /* ===== Modal — full width on mobile ===== */
    .modal-content {
        max-width: 100%;
        border-radius: 12px;
    }

    .modal-content-lg {
        max-width: 100%;
    }
}

/* Tasks / Alerts Styling */
.alerts-container {
    background-color: var(--danger-bg);
    border: 1px solid var(--danger-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.alerts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.alert-card {
    background: white;
    border-left: 4px solid var(--danger-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.alert-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alert-card-title {
    font-weight: 700;
    color: var(--danger-color);
    font-size: 0.95rem;
}

.alert-card-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.alert-card-patient {
    font-weight: 600;
    font-size: 0.9rem;
}

.alert-card-details {
    font-size: 0.85rem;
    color: var(--text-main);
}

.alert-card-actions {
    margin-top: 0.5rem;
    display: flex;
    justify-content: flex-end;
}

/* ===== Schedule Section ===== */
.schedule-section {
    background: var(--bg-surface);
    border-radius: 12px;
    padding: 1.25rem;
    border: 1px solid var(--border-color);
}

.schedule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.schedule-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.schedule-header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.schedule-slots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
}

.slot-card {
    background: var(--bg-app);
    border-radius: 10px;
    padding: 0.875rem;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
    position: relative;
}

.slot-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.slot-card-time {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.slot-card-duration {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.slot-card-status {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.slot-status-available {
    background: #ecfdf5;
    color: #059669;
}

.slot-status-booked {
    background: #e0e7ff;
    color: #4338ca;
}

.slot-status-completed {
    background: #f1f5f9;
    color: #64748b;
}

.slot-status-cancelled {
    background: #fef2f2;
    color: #dc2626;
}

.slot-card-patient {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.slot-card-actions {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.35rem;
}

.slot-card-actions button {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: white;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--text-muted);
}

.slot-card-actions button:hover {
    background: var(--danger-bg);
    color: var(--danger-color);
    border-color: var(--danger-color);
}

/* Modal overlay for slot creation */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-header .close-modal {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    color: var(--text-muted);
    padding: 0.25rem;
    border-radius: 6px;
    transition: all 0.15s;
}

.modal-header .close-modal:hover {
    background: var(--danger-bg);
    color: var(--danger-color);
}

.modal-body {
    padding: 1.25rem;
}

.modal-body .form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.35rem;
}

.modal-body input[type="date"],
.modal-body input[type="time"],
.modal-body select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.modal-body input:focus,
.modal-body select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.slot-preview-area {
    background: var(--bg-app);
    border-radius: 8px;
    padding: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    min-height: 2.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.preview-chip {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-main);
}

.w-100 {
    width: 100%;
}

/* Schedule mobile rules moved into main @media block above */
/* Sync button pulse animation */
@keyframes pulse-sync {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); box-shadow: 0 0 12px rgba(99, 102, 241, 0.4); }
    100% { transform: scale(1); }
}


/* CDSS Section Styles */
.cdss-h { margin: 1.2rem 0 0.5rem; padding: 6px 12px; border-radius: 6px; font-size: 0.95rem; }
.cdss-h.questions { background: #eff6ff; color: #1d4ed8; border-left: 4px solid #3b82f6; }
.cdss-h.routing { background: #fefce8; color: #a16207; border-left: 4px solid #eab308; }
.cdss-h.profile { background: #f0fdf4; color: #15803d; border-left: 4px solid #22c55e; }
.cdss-h.recs { background: #fef2f2; color: #b91c1c; border-left: 4px solid #ef4444; }
#ai-content { line-height: 1.7; font-size: 0.92rem; }


/* Utility: hidden class */
.hidden { display: none !important; }

/* Refactored Inline Styles */
.btn-sync-header {
    margin-left: 0.5rem; color: #6366f1; background: #eef2ff; font-size: 0.8rem; display: flex; align-items: center; gap: 0.4rem; padding: 0.5rem 0.75rem; border-radius: 8px; white-space: nowrap;
}

.btn-logout-header {
    margin-left: 0.5rem; color: #ef4444; background: #fee2e2;
}

.dashboard-widgets-grid-layout {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem;
}

.messages-container-card {
    background: white; border-radius: 12px; padding: 1.25rem; border: 1px solid var(--border-color); display: flex; flex-direction: column;
}

.recent-messages-scrollable {
    display: flex; flex-direction: column; gap: 0.75rem; flex-grow: 1; overflow-y: auto; max-height: 300px;
}

.modal-content-lg {
    max-width: 560px;
}

/* ===== Archive Feature Styles ===== */
.btn-warning {
    background: #f59e0b;
    color: white;
    border: none;
    font-weight: 600;
}

.btn-warning:hover {
    background: #d97706;
}

.btn-warning:disabled {
    background: #d1d5db;
    color: #9ca3af;
    cursor: not-allowed;
}

.status-pill.archived {
    background: #f1f5f9;
    color: #64748b;
}

.archive-row {
    opacity: 0.85;
}

.archive-row:hover {
    opacity: 1;
}

#archive-section .data-section-header {
    border-left: 4px solid #f59e0b;
}

/* ===== Pagination Styles ===== */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
    background: white;
    border-radius: 0 0 12px 12px;
}

.pagination-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-main);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.pagination-btn:hover:not(:disabled):not(.active) {
    background: #f1f5f9;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.pagination-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3);
}

.pagination-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.pagination-ellipsis {
    padding: 0 4px;
    color: var(--text-muted);
    font-size: 0.85rem;
    -webkit-user-select: none;
    user-select: none;
}

/* ───── Merge Duplicates Button ───── */
.btn-merge-header {
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    color: #fff;
    border: none;
    padding: 0.45rem 0.8rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
}
.btn-merge-header:hover {
    background: linear-gradient(135deg, #7c3aed, #5b21b6);
    transform: translateY(-1px);
}

/* ───── Merge Modal ───── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-box {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}
.modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.modal-header h3 i {
    color: #8b5cf6;
}
.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 0 0.25rem;
    transition: color 0.15s;
}
.modal-close-btn:hover {
    color: var(--danger-color);
}

.modal-body {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Merge content */
.merge-loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 1rem;
}
.merge-loading i {
    font-size: 1.5rem;
    margin-right: 0.5rem;
    color: #8b5cf6;
}

.merge-empty {
    text-align: center;
    padding: 2rem;
}

.merge-group {
    background: var(--bg-app);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
}
.merge-group-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-main);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.merge-table {
    width: 100%;
    font-size: 0.82rem;
    border-collapse: collapse;
}
.merge-table th {
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0.4rem 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.merge-table td {
    padding: 0.5rem;
    border-top: 1px solid var(--border-color);
}
.merge-primary-row {
    background: rgba(34, 197, 94, 0.08);
}
.merge-dup-row {
    background: rgba(239, 68, 68, 0.05);
}
.merge-primary-row td:first-child,
.merge-dup-row td:first-child {
    text-align: center;
}

/* Responsive */
@media (max-width: 600px) {
    .modal-box { max-width: 100%; border-radius: 12px; }
    .merge-table { font-size: 0.75rem; }
    .merge-btn-text { display: none; }
}

