/* CSS Variables - MSC Brand Colors - Dark Theme */
:root {
    /* MSC Brand Colors */
    --msc-blue-dark: #0494c8;
    --msc-blue-medium: #57b0d7;
    --msc-blue-light: #94cbe5;
    --msc-grey: #7e8586;
    --msc-orange: #ff8400;

    /* Dark Theme - Professional Corporate */
    --bg-page: #0f172a;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --bg-active: #1e3a5f;

    /* Text Colors */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-inverse: #0f172a;

    /* Accent Colors */
    --accent: #0494c8;
    --accent-hover: #06b6d4;
    --accent-light: #57b0d7;
    --accent-lighter: #94cbe5;
    --accent-pale: rgba(4, 148, 200, 0.15);

    /* Semantic Colors */
    --success: #22c55e;
    --success-light: rgba(34, 197, 94, 0.15);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.15);
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.15);
    --info: #0494c8;
    --info-light: rgba(4, 148, 200, 0.15);

    /* Borders & Shadows */
    --border-light: #334155;
    --border-medium: #475569;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.3);

    /* Layout */
    --radius-sm: 4px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Legacy variables for compatibility */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --border: #334155;
    --shadow: var(--shadow-md);
    --sidebar-width: 260px;

    /* Typography Scale - Compact */
    --font-xs: 0.675rem;
    --font-sm: 0.8rem;
    --font-base: 0.9rem;
    --font-lg: 1rem;
    --font-xl: 1.35rem;
    --font-2xl: 1.8rem;

    /* Spacing Scale - Compact */
    --space-1: 3px;
    --space-2: 6px;
    --space-3: 10px;
    --space-4: 14px;
    --space-5: 18px;
    --space-6: 22px;
    --space-8: 28px;
}

/* Screen reader only - visually hidden but accessible */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==================== TOP NAVIGATION BAR ==================== */
.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 52px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 1000;
}

/* Brand/Logo */
.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--msc-blue-dark);
    letter-spacing: -0.02em;
    transition: opacity 0.2s ease;
}

.nav-brand img {
    height: 32px;
    width: auto;
}

.nav-brand:hover {
    opacity: 0.85;
}

/* Main Menu */
.nav-menu {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Dropdown Container */
.nav-dropdown {
    position: relative;
}

.nav-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    background: transparent;
    border: none;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius);
    transition: all 0.2s ease;
}

.nav-dropdown-btn:hover {
    background: var(--bg-hover);
    color: var(--msc-blue-dark);
}

.nav-dropdown:hover .nav-dropdown-btn {
    background: var(--bg-hover);
    color: var(--msc-blue-dark);
}

.nav-dropdown-btn i,
.nav-dropdown-btn svg {
    width: 14px;
    height: 14px;
    opacity: 0.7;
    transition: transform 0.2s ease;
}

.nav-dropdown:hover .nav-dropdown-btn i,
.nav-dropdown:hover .nav-dropdown-btn svg {
    transform: rotate(180deg);
    opacity: 1;
}

/* Dropdown Content */
.dropdown-content {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    min-width: 190px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: all 0.2s ease;
    z-index: 1001;
    padding: 4px;
}

.nav-dropdown:hover .dropdown-content {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-content a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 450;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.dropdown-content a:hover {
    background: var(--accent-pale);
    color: var(--msc-blue-dark);
}

.dropdown-content a i,
.dropdown-content a svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.dropdown-content a:hover i,
.dropdown-content a:hover svg {
    color: var(--msc-blue-dark);
}

.dropdown-placeholder {
    display: block;
    padding: 8px 12px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-style: italic;
}

/* Right Side (Connection Status + User) */
.nav-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* Connection Status in Top Nav */
.top-nav .connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
}

.top-nav .connection-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    box-shadow: 0 0 0 2px rgba(148, 163, 184, 0.2);
}

.top-nav .connection-status.connected .status-dot {
    background: var(--success);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.top-nav .connection-status.disconnected .status-dot {
    background: var(--danger);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

/* User Dropdown */
.user-dropdown {
    position: relative;
}

.user-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.user-dropdown-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-medium);
}

.user-avatar {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--msc-blue-dark) 0%, var(--accent-hover) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.75rem;
}

.user-avatar i,
.user-avatar svg {
    width: 14px;
    height: 14px;
}

.user-dropdown-btn .user-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-dropdown-btn > i,
.user-dropdown-btn > svg {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.user-dropdown.open .user-dropdown-btn > i,
.user-dropdown.open .user-dropdown-btn > svg {
    transform: rotate(180deg);
}

/* User Dropdown Content */
.user-dropdown-content {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: all 0.2s ease;
    z-index: 1002;
    overflow: hidden;
}

.user-dropdown.open .user-dropdown-content {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown-header {
    padding: 12px 14px;
    background: linear-gradient(135deg, var(--msc-blue-dark) 0%, var(--accent-hover) 100%);
    color: white;
}

.user-dropdown-name {
    display: block;
    font-weight: 600;
    color: white;
    font-size: 0.85rem;
}

.user-dropdown-role {
    display: block;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 3px;
    text-transform: capitalize;
}

.user-dropdown-divider {
    height: 1px;
    background: var(--border-light);
    margin: 3px 6px;
}

.user-dropdown-content > a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 450;
    transition: all 0.15s ease;
}

.user-dropdown-content > a:hover {
    background: var(--accent-pale);
    color: var(--msc-blue-dark);
}

.user-dropdown-content > a i,
.user-dropdown-content > a svg {
    width: 15px;
    height: 15px;
    color: var(--text-muted);
}

.user-dropdown-content > a:hover i,
.user-dropdown-content > a:hover svg {
    color: var(--msc-blue-dark);
}

.user-dropdown-content > a.logout-link:hover {
    background: var(--danger-light);
    color: var(--danger);
}

.user-dropdown-content > a.logout-link:hover i,
.user-dropdown-content > a.logout-link:hover svg {
    color: var(--danger);
}

/* Lucide Icons */
.nav-icon i,
.stat-icon i,
.schedule-icon i,
.btn i,
.settings-tab i,
.btn-logout i {
    width: 18px;
    height: 18px;
    stroke-width: 2;
    vertical-align: middle;
}

.stat-icon i {
    width: 28px;
    height: 28px;
    color: var(--accent);
}

.schedule-icon i {
    width: 24px;
    height: 24px;
    color: var(--accent);
}

.btn i {
    margin-right: 6px;
    vertical-align: -2px;
}

.settings-tab i {
    margin-right: 6px;
    vertical-align: -3px;
}

.btn-logout i {
    width: 16px;
    height: 16px;
}

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

html,
html {
    scrollbar-gutter: stable;
}

body {
    width: 100%;
    overflow-x: hidden;
}

body {
    font-family:
        'Inter',
        'Segoe UI',
        system-ui,
        -apple-system,
        sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: var(--font-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* App Layout */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    transition:
        width 0.3s ease,
        transform 0.3s ease;
    z-index: 100;
}

.sidebar.collapsed {
    width: 60px;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px;
}

/* Tooltip styles */
.nav-tooltip {
    position: fixed;
    background: #1e293b;
    border: 1px solid #334155;
    padding: 8px 14px;
    border-radius: 6px;
    white-space: nowrap;
    font-size: 0.875rem;
    color: #fff;
    z-index: 99999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.nav-tooltip.visible {
    opacity: 1;
}

/* Widget table styles */
.widget-table-container {
    max-height: 280px;
    overflow-y: auto;
    overflow-x: hidden;
}

.widget-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    table-layout: fixed;
}

.widget-table td,
.widget-table th {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
    padding: 6px 8px;
}

.widget-table td:first-child,
.widget-table th:first-child {
    width: 30px;
    max-width: 30px;
}

.widget-table td:last-child,
.widget-table th:last-child {
    width: 60px;
    max-width: 60px;
    text-align: right;
}

.widget-table th {
    text-align: left;
    padding: 7px 10px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-weight: 500;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
}

.widget-table td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.widget-table tbody tr {
    cursor: pointer;
    transition: background 0.15s ease;
}

.widget-table tbody tr:hover {
    background: rgba(4, 148, 200, 0.1);
}

.widget-table .count-badge {
    display: inline-block;
    background: var(--accent);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.8rem;
}

.widget-table .contact-name {
    font-weight: 500;
}

.widget-table .company-name {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* Compact table variant */
.widget-table.compact th,
.widget-table.compact td {
    padding: 6px 10px;
    font-size: 0.8rem;
}

.widget-table.compact .count-badge {
    padding: 2px 8px;
    font-size: 0.75rem;
}

/* SLA Summary Widget */
.sla-summary {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 8px 0;
}

.sla-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.2s ease;
}

.sla-row:hover {
    background: var(--bg-hover);
}

.sla-count {
    font-size: 2rem;
    font-weight: 700;
    min-width: 50px;
    text-align: center;
}

.sla-count.overdue {
    color: var(--danger);
}

.sla-count.warning {
    color: var(--warning);
}

.sla-count.ok {
    color: var(--success);
}

.sla-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sla-label-title {
    font-weight: 600;
    color: var(--text-primary);
}

.sla-label-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Stale Tickets widget */
.stale-buckets {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 4px 0;
}

.stale-bucket {
    padding: 12px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    background: var(--bg-secondary);
    cursor: pointer;
    transition:
        border-color 0.2s ease,
        background 0.2s ease;
}

.stale-bucket:hover {
    background: var(--bg-hover);
    border-color: var(--border-medium);
}

.stale-bucket-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 10px;
}

.stale-bucket-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    min-width: 140px;
}

.stale-bucket-count {
    font-size: 2rem;
    font-weight: 700;
    min-width: 44px;
    text-align: center;
    line-height: 1;
}

.stale-bucket-count.overdue {
    color: var(--danger);
}
.stale-bucket-count.warning {
    color: var(--warning);
}
.stale-bucket-count.ok {
    color: var(--success);
}

.stale-bucket-labels {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stale-bucket-title {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.stale-bucket-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.stale-bucket-bar-wrap {
    flex: 1;
    height: 6px;
    background: var(--bg-primary);
    border-radius: 99px;
    overflow: hidden;
}

.stale-bucket-bar {
    height: 100%;
    border-radius: 99px;
    transition: width 0.4s ease;
}

.stale-bucket-bar.overdue {
    background: var(--danger);
}
.stale-bucket-bar.warning {
    background: var(--warning);
}
.stale-bucket-bar.ok {
    background: var(--success);
}

.stale-ticket-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.stale-ticket-chip {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--bg-primary);
    border: 1px solid var(--border-medium);
    color: var(--text-secondary);
    cursor: pointer;
    transition:
        border-color 0.15s ease,
        color 0.15s ease;
}

.stale-ticket-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.stale-ticket-more {
    color: var(--text-muted);
    border-style: dashed;
}

.stale-none {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

/* MAT per-school stale/SLA card layout — horizontal grid so all schools fit on one row */
.mat-bucket-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 8px;
    padding: 2px 0;
    width: 100%;
}

.mat-bucket-card {
    padding: 10px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
    border-left: 3px solid var(--card-accent, var(--border-light));
    background: var(--bg-secondary);
    min-width: 0;
    transition: border-color 0.2s ease;
}

.mat-bucket-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 7px;
    gap: 6px;
}

.mat-bucket-card-name {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mat-bucket-card-total {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-muted);
    line-height: 1;
    flex-shrink: 0;
}

.mat-bucket-card-total--active {
    color: var(--card-accent, var(--text-primary));
}

.mat-bucket-bar {
    height: 6px;
    border-radius: 99px;
    background: var(--bg-primary);
    overflow: hidden;
    display: flex;
    margin-bottom: 8px;
}

.mat-bucket-bar-empty {
    background: var(--border-light);
    opacity: 0.4;
}

.mat-bucket-bar-seg {
    height: 100%;
    transition: width 0.4s ease;
}

.mat-bucket-stats {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.mat-bucket-stat {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 6px;
    border-radius: 4px;
    background: color-mix(in srgb, var(--stat-color) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--stat-color) 25%, transparent);
    gap: 6px;
}

.mat-bucket-stat[onclick]:hover {
    background: color-mix(in srgb, var(--stat-color) 20%, transparent);
    cursor: pointer;
}

.mat-bucket-stat-label {
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.mat-bucket-stat-count {
    font-size: 1rem;
    font-weight: 800;
    color: var(--stat-color);
    line-height: 1;
}

.mat-bucket-stats--clear {
    padding: 2px 0;
}

.mat-bucket-all-clear {
    font-size: 0.7rem;
    color: var(--success);
    font-weight: 600;
    opacity: 0.8;
}

/* Bucket badges — count + label pairs displayed as compact coloured chips */
.mat-bucket-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 2px;
}

.mat-bucket-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 7px 3px 5px;
    border-radius: 99px;
    background: color-mix(in srgb, var(--badge-color) 15%, transparent);
    border: 1px solid color-mix(in srgb, var(--badge-color) 35%, transparent);
    cursor: default;
    transition: background 0.15s ease;
}

.mat-bucket-badge[onclick] {
    cursor: pointer;
}

.mat-bucket-badge[onclick]:hover {
    background: color-mix(in srgb, var(--badge-color) 28%, transparent);
}

.mat-bucket-badge-count {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--badge-color);
    line-height: 1;
}

.mat-bucket-badge-label {
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--text-secondary);
    line-height: 1;
    white-space: nowrap;
}

/* MAT multi-school bucket layout — one column per school using stale-bucket style */
.mat-school-cols {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    width: 100%;
}

.mat-school-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.mat-school-col-name {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0 2px 2px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 2px;
}

.mat-school-col .stale-buckets {
    gap: 6px;
}

.mat-school-col .stale-bucket {
    padding: 8px 10px;
}

.mat-school-col .stale-bucket-header {
    margin-bottom: 6px;
    gap: 8px;
}

.mat-school-col .stale-bucket-meta {
    min-width: 0;
    gap: 8px;
}

.mat-school-col .stale-bucket-count {
    font-size: 1.5rem;
    min-width: 32px;
}

.mat-school-col .stale-ticket-chips {
    gap: 4px;
}

/* SLA table cell colors */
td.overdue {
    color: var(--danger);
    font-weight: 600;
}

td.warning {
    color: var(--warning);
    font-weight: 600;
}

/* Modal tabs */
.modal-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
}

.modal-tab {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.modal-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-tab.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.modal-summary {
    margin-bottom: 12px;
    color: var(--text-secondary);
}

/* Stat widgets - 1 column x 1 row (6 across) */
.widget.stat-widget {
    grid-column: span 1;
    grid-row: span 1;
    justify-self: stretch;
    align-self: start;
    height: 100px !important;
    max-height: 100px !important;
    min-height: 100px !important;
    min-width: 0 !important;
    width: 100% !important;
    overflow: hidden;
    padding: 0 !important;
}

.widget.stat-widget .stat-card {
    margin: 0;
    height: 110px;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 8px 12px;
    gap: 4px;
    box-sizing: border-box;
    border-radius: var(--radius);
}

.widget.stat-widget .stat-label {
    font-size: 0.75rem;
    line-height: 1.2;
    margin-bottom: 4px;
}

.widget.stat-widget .stat-value {
    font-size: clamp(1rem, 1.4vw, 1.5rem);
    font-weight: 700;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

/* Color coding for widget counts (internal dashboards) */
.widget.stat-widget .stat-value.count-green,
.mat-stat-company-value.count-green {
    color: var(--success);
}

.widget.stat-widget .stat-value.count-amber,
.mat-stat-company-value.count-amber {
    color: var(--warning);
}

.widget.stat-widget .stat-value.count-red,
.mat-stat-company-value.count-red {
    color: var(--danger);
}

.widget.stat-widget .stat-detail {
    font-size: 0.65rem;
    line-height: 1.2;
    color: var(--text-secondary);
}

.widget.stat-widget .stat-card.clickable {
    cursor: pointer;
}

.widget.stat-widget .stat-card.clickable:hover {
    background: rgba(4, 148, 200, 0.15);
}

.widget.stat-widget .widget-drag-handle {
    top: 4px;
    right: 4px;
}

/* MAT multi-company stat widget — shows per-child breakdown inside a single stat card */
.widget.stat-widget.mat-stat-widget {
    height: 120px !important;
    max-height: 120px !important;
    min-height: 120px !important;
}

.widget.stat-widget.mat-stat-widget .stat-card {
    height: 100%;
    padding: 8px 10px 6px;
    gap: 0;
}

.mat-stat-companies {
    display: flex;
    gap: 4px;
    width: 100%;
    flex: 1;
    align-items: center;
    justify-content: space-around;
}

.mat-stat-company {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    flex: 1;
    min-width: 0;
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 4px 2px;
    transition: background 0.15s ease;
}

.mat-stat-company:hover {
    background: rgba(4, 148, 200, 0.15);
}

.mat-stat-company-value {
    font-size: clamp(1rem, 1.3vw, 1.4rem);
    font-weight: 700;
    line-height: 1.1;
    color: var(--text-primary);
}

.mat-stat-company-name {
    font-size: 0.6rem;
    color: var(--text-secondary);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    line-height: 1.2;
}

.mat-stat-divider {
    width: 1px;
    height: 36px;
    background: var(--border-light);
    flex-shrink: 0;
}

/* Kill rate colouring inside MAT stat companies */
.mat-stat-company-value.kr-good {
    color: var(--success);
}
.mat-stat-company-value.kr-bad {
    color: var(--danger);
}

/* MAT top-creators column header (legacy, kept for compat) */
.mat-creators-company-name {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 6px 4px 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 2px;
}

/* MAT per-school column grid for table widgets (creators / resources / issue types) */
.mat-cols-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    width: 100%;
}

.mat-col-panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    overflow: hidden;
}

