/* Cottonwood Integration Hub Styles */

/* Utility Classes */
.hidden {
    display: none !important;
}

:root {
    /* Color Palette - Forest/Nature Theme */
    --color-primary: #2d5a3d;
    --color-primary-light: #3d7a53;
    --color-primary-dark: #1d3a2d;
    --color-accent: #c9a227;
    --color-accent-light: #e6c547;
    
    /* Status Colors */
    --color-success: #22c55e;
    --color-success-bg: #dcfce7;
    --color-error: #ef4444;
    --color-error-bg: #fee2e2;
    --color-warning: #f59e0b;
    --color-warning-bg: #fef3c7;
    --color-info: #3b82f6;
    --color-info-bg: #dbeafe;
    
    /* Neutrals */
    --color-bg: #f8faf9;
    --color-surface: #ffffff;
    --color-border: #e2e8f0;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-text-light: #94a3b8;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    /* Typography */
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    /* Spacing */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    
    /* Sidebar */
    --sidebar-width: 240px;
    --navbar-height: 64px;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navbar */
.navbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0 2rem;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--color-primary);
}

.logo-icon {
    width: 28px;
    height: 28px;
}

.nav-links {
    display: flex;
    gap: 0.5rem;
}

.nav-link {
    padding: 0.5rem 1rem;
    text-decoration: none;
    color: var(--color-text-muted);
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all 0.2s;
}

.nav-link:hover {
    color: var(--color-text);
    background: var(--color-bg);
}

.nav-link.active {
    color: var(--color-primary);
    background: rgba(45, 90, 61, 0.1);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.user-name {
    font-weight: 500;
    color: var(--color-text);
}

/* App Layout with Sidebar */
.app-layout {
    display: flex;
    min-height: calc(100vh - var(--navbar-height) - 53px);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    padding: 1rem 0;
    flex-shrink: 0;
    overflow-y: auto;
}

.sidebar-section {
    padding: 0.5rem 0;
}

.sidebar-section-title {
    padding: 0.5rem 1.25rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1.25rem;
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.sidebar-link:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.sidebar-link.active {
    background: rgba(45, 90, 61, 0.1);
    color: var(--color-primary);
}

.sidebar-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-badge {
    margin-left: auto;
    padding: 0.125rem 0.5rem;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    border-radius: 9999px;
}

.sidebar-badge.badge-active {
    background: rgba(45, 90, 61, 0.1);
    color: var(--color-primary);
}

.sidebar-badge.badge-coming,
.sidebar-badge.badge-inactive {
    background: var(--color-bg);
    color: var(--color-text-muted);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    max-width: 1200px;
    width: 100%;
    overflow-x: hidden;
}

.main-content-full {
    max-width: none;
    margin: 0 auto;
}

/* Footer */
.footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: 1rem 2rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--color-primary-light);
}

.btn-primary:disabled {
    background: var(--color-text-light);
    cursor: not-allowed;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text);
}

.btn-outline:hover {
    background: var(--color-bg);
    border-color: var(--color-text-muted);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-google {
    background: white;
    border: 1px solid var(--color-border);
    color: var(--color-text);
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    width: 100%;
}

.btn-google:hover {
    background: var(--color-bg);
    box-shadow: var(--shadow-md);
}

.google-icon {
    width: 20px;
    height: 20px;
}

/* Cards */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
}

.card-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.card-body {
    padding: 1.5rem;
}

/* Login Page */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 80px);
    padding: 2rem;
}

.login-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

.login-header {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: white;
    padding: 2.5rem 2rem;
    text-align: center;
}

.login-logo {
    width: 56px;
    height: 56px;
    margin-bottom: 1rem;
}

.login-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.login-subtitle {
    opacity: 0.9;
    font-size: 0.9375rem;
}

.login-body {
    padding: 2rem;
}

.login-info {
    color: var(--color-text-muted);
    margin-bottom: 1.5rem;
    text-align: center;
}

.login-footer {
    padding: 1rem 2rem 1.5rem;
    text-align: center;
    color: var(--color-text-light);
    font-size: 0.8125rem;
}

/* Alert */
.alert {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    margin: 0 2rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
}

