/* Color Variables */
:root {
    --primary-blue: #0b0b48;
    --green-accent: #2e7d32;
    --yellow-accent: #FADC4A;
    --navy-deep: #0b0b48;
    --bg-light: #f8f8f5;
    --white: #ffffff;
    --text-primary: #1a202c;
    --text-secondary: #5f6b80; /* was #718096 (4.0:1 on white); 4.7:1 or more on every page background */
    --border-color: #e2e8f0;
    --danger: #c91433;
    --success: #2e7d32;
    --warning: #fb923c;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-light);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--navy-deep);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    box-shadow: var(--shadow-lg);
}

.logo {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo h2 {
    font-size: 24px;
    margin-bottom: 4px;
}

.logo .role {
    color: var(--yellow-accent);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-menu {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--white);
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.08);
    color: var(--white);
    font-weight: 600;
    /* Brand yellow marks where you are (as in the app) */
    border-left-color: var(--yellow-accent);
}

.nav-item .icon {
    font-size: 20px;
    margin-right: 12px;
    width: 24px;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-info .name {
    font-weight: 600;
    font-size: 14px;
}

.user-info .email {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

.logout-btn {
    width: 100%;
    padding: 10px;
    background: rgba(201, 20, 51, 0.1);
    border: 1px solid rgba(201, 20, 51, 0.3);
    color: #ff6b6b;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: rgba(201, 20, 51, 0.2);
}

/* Main Content */
.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 24px;
    max-width: calc(100vw - 260px);
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.header-left h1 {
    font-size: 28px;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.header-left p {
    color: var(--text-secondary);
    font-size: 14px;
}

.header-right {
    display: flex;
    gap: 16px;
    align-items: center;
}

.search-box {
    position: relative;
    width: 300px;
}

.search-box input {
    width: 100%;
    padding: 10px 40px 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
}

.search-box .icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
}

.notification-btn {
    position: relative;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border-color);
    background: var(--white);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.notification-btn:hover {
    background: var(--bg-light);
}

.notification-btn .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: var(--white);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Content Sections */
.content-section {
    display: none;
}

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

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

.stat-card {
    background: var(--white);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.stat-card.blue::before {
    background: var(--primary-blue);
}

.stat-card.green::before {
    background: var(--green-accent);
}

.stat-card.yellow::before {
    background: var(--yellow-accent);
}

.stat-card.navy::before {
    background: var(--navy-deep);
}

.stat-icon {
    font-size: 40px;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.stat-card.blue .stat-icon {
    background: rgba(11, 11, 72, 0.1);
}

.stat-card.green .stat-icon {
    background: rgba(46, 125, 50, 0.1);
}

.stat-card.yellow .stat-icon {
    background: rgba(249, 115, 22, 0.1);
}

.stat-card.navy .stat-icon {
    background: rgba(30, 58, 95, 0.1);
}

.stat-info h3 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-info p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 8px;
}

.trend {
    font-size: 12px;
    font-weight: 600;
}

.trend.up {
    color: var(--success);
}

.trend.down {
    color: var(--danger);
}

/* Charts Row */
.charts-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.chart-card {
    background: var(--white);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

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

.card-header h3 {
    font-size: 18px;
    color: var(--text-primary);
}

.card-header select {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
}

/* Revenue Stats */
.revenue-stats {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.revenue-item {
    display: flex;
    justify-content: space-between;
    padding: 16px;
    background: var(--bg-light);
    border-radius: 8px;
}

.revenue-item .label {
    color: var(--text-secondary);
    font-size: 14px;
}

.revenue-item .value {
    font-size: 20px;
    font-weight: 700;
    color: var(--green-accent);
}

/* Card */
.card {
    background: var(--white);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

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

.activity-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--bg-light);
    border-radius: 8px;
    border-left: 3px solid var(--primary-blue);
}

.activity-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.activity-text .title {
    font-weight: 600;
    margin-bottom: 4px;
}

.activity-text .subtitle {
    font-size: 13px;
    color: var(--text-secondary);
}

.activity-time {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Queues Grid */
.queues-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.queue-card {
    padding: 20px;
    background: var(--bg-light);
    border-radius: 8px;
    border-left: 4px solid var(--primary-blue);
}

.queue-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 16px;
}

.queue-info h4 {
    font-size: 16px;
    margin-bottom: 4px;
}

.queue-info p {
    font-size: 13px;
    color: var(--text-secondary);
}

.queue-status {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.queue-status.active {
    background: rgba(46, 125, 50, 0.1);
    color: var(--success);
}

.queue-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.queue-stat {
    text-align: center;
}

.queue-stat .value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-blue);
}

.queue-stat .label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Section Header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.section-header h2 {
    font-size: 24px;
    margin-bottom: 4px;
}

.section-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Buttons */
.btn-primary {
    padding: 10px 20px;
    background: var(--primary-blue);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: #0b0b48;
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    padding: 8px 16px;
    background: transparent;
    color: var(--primary-blue);
    border: 1px solid var(--primary-blue);
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: rgba(11, 11, 72, 0.1);
}

.btn-delete-queue {
    padding: 8px 12px;
    background: #c91433;
    color: var(--white);
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 10px;
    width: 100%;
}

.btn-delete-queue:hover {
    background: #c91433;
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

/* Filters Bar */
.filters-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-input,
.filter-select {
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
}

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

.filter-select {
    min-width: 150px;
}

/* Table */
.table-container {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

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

.data-table thead {
    background: var(--bg-light);
}

.data-table th {
    padding: 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

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

.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.status-badge.active {
    background: rgba(46, 125, 50, 0.1);
    color: var(--success);
}

.status-badge.suspended {
    background: rgba(201, 20, 51, 0.1);
    color: var(--danger);
}

.status-badge.pending {
    background: rgba(249, 115, 22, 0.1);
    color: var(--warning);
}

.action-btns {
    display: flex;
    gap: 8px;
}

.action-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.action-btn.view {
    background: rgba(11, 11, 72, 0.1);
    color: var(--primary-blue);
}

.action-btn.edit {
    background: rgba(46, 125, 50, 0.1);
    color: var(--success);
}

.action-btn.delete {
    background: rgba(201, 20, 51, 0.1);
    color: var(--danger);
}

.action-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

/* Doctors Grid */
.doctors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.doctor-card {
    background: var(--white);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    text-align: center;
}

.doctor-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--primary-blue);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin: 0 auto 16px;
}

.doctor-card h4 {
    font-size: 18px;
    margin-bottom: 4px;
}

.doctor-card .specialization {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 12px;
}

.doctor-meta {
    display: flex;
    justify-content: space-around;
    padding: 16px 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    margin: 16px 0;
}

.meta-item {
    text-align: center;
}

.meta-item .value {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-blue);
}

.meta-item .label {
    font-size: 12px;
    color: var(--text-secondary);
}

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

.analytics-grid .full-width {
    grid-column: 1 / -1;
}

.performance-metrics {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.metric {
    display: flex;
    justify-content: space-between;
    padding: 16px;
    background: var(--bg-light);
    border-radius: 8px;
}

.metric .label {
    color: var(--text-secondary);
}

.metric .value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-blue);
}

/* Settings Grid */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
}

.settings-card {
    background: var(--white);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.settings-card h3 {
    margin-bottom: 20px;
    font-size: 18px;
}

.setting-item {
    margin-bottom: 16px;
}

.setting-item label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.setting-item input[type="number"],
.setting-item input[type="text"],
.setting-item input[type="tel"],
.setting-item input[type="email"],
.setting-item input[type="date"] {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
}

.setting-item input[type="checkbox"] {
    margin-right: 8px;
}

.plan-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.plan-item label {
    flex: 1;
}

.plan-item input {
    width: 100px;
}

.plan-item span {
    color: var(--text-secondary);
    font-size: 13px;
}

/* Status Indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: rgba(46, 125, 50, 0.08);
    border-radius: 6px;
    font-size: 13px;
    color: var(--success);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.dot.active {
    background: var(--success);
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }

    .main-content {
        margin-left: 220px;
        max-width: calc(100vw - 220px);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .main-content {
        margin-left: 0;
        max-width: 100vw;
    }

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

    .charts-row {
        grid-template-columns: 1fr;
    }
}

/* Queue Monitor Button */
.queue-monitor-btn {
    display: inline-block;
    background: white;
    color: #0b0b48;
    padding: 12px 24px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

.queue-monitor-btn:hover {
    transform: scale(1.05);
}
/* --- Super admin page fixes --- */
html.auth-pending body { visibility: hidden; }
.stat-loading { opacity: 0.5; }
.hint { font-size: 12px; color: #6b7280; margin: 0 0 10px; }
.form-row { display: flex; gap: 8px; margin-bottom: 10px; }
.form-row input { flex: 1; min-width: 0; padding: 8px; }
.inline-toggle { font-size: 13px; color: #4b5563; display: flex; align-items: center; gap: 6px; margin-left: auto; margin-right: 12px; }
.status-badge.inactive { background: rgba(107, 114, 128, 0.15); color: #4b5563; }
.status-badge.paused { background: rgba(249, 115, 22, 0.15); color: #c2410c; }
.status-badge.closed { background: rgba(107, 114, 128, 0.15); color: #4b5563; }
.card.clinic-inactive { opacity: 0.6; }
.role-btn { padding: 6px 10px; border: 1px solid #d1d5db; background: #fff; border-radius: 6px; cursor: pointer; font-size: 12px; }
.role-btn:hover { background: #f3f4f6; }
.muted { color: #9ca3af; font-size: 12px; }

/* --- Platform analytics (Overview) --- */
.section-header h1 { font-size: 26px; margin-bottom: 4px; }
#an-range-label { color: var(--text-secondary); font-size: 14px; }
.an-filters { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; margin-bottom: 16px; }
.an-presets { display: inline-flex; border: 1px solid var(--border-color); border-radius: 8px; overflow: hidden; background: var(--white); }
.an-preset { font: inherit; font-size: 13px; padding: 8px 14px; border: none; background: none; color: var(--text-primary); cursor: pointer; }
.an-preset + .an-preset { border-left: 1px solid var(--border-color); }
.an-preset:hover { background: var(--bg-light); }
.an-preset[aria-pressed="true"] { background: var(--navy-deep); color: var(--white); }
.an-preset:focus-visible, .an-custom input:focus-visible, .fee-row input:focus-visible { outline: 2px solid var(--primary-blue); outline-offset: 1px; }
.an-custom { display: flex; gap: 12px; flex-wrap: wrap; }
.an-custom label { font-size: 13px; color: var(--text-secondary); display: inline-flex; align-items: center; gap: 6px; }
.an-custom input { font: inherit; font-size: 13px; padding: 6px 8px; border: 1px solid var(--border-color); border-radius: 6px; background: var(--white); color: var(--text-primary); }
.an-error { color: #a10f29; background: #fae7eb; border: 1px solid #f3c1cc; border-radius: 8px; padding: 8px 12px; font-size: 13px; margin: 0 0 16px; white-space: pre-line; }
.an-error[hidden], .fee-ok[hidden] { display: none; }
.fee-ok { color: #1b5e20; background: #edf7ee; border: 1px solid #c8e6c9; border-radius: 8px; padding: 8px 12px; font-size: 13px; margin: 12px 0 0; }
#clinics-status { margin: 0 0 16px; }
.an-body { transition: opacity .15s; }
.an-body.is-loading { opacity: .5; pointer-events: none; }
.an-block { margin-bottom: 20px; }
.an-card { padding: 20px; }
.an-card h3 { font-size: 16px; margin-bottom: 4px; }
.an-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.an-card-head .hint { margin: 0; }
.btn-secondary:disabled { opacity: .5; cursor: not-allowed; }
.table-scroll { overflow-x: auto; }
.an-table { font-size: 14px; }
.an-table th, .an-table td { padding: 10px 12px; vertical-align: top; }
.an-table th { font-size: 12px; }
.an-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.an-table tfoot th, .an-table tfoot td, .an-table .row-total th, .an-table .row-total td { font-weight: 600; color: var(--text-primary); background: var(--bg-light); border-top: 2px solid var(--border-color); text-transform: none; letter-spacing: 0; font-size: 14px; }
.an-table tbody th { text-transform: none; letter-spacing: 0; font-weight: 400; }
.an-two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.an-two-col .card { margin-bottom: 20px; }

/* Plan badge + subscription status (icon + text, not colour alone) */
.plan-badge { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 12px; font-weight: 600; border: 1px solid transparent; }
.plan-free { background: #f3f4f6; color: #374151; border-color: #e5e7eb; }
.plan-basic { background: #edf2ff; color: #1d1d88; border-color: #d9e2f9; }
.plan-premium { background: #ffedd5; color: #9a3412; border-color: #fed7aa; }
.sub-status { font-size: 13px; white-space: nowrap; }
.sub-active { color: #2e7d32; }
.sub-expired { color: #a10f29; font-weight: 600; }
.sub-cancelled { color: #4b5563; }
.sub-date { color: var(--text-secondary); font-weight: 400; }
.row-expired td:first-child { box-shadow: inset 3px 0 0 #c91433; }
.clinic-sub { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.clinic-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* Service fee */
.fee-view { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.fee-view[hidden], .fee-form[hidden] { display: none; }
.fee-value strong { font-size: 18px; }
.fee-form label { display: block; font-size: 13px; color: var(--text-secondary); margin: 8px 0 6px; }
.fee-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fee-prefix { font-weight: 600; }
.fee-row input { width: 120px; font: inherit; padding: 8px; border: 1px solid var(--border-color); border-radius: 6px; }
.fee-row input[aria-invalid="true"] { border-color: #c91433; }
.fee-form .an-error { margin-top: 10px; }

/* Subscription modal */
.modal-panel { background: white; width: 420px; max-width: calc(100% - 32px); margin: 80px auto; padding: 24px; border-radius: 8px; max-height: 90vh; overflow-y: auto; }
.modal-panel h3 { margin-bottom: 4px; }
#subscription-form > label { display: block; font-size: 13px; color: #4b5563; margin: 12px 0 4px; }
#subscription-form select, #subscription-form input[type="date"] { width: 100%; padding: 8px; font: inherit; border: 1px solid var(--border-color); border-radius: 6px; }
.sub-expiry-row { display: flex; gap: 12px; align-items: center; }
.sub-expiry-row input[type="date"] { flex: 1; min-width: 0; }
.sub-expiry-row input[type="date"]:disabled { opacity: .5; }
.sub-noexpiry { margin: 0; white-space: nowrap; }
#sub-effective-hint { color: #c2410c; margin-top: 6px; }
#sub-effective-hint:empty { display: none; }

@media (max-width: 768px) {
    .an-filters { flex-direction: column; align-items: flex-start; }
    .an-two-col { grid-template-columns: 1fr; }
}
.an-two-col > *, .an-body > * { min-width: 0; }
/* 7 tiles: 4 + 3 on wide screens instead of 6 + 1 */
#an-tiles .qc-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 900px) { #an-tiles .qc-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* --- Super admin page only (body.sa-page) --- */
.sa-page .modal { overflow-y: auto; z-index: 1200 !important; }
.sa-page .modal-panel { width: 450px; margin: 5vh auto; }
.sa-page .modal-panel form > label { display: block; font-size: 13px; color: #4b5563; margin-bottom: 4px; }
.sa-page .modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.sa-page .modal-close { flex: none; width: 32px; height: 32px; border: none; border-radius: 6px; background: transparent; color: #4b5563; font-size: 18px; line-height: 1; cursor: pointer; }
.sa-page .modal-close:hover { background: #f3f4f6; color: var(--text-primary); }
.sa-page .modal-close:focus-visible, .sa-page .retry-btn:focus-visible { outline: 2px solid var(--primary-blue); outline-offset: 1px; }
.sa-page .modal .an-error { margin: 10px 0 0; }
.sa-page .field-label { display: block; font-size: 13px; color: #4b5563; margin: 4px 0 4px; }
.sa-page .phone-field { display: flex; align-items: stretch; }
.sa-page .phone-prefix { display: flex; align-items: center; padding: 0 10px; background: #f3f4f6; border: 1px solid #ccc; border-right: none; border-radius: 4px 0 0 4px; font-size: 14px; color: #374151; }
.sa-page .phone-field input { flex: 1; min-width: 0; padding: 8px; border: 1px solid #ccc; border-radius: 0 4px 4px 0; font: inherit; }
.sa-page #sc-phone-hint { margin-top: 4px; }
.sa-page input[aria-invalid="true"], .sa-page select[aria-invalid="true"] { border-color: #c91433; outline-color: #c91433; }

/* Error state with Retry */
.sa-page .error-state { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; color: #a10f29; background: #fae7eb; border: 1px solid #f3c1cc; border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.sa-page .retry-btn { padding: 6px 14px; border: 1px solid #a10f29; background: #fff; color: #a10f29; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; }
.sa-page .retry-btn:hover { background: #fae7eb; }
.sa-page .retry-btn[hidden] { display: none; }
.sa-page #an-error:not([hidden]) { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sa-page .data-table tr:hover .error-state { background: #fae7eb; }

/* All Users: filters + paging */
.sa-page .users-filters { margin-top: 12px; }
.sa-page .users-filters .search-input { min-width: 220px; }
.sa-page .pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; font-size: 14px; color: var(--text-secondary); }
.sa-page .pager[hidden] { display: none; }
.sa-page .pager-btns { display: flex; gap: 8px; }

/* Sidebar sub-labels sit under the item title */
.sa-page .nav-item { flex-wrap: wrap; }
.sa-page .nav-sub { flex-basis: 100%; font-size: 0.7em; opacity: 0.7; margin-top: 2px; }

/* Clinic cards */
.sa-page .grid-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 20px; align-items: start; margin-top: 16px; margin-bottom: 24px; }
.sa-page .grid-container > .card { margin-bottom: 0; min-width: 0; overflow-wrap: anywhere; }
.sa-page .grid-container > p { grid-column: 1 / -1; margin: 0; }

/* Toasts */
.sa-page .toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 11000; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.sa-page .toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 8px; background: #edf7ee; color: #1b5e20; border: 1px solid #c8e6c9; box-shadow: var(--shadow-lg); font-size: 14px; white-space: pre-line; }
.sa-page .toast-error { background: #fae7eb; color: #a10f29; border-color: #f3c1cc; }
.sa-page .toast-info { background: #edf2ff; color: #1d1d88; border-color: #d9e2f9; }
.sa-page .toast-text { flex: 1; }
.sa-page .toast-close { border: none; background: none; color: inherit; cursor: pointer; font-size: 14px; padding: 0 2px; }

/* Narrow screens */
.sa-page .main-content { min-width: 0; }
.sa-page .section-header { flex-wrap: wrap; gap: 12px; }
.sa-page .job-monitor-card > div { flex-wrap: wrap; gap: 16px; }
@media (max-width: 768px) {
    .sa-page .main-content { padding: 64px 16px 24px; }
    .sa-page .section-header { align-items: flex-start; }
    .sa-page .section-header h1 { font-size: 22px; }
    .sa-page .inline-toggle { margin-left: 0; }
    .sa-page .card { padding: 16px; }
    .sa-page .data-table th, .sa-page .data-table td { padding: 10px 12px; }
    .sa-page .table-scroll .data-table { min-width: 560px; }
    .sa-page .table-scroll .data-table td { white-space: nowrap; }
    .sa-page .table-scroll .data-table td .error-state { white-space: normal; }
    .sa-page .users-filters .search-input { min-width: 0; flex-basis: 100%; }
    .sa-page .users-filters .filter-select { flex: 1; min-width: 0; }
    .sa-page .an-custom input { max-width: 150px; }
    .sa-page .modal-panel { width: auto; max-width: none; margin: 16px; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); padding: 18px; }
    .sa-page .toast-region { left: 16px; right: 16px; bottom: 16px; max-width: none; }
}

/* ---- Mobile navigation (public/qc-nav.js) ---- */
.qc-menu-btn { display: none; }
.qc-nav-backdrop { display: none; }

@media (max-width: 768px) {
    .qc-menu-btn {
        display: flex; align-items: center; justify-content: center;
        position: fixed; top: 12px; left: 12px; z-index: 1100;
        width: 44px; height: 44px; border-radius: 10px; border: none;
        background: #0b0b48; color: #fff; font-size: 22px; cursor: pointer;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    }
    .sidebar { transition: transform 0.2s ease; z-index: 1050; }
    .qc-menu-btn.qc-open { left: auto; right: 12px; background: #fff; color: #0b0b48; }
    .sidebar.qc-open { transform: translateX(0); }
    .qc-nav-backdrop.qc-open {
        display: block; position: fixed; inset: 0; z-index: 1040; background: rgba(0, 0, 0, 0.4);
    }
    /* leave room for the menu button */
    .main-content { padding-top: 64px; }
}

/* Clinic card: who logs in for the clinic */
.sa-page .clinic-admins { margin-top: 12px; padding: 10px 12px; background: var(--bg-light); border: 1px solid var(--border-color); border-radius: 8px; }
.sa-page .clinic-admins h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); margin-bottom: 6px; }
.sa-page .clinic-admins ul { list-style: none; display: grid; gap: 8px; }
.sa-page .clinic-admins li { font-size: 14px; }
.sa-page .clinic-admins .admin-contact { display: block; font-size: 13px; color: #4b5563; margin-top: 2px; }
.sa-page .clinic-admins .status-badge { padding: 2px 8px; font-size: 11px; }
.sa-page .clinic-admins .muted { font-size: 13px; }
.sa-page .clinic-admins .owner-adds-staff { margin-top: 8px; }
.sa-page .clinic-actions button:disabled { opacity: .6; cursor: wait; }

/* Labelled forms (Edit clinic, Add clinic admin, My profile) */
.sa-page .form-field { flex: 1; min-width: 0; }
.sa-page .labelled-form .field-label, .sa-page .profile-form .field-label { margin-top: 10px; }
.sa-page .labelled-form .form-row, .sa-page .profile-form .form-row { margin-bottom: 0; }
.sa-page .labelled-form input:not([type="checkbox"]), .sa-page .labelled-form textarea,
.sa-page .profile-form input { width: 100%; padding: 8px; font: inherit; font-size: 14px; border: 1px solid #ccc; border-radius: 4px; }
.sa-page .labelled-form .phone-field input { border-radius: 0 4px 4px 0; }
.sa-page .labelled-form textarea { resize: vertical; }
.sa-page .labelled-form .hint, .sa-page .profile-form .hint { margin: 4px 0 0; }
.sa-page .profile-form input[readonly] { background: #f3f4f6; color: #4b5563; }
.sa-page .btn-primary:disabled { opacity: .6; cursor: wait; transform: none; }

/* My profile */
.sa-page .profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr)); gap: 20px; align-items: start; }
.sa-page .profile-grid .card { margin-bottom: 0; min-width: 0; }
.sa-page .profile-grid h3 { font-size: 16px; margin-bottom: 8px; }
.sa-page .profile-form { max-width: 480px; }
.sa-page .profile-form #pf-save-btn { margin-top: 16px; }
.sa-page .profile-form .an-error { margin: 12px 0 0; }

/* Signed-in user in the sidebar */
.sa-page .user-info[hidden] { display: none; }
.sa-page .user-info > div:last-child { min-width: 0; overflow-wrap: anywhere; }

/* The shared change-password form styles every button; keep the Show/Hide toggles as links */
.sa-page .qc-cp .qc-password-toggle { background: transparent; color: #0b0b48; padding: 4px 8px; font-weight: 600; }
.sa-page .qc-cp .qc-password-toggle:hover { background: rgba(11, 11, 72, 0.08); }

/* All Users on phones: one stacked block per user (labels from data-label) */
@media (max-width: 768px) {
    .sa-page .table-scroll .users-table { min-width: 0; }
    .sa-page .users-table thead { display: none; }
    .sa-page .users-table tr { display: block; padding: 10px 0; border-top: 1px solid var(--border-color); }
    .sa-page .users-table tr:first-child { border-top: none; }
    .sa-page .table-scroll .users-table td { display: flex; gap: 12px; padding: 3px 0; border-top: none; white-space: normal; overflow-wrap: anywhere; }
    .sa-page .users-table td[data-label]::before { content: attr(data-label); flex: 0 0 64px; font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; padding-top: 2px; }
    .sa-page .users-table td:not([data-label]) { display: block; }
}

/* Sidebar name block opens "My profile" */
.user-info-btn { width: 100%; background: transparent; border: 0; color: inherit; text-align: left; padding: 8px; margin: 0 -8px 12px; border-radius: 8px; cursor: pointer; font: inherit; }
.user-info-btn:hover, .user-info-btn:focus-visible { background: rgba(255, 255, 255, 0.08); }
.user-info-btn:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.6); outline-offset: 1px; }
.user-info-btn .user-info-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-info-btn .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-info-btn .user-info-edit { color: rgba(255, 255, 255, 0.6); font-size: 14px; }
.sa-page .modal-panel.modal-panel-wide { width: 820px; }
.sa-page .modal-panel-wide .profile-grid .card { box-shadow: none; border: 1px solid var(--border-color); }
#profile-modal input[readonly] { background: #f3f4f6; color: #4b5563; cursor: default; }

/* Clinic admin login actions (clinic cards + All Users) */
.sa-page .admin-actions, .sa-page .user-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.sa-page .user-actions { margin-top: 0; }
.sa-page .role-btn:disabled { opacity: .6; cursor: wait; }
.sa-page .users-patient-count { margin: -8px 0 12px; font-size: 13px; color: var(--text-secondary); }
.sa-page .users-patient-count[hidden] { display: none; }

/* Support requests (Overview) + clinic card badge */
.sa-page .support-card { margin-bottom: 20px; }
.sa-page .support-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--border-color); }
.sa-page .support-item:first-child { border-top: none; padding-top: 4px; }
.sa-page .support-info { min-width: 0; flex: 1 1 240px; overflow-wrap: anywhere; }
.sa-page .support-clinic { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 15px; }
.sa-page .support-state { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 12px; font-weight: 600; border: 1px solid transparent; }
.sa-page .support-state.is-waiting { background: #ffedd5; color: #9a3412; border-color: #fed7aa; }
.sa-page .support-state.is-open { background: #edf7ee; color: #2e7d32; border-color: #c8e6c9; }
.sa-page .support-note { font-size: 14px; color: #374151; margin-top: 4px; }
.sa-page .support-until { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.sa-page .support-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sa-page .support-actions button:disabled { opacity: .6; cursor: wait; }
.sa-page .support-empty { font-size: 13px; }
.sa-page .support-badge { display: inline-block; margin: 6px 0 4px; padding: 3px 10px; border-radius: 10px; background: #edf2ff; color: #1d1d88; border: 1px solid #d9e2f9; font-size: 13px; font-weight: 600; }

/* Open clinic / temporary password modals */
.sa-page .modal-intro { font-size: 14px; color: #374151; margin: 8px 0 4px; }
.sa-page #temp-password-modal .hint { margin: 4px 0 0; font-size: 13px; }

@media (max-width: 768px) {
    .sa-page .support-actions { width: 100%; }
    .sa-page .support-actions button { flex: 1; }
}
.sa-page .clinics-search-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 4px 0 16px; }
.sa-page .clinics-search-row .search-input { flex: 1 1 320px; max-width: 480px; min-width: 0; }
.sa-page .clinics-search-row .hint { margin: 0; }

/* Invite links: the login column / pills (All Users, clinic cards) and the create form's owner block */
.sa-page .link-btn { background: none; border: 0; padding: 0; color: var(--qc-ink, #0b0b48); font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }
.sa-page #sc-shortcut { margin: 6px 0 4px; padding: 8px 10px; border: 1px dashed #d1d5db; border-radius: 8px; }
.sa-page #sc-shortcut .inline-toggle { margin: 0; }
.sa-page #clinics-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.login-pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.login-pill.invited { background: rgba(37, 99, 235, 0.1); color: #1d4ed8; }
.login-pill.set_up { background: rgba(46, 125, 50, 0.1); color: var(--success, #2e7d32); }
.login-pill.reset_sent { background: rgba(249, 115, 22, 0.12); color: #c2410c; }
.login-pill.expired { background: var(--qc-warning-light, #fef3c7); color: var(--qc-warning-ink, #92400e); }
.login-pill.login_off, .login-pill.key_only { background: rgba(107, 114, 128, 0.15); color: #4b5563; }
.login-when { display: block; font-size: 12px; color: #6b7280; margin-top: 2px; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .login-pill.invited { color: #93c5fd; }
    :root:not([data-theme="light"]) .login-when { color: #9ca3af; }
}
:root[data-theme="dark"] .login-pill.invited { color: #93c5fd; }
:root[data-theme="dark"] .login-when { color: #9ca3af; }