.mat-col-header {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 8px 10px 6px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-primary);
}

.mat-col-table {
    width: 100%;
    margin: 0;
}

.mat-col-table thead th {
    font-size: 0.68rem;
    color: var(--text-muted);
    padding: 5px 8px;
    background: transparent;
    border-bottom: 1px solid var(--border-light);
}

.mat-col-table tbody tr:hover {
    background: var(--bg-hover);
}

.mat-col-table tbody td {
    padding: 6px 8px;
    font-size: 0.8rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.mat-col-table tbody tr:last-child td {
    border-bottom: none;
}

.mat-col-rank {
    color: var(--text-muted);
    font-size: 0.72rem;
    width: 20px;
    text-align: center;
}

.mat-col-subtype {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* Kill rate summary in modal */
.kill-rate-summary {
    display: flex;
    gap: 24px;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.summary-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.summary-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

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

.summary-value.text-success {
    color: #10b981;
}

.summary-value.text-danger {
    color: #ef4444;
}

.sidebar.collapsed .sidebar-header h1,
.sidebar.collapsed .sidebar-logo,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .status-text,
.sidebar.collapsed .connection-status {
    display: none;
    visibility: hidden;
    width: 0;
    opacity: 0;
}

.sidebar.collapsed .nav-icon {
    margin: 0;
    font-size: 1.1rem;
}

.sidebar.collapsed .sidebar-header {
    padding: 10px;
    justify-content: center;
    flex-direction: row;
}

.sidebar.collapsed .sidebar-toggle {
    position: static;
    margin: 0 auto;
}

/* ==================== SIDEBAR HEADER ==================== */
.sidebar-header {
    padding: 12px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.1);
}

.sidebar-logo {
    width: 100%;
    max-width: 160px;
    margin-bottom: 2px;
    background: #ffffff;
    padding: 10px 14px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.sidebar-logo img {
    width: 100%;
    height: auto;
    display: block;
}

.sidebar-header h1 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-light);
    white-space: nowrap;
    overflow: hidden;
    letter-spacing: 0.5px;
}

.sidebar-header .sidebar-toggle {
    position: absolute;
    top: 12px;
    right: 10px;
}

/* ==================== USER INFO SECTION ==================== */
.sidebar-user {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    margin-top: auto;
    background: rgba(0, 0, 0, 0.1);
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.8rem;
}

.user-role {
    font-size: 0.65rem;
    color: var(--accent-light);
    text-transform: capitalize;
    font-weight: 500;
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.btn-logout i {
    width: 16px;
    height: 16px;
}

.btn-logout:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

.sidebar.collapsed .sidebar-user {
    padding: 10px;
    justify-content: center;
}

.sidebar.collapsed .user-info {
    display: none;
}

/* Card header row */
.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-header-row h3 {
    margin: 0;
}

/* Form styles */
.form-inline .form-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group label {
    font-size: var(--font-xs);
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.form-group input,
.form-group select {
    padding: 7px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.8rem;
    min-width: 180px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(4, 148, 200, 0.15);
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* Modal small */
.modal-small {
    max-width: 500px;
}

/* Permissions table */
.permissions-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
}

.permissions-table th,
.permissions-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.permissions-table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 600;
}

.permissions-table td:last-child {
    text-align: center;
    width: 60px;
}

.permissions-table th:last-child {
    text-align: center;
    width: 60px;
}

.permissions-table input[type='checkbox'] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent);
}

.permissions-note {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-style: italic;
    margin: 4px 0;
}

/* Company access checkboxes in user modal */
.company-access-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 4px;
}

.company-access-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.company-access-item:last-child {
    border-bottom: none;
}

.company-access-item:hover {
    background: rgba(4, 148, 200, 0.05);
}

.company-access-item input[type='checkbox'] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

.company-access-item label {
    cursor: pointer;
    font-size: 0.9rem;
    margin: 0;
}

.company-access-empty {
    padding: 12px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-align: center;
}

/* Permissions page */
.permission-reference-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.permission-category {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.permission-category:last-child {
    border-bottom: none;
}

.permission-category-title {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
    margin: 0 0 10px 0;
}

.permission-ref-list {
    margin: 0;
    padding-left: 20px;
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.6;
}

.permission-ref-list li {
    margin-bottom: 6px;
}

.permissions-modal-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 4px 0;
}

/* Category group */
.perm-group {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.perm-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-secondary, rgba(255, 255, 255, 0.04));
    border-bottom: 1px solid var(--border);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
}

.perm-group-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: var(--accent);
}

.perm-group-rows {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

/* Individual permission row */
.perm-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
}

.perm-row:last-child,
.perm-group-rows .perm-row:nth-last-child(-n + 2):not(:nth-child(odd) ~ .perm-row) {
    border-bottom: none;
}

.perm-group-rows .perm-row:nth-child(even) {
    border-right: none;
}

.perm-row:hover {
    background: rgba(var(--accent-rgb, 99, 102, 241), 0.07);
}

.perm-row--active {
    background: rgba(var(--accent-rgb, 99, 102, 241), 0.1);
}

.perm-row input[type='checkbox'] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-top: 2px;
    accent-color: var(--accent);
    cursor: pointer;
}

.perm-row-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.perm-row-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
}

.perm-row-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Legacy label kept for any remaining references */
.permission-modal-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9rem;
}

.permission-modal-checkbox-label input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

#permissionsModal .modal-content {
    max-width: 820px;
    width: 95vw;
}

#permissionsModal .modal-body {
    overflow-y: auto;
    max-height: calc(90vh - 80px);
    padding: 20px 24px;
}

.permissions-role-note {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 12px;
}

.text-muted {
    color: var(--text-secondary);
    font-weight: normal;
}

/* ==================== NAVIGATION SECTIONS ==================== */
/* Collapsible sections (Database, Dashboards, Settings) */

.nav-section {
    margin-top: 4px;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.02);
    overflow: hidden;
}

.nav-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
    border-radius: var(--radius);
}

.nav-section-header:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.04);
}

.nav-section-header .nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.nav-section-header .nav-icon i {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

.nav-section-header .nav-text {
    flex: 1;
}

.nav-section-header .nav-chevron {
    font-size: 0.6rem;
    transition: transform 0.2s;
    opacity: 0.6;
}

/* Add button in section header */
.nav-section-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    background: rgba(4, 148, 200, 0.1);
    border: none;
    border-radius: 4px;
    color: var(--accent);
    cursor: pointer;
    opacity: 0;
    transition: all 0.15s;
}

.nav-section-add-btn i {
    width: 14px;
    height: 14px;
}

.nav-section-header:hover .nav-section-add-btn {
    opacity: 1;
}

.nav-section-add-btn:hover {
    background: rgba(4, 148, 200, 0.25);
    transform: scale(1.1);
}

.nav-section.collapsed .nav-chevron {
    transform: rotate(-90deg);
}

/* Section items container */
.nav-section-items {
    max-height: 600px;
    overflow-y: auto;
    overflow-x: hidden;
    transition:
        max-height 0.3s ease,
        opacity 0.2s ease,
        padding 0.3s ease;
    padding: 4px 6px 8px 6px;
    background: rgba(0, 0, 0, 0.15);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.nav-section.collapsed .nav-section-items {
    max-height: 0;
    opacity: 0;
    padding: 0 6px;
    border-top: none;
}

/* Sub-items within sections */
.nav-section-items .nav-item {
    padding: 8px 10px !important;
    margin: 2px 0;
    font-size: 0.8rem;
    font-weight: 400;
    border-radius: 6px;
}

.nav-section-items .nav-item .nav-icon {
    width: 18px;
    height: 18px;
}

.nav-section-items .nav-item .nav-icon i {
    width: 16px;
    height: 16px;
}

.nav-section-items .nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
}

.nav-section-items .nav-item.active {
    background: var(--accent);
    box-shadow: 0 2px 6px rgba(4, 148, 200, 0.25);
}

/* Collapsed sidebar section styles */
.sidebar.collapsed .nav-section-header .nav-text,
.sidebar.collapsed .nav-section-header .nav-chevron,
.sidebar.collapsed .nav-section-add-btn {
    display: none;
}

.sidebar.collapsed .nav-section-items {
    display: none;
}

.sidebar.collapsed .nav-section {
    background: transparent;
}

/* ==================== SUBSECTION HEADERS ==================== */
/* Category headers within Dashboards (Internal, Managed, Co-Managed) */

.nav-subsection-header {
    display: flex;
    align-items: center;
    padding: 12px 8px 6px 8px;
    color: var(--accent-light);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 4px;
    position: relative;
}

.nav-subsection-header::before {
    content: '';
    position: absolute;
    left: 8px;
    right: 8px;
    top: 4px;
    height: 1px;
    background: linear-gradient(90deg, var(--border) 0%, transparent 100%);
}

.nav-subsection-header:first-child {
    margin-top: 0;
    padding-top: 8px;
}

.nav-subsection-header:first-child::before {
    display: none;
}

.sidebar.collapsed .nav-subsection-header {
    display: none;
}

/* Welcome page */
.welcome-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 65vh;
}

.welcome-content {
    text-align: center;
    padding: 32px;
}

.welcome-content h1 {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    letter-spacing: -0.03em;
}

.welcome-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    max-width: 400px;
    margin: 0 auto;
}

/* Tools Section Grouping */
.tools-section {
    margin-bottom: 32px;
}

.tools-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.tools-section-header svg,
.tools-section-header i {
    width: 14px;
    height: 14px;
    color: var(--accent);
    stroke: var(--accent);
}

/* Navigation Tile Grid */
.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 8px;
}

.nav-tile {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 16px 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.nav-tile:hover {
    border-color: var(--msc-blue-medium);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.nav-tile .tile-icon {
    width: 48px;
    height: 48px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.nav-tile .tile-icon i,
.nav-tile .tile-icon svg {
    width: 24px;
    height: 24px;
    color: white;
    stroke: white;
}

.nav-tile .tile-content h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.nav-tile .tile-content p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin: 0;
}

/* Tile category sections */
.tile-section-header {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
}

.tile-category-section {
    margin-bottom: 24px;
}

.tile-category-header {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding-left: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tile-grid-inner {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}

.tile-empty {
    color: var(--text-muted);
    font-style: italic;
    padding: 12px;
    font-size: 0.9rem;
}

/* Dashboard header with title and add button */
.dashboards-header .header-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

/* Tiny Add Dashboard button */
.btn-add-dashboard-tiny {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--msc-blue-light);
    background: var(--accent-pale);
    border: 1px solid var(--msc-blue-dark);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-add-dashboard-tiny:hover {
    background: var(--msc-blue-dark);
    border-color: var(--msc-blue-dark);
    color: white;
}

.btn-add-dashboard-tiny i,
.btn-add-dashboard-tiny svg {
    width: 10px;
    height: 10px;
}

/* 4-Column Categories Grid */
.tile-categories-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    padding: 8px;
}

@media (max-width: 1200px) {
    .tile-categories-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .tile-categories-grid {
        grid-template-columns: 1fr;
    }
}

.tile-category-column {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 12px;
    min-height: 200px;
}

.tile-category-column .tile-category-header {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 12px 0;
    padding-left: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tile-column-inner {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Small tiles - uniform size */
.nav-tile-small {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
}

.nav-tile-small:hover {
    border-color: var(--msc-blue-medium);
    background: var(--bg-hover);
    transform: translateX(2px);
}

.tile-icon-small {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tile-icon-small i,
.tile-icon-small svg {
    width: 14px;
    height: 14px;
    color: white;
    stroke: white;
}

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

.tile-content-small h4 {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Edit/delete buttons for small tiles */
.nav-tile-small .tile-edit-btn,
.nav-tile-small .tile-delete-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    padding: 0;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-tile-small .tile-edit-btn {
    right: 28px;
    color: #60a5fa;
}

.nav-tile-small .tile-delete-btn {
    right: 4px;
    color: #f87171;
}

.nav-tile-small:hover .tile-edit-btn,
.nav-tile-small:hover .tile-delete-btn,
.nav-tile-small:hover .tile-mats-btn {
    opacity: 1;
}

.nav-tile-small .tile-edit-btn i,
.nav-tile-small .tile-delete-btn i,
.nav-tile-small .tile-mats-btn i,
.nav-tile-small .tile-edit-btn svg,
.nav-tile-small .tile-delete-btn svg,
.nav-tile-small .tile-mats-btn svg {
    width: 12px;
    height: 12px;
}

/* MATS button for managing schools */
.nav-tile-small .tile-mats-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 52px;
    width: 22px;
    height: 22px;
    padding: 0;
    background: rgba(139, 92, 246, 0.7);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.nav-tile-small .tile-mats-btn:hover {
    background: rgba(139, 92, 246, 1);
}

/* MATS Modal Styles */
.mats-parent-info {
    background: var(--bg-secondary);
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.85rem;
}

.mats-section {
    margin-bottom: 20px;
}

.mats-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.mats-section h4 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 8px 0;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.mats-section-header h4 {
    margin: 0;
}

.mats-children-list {
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.mats-child-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.mats-child-item:last-child {
    margin-bottom: 0;
}

.mats-child-name {
    flex: 1;
    color: var(--text-primary);
}

.mats-child-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    font-weight: 500;
}

.mats-child-badge.autotask {
    background: var(--primary);
    color: white;
}

.mats-remove-btn {
    background: transparent;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mats-remove-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

.mats-remove-btn i,
.mats-remove-btn svg {
    width: 14px;
    height: 14px;
}

.mats-empty {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.8rem;
    padding: 8px;
    margin: 0;
}

/* Short name input row inside Manage MAT Schools modal */
.mats-shortname-row {
    gap: 10px;
}

.mats-shortname-row .mats-child-name {
    flex: 1 1 55%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mats-shortname-input {
    flex: 0 0 120px;
    padding: 5px 8px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.8rem;
    min-width: 0;
}

.mats-shortname-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-pale);
}

.mats-save-shortnames-btn {
    margin-top: 10px;
}

.mats-section-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin: 0 0 10px;
    line-height: 1.4;
}

.mats-add-section {
    border-top: 1px solid var(--border-light);
    padding-top: 16px;
}

.mats-search-container {
    position: relative;
}

.mats-search-container input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.85rem;
}

.mats-search-container input:focus {
    outline: none;
    border-color: var(--primary);
}

.mats-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    margin-top: 4px;
    box-shadow: var(--shadow-md);
}

.mats-search-item {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border-light);
}

.mats-search-item:last-child {
    border-bottom: none;
}

.mats-search-item:hover {
    background: var(--bg-hover);
}

/* MAT Dashboard Creation Modal */
.mat-selected-company {
    margin-top: 8px;
}

.mat-selected-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #8b5cf6;
    color: white;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.mat-clear-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0.8;
}

.mat-clear-btn:hover {
    opacity: 1;
}

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

/* Tile action buttons */
.nav-tile {
    position: relative;
}

.tile-edit-btn,
.tile-delete-btn {
    position: absolute;
    top: 8px;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.tile-edit-btn {
    right: 40px;
    background: var(--primary);
    color: white;
}

.tile-delete-btn {
    right: 8px;
    background: var(--danger);
    color: white;
}

.nav-tile:hover .tile-edit-btn,
.nav-tile:hover .tile-delete-btn {
    opacity: 1;
}

.tile-edit-btn:hover {
    background: var(--primary-hover);
}

.tile-delete-btn:hover {
    background: #dc2626;
}

.tile-edit-btn i,
.tile-delete-btn i,
.tile-edit-btn svg,
.tile-delete-btn svg {
    width: 14px;
    height: 14px;
}

/* Tile category sections */
.tile-section-header {
    margin-bottom: 16px;
    padding: 0 8px;
}

/* Add Dashboard button - compact style */
.btn-add-dashboard {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--msc-blue-light);
    background: var(--accent-pale);
    border: 1px solid var(--msc-blue-dark);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-add-dashboard:hover {
    background: var(--msc-blue-dark);
    border-color: var(--msc-blue-dark);
    color: white;
}

.btn-add-dashboard i,
.btn-add-dashboard svg {
    width: 12px;
    height: 12px;
}

/* Legacy company section styles - kept for compatibility */
.company-section {
    margin-top: 4px;
}

.company-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    user-select: none;
    transition: color 0.2s;
}

.company-section-header:hover {
    color: var(--text-primary);
}

.company-section-header .chevron {
    font-size: 0.6rem;
    transition: transform 0.2s;
}

.company-section.collapsed .chevron {
    transform: rotate(-90deg);
}

.company-section-list {
    max-height: 280px;
    overflow-y: auto;
    overflow-x: hidden;
    transition:
        max-height 0.3s ease,
        opacity 0.2s ease;
}

.company-section.collapsed .company-section-list {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
}

/* ==================== DASHBOARD NAV ITEMS ==================== */
/* Individual dashboard items in the sidebar */

.company-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 400;
    border-radius: 6px;
    margin: 2px 0;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
}

.company-nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.company-nav-item.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 6px rgba(4, 148, 200, 0.25);
}

.company-nav-item .company-dot {
    width: 8px;
    height: 8px;
    min-width: 8px;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}