.alert svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.alert-error {
    background: var(--color-bg);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}

/* Dashboard */
.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.dashboard-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
}

.dashboard-subtitle {
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon svg {
    width: 24px;
    height: 24px;
}

.stat-icon-total,
.stat-icon-success,
.stat-icon-failed,
.stat-icon-rate {
    background: var(--color-bg);
    color: var(--color-text-muted);
}

.stat-label {
    color: var(--color-text-muted);
    font-size: 0.8125rem;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* Activity List */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--color-bg);
    border-radius: var(--radius-md);
}

.activity-status {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.activity-status svg {
    width: 16px;
    height: 16px;
}

.activity-status.status-success,
.activity-status.status-failed,
.activity-status.status-in_progress {
    background: var(--color-bg);
    color: var(--color-text-muted);
}

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-title {
    font-weight: 600;
    font-size: 0.875rem;
}

.activity-meta {
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

/* Badges */
.badge {
    padding: 0.25rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    border-radius: var(--radius-sm);
}

.badge-scheduled {
    background: var(--color-bg);
    color: var(--color-text-muted);
}

.badge-manual {
    background: rgba(45, 90, 61, 0.1);
    color: var(--color-primary);
}

/* Category badges (sync vs push) — used in the unified activity feeds on both
   the Logs page and each integration dashboard's "Recent Activity" card. */
.cat-badge {
    margin-right: 0.5rem;
    letter-spacing: 0.03em;
    vertical-align: middle;
}
.cat-sync {
    background: rgba(59, 130, 246, 0.14);
    color: #1d4ed8;
}
.cat-push {
    background: rgba(34, 197, 94, 0.12);
    color: #166534;
}

/* Sync rows in the activity feed link to that run's change detail. */
.activity-link {
    color: var(--color-text);
    text-decoration: none;
    border-bottom: 1px dashed var(--color-border);
}
.activity-link:hover {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

/* ── Data Changes cards (per data type, on each integration dashboard) ── */
.change-section .card-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.change-section-hint {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}
.change-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}
.change-card {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding: 1.1rem 1.15rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md, 10px);
    background: var(--color-surface);
    color: var(--color-text);
    text-decoration: none;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.change-card:hover,
.change-card:focus-visible {
    border-color: var(--color-primary);
    box-shadow: 0 4px 16px rgba(16, 33, 27, 0.07);
    transform: translateY(-1px);
    outline: none;
}
.change-card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
}
.change-card-label {
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
}
.change-card-count {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.change-deltas {
    display: flex;
    gap: 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.change-deltas .delta {
    padding: 0.2rem 0.55rem;
    border-radius: 7px;
    line-height: 1.2;
}
.delta-add { background: rgba(34, 197, 94, 0.12); color: #166534; }
.delta-rem { background: rgba(220, 38, 38, 0.10); color: #b91c1c; }
.delta-mod { background: rgba(180, 83, 9, 0.12); color: #b45309; }
.change-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: auto;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}
.change-card-link {
    color: var(--color-primary);
    font-weight: 600;
    white-space: nowrap;
}

/* Configuration */
.config-section {
    margin-bottom: 1.5rem;
}

.config-section:last-child {
    margin-bottom: 0;
}

.config-section h3 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 0.75rem;
}

.config-value {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.config-value svg {
    width: 18px;
    height: 18px;
    color: var(--color-text-muted);
}

.sheets-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sheet-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem;
    background: var(--color-bg);
    border-radius: var(--radius-md);
}

.sheet-icon {
    width: 36px;
    height: 36px;
    background: rgba(45, 90, 61, 0.1);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
}

.sheet-icon svg {
    width: 18px;
    height: 18px;
}

.sheet-name {
    font-weight: 600;
    font-size: 0.875rem;
}

.sheet-filename {
    color: var(--color-text-muted);
    font-size: 0.75rem;
    font-family: var(--font-mono);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--color-text-muted);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-hint {
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* Modal */

/* Transfer Status */
.transfer-status {
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.transfer-result.hidden {
    display: none;
}

.result-success, .result-error {
    text-align: center;
}

.result-success svg, .result-error svg {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
}

.result-success svg {
    color: var(--color-primary);
}

.result-error svg {
    color: var(--color-text-muted);
}

.result-success h4, .result-error h4 {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.result-details {
    margin-top: 1.5rem;
    text-align: left;
}

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.result-item.success,
.result-item.failed {
    border-left: 3px solid var(--color-border);
}

.error-detail {
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

/* Logs Page */
.logs-header {
    margin-bottom: 2rem;
}

.logs-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
}

.logs-subtitle {
    color: var(--color-text-muted);
    margin-top: 0.25rem;
}

.logs-table-container {
    overflow-x: auto;
}

.logs-table {
    width: 100%;
    border-collapse: collapse;
}

.logs-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--color-text-muted);
    border-bottom: 1px solid var(--color-border);
}

.logs-table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.875rem;
}

.logs-table .log-row:hover {
    background: var(--color-bg);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge svg {
    width: 14px;
    height: 14px;
}

.status-badge.status-success,
.status-badge.status-failed,
.status-badge.status-in_progress {
    background: var(--color-bg);
    color: var(--color-text-muted);
}

.filename {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    background: var(--color-bg);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
}

.user-email {
    color: var(--color-text);
}

.user-system {
    color: var(--color-text-muted);
    font-style: italic;
}

.timestamp {
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
}

.error-row td {
    padding: 0;
    border-bottom: 1px solid var(--color-border);
}

.error-details {
    padding: 0.75rem 1rem;
    background: var(--color-bg);
    font-size: 0.8125rem;
}

.error-details pre {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--color-text-muted);
    white-space: pre-wrap;
    word-break: break-word;
}

/* Links */
.link {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
}

.link:hover {
    text-decoration: underline;
}

/* Header Buttons */
.header-buttons {
    display: flex;
    gap: 0.75rem;
}

/* Change Type Badges */
.badge-added,
.badge-removed,
.badge-modified {
    background: var(--color-bg);
    color: var(--color-text-muted);
}

/* Activity Changes Summary */
.activity-changes {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.change-added,
.change-removed,
.change-modified {
    color: var(--color-text-muted);
}

/* CSS Variables for templates */
:root {
    --primary-color: var(--color-primary);
    --text-primary: var(--color-text);
    --text-secondary: var(--color-text-muted);
    --bg-secondary: var(--color-bg);
    --card-bg: var(--color-surface);
    --border-color: var(--color-border);
    --success-color: var(--color-success);
    --success-bg: var(--color-success-bg);
    --error-color: var(--color-error);
    --error-bg: var(--color-error-bg);
}

/* ==========================================================================
   Shared Data Table & List Page Styles
   Used by: parents.html, staff.html, students.html, changes.html,
            staff_changes.html
   ========================================================================== */

/* Header Actions (search bar area) */
.header-actions {
    display: flex;
    gap: 1rem;
}

.header-stats {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
}

/* Search Form */
.search-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-input {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    min-width: 220px;
    background: var(--card-bg);
    color: var(--text-primary);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Data Table Container */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    line-height: 1.5;
}

.data-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    white-space: nowrap;
}

.data-table tbody tr:hover {
    background: var(--bg-secondary);
}

/* Table Cell Types - Consistent across all list pages */
.id-cell {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.name-cell {
    font-weight: 500;
}

.parent-name,
.staff-name,
.student-name {
    font-weight: 500;
}

.email-cell a {
    color: var(--primary-color);
    text-decoration: none;
}

.email-cell a:hover {
    text-decoration: underline;
}

.date-cell {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.gender-cell {
    font-size: 0.875rem;
}

.department-cell {
    font-size: 0.875rem;
}

.phone-cell {
    font-size: 0.875rem;
}

.grade-cell .badge-info {
    background: var(--color-bg);
    color: var(--color-text-muted);
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.no-value {
    color: var(--text-secondary);
    opacity: 0.5;
}

/* Table Footer & Pagination */
.table-footer {
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.table-footer-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.pagination {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.pagination-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.btn-disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: default;
}

.empty-state-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* Stat Badges (used in changes pages) */
.stat-badge {
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
}

.stat-badge-success,
.stat-badge-danger,
.stat-badge-warning {
    background: var(--color-bg);
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}

/* Changes & Sync History Lists (used in changes.html, staff_changes.html) */
.changes-list,
.sync-history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.change-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 0.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
}

.change-item.change-added,
.change-item.change-removed,
.change-item.change-modified {
    border-left: 3px solid var(--color-border);
}

.change-icon {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}

.change-icon svg {
    width: 1rem;
    height: 1rem;
}

.change-added .change-icon,
.change-removed .change-icon,
.change-modified .change-icon {
    background: var(--color-bg);
    color: var(--color-text-muted);
}

.change-content {
    flex: 1;
    min-width: 0;
}

.change-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.change-meta {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.change-type-badge {
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.625rem;
    text-transform: uppercase;
}

.change-details {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-secondary);
    border-radius: 0.25rem;
    font-size: 0.75rem;
}

.field-change {
    display: block;
    margin-bottom: 0.25rem;
}

.field-change del {
    color: var(--color-text-muted);
    text-decoration: line-through;
}

.field-change ins {
    color: var(--color-primary);
    text-decoration: none;
}

.change-id {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.sync-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 0.5rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
}

.sync-status {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}

.sync-status svg {
    width: 1rem;
    height: 1rem;
}

.sync-status.status-success,
.sync-status.status-failed,
.sync-status.status-in_progress {
    background: var(--color-bg);
    color: var(--color-text-muted);
}

.sync-content {
    flex: 1;
}

.sync-time {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.sync-stats {
    display: flex;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.sync-error {
    color: var(--color-text-muted);
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.sync-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

.sync-duration {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

/* Large tablets / small desktops */
@media (max-width: 1024px) {
    .sidebar {
        width: 200px;
    }

    :root {
        --sidebar-width: 200px;
    }

    .search-input {
        min-width: 180px;
    }
}

/* Tablets */
@media (max-width: 768px) {
    /* Navbar */
    .navbar {
        padding: 0 1rem;
    }

    .nav-brand span {
        font-size: 0.9375rem;
    }

    .user-name {
        display: none;
    }

    /* Layout */
    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
        display: flex;
        overflow-x: auto;
        padding: 0.5rem;
    }

    .sidebar-section {
        display: flex;
        padding: 0;
        flex-shrink: 0;
    }

    .sidebar-section-title {
        display: none;
    }

    .sidebar-link {
        padding: 0.5rem 0.75rem;
        white-space: nowrap;
    }

    .sidebar-link span:not(.sidebar-badge) {
        display: none;
    }

    .sidebar-badge {
        display: none;
    }

    /* Main Content */
    .main-content {
        padding: 1rem;
    }

    /* Dashboard Headers */
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .dashboard-header h1 {
        font-size: 1.375rem;
    }

    /* Stats Grid */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    /* Header Buttons */
    .header-buttons {
        flex-direction: column;
        width: 100%;
    }

    .header-buttons .btn {
        width: 100%;
    }

    /* Search */
    .header-actions {
        width: 100%;
    }

    .search-form {
        width: 100%;
    }

    .search-input {
        min-width: 0;
        flex: 1;
    }

    /* Header Stats (changes pages) */
    .header-stats {
        flex-wrap: wrap;
    }

    .stat-badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }

    /* Card Header Row (changes pages) */
    .card-header-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .card-header-row .search-form {
        width: 100%;
    }

    .card-header-row .search-input {
        min-width: 0;
        flex: 1;
    }

    /* Dashboard Grid */
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    /* Table Footer & Pagination */
    .table-footer-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .pagination {
        width: 100%;
        justify-content: space-between;
    }

    /* Change Items (changes pages) */
    .change-item {
        flex-wrap: wrap;
    }

    .change-id {
        width: 100%;
        text-align: right;
        margin-top: 0.25rem;
    }

    /* Sync Items (changes pages) */
    .sync-item {
        flex-wrap: wrap;
    }

    .sync-meta {
        width: 100%;
        flex-direction: row;
        align-items: center;
        justify-content: flex-end;
        gap: 0.5rem;
        margin-top: 0.25rem;
    }
}

/* Mobile phones */
@media (max-width: 480px) {
    /* Navbar */
    .navbar {
        padding: 0 0.75rem;
        height: 56px;
    }

    .nav-brand span {
        font-size: 0.8125rem;
    }

    .logo-icon {
        width: 24px;
        height: 24px;
    }

    /* Main Content */
    .main-content {
        padding: 0.75rem;
    }

    /* Dashboard */
    .dashboard-header h1 {
        font-size: 1.25rem;
    }

    .dashboard-subtitle {
        font-size: 0.8125rem;
    }

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

    /* Cards */
    .card {
        border-radius: var(--radius-md);
    }

    .card-header {
        padding: 1rem;
    }

    .card-body {
        padding: 1rem;
    }

    /* Data Table - use tighter padding on mobile */
    .data-table th {
        padding: 0.5rem 0.625rem;
        font-size: 0.6875rem;
    }

    .data-table td {
        padding: 0.5rem 0.625rem;
        font-size: 0.8125rem;
    }

    /* Footer */
    .footer {
        padding: 0.75rem 1rem;
        font-size: 0.75rem;
    }

    /* Stat Cards */
    .stat-card {
        padding: 1rem;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
    }

    .stat-icon svg {
        width: 20px;
        height: 20px;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    /* Change Items */
    .change-item {
        padding: 0.625rem;
    }

    .change-name {
        font-size: 0.875rem;
    }

    /* Sync Items */
    .sync-item {
        padding: 0.625rem;
    }
}


/* =============================================================================
   Modal Overlay & Dialog
   ============================================================================= */

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.5);
    z-index: 9999;
}

.modal-overlay.active {
    display: block;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px -12px rgba(0, 0, 0, 0.25);
    width: calc(100% - 2rem);
    max-width: 620px;
    max-height: 94vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10000;
    animation: modalSlideIn 0.2s ease-out;
}

.modal.modal-sm {
    max-width: 440px;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) translateY(-16px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
    gap: 1rem;
}

.modal-header h2 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--color-text);
    margin: 0;
    flex: 1;
}

.modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: 1px solid transparent;
    font-size: 1.25rem;
    color: var(--color-text-muted);
    cursor: pointer;
    line-height: 1;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    margin-left: auto;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.modal-close:hover {
    color: var(--color-text);
    background: var(--color-bg);
    border-color: var(--color-border);
}

.modal form {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
    min-height: 0;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.625rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border);
    flex-shrink: 0;
}


/* =============================================================================
   Form Elements (Modal Forms)
   ============================================================================= */

.form-group {
    margin-bottom: 1rem;
    flex: 1;
    min-width: 0;
}

.form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.375rem;
}

.form-group .required {
    color: var(--color-error);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.5625rem 0.75rem;
    font-size: 0.875rem;
    font-family: var(--font-sans);
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s, box-shadow 0.15s;
    appearance: none;
    -webkit-appearance: none;
}

.form-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(45, 90, 61, 0.12);
}

.form-group input:disabled {
    background: var(--color-bg);
    color: var(--color-text-light);
    cursor: not-allowed;
    border-style: dashed;
}

.form-group input::placeholder {
    color: var(--color-text-light);
}

.form-row {
    display: flex;
    gap: 0.75rem;
}

.form-error {
    color: var(--color-error);
    font-size: 0.8125rem;
    font-weight: 500;
    margin-top: 0.5rem;
    min-height: 1.2em;
}

.form-hint {
    color: var(--color-text-muted);
    font-size: 0.8125rem;
    margin-top: 0.25rem;
}


/* =============================================================================
   Action Buttons (Table Row Icons)
   ============================================================================= */

.actions-col {
    width: 90px;
    text-align: center;
}

.actions-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.btn-icon svg {
    width: 16px;
    height: 16px;
}

.btn-icon-edit {
    color: var(--color-text-muted);
}

.btn-icon-edit:hover {
    background: var(--color-bg);
    color: var(--color-primary);
}

.btn-icon-delete {
    color: var(--color-text-muted);
}

.btn-icon-delete:hover {
    background: var(--color-bg);
    color: var(--color-text);
}


/* =============================================================================
   Danger Button Variant
   ============================================================================= */

.btn-danger {
    background: var(--color-error);
    color: white;
    border: none;
}

.btn-danger:hover {
    background: #dc2626;
}


/* =============================================================================
   Integration Tabs
   ============================================================================= */

.integration-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.integration-tab {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

.integration-tab:hover {
    background: var(--color-hover);
    color: var(--color-text);
    text-decoration: none;
}

.integration-tab.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.integration-tab.active:hover {
    background: var(--color-primary-dark);
}


/* =============================================================================
   Password Mask (Clever Table)
   ============================================================================= */

.password-mask {
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    letter-spacing: 0.05em;
    user-select: none;
}

.password-mask:hover {
    color: var(--color-primary);
}

.password-mask.revealed {
    color: var(--color-text);
    letter-spacing: normal;
}


/* =============================================================================
   Responsive Modal & Form Overrides
   ============================================================================= */

@media (max-width: 640px) {
    .modal {
        width: calc(100% - 1rem);
        max-height: 90vh;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-header,
    .modal-footer {
        padding: 0.875rem 1rem;
    }

    .modal-header h2 {
        font-size: 1rem;
    }
}

/* ── Clever dashboard restructure (2026-05-01) ───────────────────────────── */

/* Vertical rhythm between top-level sections (replaces ad-hoc margin-top) */
.section-stack-item {
    margin-top: 1.5rem;
}
.section-stack-item:first-of-type {
    margin-top: 1.5rem;
}

/* Card subtitle: muted descriptor next to a section title */
.card-subtitle {
    margin: 0.125rem 0 0;
    color: var(--color-text-muted);
    font-size: 0.8125rem;
    font-weight: 400;
}

/* Inventory row hover hint */
.inventory-table tbody tr {
    transition: background-color 120ms ease;
}
.inventory-table tbody tr:hover {
    background: var(--color-bg);
}
.inventory-file {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}
.inventory-filename {
    color: var(--color-text-muted);
    font-size: 0.75rem;
    font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
}

/* Sync-direction badges (extends .badge) */
.badge-pull {
    background: rgba(45, 90, 61, 0.08);
    color: var(--color-primary);
    letter-spacing: 0.04em;
}
.badge-push {
    background: rgba(34, 197, 94, 0.12);
    color: #166534;
    letter-spacing: 0.04em;
}
.badge-direction {
    background: var(--color-bg);
    color: var(--color-text-muted);
    letter-spacing: 0.04em;
    border: 1px solid var(--color-border);
}


/* ============================================================
   Scheduler health
   ------------------------------------------------------------
   A dead scheduler used to be invisible: the only symptom was a
   "Next run" timestamp quietly drifting into the past. The banner
   spans the full width directly under the navbar so it cannot be
   scrolled past or mistaken for ordinary page content.
   ============================================================ */
.scheduler-alert {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-bottom: 1px solid var(--color-border);
}

.scheduler-alert svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.scheduler-alert-text {
    flex: 1;
    min-width: 0;
}

.scheduler-alert-critical {
    background: var(--color-error-bg);
    color: #991b1b;
    border-bottom-color: #fecaca;
}

.scheduler-alert-warn {
    background: var(--color-warning-bg);
    color: #92400e;
    border-bottom-color: #fde68a;
}

.scheduler-alert-link {
    flex-shrink: 0;
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
    white-space: nowrap;
}

/* Status chip in the Schedules card header */
.card-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sched-status {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: default;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    color: var(--color-text-muted);
}

.sched-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    background: currentColor;
}

.sched-status-ok {
    color: #15803d;
    background: var(--color-success-bg);
    border-color: #bbf7d0;
}

.sched-status-warn {
    color: #92400e;
    background: var(--color-warning-bg);
    border-color: #fde68a;
}

.sched-status-critical {
    color: #991b1b;
    background: var(--color-error-bg);
    border-color: #fecaca;
}

/* A dead scheduler is urgent — draw the eye without animating forever. */
.sched-status-critical .sched-status-dot {
    animation: sched-pulse 2s ease-in-out infinite;
}

@keyframes sched-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

@media (max-width: 640px) {
    .scheduler-alert {
        align-items: flex-start;
        flex-wrap: wrap;
        padding: 0.75rem 1rem;
    }

    .card-header-actions {
        gap: 0.5rem;
    }
}