.company-nav-item.active .company-dot {
    background: white !important;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

.company-nav-item .company-label {
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

/* Company delete button */
.company-delete-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    margin-left: auto;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.15s;
}

.company-delete-btn i {
    width: 12px;
    height: 12px;
}

.company-nav-item:hover .company-delete-btn {
    display: flex;
}

.company-delete-btn:hover {
    opacity: 1;
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.company-nav-item.active .company-delete-btn {
    color: rgba(255, 255, 255, 0.7);
}

.company-nav-item.active .company-delete-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Internal dashboard edit button */
.internal-edit-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    margin-left: auto;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.15s;
}

.internal-edit-btn i {
    width: 12px;
    height: 12px;
}

.company-nav-item:hover .internal-edit-btn {
    display: flex;
}

.internal-edit-btn:hover {
    opacity: 1;
    background: rgba(4, 148, 200, 0.2);
    color: var(--accent);
}

.company-nav-item.active .internal-edit-btn {
    color: rgba(255, 255, 255, 0.7);
}

.company-nav-item.active .internal-edit-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Internal dashboard delete button */
.internal-delete-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    margin-left: 4px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.15s;
}

.internal-delete-btn i {
    width: 12px;
    height: 12px;
}

.company-nav-item:hover .internal-delete-btn {
    display: flex;
}

.internal-delete-btn:hover {
    opacity: 1;
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.company-nav-item.active .internal-delete-btn {
    color: rgba(255, 255, 255, 0.7);
}

.company-nav-item.active .internal-delete-btn:hover {
    background: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

/* Draggable dashboard items */
.draggable-dashboard {
    cursor: grab;
}

.draggable-dashboard:active {
    cursor: grabbing;
}

.draggable-dashboard.dragging,
.internal-dashboard-item.dragging {
    opacity: 0.5;
    background: var(--bg-hover);
}

.draggable-dashboard.drag-over,
.internal-dashboard-item.drag-over {
    border-top: 2px solid var(--accent);
    margin-top: -2px;
}

/* Internal dashboard items - draggable and renameable */
.internal-dashboard-item[draggable='true'] {
    cursor: grab;
}

.internal-dashboard-item[draggable='true']:active {
    cursor: grabbing;
}

/* Hide company section when sidebar collapsed */
.sidebar.collapsed .company-section {
    display: none;
}

/* Company search results */
.company-search-results {
    max-height: 300px;
    overflow-y: auto;
}

.company-search-item {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.15s;
}

.company-search-item:hover:not(.disabled) {
    background: rgba(4, 148, 200, 0.1);
}

.company-search-item.disabled {
    opacity: 0.5;
    cursor: default;
}

.company-search-item .company-name {
    font-size: 0.9rem;
}

.company-search-item .add-icon {
    color: var(--accent);
    font-weight: bold;
    font-size: 1.2rem;
}

.company-search-item .badge {
    font-size: 0.7rem;
    padding: 2px 8px;
    background: var(--bg-primary);
    border-radius: 10px;
    color: var(--text-secondary);
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.badge-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.badge-info {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.badge-admin {
    background: rgba(139, 92, 246, 0.2);
    color: #8b5cf6;
}

.badge-user {
    background: rgba(4, 148, 200, 0.2);
    color: #0494c8;
}

.badge-viewer {
    background: rgba(148, 163, 184, 0.2);
    color: #94a3b8;
}

.badge-secondary {
    background: rgba(148, 163, 184, 0.2);
    color: #94a3b8;
}

/* URL cell for TV displays */
.url-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.url-cell code {
    background: var(--bg-primary);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    color: var(--accent);
}

.btn-sm {
    padding: 4px 8px;
    font-size: 0.8rem;
}

.btn-sm i {
    width: 14px;
    height: 14px;
}

/* Info list for TV displays */
.info-list {
    list-style: none;
    padding: 0;
    margin: 10px 0 0 0;
}

.info-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.info-list li:last-child {
    border-bottom: none;
}

.info-list li strong {
    color: var(--text-primary);
}

/* Action buttons */
.action-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 1rem;
    transition: background 0.2s ease;
}

.action-btn:hover {
    background: var(--bg-primary);
}

.action-btn.delete:hover {
    background: rgba(239, 68, 68, 0.2);
}

.sidebar-toggle {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 22px;
    height: 22px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.sidebar.collapsed .sidebar-toggle {
    transform: rotate(180deg);
}

.sidebar-nav {
    flex: 1;
    padding: 8px 8px;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Main navigation items (top-level) */
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: var(--radius);
    margin-bottom: 0;
    transition: all 0.2s ease;
    position: relative;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(90deg, var(--accent) 0%, rgba(4, 148, 200, 0.7) 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(4, 148, 200, 0.3);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 3px;
    background: white;
    border-radius: 0 2px 2px 0;
}

.nav-item .nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

.nav-item .nav-icon i {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

/* Navigation divider */
.nav-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 4px;
    opacity: 0.5;
}

.nav-icon {
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-footer {
    padding: 8px 14px;
    border-top: 1px solid var(--border);
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warning);
}

.status-dot.connected {
    background: var(--success);
}

.status-dot.disconnected {
    background: var(--danger);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 0;
    margin-top: 52px; /* Account for fixed top nav */
    padding: 20px 28px;
    min-height: calc(100vh - 52px);
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    box-sizing: border-box;
    background: var(--bg-page);
}

/* Views */
.view {
    display: none;
}

.view.active {
    display: block;
}

.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.view-header.compact {
    margin-bottom: 4px;
}

.view-header h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: var(--space-1);
    letter-spacing: -0.025em;
    color: var(--text-primary);
}

.view-header .subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.view-header-left {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.view-header-left > div {
    display: flex;
    flex-direction: column;
}

.view-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    margin-top: 4px;
    transition:
        color 0.15s,
        border-color 0.15s,
        background 0.15s;
}

.back-btn:hover {
    color: var(--text-primary);
    border-color: var(--primary, #4299e1);
    background: rgba(66, 153, 225, 0.06);
}

.view-header.compact {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.view-header.compact h2 {
    font-size: clamp(1rem, 2vh, 1.5rem);
    margin-bottom: 0;
}

/* Dashboard title row with settings */
.dashboard-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dashboard-title-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.dashboard-settings-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dashboard-settings-btn:hover {
    background: var(--bg-hover);
    color: var(--accent);
    border-color: var(--accent);
}

.dashboard-settings-btn i {
    width: 16px;
    height: 16px;
}

.admin-only {
    display: none;
}

body.is-admin .admin-only {
    display: flex;
}

/* Refresh countdown indicator */
.refresh-countdown {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: var(--font-xs);
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s ease;
}

.refresh-countdown:hover {
    color: var(--text-secondary);
    border-color: var(--accent);
    background: var(--bg-hover);
}

/* Refresh Settings Popup */
.refresh-settings-popup {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    min-width: 200px;
}

.refresh-settings-popup.active {
    display: block;
}

.refresh-settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.refresh-settings-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.refresh-settings-close:hover {
    color: var(--text-primary);
}

.refresh-settings-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 10px 12px;
}

.refresh-option {
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.refresh-option:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent);
}

.refresh-option.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.refresh-settings-custom {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--border);
}

.refresh-settings-custom input {
    flex: 1;
    padding: 6px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.8rem;
}

.refresh-settings-custom input:focus {
    outline: none;
    border-color: var(--accent);
}

.refresh-countdown .refresh-icon {
    width: 12px;
    height: 12px;
    opacity: 0.7;
}

.refresh-countdown.refreshing .refresh-icon {
    animation: spin 1s linear infinite;
}

#countdownValue {
    font-weight: 600;
    min-width: 18px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.subtitle {
    color: var(--text-secondary);
    font-size: var(--font-sm);
}

.last-updated {
    color: var(--text-muted);
    font-size: var(--font-xs);
    margin-left: 8px;
}

.last-updated::before {
    content: '•';
    margin-right: 8px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
    max-width: 100%;
}

/* Widget refresh flash animation */
@keyframes widgetRefresh {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
        background: rgba(4, 148, 200, 0.15);
    }
    100% {
        opacity: 1;
    }
}

.widget.refreshing,
.widget.refreshing .stat-card,
.widget.refreshing .card {
    animation: widgetRefresh 0.4s ease-out;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-left: 3px solid var(--msc-blue-dark);
    border-radius: var(--radius);
    padding: 14px 18px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(4, 148, 200, 0.1) 0%, transparent 70%);
    pointer-events: none;
    opacity: 0.5;
}

.stat-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    border-left-color: var(--accent-hover);
}

.stat-card.success {
    border-left-color: var(--success);
}
.stat-card.warning {
    border-left-color: var(--warning);
}
.stat-card.danger {
    border-left-color: var(--danger);
}
.stat-card.success .stat-value {
    color: var(--success);
}
.stat-card.warning .stat-value {
    color: var(--warning);
}
.stat-card.danger .stat-value {
    color: var(--danger);
}

.stat-card .stat-label {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stat-card .stat-value {
    font-size: clamp(1rem, 1.5vw, 1.6rem);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-card .stat-icon {
    font-size: 1.5rem;
    margin-bottom: 6px;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: clamp(10px, 1.2vh, 16px);
    margin-bottom: 0;
    box-shadow: var(--shadow-sm);
    max-width: 100%;
    overflow: hidden;
    transition: all 0.2s ease;
}

.card:hover {
    border-color: var(--border-medium);
    box-shadow: var(--shadow-md);
}

/* Large chart widgets - span 2 columns (3 across), height auto */
.card-large {
    grid-column: span 2 !important;
    grid-row: span 1;
    height: 350px;
    max-height: 350px;
    width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 8px 12px;
}

.card-large h3 {
    font-size: clamp(0.7rem, 1vw, 0.9rem);
    margin-bottom: 2px;
}

.card-large .chart-subtitle {
    font-size: clamp(0.5rem, 0.7vw, 0.65rem);
    margin-bottom: 4px;
}

.card-large .chart-container {
    height: calc(100% - 50px);
    position: relative;
}

/* Half-width widgets (legacy) */
/* Compact chart widget — full-width row above the stat widgets on MAT dashboards */
.card-compact-chart {
    grid-column: 1 / -1;
    grid-row: span 1;
    height: 220px;
    max-height: 220px;
    min-width: 0;
    overflow: hidden;
    padding: 10px 14px 8px;
}

.card-compact-chart h3 {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 1px;
}

.card-compact-chart .chart-subtitle {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.card-compact-chart .chart-container {
    height: calc(100% - 44px);
    position: relative;
}

.card-half {
    grid-column: span 2;
    grid-row: span 1;
    height: 350px;
    max-height: 350px;
    min-width: 0;
    overflow: hidden;
    padding: 8px 12px;
}

.card-half h3 {
    font-size: clamp(0.7rem, 1vw, 0.9rem);
    margin-bottom: 2px;
}

.card-half .chart-subtitle {
    font-size: clamp(0.5rem, 0.7vw, 0.65rem);
    margin-bottom: 4px;
}

.card-half .chart-container {
    height: calc(100% - 50px);
    position: relative;
}

.card-half h3 {
    font-size: clamp(0.8rem, 1.2vw, 1.1rem);
}

.card-half .chart-subtitle {
    font-size: clamp(0.5rem, 0.8vw, 0.75rem);
}

/* Draggable Widgets */
.widgets-container {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-auto-rows: auto;
    grid-auto-flow: dense;
    gap: 8px;
    align-items: stretch;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.widget {
    position: relative;
    cursor: move;
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;
    resize: none;
    overflow: hidden;
    max-width: 100%;
}

/* Large widgets need minimum dimensions */
.widget.card-large,
.widget.card-half {
    min-height: 300px;
    grid-column: span 2 !important;
    width: 100% !important;
}

/* When a large widget is promoted to full-width (MAT mode), remove fixed height constraints */
.widget.card-large.card-full-width,
.widget.card-half.card-full-width {
    min-height: auto;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}

/* Full-width card - spans all columns */
.card-full-width {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    min-height: auto;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 12px 16px;
}

.card-full-width .widget-table-container {
    max-height: none;
    overflow-y: visible;
}

/* MAT full-width table widgets: show all columns without scroll */
.card-full-width .mat-cols-grid {
    overflow: visible;
}

/* MAT full-width bucket widgets (SLA / Stale): no scroll, auto height */
.card-full-width .sla-summary,
.card-full-width #slaFirstResponseSummary,
.card-full-width #staleTicketsSummary {
    overflow: visible;
    max-height: none;
}

/* MAT status chart widget needs a fixed height for Chart.js to render */
/* MAT placeholder widget */
[data-widget-id='matPlaceholderWidget'] .placeholder-content {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
    color: var(--text-muted);
    font-size: 1.1rem;
    font-style: italic;
    opacity: 0.6;
}

/* matStatusWidget: constrain height and force to bottom of grid */
[data-widget-id='matStatusWidget'] {
    height: 320px !important;
    max-height: 320px !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    order: 999 !important;
}

[data-widget-id='matStatusWidget'] .chart-container {
    flex: 1;
    position: relative;
    min-height: 0;
    height: 0;
}

/* MAT layout: wide table widgets — half width (3 of 6 cols), 2 per row */
.widget.card-large.card-mat-wide,
.widget.card-mat-wide {
    grid-column: span 3 !important;
    width: 100% !important;
    min-height: auto !important;
    height: auto !important;
    max-height: none !important;
    overflow: hidden !important;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
}

.card-mat-wide .widget-table-container,
.widget.card-mat-wide .widget-table-container {
    overflow-y: visible !important;
    overflow-x: hidden;
    max-height: none !important;
}

.card-mat-wide .mat-cols-grid,
.widget.card-mat-wide .mat-cols-grid {
    overflow: visible !important;
}

/* MAT layout: narrow bucket widgets — ~1.5 cols wide (span 2 of 6) */
.widget.card-large.card-mat-narrow,
.widget.card-mat-narrow {
    grid-column: span 2 !important;
    width: 100% !important;
    min-height: auto !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 12px 16px;
}

.card-mat-narrow .mat-bucket-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.card-mat-narrow .sla-summary,
.card-mat-narrow #slaFirstResponseSummary,
.card-mat-narrow #staleTicketsSummary {
    overflow: visible;
    max-height: none;
}

.widget:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.widget.dragging {
    opacity: 0.5;
    transform: scale(1.02);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.widget.drag-over {
    border: 2px dashed var(--accent);
    background: rgba(4, 148, 200, 0.1);
}

.widget-drag-handle {
    position: absolute;
    top: 8px;
    right: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: grab;
    padding: 4px 8px;
    border-radius: 4px;
    opacity: 0.5;
    transition:
        opacity 0.2s ease,
        background 0.2s ease;
    user-select: none;
}

.widget:hover .widget-drag-handle {
    opacity: 1;
    background: var(--bg-primary);
}

.widget-drag-handle:active {
    cursor: grabbing;
}

.widget-placeholder {
    border: 2px dashed var(--border);
    background: var(--bg-primary);
    border-radius: var(--radius);
    min-height: 200px;
}

/* Resize handle styling */
.widget::-webkit-resizer {
    background: linear-gradient(135deg, transparent 50%, var(--accent) 50%);
    border-radius: 0 0 var(--radius) 0;
}

.widget-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: se-resize;
    background: linear-gradient(135deg, transparent 50%, var(--text-secondary) 50%);
    border-radius: 0 0 var(--radius) 0;
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.widget:hover .widget-resize-handle {
    opacity: 1;
    background: linear-gradient(135deg, transparent 50%, var(--accent) 50%);
}

.card h3 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
}

/* Table List */
.table-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.table-item {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.table-item:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.table-item .table-name {
    font-weight: 500;
    color: var(--text-primary);
}

/* Table Select */
.table-select {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 16px;
    color: var(--text-primary);
    font-size: 0.9rem;
    min-width: 200px;
    cursor: pointer;
}

.table-select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Filters */
.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.filter-group input,
.filter-group select {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(4, 148, 200, 0.15);
}

.filter-group input::placeholder {
    color: var(--text-secondary);
}

.filter-actions {
    display: flex;
    gap: 12px;
}

#filteredCount {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: normal;
}

/* Table Container */
.table-container {
    overflow-x: auto;
    max-width: 100%;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-sm);
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table th,
.data-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: var(--bg-primary);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.65rem;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--accent);
}

.data-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.data-table tbody tr {
    transition: background 0.15s ease;
}

.data-table tr:hover td {
    background: rgba(4, 148, 200, 0.08);
}

.data-table td {
    color: var(--text-primary);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
}

.pagination button {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 16px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.pagination button:hover:not(:disabled) {
    border-color: var(--accent);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination .page-info {
    display: flex;
    align-items: center;
    padding: 0 16px;
    color: var(--text-secondary);
}

/* Query Editor */
.query-editor {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.query-editor textarea {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    color: var(--text-primary);
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9rem;
    min-height: 150px;
    resize: none;
}

.query-editor textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(4, 148, 200, 0.15);
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: var(--font-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

.btn-primary {
    background: var(--msc-blue-dark);
    color: white;
    box-shadow: 0 1px 3px rgba(4, 148, 200, 0.3);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

/* Ghost button */
.btn-ghost {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 12px;
}

.btn-ghost:hover {
    background: rgba(4, 148, 200, 0.1);
    color: var(--text-primary);
}

/* Success button */
.btn-success {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3);
}

.btn-success:hover {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
    transform: translateY(-1px);
}

/* Ghost button - Tertiary actions */
.btn-ghost {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 12px;
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

/* Utilities */
.loading {
    color: var(--text-secondary);
    font-style: italic;
}

.placeholder {
    color: var(--text-secondary);
    text-align: center;
    padding: 40px;
}

.error {
    color: var(--danger);
    padding: 16px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: var(--radius);
}

/* Table Info */
.table-info {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.column-badge {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-size: 0.8rem;
}

.column-badge .column-name {
    font-weight: 600;
    color: var(--accent);
}

.column-badge .column-type {
    color: var(--text-secondary);
    margin-left: 8px;
}

/* Sync View */
.sync-description {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* API Threshold Status */
.api-threshold-status {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 16px;
}

.threshold-loading {
    color: var(--text-muted);
    font-style: italic;
}

.threshold-meter {
    margin-bottom: 12px;
}

.threshold-meter-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.threshold-meter-fill {
    height: 100%;
    border-radius: 4px;
    transition:
        width 0.3s ease,
        background 0.3s ease;
}

.threshold-meter-fill.ok {
    background: var(--success);
}
.threshold-meter-fill.warning {
    background: var(--warning);
}
.threshold-meter-fill.critical {
    background: var(--danger);
}

.threshold-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.threshold-stat {
    text-align: center;
    padding: 12px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

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

.threshold-stat-value.ok {
    color: var(--success);
}
.threshold-stat-value.warning {
    color: var(--warning);
}
.threshold-stat-value.critical {
    color: var(--danger);
}

.threshold-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 4px;
}

.sync-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

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

.btn-secondary:hover {
    border-color: var(--accent);
    background: rgba(4, 148, 200, 0.1);
    transform: translateY(-1px);
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #000;
    border: none;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.btn-warning:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sync-result {
    margin-top: 16px;
    padding: 16px;
    border-radius: var(--radius);
    display: none;
}

.sync-result.success {
    display: block;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid var(--success);
    color: var(--success);
}

.sync-result.error {
    display: block;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--danger);
    color: var(--danger);
}

.sync-result.loading {
    display: block;
    background: rgba(4, 148, 200, 0.1);
    border: 1px solid var(--msc-blue-dark);
    color: var(--msc-blue-dark);
}

.sync-times {
    display: grid;
    gap: 12px;
}

.sync-time-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-primary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.sync-time-item .label {
    font-weight: 500;
    color: var(--text-primary);
}

.sync-time-item .time {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.schedule-info {
    display: grid;
    gap: 12px;
    margin-bottom: 16px;
}

.schedule-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-primary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.schedule-icon {
    font-size: 1.5rem;
}

.schedule-name {
    flex: 1;
    font-weight: 500;
}

.schedule-time {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.scheduler-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    padding: 12px 16px;
    background: var(--bg-primary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.scheduler-status {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-label {
    font-weight: 500;
    color: var(--text-secondary);
}

.status-indicator {
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.875rem;
}

.status-indicator.stopped {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.status-indicator.running {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

/* Schedule Configuration */
.schedule-config-section {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.schedule-config-section h4 {
    margin: 0 0 12px 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.business-hours-config {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.config-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.config-row label {
    min-width: 100px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.config-row span {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.schedule-select,
.schedule-select-sm {
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.875rem;
}

.schedule-select-sm {
    padding: 6px 8px;
}

.schedule-input,
.schedule-input-time {
    padding: 6px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.875rem;
    width: 70px;
    text-align: center;
}

.schedule-input-time {
    width: 100px;
}

.schedule-jobs-config {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.schedule-job-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.job-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.job-toggle input[type='checkbox'] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.job-name {
    font-size: 0.875rem;
    color: var(--text-primary);
}

.job-config {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.schedule-job-row:has(input[type='checkbox']:not(:checked)) .job-config {
    opacity: 0.5;
    pointer-events: none;
}

.schedule-job-section-divider {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 8px 4px 2px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

.schedule-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

/* Management Dashboard */
.charts-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
    max-width: 100%;
}

.chart-card {
    min-height: 400px;
}

.chart-card-wide {
    min-height: 350px;
}

.chart-container {
    position: relative;
    height: 320px;
    width: 100%;
}

.chart-container-wide {
    position: relative;
    height: 300px;
    width: 100%;
}

.chart-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 16px;
    margin-top: -8px;
}

.stat-detail {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.kill-rate-card.success .stat-value {
    color: var(--success);
}

.kill-rate-card.warning .stat-value {
    color: var(--warning);
}

.kill-rate-card.danger .stat-value {
    color: var(--danger);
}

@media (max-width: 1200px) {
    .charts-row {
        grid-template-columns: 1fr;
    }

    .widgets-container {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 992px) {
    .widgets-container {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

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

@media (max-width: 480px) {
    .widgets-container {
        grid-template-columns: 1fr;
    }
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

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

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    width: 95vw;
    max-width: 1400px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

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

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-body .form-group {
    margin-bottom: 12px;
}

.modal-body .form-group label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-bottom: 4px;
}

.modal-body .form-select {
    width: 100%;
    padding: 7px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
}

.modal-body .form-select:hover {
    border-color: var(--accent);
}

.modal-body .form-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(4, 148, 200, 0.2);
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: var(--bg-card);
}

.modal-large {
    max-width: 900px;
    width: 95%;
}

/* Pagination Controls */
.pagination-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: var(--radius);
}

.pagination-controls button {
    min-width: 100px;
}

.pagination-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#pageInfo {
    font-weight: 500;
    color: var(--text-primary);
    min-width: 120px;
    text-align: center;
}

.ticket-summary {
    margin-bottom: 12px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Ticket modal: toolbar (summary + pagination) and table */
#ticketModal .ticket-modal-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

#ticketModal .ticket-modal-toolbar .ticket-summary {
    margin-bottom: 0;
    font-weight: 500;
    color: var(--text-primary);
}

#ticketModal .ticket-modal-toolbar .pagination-controls {
    margin-bottom: 0;
}

#ticketModal .ticket-table-scroll {
    max-height: 60vh;
    overflow-y: auto;
    overflow-x: auto;
}

#ticketModal .ticket-table,
#ticketModal .data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
    table-layout: auto;
}

/* Ticket # column — keep compact */
#ticketModal .ticket-table th:nth-child(1),
#ticketModal .ticket-table td:nth-child(1) {
    width: 1%;
    white-space: nowrap;
}

#ticketModal .ticket-table th,
#ticketModal .data-table th {
    text-align: left;
    padding: 10px 12px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

#ticketModal .ticket-table td,
#ticketModal .data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

#ticketModal .ticket-table tbody tr:hover,
#ticketModal .data-table tbody tr.clickable-row:hover {
    background: var(--bg-primary);
}

#ticketModal .ticket-table .ticket-title-cell,
#ticketModal .data-table td:nth-child(2) {
    max-width: 350px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#ticketModal .ticket-table .ticket-date-cell,
#ticketModal .ticket-table td.overdue,
#ticketModal .ticket-table td.warning {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

#ticketModal .ticket-table td.overdue {
    color: var(--danger);
    font-weight: 500;
}

#ticketModal .ticket-table td.warning {
    color: var(--warning);
}

/* Tab buttons for kill rate view */
.tab-buttons {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.tab-buttons .btn {
    min-width: 120px;
}

/* Clickable table rows */
.data-table tr.clickable-row {
    cursor: pointer;
    transition: background 0.2s ease;
}

.data-table tr.clickable-row:hover {
    background: rgba(4, 148, 200, 0.1);
}

/* Ticket Detail View */
.ticket-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.ticket-detail-item {
    padding: 12px;
    background: var(--bg-primary);
    border-radius: var(--radius);
}

.ticket-detail-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.ticket-detail-value {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 500;
}

.ticket-detail-full {
    grid-column: span 2;
}

.ticket-description {
    padding: 16px;
    background: var(--bg-primary);
    border-radius: var(--radius);
    white-space: pre-wrap;
    font-size: 0.9rem;
    line-height: 1.6;
    max-height: 300px;
    overflow-y: auto;
}

.modal-body .data-table {
    font-size: 0.8rem;
}

.modal-body .data-table th {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 1;
}

.modal-body .data-table td {
    max-width: 250px;
}

.ticket-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

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

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-badge.new {
    background: rgba(4, 148, 200, 0.2);
    color: #0494c8;
}

.status-badge.in-progress {
    background: rgba(139, 92, 246, 0.2);
    color: #8b5cf6;
}

.status-badge.awaiting {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

/* Stale ticket styling */
.stale-row {
    background: rgba(245, 158, 11, 0.1) !important;
}

.stale-row:hover {
    background: rgba(245, 158, 11, 0.15) !important;
}

td.stale {
    color: #f59e0b;
    font-weight: 500;
}

/* Version info in sidebar */
.version-info {
    margin-top: 6px;
    font-size: 0.6rem;
    color: var(--text-secondary);
    opacity: 0.6;
}

.sidebar.collapsed .version-info {
    display: none;
}

/* Environment banner */
.env-banner {
    padding: 4px 12px;
    text-align: center;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.env-banner.dev {
    background: #f59e0b;
    color: #000;
}

.env-banner.prod {
    display: none !important;
}

/* Deployment section */
.deploy-status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.deploy-env-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    text-align: center;
}

.deploy-env-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.deploy-env-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: capitalize;
}

.deploy-env-detail {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.deploy-actions {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-warning {
    background: #f59e0b;
    color: #000;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: background 0.2s;
}

.btn-warning:hover {
    background: #d97706;
}

/* API Config Form */
.api-config-form {
    max-width: 600px;
}

.api-config-form .form-group {
    margin-bottom: 12px;
}

.api-config-form label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text-secondary);
}

.api-config-form input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.api-config-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(4, 148, 200, 0.15);
}

.form-actions-inline {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

/* Settings Tabs */
.settings-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 8px;
}

.settings-tab {
    background: transparent;
    border: none;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius) var(--radius) 0 0;
    transition: all 0.2s;
    position: relative;
}

.settings-tab:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.settings-tab.active {
    background: var(--accent);
    color: white;
}

.settings-tab.active::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
}

.settings-content {
    display: none;
}

.settings-content.active {
    display: block;
}

/* Autotask Tabs */
.autotask-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    padding: 4px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.autotask-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.autotask-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.autotask-tab.active {
    background: var(--accent);
    color: white;
}

.autotask-tab i {
    width: 18px;
    height: 18px;
}

.autotask-tab-content {
    display: none;
}

.autotask-tab-content.active {
    display: block;
}

/* ==================== INTEGRATIONS ==================== */

/* Integrations Grid */
.integrations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
    padding: 8px 0;
}

/* Integration Tile */
.integration-tile {
    background: linear-gradient(145deg, var(--bg-card) 0%, rgba(30, 41, 59, 0.8) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    padding: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    overflow: hidden;
}

.integration-tile::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.integration-tile:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.3),
        0 0 0 1px var(--accent);
}

.integration-tile:hover::before {
    opacity: 1;
}

.integration-tile.coming-soon {
    opacity: 0.5;
    cursor: not-allowed;
}

.integration-tile.coming-soon:hover {
    transform: none;
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: none;
}

.integration-tile.coming-soon::before {
    display: none;
}

/* Tile Logo */
.integration-tile-logo {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}

.integration-tile-logo img {
    max-width: 48px;
    max-height: 48px;
    object-fit: contain;
}

.integration-tile-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--accent);
}

.integration-tile-icon i {
    width: 32px;
    height: 32px;
}

/* Tile Content */
.integration-tile-content h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.integration-tile-content p {
    margin: 8px 0 0 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Tile Status */
.integration-tile-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

.integration-tile-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}

.integration-tile-status.connected .status-dot {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.integration-tile-status.disconnected .status-dot {
    background: var(--danger);
}

.integration-tile-status.checking .status-dot {
    background: var(--warning);
    animation: pulse 1.5s infinite;
}

.integration-tile-status .status-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Severity Badges (for vPenTest and security integrations) */
.severity-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.severity-critical {
    background: rgba(220, 38, 38, 0.2);
    color: #ef4444;
    border: 1px solid rgba(220, 38, 38, 0.3);
}

.severity-high {
    background: rgba(249, 115, 22, 0.2);
    color: #f97316;
    border: 1px solid rgba(249, 115, 22, 0.3);
}

.severity-medium {
    background: rgba(234, 179, 8, 0.2);
    color: #eab308;
    border: 1px solid rgba(234, 179, 8, 0.3);
}

.severity-low {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.severity-info {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.severity-unknown {
    background: rgba(148, 163, 184, 0.2);
    color: #94a3b8;
    border: 1px solid rgba(148, 163, 184, 0.3);
}

/* Integration Header with Back Button */
.integration-header {
    position: relative;
}

.integration-header .btn-back {
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.integration-header .btn-back:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent);
}

.integration-header .btn-back i {
    width: 16px;
    height: 16px;
}

.integration-header h2 {
    padding-top: 48px;
}

/* Integration Tabs (generic - reusable for all integrations) */
.integration-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    padding: 4px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.integration-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.integration-tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

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

.integration-tab i {
    width: 18px;
    height: 18px;
}

.integration-tab-content {
    display: none;
}

.integration-tab-content.active {
    display: block;
}

/* Account Stats (for UptimeRobot, etc.) */
.account-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
}

.account-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.account-stat .label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.account-stat .value {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* API Info Grid */
.api-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.api-info-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.api-info-item i {
    width: 24px;
    height: 24px;
    color: var(--accent);
    flex-shrink: 0;
    margin-top: 2px;
}

.api-info-item strong {
    display: block;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.api-info-item p {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Devices List */
.devices-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.device-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.device-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.device-status.online {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.device-status.offline {
    background: var(--danger);
}

.device-name {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text-primary);
    font-weight: 500;
}

.device-type {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--bg-primary);
    padding: 2px 8px;
    border-radius: 4px;
}

/* Domains List (Datto SaaS Protection) */
.domains-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.domain-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.domain-name {
    font-size: 0.9375rem;
    color: var(--text-primary);
    font-weight: 500;
}

.domain-stats {
    display: flex;
    gap: 16px;
}

.domain-stats .stat {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.domain-stats .stat svg {
    width: 14px;
    height: 14px;
}

/* Deploy Actions Grid */
.deploy-actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 12px;
}

.deploy-action-item {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.deploy-action-item h4 {
    margin: 0 0 8px 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.deploy-action-item p {
    margin: 0 0 12px 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Git status card */
.deploy-git-status-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}
.deploy-git-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.deploy-git-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.deploy-git-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}
.deploy-git-hash {
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--accent);
    background: var(--bg-primary);
    padding: 2px 6px;
    border-radius: 4px;
}
.deploy-badge-ok {
    background: #16a34a22;
    color: #16a34a;
    border: 1px solid #16a34a44;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
}
.deploy-badge-update {
    background: #d9770622;
    color: #d97706;
    border: 1px solid #d9770644;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
}
.deploy-commits-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}
.deploy-commits-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.deploy-commit-row {
    display: flex;
    gap: 10px;
    align-items: baseline;
    font-size: 0.8rem;
}
.deploy-commit-hash {
    font-family: monospace;
    color: var(--accent);
    min-width: 52px;
}
.deploy-commit-msg {
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Live deploy progress */
.deploy-progress-title {
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-primary);
}
.deploy-steps-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.deploy-step {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
}
.deploy-step-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}
.deploy-step.step-running {
    border-color: #3b82f6;
    background: #3b82f611;
}
.deploy-step.step-done {
    border-color: #16a34a;
    background: #16a34a11;
}
.deploy-step.step-warn {
    border-color: #d97706;
    background: #d9770611;
}
.deploy-step.step-error {
    border-color: #ef4444;
    background: #ef444411;
}
.deploy-step.step-success {
    border-color: #16a34a;
    background: #16a34a22;
    font-weight: 600;
}
.deploy-step-text {
    flex: 1;
}
.deploy-step-detail {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
    font-family: monospace;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
.spin {
    animation: spin 1s linear infinite;
    transform-origin: center;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
    transform: translateY(-1px);
}

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

.btn-danger:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

/* Database Info Grid */
.db-info-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.db-info-item {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    text-align: center;
}

.db-info-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.db-info-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-all;
}

/* Rollback row highlight */
.data-table tr.rollback-selected {
    background: rgba(239, 68, 68, 0.1);
    border-left: 3px solid #ef4444;
}

.data-table tr.rollback-selectable {
    cursor: pointer;
}

.data-table tr.rollback-selectable:hover {
    background: rgba(4, 148, 200, 0.1);
}

.data-table tr.current-commit {
    background: rgba(34, 197, 94, 0.1);
    border-left: 3px solid var(--success);
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, var(--bg-primary) 25%, var(--bg-secondary) 50%, var(--bg-primary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius);
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
    border-radius: 4px;
}

.skeleton-text.short {
    width: 40%;
}

.skeleton-text.medium {
    width: 70%;
}

.skeleton-text.full {
    width: 100%;
}

.skeleton-card {
    height: 100px;
    border-radius: var(--radius);
}

.skeleton-chart {
    height: 300px;
    border-radius: var(--radius);
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Fade in animation for dynamically loaded content */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* Spin animation for loading indicators */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.spin {
    animation: spin 1s linear infinite;
}

/* Pulse animation for attention */
@keyframes pulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* Global transition for interactive elements */
a,
button,
input,
select,
textarea,
.card,
.stat-card,
.nav-item,
.widget {
    transition: all 0.2s ease;
}

/* Hover lift effect */
.hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Responsive */
@media (max-width: 1024px) {
    .deploy-actions-grid {
        grid-template-columns: 1fr;
    }

    .db-info-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .main-content {
        padding: 20px 16px;
    }
}

/* Dashboard Settings Styles */
.widget-settings-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.widget-settings-item {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
}

.widget-settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.widget-settings-header h4 {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

.widget-settings-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--font-xs);
    color: var(--text-secondary);
}

.widget-filter-section {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
}

.widget-filter-section label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.filter-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-height: 100px;
    overflow-y: auto;
    padding: 4px;
    background: var(--bg-card);
    border-radius: var(--radius);
}

.filter-checkbox-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.filter-checkbox-item:hover {
    border-color: var(--accent);
}

.filter-checkbox-item input[type='checkbox'] {
    width: 12px;
    height: 12px;
    cursor: pointer;
}

.filter-checkbox-item.excluded {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.filter-checkbox-item.excluded:hover {
    opacity: 0.9;
}

/* Dropdown filter styles */
.filter-dropdown-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-dropdown {
    width: 100%;
    padding: 5px 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.75rem;
    cursor: pointer;
}

.filter-dropdown:hover {
    border-color: var(--accent);
}

.filter-dropdown:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(4, 148, 200, 0.2);
}

/* Search filter styles */
.filter-search-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
}

.filter-search-input {
    width: 100%;
    padding: 5px 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.75rem;
}

.filter-search-input:hover {
    border-color: var(--accent);
}

.filter-search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(4, 148, 200, 0.2);
}

.filter-search-input::placeholder {
    color: var(--text-secondary);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.search-result-item {
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--bg-tertiary);
}

.search-result-item.no-results {
    color: var(--text-secondary);
    cursor: default;
}

.search-result-item.no-results:hover {
    background: transparent;
}

.excluded-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-height: 20px;
}

.excluded-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 4px 2px 8px;
    background: var(--danger);
    color: white;
    border-radius: 10px;
    font-size: 0.7rem;
    max-width: 220px;
    overflow: hidden;
}

/* Label can truncate; button always visible */
.excluded-tag .excluded-tag-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.excluded-tag button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
}

.excluded-tag button:hover {
    background: rgba(255, 255, 255, 0.4);
}

.dashboard-settings-info {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    margin-bottom: 10px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.dashboard-settings-info strong {
    color: var(--text-primary);
}

.dashboard-settings-type {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--accent);
    margin-top: 2px;
}

.widget-settings-list--internal .widget-settings-item {
    margin-bottom: 8px;
}

.widget-settings-list--internal .widget-settings-header {
    cursor: default;
}

.widget-settings-global {
    border-left: 3px solid var(--accent);
}
/* Compact modal body for dashboard settings */
#dashboardSettingsModal .modal-body {
    padding: 12px 16px;
    max-height: 70vh;
}

#dashboardSettingsModal .modal-footer {
    padding: 10px 16px;
}

/* ==================== REPORTS ==================== */

/* Report Builder */
.report-builder {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 32px 20px;
}

.report-builder-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 32px;
    max-width: 720px;
    width: 100%;
    box-shadow: var(--shadow);
}

.report-builder-card h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    color: var(--text-primary);
    font-size: 1.25rem;
}

.report-builder-card h3 i {
    color: var(--accent);
}

.report-builder-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.report-builder-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.report-builder-form .form-group label {
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.report-builder-form .form-row {
    display: flex;
    gap: 16px;
}

.report-builder-form .form-row .form-group {
    flex: 1;
}

.report-builder-form .form-select {
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
}

.report-builder-form .form-select:hover {
    border-color: var(--accent);
}

.report-builder-form .form-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(4, 148, 200, 0.2);
}

.report-builder-form .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 1rem;
    margin-top: 4px;
    width: 100%;
    max-width: 240px;
}

/* Report Sections Filter */
.report-sections-filter label {
    margin-bottom: 2px;
}

.section-checkboxes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 20px;
    padding: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.section-checkboxes .checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
    white-space: normal;
    line-height: 1.35;
}

.section-checkboxes .checkbox-label input[type='checkbox'] {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

.section-checkboxes .checkbox-label:hover {
    color: var(--accent);
}

/* Report Exclusions Filter */
.report-exclusions-filter label {
    margin-bottom: 2px;
}

.report-exclusions-filter .filter-search-container {
    position: relative;
}

.report-exclusions-filter .filter-search-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.report-exclusions-filter .filter-search-input:focus {
    outline: none;
    border-color: var(--accent);
}

.report-exclusions-filter .search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: var(--shadow);
}

.report-exclusions-filter .search-results.show {
    display: block;
}

.report-exclusions-filter .search-result-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
}

.report-exclusions-filter .search-result-item:hover {
    background: var(--bg-hover);
}

.report-exclusions-filter .search-result-item:last-child {
    border-bottom: none;
}

.excluded-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.excluded-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--accent);
    color: white;
    border-radius: 20px;
    font-size: 0.8rem;
}

.excluded-tag .remove-tag {
    cursor: pointer;
    opacity: 0.8;
    font-weight: bold;
}

.excluded-tag .remove-tag:hover {
    opacity: 1;
}

@media (max-width: 640px) {
    .section-checkboxes {
        grid-template-columns: 1fr;
    }
    .report-builder-card {
        padding: 20px 16px;
    }
}

/* Report Preview Wrapper */
.report-preview-wrapper {
    padding: 20px;
}

.report-actions {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 0 20px;
}

.report-actions .btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
}

/* Report Preview (White background for PDF) */
.report-preview {
    background: white;
    max-width: 210mm;
    margin: 0 auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    border-radius: var(--radius);
    overflow: hidden;
}

/* Report Pages */
.report-page {
    padding: 40px;
    min-height: 280mm;
    box-sizing: border-box;
    background-color: #ffffff;
}

/* PDF Export mode - remove min-height for proper PDF generation */
.pdf-export .report-page {
    min-height: auto !important;
    padding: 30px;
}

.pdf-export .report-cover {
    min-height: auto !important;
    padding: 80px 40px;
}

.pdf-export .report-chart-container {
    max-height: 300px;
    overflow: hidden;
}

.pdf-export .report-chart-container img {
    max-height: 280px;
    width: auto;
    margin: 0 auto;
    display: block;
}

.report-page:last-child {
    page-break-after: auto;
}

/* Cover Page */
.report-cover {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #1e293b;
    color: white;
    text-align: center;
}

.report-cover-content {
    max-width: 400px;
}

.report-logo-placeholder {
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 40px;
}

.report-logo-placeholder i {
    width: 50px;
    height: 50px;
    color: #0494c8;
}

.report-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: white;
}

.report-company-name {
    font-size: 1.5rem;
    font-weight: 600;
    color: #0494c8;
    margin-bottom: 16px;
}

.report-period {
    font-size: 1.25rem;
    color: #94a3b8;
    margin-bottom: 40px;
}

.report-generated {
    font-size: 0.875rem;
    color: #64748b;
}

/* Report Sections */
.report-section {
    background: white;
    color: #1e293b;
}

.report-section-header {
    border-bottom: 2px solid #0494c8;
    padding-bottom: 16px;
    margin-bottom: 32px;
}

.report-section-header h2 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #64748b;
    margin-bottom: 4px;
}

.report-section-header h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

.report-section-content {
    color: #334155;
}

/* Report Stats Row */
.report-stats-row {
    display: flex;
    gap: 20px;
    margin-bottom: 32px;
}

.report-stat-card {
    flex: 1;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
}

.report-stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.report-stat-label {
    font-size: 0.875rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.report-stat-opened .report-stat-value {
    color: #0494c8;
}

.report-stat-closed .report-stat-value {
    color: #22c55e;
}

.report-stat-net.positive .report-stat-value {
    color: #22c55e;
}

.report-stat-net.negative .report-stat-value {
    color: #f59e0b;
}

/* Report Chart */
.report-chart-container {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 32px;
}

.report-chart-container h4 {
    font-size: 1rem;
    color: #1e293b;
    margin-bottom: 16px;
}

.report-chart-container canvas {
    max-height: 300px;
}

/* Report Summary */
.report-section-summary {
    background: #f8fafc;
    border-left: 4px solid #0494c8;
    padding: 16px 20px;
    border-radius: 0 8px 8px 0;
    font-size: 0.95rem;
    line-height: 1.6;
}

.report-section-summary p {
    margin: 0;
}

/* Placeholder Sections */
.report-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: #94a3b8;
}

.report-placeholder i {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.report-placeholder p {
    font-size: 1.25rem;
    font-weight: 500;
}

/* Report Tables */
.report-table-container {
    margin-top: 24px;
}

.report-table-container h4 {
    font-size: 1rem;
    color: #1e293b;
    margin-bottom: 12px;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.report-table thead {
    background: #f1f5f9;
}

.report-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #1e293b;
    font-size: 0.875rem;
    border-bottom: 2px solid #e2e8f0;
}

.report-table td {
    padding: 10px 16px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.875rem;
    color: #334155;
}

.report-table tbody tr:last-child td {
    border-bottom: none;
}

.report-table tbody tr:hover {
    background: #f8fafc;
}

.report-table .rank {
    display: inline-block;
    background: #0494c8;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    margin-right: 8px;
}

/* Report Comparison Section */
.report-comparison {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
}

.report-comparison-card {
    flex: 1;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 24px;
}

.report-comparison-card h4 {
    font-size: 1rem;
    color: #1e293b;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #0494c8;
}

.comparison-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 0.95rem;
}

.comparison-label {
    color: #64748b;
}

.comparison-value {
    font-weight: 600;
    color: #1e293b;
}

.comparison-change {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
    text-align: center;
    font-weight: 600;
}

.change-up {
    color: #f59e0b;
}

.change-down {
    color: #22c55e;
}

.change-neutral {
    color: #64748b;
}

/* Table of Contents */
.report-toc .toc-list {
    background: #f8fafc;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 32px;
}

.toc-item {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #e2e8f0;
}

.toc-item:last-child {
    border-bottom: none;
}

.toc-number {
    font-weight: 600;
    color: #0494c8;
    min-width: 100px;
    font-size: 0.9rem;
}

.toc-title {
    color: #1e293b;
    font-size: 1rem;
}

.toc-summary {
    background: #f1f5f9;
    border-left: 4px solid #0494c8;
    padding: 16px 20px;
    border-radius: 0 8px 8px 0;
}

.toc-summary p {
    margin: 0;
    color: #475569;
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Report Notes */
.report-notes {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
}

.report-notes p {
    font-size: 1rem;
    line-height: 1.8;
    color: #334155;
    margin: 0;
}

.report-footer-info {
    background: #1e293b;
    color: #f1f5f9;
    border-radius: 12px;
    padding: 20px 24px;
}

.report-footer-info p {
    margin: 8px 0;
    font-size: 0.875rem;
}

.report-footer-info strong {
    color: #94a3b8;
}

/* No data message */
.report-no-data {
    text-align: center;
    color: #94a3b8;
    font-style: italic;
    padding: 40px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px dashed #e2e8f0;
}

/* Spin animation for loading */
.spin {
    animation: spin 1s linear infinite;
}

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

/* Print/PDF styles */
@media print {
    .report-preview {
        box-shadow: none;
        max-width: none;
    }

    .report-page {
        page-break-after: always;
        padding: 20mm;
    }

    .report-actions {
        display: none;
    }
}

/* PDF Generation specific styles (applied via JS) */
.generating-pdf .report-page {
    background: #ffffff !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}

.generating-pdf .report-cover {
    background: #1e293b !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}

.generating-pdf .report-section-header {
    background: #f1f5f9 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}

.generating-pdf .report-stat-card {
    background: #f8fafc !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
}

.generating-pdf canvas {
    max-width: 100% !important;
    height: auto !important;
}

@media (max-width: 768px) {
    .main-content {
        padding: 16px 12px;
    }

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

    .settings-tabs {
        flex-wrap: wrap;
    }
}

/* ==================== AUTO-CANCEL RULES ==================== */

/* Card header with actions */
.card-header-with-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.card-header-with-actions h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Toggle switch - scoped to auto-cancel view to avoid conflicts */
#auto-cancelView .toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    vertical-align: middle;
    margin-right: 8px;
}

#auto-cancelView .toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

#auto-cancelView .toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-primary);
    border: 1px solid var(--border);
    transition: 0.3s;
    border-radius: 22px;
}

#auto-cancelView .toggle-slider:before {
    position: absolute;
    content: '';
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-secondary);
    transition: 0.3s;
    border-radius: 50%;
}

#auto-cancelView .toggle-switch input:checked + .toggle-slider {
    background-color: var(--success);
    border-color: var(--success);
}

#auto-cancelView .toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(18px);
    background-color: white;
}

/* Toggle switch - scoped to ticket-routing view to avoid conflicts */
#ticket-routingView .toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    vertical-align: middle;
    margin-right: 8px;
}

#ticket-routingView .toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

#ticket-routingView .toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-primary);
    border: 1px solid var(--border);
    transition: 0.3s;
    border-radius: 22px;
}

#ticket-routingView .toggle-slider:before {
    position: absolute;
    content: '';
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-secondary);
    transition: 0.3s;
    border-radius: 50%;
}

#ticket-routingView .toggle-switch input:checked + .toggle-slider {
    background-color: var(--success);
    border-color: var(--success);
}

#ticket-routingView .toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(18px);
    background-color: white;
}

/* Conditions cell */
.conditions-cell {
    font-size: 0.85rem;
    line-height: 1.5;
    max-width: 300px;
}

.conditions-cell em {
    color: var(--text-secondary);
}

/* Actions cell */
#auto-cancelView .actions-cell {
    white-space: nowrap;
}

#auto-cancelView .actions-cell .btn-icon {
    padding: 6px 8px;
    margin-right: 4px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: all 0.2s;
}

#auto-cancelView .actions-cell .btn-icon:hover {
    background: var(--primary);
    color: white;
}

#auto-cancelView .actions-cell .btn-icon.btn-danger {
    background: var(--bg-secondary);
}

#auto-cancelView .actions-cell .btn-icon.btn-danger:hover {
    background: var(--danger);
    color: white;
}

#auto-cancelView .actions-cell .btn-icon i {
    width: 16px;
    height: 16px;
}

/* Auto-cancel status line */
.auto-cancel-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    margin: 12px 0;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    font-size: 0.9rem;
    border-left: 3px solid var(--primary);
}

.auto-cancel-status .status-label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
}

.auto-cancel-status .status-label i {
    width: 16px;
    height: 16px;
}

.auto-cancel-status .status-value {
    color: var(--text-primary);
    font-weight: 500;
}

.auto-cancel-status .status-value.success {
    color: var(--success);
}

.auto-cancel-status .status-value.error {
    color: var(--danger);
}

.auto-cancel-status .status-value.warning {
    color: var(--warning);
}

/* Title and reason cells */
.title-cell,
.reason-cell {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Empty and loading cells */
.empty-cell,
.loading-cell {
    text-align: center;
    color: var(--text-secondary);
    padding: 24px !important;
    font-style: italic;
}

/* Input with select (email pattern) */
.input-with-select {
    display: flex;
    gap: 8px;
}

.input-with-select input {
    flex: 1;
}

.input-with-select select {
    width: 140px;
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.9rem;
}

/* Form help text */
.form-help {
    display: block;
    margin-top: 4px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Checkbox label */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
}

.checkbox-label input[type='checkbox'] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Modal medium size */
.modal-medium {
    max-width: 600px;
}

/* Modal for auto-cancel */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
}

.page-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Warning text style */
.warning {
    color: var(--warning);
}

/* ==================== CASH FLOW FORECASTER ==================== */

.cashflow-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    width: 100%;
}

.cashflow-header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-left: auto;
}

.cashflow-header-actions select {
    min-width: 150px;
}

/* Scenario selector dropdown */
.scenario-selector-wrapper {
    position: relative;
}

.scenario-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 250px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 100;
    margin-top: 4px;
}

.scenario-dropdown.show {
    display: block;
}

.scenario-dropdown-content {
    padding: 8px 0;
    max-height: 300px;
    overflow-y: auto;
}

.scenario-checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s;
}

.scenario-checkbox-item:hover {
    background: var(--bg-primary);
}

.scenario-checkbox-item input[type='checkbox'] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.scenario-color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.scenario-checkbox-label {
    flex: 1;
    font-size: 0.9rem;
}

.scenario-checkbox-label.is-base {
    font-weight: 600;
}

/* KPI Grid */
.cashflow-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

/* Row 1: Balance, Receivables, Payables, Zero Date - 4 equal columns */
.cashflow-kpi-row-1 {
    grid-template-columns: repeat(4, 1fr);
}

/* Cash Runway / Zero-balance warning card */
.kpi-card.kpi-zero-warning {
    border-color: var(--warning, #f59e0b);
    background: rgba(245, 158, 11, 0.08);
}

.kpi-card.kpi-zero-warning.kpi-zero-danger {
    border-color: var(--danger, #ef4444);
    background: rgba(239, 68, 68, 0.1);
    animation: kpi-pulse 2s ease-in-out infinite;
}

.kpi-card.kpi-zero-warning.kpi-zero-safe {
    border-color: var(--success, #22c55e);
    background: rgba(34, 197, 94, 0.07);
}

@keyframes kpi-pulse {
    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.3);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
    }
}

/* Row 2: Projections - 5 equal columns, smaller cards */
.cashflow-kpi-row-2 {
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}

.kpi-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    text-align: center;
}

/* Smaller KPI cards for projection row */
.kpi-card.kpi-card-sm {
    padding: 10px 8px;
}

.kpi-card-sm .kpi-label {
    font-size: 0.65rem;
    margin-bottom: 4px;
}

.kpi-card-sm .kpi-value {
    font-size: 1.1rem;
    margin-bottom: 2px;
}

.kpi-card-sm .kpi-detail {
    font-size: 0.6rem;
}

.kpi-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 3px;
}

.kpi-value.kpi-positive {
    color: var(--success);
}

.kpi-value.kpi-negative {
    color: var(--danger);
}

.kpi-value.kpi-warning {
    color: var(--danger);
}

.kpi-detail {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

/* Responsive: Stack projection cards on smaller screens */
@media (max-width: 900px) {
    .cashflow-kpi-row-1 {
        grid-template-columns: repeat(3, 1fr);
    }
    .cashflow-kpi-row-2 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 600px) {
    .cashflow-kpi-row-1,
    .cashflow-kpi-row-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Cash Flow Chart */
.cashflow-chart-card {
    margin-bottom: 16px;
}

.cashflow-chart-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}

.cashflow-chart-card .card-header h3 {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    font-size: 0.85rem;
}

.chart-controls {
    display: flex;
    gap: 6px;
}

.chart-controls button.active {
    background: var(--primary);
    color: white;
}

.cashflow-chart-container {
    padding: 14px;
    height: 300px;
}

/* Dual Chart Layout (Helm-style) */
.cashflow-charts-wrapper {
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.cashflow-balance-chart {
    height: 160px;
    position: relative;
    padding-bottom: 8px;
}

.cashflow-transactions-chart {
    height: 220px;
    position: relative;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.chart-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.chart-legend-inline {
    position: absolute;
    top: 3px;
    right: 0;
    display: flex;
    gap: 20px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    z-index: 10;
}

.chart-legend-inline .legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chart-legend-inline .legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

/* Transaction Subtabs */
.transactions-subtabs {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.transactions-subtabs .subtab {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: -1px;
}

.transactions-subtabs .subtab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.transactions-subtabs .subtab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.transactions-count {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-left: auto;
    padding-right: 10px;
}

.per-page-select {
    padding: 5px 10px;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    margin-right: 10px;
}

.per-page-select:hover {
    border-color: var(--primary);
}

.per-page-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Compact Transaction Table */
.compact-table {
    font-size: 0.85rem;
}

.compact-table th,
.compact-table td {
    padding: 8px 10px;
}

.compact-table .txn-company {
    font-weight: 500;
}

.compact-table .txn-invoice-num {
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.compact-table .txn-date {
    white-space: nowrap;
    font-size: 0.8rem;
}

.compact-table .row-overdue {
    background: rgba(231, 76, 60, 0.1);
}

/* Inline Input Styling */
.inline-input {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    padding: 4px 6px;
    font-size: 0.8rem;
    width: 100%;
    transition:
        border-color 0.2s,
        box-shadow 0.2s;
}

.inline-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.inline-input:hover {
    border-color: var(--text-secondary);
}

.adr-input {
    width: 55px;
    text-align: center;
}

.adr-input.adr-calculated {
    background: rgba(46, 204, 113, 0.15);
    border-color: rgba(46, 204, 113, 0.4);
}

.adr-input.adr-manual {
    background: rgba(52, 152, 219, 0.15);
    border-color: rgba(52, 152, 219, 0.4);
}

.expected-date-input {
    width: 130px;
}

/* Transaction search filter bar */
.tx-filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.03));
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.tx-filter-input {
    padding: 5px 10px;
    font-size: 0.8rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 4px);
    color: var(--text-primary);
    flex: 1 1 160px;
    min-width: 120px;
}

.tx-filter-input.tx-filter-date {
    flex: 0 0 140px;
    min-width: 120px;
}

.tx-filter-input:focus {
    outline: none;
    border-color: var(--primary);
}

.tx-filter-sep {
    color: var(--text-muted);
    font-size: 0.8rem;
    flex-shrink: 0;
}

/* Transaction search filter bar */
.tx-filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.03));
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.tx-filter-input {
    padding: 5px 10px;
    font-size: 0.8rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 4px);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s;
}

.tx-filter-input:focus {
    border-color: var(--primary);
}

.tx-filter-input:not(.tx-filter-date) {
    flex: 1 1 160px;
    min-width: 140px;
}

.tx-filter-date {
    width: 140px;
}

.tx-filter-sep {
    color: var(--text-muted);
    font-size: 0.8rem;
    flex-shrink: 0;
}

/* Recalc ADR button in subtabs */
.transactions-subtabs .btn {
    margin-left: 10px;
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* Cashflow Tabs */
.cashflow-tabs {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.cashflow-tabs .tab-buttons {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: var(--bg-primary);
    border-radius: var(--radius) var(--radius) 0 0;
    overflow-x: auto;
}

.cashflow-tabs .tab-btn {
    padding: 10px 18px;
    background: none;
    border: none;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.cashflow-tabs .tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-secondary);
}

.cashflow-tabs .tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: var(--bg-secondary);
}

.cashflow-tabs .tab-content {
    display: none;
    padding: 14px;
}

.cashflow-tabs .tab-content.active {
    display: block;
}

/* Manual Entry Form */
.manual-entry-form {
    padding: 20px;
    margin-bottom: 0;
}

.manual-entry-form h4 {
    margin: 0 0 16px 0;
    font-size: 1rem;
}

.manual-entry-form .form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.manual-entry-form .form-group {
    flex: 1;
    min-width: 150px;
}

.manual-entry-form .form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.manual-entry-form input,
.manual-entry-form select,
.manual-entry-form textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 0.9rem;
}

/* Patterns Header */
.patterns-header,
.scenarios-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.patterns-header p,
.scenarios-header p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.8rem;
    flex: 1;
}

/* Patterns Subtabs */
.patterns-subtabs {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.patterns-subtabs .subtab-group {
    display: flex;
    gap: 0;
}

.patterns-subtabs .subtab {
    padding: 8px 14px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: -1px;
}

.patterns-subtabs .subtab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.patterns-subtabs .subtab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.patterns-subtabs .subtab-separator {
    width: 1px;
    height: 20px;
    background: var(--border);
    margin: 0 10px;
    align-self: center;
}

.patterns-count {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-left: auto;
    padding-right: 10px;
}

/* ==================== FORECASTING RULES ==================== */

/* Rules Header */
.rules-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.rules-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.rules-search {
    position: relative;
    display: flex;
    align-items: center;
}

.rules-search i {
    position: absolute;
    left: 10px;
    color: var(--text-secondary);
    width: 14px;
    height: 14px;
}

.rules-search input {
    padding-left: 32px;
    font-size: 0.85rem;
    height: 32px;
}

.rules-search input {
    padding-left: 36px;
    width: 220px;
}

.rules-group-by {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rules-group-by label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.rules-group-by select {
    min-width: 120px;
}

/* Rules Filters Panel */
.rules-filters {
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    flex-wrap: wrap;
    font-size: 0.8rem;
}

/* Rules List */
.rules-list {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.rules-group {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 8px;
}

.rules-group-header {
    padding: 8px 12px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.rules-group-header:hover {
    background: var(--bg-secondary);
}

.rules-group-header .collapse-icon {
    display: flex;
    transition: transform 0.2s;
}

.rules-group-header .collapse-icon svg {
    width: 14px;
    height: 14px;
}

.rules-group.collapsed .rules-group-header .collapse-icon {
    transform: rotate(-90deg);
}

.rules-group-header .group-count {
    color: var(--text-secondary);
    font-weight: 400;
    font-size: 0.75rem;
    margin-left: auto;
}

.rules-group-content {
    transition: max-height 0.3s ease;
    overflow: hidden;
}

.rules-group.collapsed .rules-group-content {
    display: none;
}

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

.rules-table th {
    text-align: left;
    padding: 6px 10px;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.rules-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: 0.85rem;
}

.rules-table tr:last-child td {
    border-bottom: none;
}

.rules-table tr:hover {
    background: var(--bg-primary);
}

.rules-table .rule-name {
    font-weight: 500;
    font-size: 0.85rem;
}

.rules-table .rule-contact {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.rules-table .rule-inactive {
    opacity: 0.5;
}

.rules-table .rule-pattern {
    background: rgba(var(--info-rgb, 52, 152, 219), 0.05);
}

.rules-table .rule-pattern .rule-name .badge {
    font-size: 0.6rem;
    margin-left: 6px;
    vertical-align: middle;
}

.pattern-active-indicator {
    color: var(--success);
    font-size: 0.75rem;
}

.rule-actions {
    display: flex;
    gap: 3px;
    justify-content: flex-end;
}

.rule-actions .btn-icon {
    padding: 4px 8px;
}

.rule-toggle {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Rule Modal - Compact */
.modal-wide {
    max-width: 920px;
    width: 98%;
}

.modal-wide .modal-body {
    padding: 0;
    overflow: visible;
}

.rule-form-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 0;
}

.rule-form-section {
    padding: 15px 20px;
}

.rule-form-section:first-child {
    border-right: 1px solid var(--border);
}

.rule-form-section:last-child {
    min-width: 420px;
}

.rule-form-section h4 {
    margin: 0 0 10px 0;
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 600;
}

.rule-form-section .form-group {
    margin-bottom: 10px;
}

.rule-form-section .form-group:last-child {
    margin-bottom: 0;
}

.rule-form-section .form-group label {
    font-size: 0.75rem;
    margin-bottom: 3px;
}

.rule-form-section input,
.rule-form-section select {
    padding: 6px 10px;
    font-size: 0.85rem;
}

.rule-form-section .form-row {
    display: flex;
    gap: 10px;
}

.rule-form-section .flex-1 {
    flex: 1;
}

.repeat-every-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.repeat-every-row input {
    width: 50px;
}

.repeat-every-row span {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* Searchable Select */
.searchable-select {
    width: 100%;
}

/* Day Picker Compact */
.day-picker {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px;
    min-width: 280px;
}

.day-picker-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
    margin-bottom: 6px;
}

.day-picker-btn {
    width: 100%;
    min-width: 32px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.15s;
    padding: 0;
}

.day-picker-btn:hover {
    border-color: var(--primary);
}

.day-picker-btn.selected {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.day-picker-last {
    width: 100%;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.15s;
}

.day-picker-last:hover {
    border-color: var(--primary);
}

.day-picker-last.selected {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Ends Row */
.ends-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.ends-row input[type='date'] {
    width: 140px;
    padding: 6px 8px;
    font-size: 0.85rem;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
    font-size: 0.85rem;
    white-space: nowrap;
}

.radio-label input[type='radio'] {
    width: 14px;
    height: 14px;
}

/* Responsive */
@media (max-width: 768px) {
    .rule-form-grid {
        grid-template-columns: 1fr;
    }

    .rule-form-section:first-child {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .rules-header-left {
        width: 100%;
    }

    .rules-search input {
        width: 100%;
    }
}

/* Scenarios Grid */
.scenarios-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.scenario-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}

.scenario-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.scenario-card-header h4 {
    margin: 0;
    font-size: 1rem;
}

.scenario-desc {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 0 0 12px 0;
}

.scenario-actions {
    display: flex;
    gap: 8px;
}

/* Amount styling */
.amount-positive {
    color: var(--success);
    font-weight: 500;
}

.amount-negative {
    color: var(--danger);
    font-weight: 500;
}

/* Ignored pattern row */
.ignored-pattern {
    opacity: 0.5;
}

/* Bank Accounts Toggle List */
.bank-accounts-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bank-account-toggle {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.bank-account-info {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.bank-account-name {
    font-weight: 500;
}

.bank-account-balance {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border);
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: '';
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

/* Modal sizes */
.modal-small {
    max-width: 450px;
}

.modal-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

/* Add dashboard choice */
.add-dashboard-choice-label {
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-size: 0.9rem;
}

.add-dashboard-choice-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.add-dashboard-choice-btn {
    width: 100%;
    justify-content: center;
}

.form-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 12px;
}

.internal-dashboard-queues-list {
    max-height: 200px;
    overflow-y: auto;
    padding: 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.internal-queue-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.internal-queue-checkbox input {
    flex-shrink: 0;
}

/* Alert styling */
.alert {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.alert-warning {
    background: rgba(243, 156, 18, 0.1);
    border: 1px solid var(--warning);
    color: var(--warning);
}

.alert a {
    color: inherit;
    text-decoration: underline;
}

/* No data styling */
.no-data {
    text-align: center;
    color: var(--text-secondary);
    padding: 24px !important;
    font-style: italic;
}

/* Clickable KPI cards */
.kpi-clickable {
    cursor: pointer;
    transition:
        transform 0.2s,
        box-shadow 0.2s;
}

.kpi-clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border-color: var(--primary);
}

/* Large modal */
.modal-large {
    max-width: 800px;
    max-height: 80vh;
}

.modal-large .modal-body {
    max-height: 60vh;
    overflow-y: auto;
}

/* KPI Detail table */
.kpi-detail-table {
    width: 100%;
    border-collapse: collapse;
}

.kpi-detail-table th,
.kpi-detail-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.kpi-detail-table th {
    background: var(--bg-primary);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
}

.kpi-detail-table tr:hover {
    background: var(--bg-primary);
}

.kpi-detail-total {
    font-weight: 600;
    background: var(--bg-primary) !important;
}

/* KPI breakdown summary */
.kpi-breakdown {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: var(--radius);
}

.kpi-breakdown-item {
    text-align: center;
}

.kpi-breakdown-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.kpi-breakdown-value {
    font-size: 1.2rem;
    font-weight: 600;
}

/* Overdue styling */
.row-overdue {
    background: rgba(239, 68, 68, 0.1) !important;
}

.badge-overdue {
    display: inline-block;
    padding: 2px 6px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #fff;
    background: var(--warning);
    border-radius: 3px;
    margin-left: 8px;
    vertical-align: middle;
}

/* ==================== ACCOUNTS TAB ==================== */

.accounts-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.accounts-header p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

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

.account-number {
    font-size: 0.8rem;
    margin-top: 2px;
}

.scheduled-transfers-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.bank-accounts-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.bank-accounts-section h4,
.scheduled-transfers-section h4 {
    margin: 0 0 5px 0;
    font-size: 1rem;
    font-weight: 600;
}

.scheduled-transfers-section h4 {
    margin: 0 0 5px 0;
    font-size: 1rem;
    font-weight: 600;
}

.scheduled-transfers-section .text-secondary {
    font-size: 0.85rem;
    margin-bottom: 15px;
}

/* Small modal variant */
.modal-sm {
    max-width: 450px;
}

/* ==================== MAT COMPARISON DASHBOARD ==================== */

/* Override grid layout when showing MAT comparison */
.widgets-container.mat-mode {
    display: block !important;
    grid-template-columns: none !important;
}

/* MAT dashboard widgets: disable dense packing so widgets flow in DOM order */
.widgets-container.mat-dashboard {
    grid-auto-flow: row !important;
}

/* Also force all other large widgets to have explicit order so grid respects DOM sequence */
.mat-dashboard .widget.card-mat-narrow {
    order: 10 !important;
}
.mat-dashboard .widget.card-mat-wide {
    order: 20 !important;
}
.mat-dashboard [data-widget-id='matStatusWidget'] {
    order: 30 !important;
}

.mat-comparison-container {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.mat-comparison-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 10px;
}

.mat-comparison-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.mat-school-count {
    background: var(--primary);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.mat-comparison-table-wrapper {
    overflow-x: auto;
}

.mat-comparison-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.mat-comparison-table th {
    background: var(--bg-secondary);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.mat-comparison-table th.stat-col {
    text-align: center;
    width: 100px;
}

.mat-comparison-table th.school-col {
    width: auto;
}

.mat-school-row td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.mat-school-row .school-name {
    font-weight: 500;
    color: var(--text-primary);
}

.mat-school-row .stat-cell {
    text-align: center;
    font-weight: 600;
    font-size: 1rem;
}

.mat-school-row .stat-cell.clickable {
    cursor: pointer;
    color: var(--primary);
    transition: all 0.2s;
}

.mat-school-row .stat-cell.clickable:hover {
    background: var(--primary-light);
    border-radius: 4px;
}

.mat-school-row .stat-cell.kr-good {
    color: var(--success);
}

.mat-school-row .stat-cell.kr-bad {
    color: var(--danger);
}

.mat-charts-row td {
    padding: 0 16px 16px 16px;
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border);
}

.mat-mini-charts {
    display: flex;
    gap: 40px;
    padding-top: 10px;
    padding-left: 20px;
}

.mat-mini-chart-container {
    flex: 0 0 350px;
    min-width: 250px;
}

.mat-mini-creators-container {
    flex: 0 0 300px;
    min-width: 200px;
}

.mini-chart-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mat-mini-chart {
    height: 80px !important;
    width: 100% !important;
}

.mat-mini-creators {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mini-creator-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    background: var(--card-bg);
    border-radius: 4px;
    font-size: 0.8rem;
}

.mini-creator-row.clickable {
    cursor: pointer;
    transition: all 0.2s;
}

.mini-creator-row.clickable:hover {
    background: var(--primary-light);
}

.creator-rank {
    color: var(--text-secondary);
    font-weight: 500;
    width: 20px;
}

.creator-name {
    flex: 1;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.creator-count {
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-light);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
}

.mat-mini-creators .no-data {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.8rem;
    padding: 8px;
}

.mat-totals-row td {
    background: var(--bg-secondary);
    padding: 14px 16px;
    border-top: 2px solid var(--border);
}

.mat-totals-row .school-name {
    font-weight: 700;
    color: var(--text-primary);
}

.mat-totals-row .stat-cell {
    text-align: center;
    font-size: 1.1rem;
}

.mat-totals-row .stat-cell.kr-good {
    color: var(--success);
}

.mat-totals-row .stat-cell.kr-bad {
    color: var(--danger);
}

/* Loading and error states */
.mat-comparison-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.mat-comparison-loading .loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

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

.mat-comparison-error {
    padding: 40px 20px;
    text-align: center;
    color: var(--danger);
    background: var(--card-bg);
    border-radius: 12px;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .mat-mini-charts {
        flex-direction: column;
    }

    .mat-mini-chart-container,
    .mat-mini-creators-container {
        max-width: 100%;
    }

    .mat-comparison-table th.stat-col {
        width: 60px;
        padding: 8px;
    }

    .mat-school-row .stat-cell {
        font-size: 0.9rem;
    }
}

/* ==================== BACKUP VIEW ==================== */

.backup-controls {
    margin-bottom: 20px;
}

.backup-controls-row {
    display: flex;
    align-items: flex-end;
    gap: 15px;
}

/* Backup table header with filters */
.backup-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 15px;
}

.backup-table-header h3 {
    margin: 0;
}

.backup-filters {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.backup-filters .filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.backup-filters .filter-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.backup-filters .form-select-sm,
.backup-filters .form-input-sm {
    padding: 6px 10px;
    font-size: 0.85rem;
    min-width: 120px;
}

.backup-filters .form-input-sm {
    width: 140px;
}

.backup-filter-summary {
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: 6px;
    margin-bottom: 10px;
}

.backup-filter-summary span {
    font-weight: 600;
    color: var(--primary);
}

.backup-summary {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.backup-summary .stat-card {
    flex: 1;
    min-width: 140px;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border: 1px solid var(--border);
}

.backup-summary .stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

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

.backup-summary .stat-card .stat-content {
    display: flex;
    flex-direction: column;
}

.backup-summary .stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.backup-summary .stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.backup-summary .stat-card.stat-success .stat-icon {
    background: rgba(46, 204, 113, 0.15);
    color: var(--success);
}

.backup-summary .stat-card.stat-warning .stat-icon {
    background: rgba(241, 196, 15, 0.15);
    color: var(--warning);
}

.backup-summary .stat-card.stat-error .stat-icon {
    background: rgba(231, 76, 60, 0.15);
    color: var(--danger);
}

/* Backup status badges */
.backup-status {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.backup-status.status-success {
    background: rgba(46, 204, 113, 0.15);
    color: var(--success);
}

.backup-status.status-warning {
    background: rgba(241, 196, 15, 0.15);
    color: var(--warning);
}

.backup-status.status-error {
    background: rgba(231, 76, 60, 0.15);
    color: var(--danger);
}

.backup-status.status-running {
    background: rgba(52, 152, 219, 0.15);
    color: var(--primary);
}

.backup-status.status-unknown {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

/* Clickable server link */
.backup-server-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
}

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

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state .empty-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    margin-bottom: 10px;
    color: var(--text-primary);
}

/* Backup modal tabs */
.backup-modal-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
}

.backup-modal-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.backup-modal-tab:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.backup-modal-tab.active {
    background: var(--primary);
    color: white;
}

.backup-modal-tab svg {
    width: 18px;
    height: 18px;
}

.backup-modal-tab-content {
    display: none;
}

.backup-modal-tab-content.active {
    display: block;
}

/* Storage actions */
.backup-storage-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.sync-status {
    font-size: 0.85rem;
}

.sync-status.success {
    color: var(--success);
}

.sync-status.error {
    color: var(--danger);
}

/* Purge indicators */
.purge-row {
    background: rgba(231, 76, 60, 0.05);
}

.purge-cell {
    color: var(--danger);
    font-weight: 600;
}

.purge-indicator {
    color: var(--danger);
    font-weight: 700;
    margin-left: 4px;
}

/* Loading and error cells */
.loading-cell {
    text-align: center;
    padding: 30px;
    color: var(--text-secondary);
}

.error-cell {
    text-align: center;
    padding: 30px;
    color: var(--danger);
}

.empty-cell {
    text-align: center;
    padding: 30px;
    color: var(--text-secondary);
    font-style: italic;
}

/* Modal large variant */
.modal-content.modal-large {
    max-width: 900px;
    width: 95%;
}

@media (max-width: 768px) {
    .backup-controls-row {
        flex-direction: column;
        align-items: stretch;
    }

    .backup-controls-row .form-group {
        max-width: 100% !important;
    }

    .backup-summary {
        flex-direction: column;
    }

    .backup-summary .stat-card {
        min-width: 100%;
    }

    .backup-modal-tabs {
        flex-wrap: wrap;
    }

    .backup-table-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .backup-filters {
        width: 100%;
    }

    .backup-filters .filter-group {
        flex: 1;
        min-width: 45%;
    }

    .backup-filters .form-select-sm,
    .backup-filters .form-input-sm {
        width: 100%;
    }
}

/* ── Room Status (Busy Light) ─────────────────────────────────────────────── */

.room-status-banner {
    padding: 10px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.875rem;
    font-weight: 500;
}
.rs-banner-success {
    background: rgba(56, 161, 105, 0.15);
    color: var(--success, #38a169);
    border: 1px solid rgba(56, 161, 105, 0.3);
}
.rs-banner-error {
    background: rgba(229, 62, 62, 0.12);
    color: var(--danger, #e53e3e);
    border: 1px solid rgba(229, 62, 62, 0.3);
}

.room-status-settings-card {
    margin-bottom: 20px;
}
.room-status-settings-card .card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    user-select: none;
}
.room-status-settings-card .card-header-row h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 0.95rem;
}
.room-status-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    padding: 20px 18px 8px;
}
.settings-group h4 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin: 0 0 12px;
}
.settings-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px 16px;
}
.save-status {
    font-size: 0.8rem;
}
.save-status.saving {
    color: var(--text-secondary);
}
.save-status.saved {
    color: var(--success, #38a169);
}
.save-status.error {
    color: var(--danger, #e53e3e);
}
.azure-setup-note {
    margin: 0 18px 16px;
    padding: 10px 14px;
    background: rgba(66, 153, 225, 0.08);
    border-left: 3px solid var(--primary, #4299e1);
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
}
.azure-setup-note code {
    background: rgba(0, 0, 0, 0.1);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.85em;
}

/* Live status grid */
.room-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    padding: 16px 18px;
}
.rs-status-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px 16px;
    background: var(--bg-secondary, rgba(0, 0, 0, 0.05));
    border: 1px solid var(--border-color);
    border-radius: 10px;
    text-align: center;
    transition: transform 0.15s;
}
.rs-status-card:hover {
    transform: translateY(-2px);
}
.rs-card-inactive {
    opacity: 0.45;
}
.rs-led-preview {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    transition:
        background 0.4s,
        box-shadow 0.4s;
}
.rs-card-info {
    width: 100%;
}
.rs-card-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 2px;
}
.rs-card-device {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.rs-card-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    font-weight: 500;
}
.rs-card-lastseen {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Status dots */
.rs-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.rs-dot-busy {
    background: #e53e3e;
    box-shadow: 0 0 5px rgba(229, 62, 62, 0.7);
}
.rs-dot-away {
    background: #ed8936;
    box-shadow: 0 0 5px rgba(237, 137, 54, 0.7);
}
.rs-dot-available {
    background: #38a169;
    box-shadow: 0 0 5px rgba(56, 161, 105, 0.7);
}
.rs-dot-unknown {
    background: #718096;
}

/* Table helpers */
.teams-id-cell {
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.row-inactive td {
    opacity: 0.5;
}
.btn-xs {
    padding: 3px 7px;
    font-size: 0.75rem;
}
.actions-cell {
    white-space: nowrap;
}

/* Firmware modal */
.modal-content-wide {
    max-width: 780px;
    width: 95vw;
}
.firmware-instructions {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.5;
}
.firmware-code-wrap {
    position: relative;
}
.firmware-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 1;
}
.firmware-code {
    background: var(--bg-secondary, #1a202c);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 40px 14px 14px;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre;
    max-height: 420px;
    overflow-y: auto;
    color: var(--text-primary);
}

/* Card header row (reusable) */
.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
}
.card-header-row h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
}
.last-updated-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.rs-integration-links {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(66, 153, 225, 0.04);
}

.rs-integration-links p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.rs-integration-link-btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

@media (max-width: 600px) {
    .room-status-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
    .room-status-settings-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   TECH UTILISATION DASHBOARD
   ============================================================ */

/* Status badge on resource cards */
.tu-status-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

/* Per-resource metric rows */
.tu-resource-metric {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin: 4px 0;
    font-size: 0.875rem;
}
.tu-metric-label {
    color: var(--text-muted, #718096);
    min-width: 80px;
    font-size: 0.8rem;
}
.tu-metric-value {
    font-weight: 600;
    font-size: 1rem;
}
.tu-metric-target {
    color: var(--text-muted, #718096);
    font-size: 0.75rem;
}

/* Progress bar on resource cards */
.tu-progress-bar-wrap {
    position: relative;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    overflow: visible;
}
.tu-progress-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}
.tu-progress-target-line {
    position: absolute;
    top: -3px;
    width: 2px;
    height: 12px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 1px;
    transform: translateX(-50%);
}

/* Category legend */
.tu-category-legend {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.tu-legend-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
}
.tu-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.tu-legend-name {
    min-width: 90px;
    font-weight: 500;
}
.tu-legend-pct {
    font-weight: 700;
    min-width: 36px;
    text-align: right;
}
.tu-legend-hrs {
    color: var(--text-muted, #718096);
    min-width: 52px;
    font-size: 0.8rem;
}
.tu-legend-range {
    font-size: 0.75rem;
}
.tu-steady-state-note {
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    line-height: 1.5;
}

/* Category flags */
.tu-flag {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 6px;
}
.tu-flag svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
.tu-flag-warning {
    background: rgba(217, 119, 6, 0.12);
    color: #f59e0b;
    border: 1px solid rgba(217, 119, 6, 0.25);
}
.tu-flag-danger {
    background: rgba(229, 62, 62, 0.12);
    color: #fc8181;
    border: 1px solid rgba(229, 62, 62, 0.25);
}
.tu-flag-ok {
    background: rgba(56, 161, 105, 0.1);
    color: #68d391;
    border: 1px solid rgba(56, 161, 105, 0.2);
}

/* Capacity bar */
.tu-capacity-bar-wrap {
    position: relative;
    margin: 16px 0 8px;
}
.tu-capacity-zones {
    display: flex;
    height: 28px;
    border-radius: 6px;
    overflow: hidden;
}
.tu-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    overflow: hidden;
}
.tu-zone span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 4px;
}
.tu-zone-spare {
    background: rgba(59, 130, 246, 0.35);
}
.tu-zone-healthy {
    background: rgba(56, 161, 105, 0.45);
}
.tu-zone-closing {
    background: rgba(217, 119, 6, 0.45);
}
.tu-zone-capacity {
    background: rgba(229, 62, 62, 0.45);
}

.tu-capacity-indicator-wrap {
    position: relative;
    height: 24px;
    margin-top: 2px;
}
.tu-capacity-indicator {
    position: absolute;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: left 0.5s ease;
}
.tu-capacity-needle {
    width: 3px;
    height: 16px;
    background: var(--needle-color, #fff);
    border-radius: 2px;
    box-shadow: 0 0 6px var(--needle-color, #fff);
}
.tu-capacity-indicator span {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--needle-color, #fff);
    margin-top: 2px;
    white-space: nowrap;
}

.tu-capacity-message {
    font-size: 0.875rem;
    padding: 8px 0;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* NOC readiness badges */
.tu-noc-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.tu-noc-badge-ok {
    background: rgba(56, 161, 105, 0.12);
    color: #68d391;
    border: 1px solid rgba(56, 161, 105, 0.25);
}
.tu-noc-badge-warn {
    background: rgba(217, 119, 6, 0.12);
    color: #f59e0b;
    border: 1px solid rgba(217, 119, 6, 0.25);
}

/* Per-resource capacity bars */
.tu-resource-bars {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.tu-res-bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.875rem;
}
.tu-res-bar-name {
    min-width: 100px;
    font-weight: 500;
}
.tu-res-bar-track {
    flex: 1;
    height: 10px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 5px;
    position: relative;
    overflow: visible;
}
.tu-res-bar-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.4s ease;
}
.tu-res-bar-target {
    position: absolute;
    top: -3px;
    width: 2px;
    height: 16px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 1px;
    transform: translateX(-50%);
}
.tu-res-bar-pct {
    min-width: 42px;
    text-align: right;
    font-weight: 600;
    font-size: 0.875rem;
}

/* Category pill in table */
.tu-cat-pill {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: capitalize;
    white-space: nowrap;
}

/* Detail table — sortable headers & filter row */
.tu-detail-table thead th.tu-sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.tu-detail-table thead th.tu-sortable:hover {
    color: var(--text-primary);
}
.tu-detail-table thead th.tu-sort-active {
    color: var(--accent, #3b82f6);
}
.tu-sort-icon {
    font-size: 0.7rem;
    opacity: 0.5;
    margin-left: 4px;
}
.tu-sort-active .tu-sort-icon {
    opacity: 1;
}
.tu-detail-filter-row td {
    padding: 4px 6px;
    background: var(--bg-secondary, #161b27);
    border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.08));
}
.tu-filter-input,
.tu-filter-select {
    width: 100%;
    background: var(--bg-tertiary, #1e2533);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.78rem;
    padding: 3px 6px;
    outline: none;
}
.tu-filter-input:focus,
.tu-filter-select:focus {
    border-color: var(--accent, #3b82f6);
}
.tu-notes-cell {
    color: var(--text-muted);
    font-size: 0.85rem;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tu-detail-row:hover {
    background: var(--hover-bg, rgba(255, 255, 255, 0.05));
}
.tu-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px 0 4px;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.tu-page-btn {
    background: var(--card-bg, #1e2535);
    border: 1px solid var(--border-color, #2d3748);
    color: var(--text-primary, #e2e8f0);
    padding: 5px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.15s;
}
.tu-page-btn:hover:not(:disabled) {
    background: var(--hover-bg, rgba(255, 255, 255, 0.08));
}
.tu-page-btn:disabled {
    opacity: 0.35;
    cursor: default;
}
.tu-page-info {
    color: var(--text-muted);
}
.tu-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px 0 4px;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.tu-page-btn {
    background: var(--card-bg, #1e2433);
    border: 1px solid var(--border-color, #2d3748);
    color: var(--text-primary, #e2e8f0);
    padding: 4px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.15s;
}
.tu-page-btn:hover:not(:disabled) {
    background: var(--hover-bg, rgba(255, 255, 255, 0.08));
}
.tu-page-btn:disabled {
    opacity: 0.35;
    cursor: default;
}
.tu-page-info {
    color: var(--text-muted);
}
.tu-entry-detail {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.tu-entry-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
    font-size: 0.9rem;
}
.tu-entry-row:last-child {
    border-bottom: none;
}
.tu-entry-label {
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 110px;
}
.tu-entry-value {
    text-align: right;
    word-break: break-word;
}
.tu-entry-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
    color: var(--accent, #3b82f6);
    font-size: 0.8rem;
    text-decoration: none;
}
.tu-entry-link:hover {
    text-decoration: underline;
}

/* Clickable widget elements */
.tu-clickable {
    cursor: pointer;
    transition: opacity 0.15s ease;
}
.tu-clickable:hover {
    opacity: 0.85;
}
.tu-kpi-card.tu-clickable:hover {
    background: var(--hover-bg, rgba(255, 255, 255, 0.06));
    border-color: var(--accent, #3b82f6);
}
.tu-engineer-card.tu-clickable:hover {
    background: var(--hover-bg, rgba(255, 255, 255, 0.06));
    border-color: var(--accent, #3b82f6);
    opacity: 1;
}
.tu-legend-row.tu-clickable:hover {
    background: var(--hover-bg, rgba(255, 255, 255, 0.05));
    border-radius: 4px;
    opacity: 1;
}
.tu-res-bar-row.tu-clickable:hover {
    background: var(--hover-bg, rgba(255, 255, 255, 0.05));
    border-radius: 4px;
    opacity: 1;
}

/* Drill-down modal */
.tu-drill-modal-content {
    max-width: 820px;
    width: 95vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}
.tu-drill-modal-body {
    overflow-y: auto;
    padding: 0;
    flex: 1;
}
.tu-drill-row:hover {
    background: var(--hover-bg, rgba(255, 255, 255, 0.05));
}

/* Settings modal */
.tu-settings-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}
.tu-settings-tab {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition:
        background 0.15s,
        color 0.15s;
}
.tu-settings-tab:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}
.tu-settings-tab.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    font-weight: 600;
}
.tu-settings-panel {
    animation: fadeIn 0.15s ease;
}

/* Resource target rows */
.tu-resource-target-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}
.tu-resource-target-row:last-child {
    border-bottom: none;
}

/* ==================== Tech Utilisation Date Picker ==================== */

.tu-date-picker {
    position: relative;
}

.tu-date-label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-card, #1e2533);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.15s;
}

.tu-date-label:hover {
    border-color: var(--accent, #3b82f6);
}

.tu-date-label i {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.tu-date-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 200;
    background: var(--bg-card, #1e2533);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
    border-radius: 8px;
    padding: 12px;
    min-width: 220px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.tu-date-dropdown.open {
    display: block;
}

.tu-date-presets {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tu-preset {
    text-align: left;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    transition:
        background 0.1s,
        color 0.1s;
}

.tu-preset:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
}

.tu-preset.active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent, #3b82f6);
    font-weight: 600;
}

.tu-date-divider {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    padding: 10px 8px 4px;
    border-top: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    margin-top: 6px;
}

.tu-date-custom {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 4px;
}

.tu-date-custom-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tu-date-custom-row label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    width: 28px;
    flex-shrink: 0;
}

.tu-date-input {
    flex: 1;
    background: var(--bg-secondary, #161b27);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.82rem;
    padding: 4px 6px;
    outline: none;
    color-scheme: dark;
}

.tu-date-input:focus {
    border-color: var(--accent, #3b82f6);
}

/* ==================== Tech Utilisation Layout ==================== */

/* KPI card row — plain flex, no drag grid */
.tu-kpi-row {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.tu-kpi-card {
    flex: 1 1 0;
    min-width: 120px;
    background: var(--bg-card, #1e2533);
    border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
    border-radius: var(--radius, 8px);
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
    box-sizing: border-box;
}

.tu-kpi-card .stat-icon {
    color: var(--text-muted);
    margin-bottom: 2px;
}

.tu-kpi-card .stat-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    line-height: 1.2;
}

.tu-kpi-card .stat-value {
    font-size: clamp(1rem, 1.4vw, 1.5rem);
    font-weight: 700;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.tu-kpi-card .stat-detail {
    font-size: 0.68rem;
    color: var(--text-secondary);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Three-column main row: Trend | Breakdown | Engineers */
.tu-main-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 16px;
    align-items: stretch;
}

.tu-main-panel {
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Trend chart fills remaining height */
.tu-main-panel .chart-container {
    flex: 1;
    min-height: 180px;
}

.tu-breakdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 8px;
}

.tu-breakdown-body {
    display: flex;
    flex: 1;
    gap: 12px;
    align-items: flex-start;
}

.tu-breakdown-chart-wrap {
    height: 180px;
    width: 180px;
    flex-shrink: 0;
}

/* Engineer panel */
.tu-engineer-panel {
    display: flex;
    flex-direction: column;
    gap: 0;
    flex: 1;
}

.tu-engineer-panel-title {
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 10px 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.72rem;
}

.tu-engineer-card {
    border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.06));
    padding: 12px 0;
}

.tu-engineer-card:first-child {
    padding-top: 0;
}

.tu-engineer-card:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.tu-engineer-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 8px;
}

.tu-engineer-card-header strong {
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 1100px) {
    .tu-main-row {
        grid-template-columns: 1fr 1fr;
    }
    .tu-engineer-panel {
        grid-column: span 2;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 12px;
    }
    .tu-engineer-card {
        flex: 1 1 200px;
        border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
        border-radius: 8px;
        padding: 12px;
    }
}

@media (max-width: 700px) {
    .tu-main-row {
        grid-template-columns: 1fr;
    }
    .tu-engineer-panel {
        grid-column: span 1;
    }
}

/* Category mapping grid */
.tu-category-mapping-grid {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 340px;
    overflow-y: auto;
}
.tu-cat-map-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 5px 8px;
    border-radius: 4px;
    transition: background 0.1s;
}
.tu-cat-map-row:hover {
    background: rgba(255, 255, 255, 0.04);
}
.tu-cat-map-name {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 500;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tu-cat-map-type {
    min-width: 80px;
}
.tu-cat-map-select {
    width: 140px;
    flex-shrink: 0;
    font-size: 0.85rem;
}
.tu-cat-type-tab.active {
    background: var(--accent, #3b82f6) !important;
    color: #fff !important;
}

/* Form grid */
.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.form-hint {
    font-size: 0.78rem;
    color: var(--text-muted, #718096);
    margin-top: 4px;
}

/* ==================== HELP PAGE ==================== */

/* Top-nav help link */
.nav-help-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 6px;
    color: var(--text-secondary, #4a5568);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition:
        background 0.15s,
        color 0.15s;
    white-space: nowrap;
}
.nav-help-link:hover,
.nav-help-link.active {
    background: var(--bg-hover, #edf2f7);
    color: var(--text-primary, #1a202c);
}
.nav-help-link svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

/* Two-pane layout */
.help-layout {
    display: flex;
    gap: 0;
    height: calc(100vh - 120px);
    overflow: hidden;
}

/* Sidebar */
.help-sidebar {
    width: 230px;
    flex-shrink: 0;
    border-right: 1px solid var(--border-color, #e2e8f0);
    overflow-y: auto;
    padding: 16px 0;
    background: var(--bg-secondary, #f7fafc);
}
.help-sidebar ul {
    list-style: none;
    margin: 0;
    padding: 0;
}
.help-nav-group-label {
    padding: 12px 16px 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted, #718096);
}
.help-nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 16px;
    font-size: 0.875rem;
    color: var(--text-secondary, #4a5568);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition:
        background 0.12s,
        color 0.12s,
        border-color 0.12s;
}
.help-nav-link:hover {
    background: var(--bg-hover, #edf2f7);
    color: var(--text-primary, #1a202c);
}
.help-nav-link.active {
    background: var(--accent-light, #ebf4ff);
    color: var(--accent, #3b82f6);
    border-left-color: var(--accent, #3b82f6);
    font-weight: 600;
}
.help-nav-link svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* Content pane */
.help-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px 40px;
}

/* Individual sections (shown/hidden) */
.help-section {
    display: none;
    max-width: 820px;
}
.help-section.active {
    display: block;
}
.help-section > h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary, #1a202c);
    margin: 0 0 6px;
}
.help-section > h2 svg {
    width: 22px;
    height: 22px;
    color: var(--accent, #3b82f6);
}
.help-intro {
    font-size: 1rem;
    color: var(--text-secondary, #4a5568);
    margin: 0 0 24px;
    line-height: 1.6;
}

/* Cards */
.help-card {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 10px;
    padding: 20px 24px;
    margin-bottom: 20px;
}
.help-card h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary, #1a202c);
    margin: 0 0 12px;
}
.help-card p,
.help-card li {
    font-size: 0.9rem;
    color: var(--text-secondary, #4a5568);
    line-height: 1.65;
    margin: 0 0 8px;
}
.help-card ul,
.help-card ol {
    padding-left: 20px;
    margin: 8px 0;
}
.help-card code {
    background: var(--bg-secondary, #f7fafc);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 0.82rem;
    font-family: 'Courier New', monospace;
    color: var(--accent, #3b82f6);
}

/* Table inside cards */
.help-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.help-table th {
    text-align: left;
    padding: 8px 12px;
    background: var(--bg-secondary, #f7fafc);
    border-bottom: 2px solid var(--border-color, #e2e8f0);
    font-weight: 600;
    color: var(--text-primary, #1a202c);
}
.help-table td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    color: var(--text-secondary, #4a5568);
    vertical-align: top;
}
.help-table tr:last-child td {
    border-bottom: none;
}

/* Two-column callout row */
.help-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.help-callout {
    border-radius: 8px;
    padding: 14px 16px;
    font-size: 0.875rem;
    line-height: 1.6;
}
.help-callout strong {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 6px;
}
.help-callout p {
    margin: 0 0 6px !important;
    color: inherit !important;
}
.help-callout-info {
    background: #ebf8ff;
    border: 1px solid #bee3f8;
    color: #2c5282;
}
.help-callout-warning {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    color: #78350f;
}

/* Coming soon placeholder */
.help-coming-soon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 60px 20px;
    color: var(--text-muted, #718096);
    text-align: center;
}
.help-coming-soon svg {
    width: 40px;
    height: 40px;
    opacity: 0.4;
}
.help-coming-soon p {
    font-size: 0.95rem;
    margin: 0;
}

@media (max-width: 768px) {
    .help-layout {
        flex-direction: column;
        height: auto;
    }
    .help-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color, #e2e8f0);
        padding: 8px 0;
    }
    .help-content {
        padding: 20px 16px;
    }
    .help-two-col {
        grid-template-columns: 1fr;
    }
}

/* ── Prepayment Tracker ──────────────────────────────────────────────────── */

.prepay-recon-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--card-bg, #1e2a3a);
    border: 1px solid var(--border-color, #2d3f55);
    border-radius: 8px;
    padding: 0.6rem 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.prepay-recon-card {
    flex: 1;
    min-width: 120px;
    text-align: center;
    padding: 0.15rem 0.75rem;
}

.prepay-recon-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #8899aa);
    margin-bottom: 0.1rem;
}

.prepay-recon-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary, #e2e8f0);
    line-height: 1.2;
}

.prepay-recon-sub {
    font-size: 0.65rem;
    color: var(--text-muted, #8899aa);
    margin-top: 0.1rem;
}

.prepay-recon-divider {
    color: var(--text-muted, #8899aa);
    font-size: 1rem;
    padding: 0 0.25rem;
    display: flex;
    align-items: center;
}

.prepay-recon-diff.recon-ok .prepay-recon-value {
    color: #4ade80;
}
.prepay-recon-diff.recon-warn .prepay-recon-value {
    color: #f87171;
}
.prepay-recon-diff.recon-minor .prepay-recon-value {
    color: #fbbf24;
}

.prepay-recon-actions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-left: auto;
    padding-left: 1rem;
}

/* Stats row */
.prepay-stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.prepay-stat-card {
    background: var(--card-bg, #1e2a3a);
    border: 1px solid var(--border-color, #2d3f55);
    border-radius: 8px;
    padding: 0.9rem 1rem;
    text-align: center;
    border-left: 3px solid var(--text-muted, #8899aa);
}

.prepay-stat-card.prepay-stat-amber {
    border-left-color: #fbbf24;
}
.prepay-stat-card.prepay-stat-green {
    border-left-color: #4ade80;
}
.prepay-stat-card.prepay-stat-blue {
    border-left-color: #60a5fa;
}

.prepay-stat-clickable {
    cursor: pointer;
    transition:
        background 0.15s,
        transform 0.1s,
        box-shadow 0.15s;
    user-select: none;
}
.prepay-stat-clickable:hover {
    background: var(--bg-hover, #253447);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
.prepay-stat-clickable.prepay-stat-active {
    background: var(--bg-hover, #253447);
    box-shadow: 0 0 0 2px var(--accent-color, #3b82f6);
}
.prepay-stat-clickable.prepay-stat-amber.prepay-stat-active {
    box-shadow: 0 0 0 2px #fbbf24;
}
.prepay-stat-clickable.prepay-stat-green.prepay-stat-active {
    box-shadow: 0 0 0 2px #4ade80;
}
.prepay-stat-clickable.prepay-stat-blue.prepay-stat-active {
    box-shadow: 0 0 0 2px #60a5fa;
}

.prepay-stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary, #e2e8f0);
}

.prepay-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted, #8899aa);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 0.2rem;
}

/* Filter row */
.prepay-filter-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.prepay-filter-row .form-input-sm,
.prepay-filter-row .form-select-sm {
    height: 34px;
    padding: 0 0.6rem;
    font-size: 0.82rem;
    min-width: 120px;
}

/* Table */
.prepay-table td,
.prepay-table th {
    white-space: nowrap;
    font-size: 0.82rem;
}

.prepay-table td.wrap-cell {
    white-space: normal;
    max-width: 180px;
}

/* Status badges */
.prepay-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.prepay-badge-pending {
    background: rgba(100, 116, 139, 0.2);
    color: #94a3b8;
}
.prepay-badge-partial {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}
.prepay-badge-complete {
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80;
}

/* Pagination */
.prepay-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color, #2d3f55);
}

/* Journal rows inside modal */
.prepay-journal-row {
    display: grid;
    grid-template-columns: 1fr 1fr 2fr auto auto;
    gap: 0.5rem;
    align-items: center;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border-color, #2d3f55);
}

.prepay-journal-row.completed-row {
    opacity: 0.6;
}

.prepay-journal-row.completed-row input {
    background: var(--input-bg-disabled, #1a2535);
}

.prepay-journal-summary {
    display: flex;
    gap: 1.5rem;
    padding: 0.75rem 0;
    font-size: 0.82rem;
    color: var(--text-muted, #8899aa);
    border-top: 1px solid var(--border-color, #2d3f55);
    margin-top: 0.5rem;
}

.prepay-journal-summary strong {
    color: var(--text-primary, #e2e8f0);
}

/* Reconciliation detail bar */
.prepay-recon-detail-bar {
    display: flex;
    gap: 1.5rem;
    padding: 1rem 1.25rem;
    background: var(--card-bg, #1e2a3a);
    border: 1px solid var(--border-color, #2d3f55);
    border-radius: 8px;
    flex-wrap: wrap;
}

.prepay-recon-detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.prepay-recon-detail-item .label {
    font-size: 0.72rem;
    text-transform: uppercase;
    color: var(--text-muted, #8899aa);
}

.prepay-recon-detail-item .value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary, #e2e8f0);
}

.prepay-recon-total-row td {
    background: var(--table-header-bg, #162032);
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.stale-row td {
    background: rgba(239, 68, 68, 0.05);
}

/* Expand journal button */
.prepay-expand-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted, #8899aa);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    transition: color 0.15s;
}

.prepay-expand-btn:hover {
    color: var(--text-primary, #e2e8f0);
}

/* Inline journal sub-table */
.prepay-main-row td {
    border-bottom: none !important;
}

.prepay-inline-journal {
    background: var(--table-alt-bg, #0f1c2d);
}

.prepay-inline-journal td {
    border-bottom: none !important;
    border-left: 3px solid transparent;
}

.prepay-inline-journal:first-of-type td {
    border-left-color: var(--accent-color, #3b82f6);
}

.prepay-inline-journal.journal-completed td {
    opacity: 0.7;
}

.prepay-inline-journal-actions {
    background: var(--table-alt-bg, #0f1c2d);
}

.prepay-inline-journal-actions td {
    border-bottom: 1px solid var(--border-color, #2d3f55) !important;
    padding: 0.3rem 0.5rem !important;
}

.prepay-journal-sub {
    background: var(--table-alt-bg, #0f1c2d);
}

.prepay-journal-sub > td {
    padding: 0 !important;
}

.prepay-journal-sub-inner {
    padding: 0.75rem 1.5rem 1rem 2rem;
    background: var(--table-alt-bg, #0f1c2d);
    border-left: 3px solid var(--accent-color, #3b82f6);
}

.prepay-journal-sub-table {
    width: 100%;
    font-size: 0.82rem;
    border-collapse: collapse;
    margin-top: 0.25rem;
    table-layout: fixed;
}

.prepay-journal-sub-table colgroup col:nth-child(1) {
    width: 110px;
}
.prepay-journal-sub-table colgroup col:nth-child(2) {
    width: 110px;
}
.prepay-journal-sub-table colgroup col:nth-child(3) {
    width: auto;
}
.prepay-journal-sub-table colgroup col:nth-child(4) {
    width: 160px;
}
.prepay-journal-sub-table colgroup col:nth-child(5) {
    width: 72px;
}

.prepay-journal-sub-table th {
    color: var(--text-muted, #8899aa);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.35rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color, #2d3f55);
    background: rgba(0, 0, 0, 0.2);
    white-space: nowrap;
}

.prepay-journal-sub-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid rgba(45, 63, 85, 0.4);
    vertical-align: middle;
}

.prepay-journal-sub-table tr:last-child td {
    border-bottom: none;
}

.prepay-journal-sub-table tfoot td {
    background: rgba(0, 0, 0, 0.15);
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
}

.prepay-journal-entry-row.journal-completed {
    opacity: 0.8;
}

.prepay-journal-entry-row.journal-completed td:first-child {
    border-left: 3px solid #4ade80;
}

.prepay-journal-entry-row:not(.journal-completed) td:first-child {
    border-left: 3px solid #fbbf24;
}

.prepay-journal-entry-row:hover td {
    background: rgba(255, 255, 255, 0.03);
}

/* Inline journal rows */
.prepay-main-row td {
    border-bottom: none;
}

.prepay-inline-journal {
    background: var(--table-alt-bg, #0f1c2d);
}

.prepay-inline-journal td {
    border-bottom: none;
}

.prepay-inline-journal.journal-completed td:first-child {
    border-left: 3px solid #4ade80;
    padding-left: 0.4rem;
}

.prepay-inline-journal:not(.journal-completed) td:first-child {
    border-left: 3px solid #fbbf24;
    padding-left: 0.4rem;
}

.prepay-inline-journal-actions {
    background: var(--table-alt-bg, #0f1c2d);
}

.prepay-inline-journal-actions td {
    padding-bottom: 0.5rem !important;
    border-bottom: 2px solid var(--border-color, #2d3f55);
}

@media (max-width: 768px) {
    .prepay-stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
    .prepay-recon-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .prepay-recon-actions {
        flex-direction: row;
        margin-left: 0;
        padding-left: 0;
    }
}
