:root {
    --bg-start: #f8fafc;
    --bg-end: #e2e8f0;
    --surface: rgba(255, 255, 255, 0.95);
    --surface-soft: #f1f5f9;
    --ink: #0f172a;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #0ea5e9;
    --primary-hover: #0284c7;
    --primary-soft: #e0f2fe;
    --danger: #ef4444;
    --danger-soft: #fee2e2;
    --success: #10b981;
    --success-soft: #d1fae5;
    --warning: #f59e0b;
    --border: #e2e8f0;
    --border-soft: #f1f5f9;
    --input-bg: #ffffff;
    --input-border: #cbd5e1;
    --ghost-bg: #f1f5f9;
    --ghost-ink: #334155;
    --badge-bg: #f1f5f9;
    --badge-ink: #0f172a;
    --stat-surface: #ffffff;
    --stat-border: #e2e8f0;
    --stat-value: #0f172a;
    --stat-label: #64748b;
    --focus-ring: rgba(14, 165, 233, 0.35);
    --panel-surface: rgba(255, 255, 255, 0.85);
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.04);
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.06), 0 4px 10px rgba(15, 23, 42, 0.03);
    --shadow-lg: 0 20px 40px rgba(15, 23, 42, 0.1), 0 8px 16px rgba(15, 23, 42, 0.05);
    --glass-border: rgba(255, 255, 255, 0.5);
}

[data-theme="dark"] {
    --bg-start: #020617;
    --bg-end: #0f172a;
    --surface: rgba(15, 23, 42, 0.85);
    --surface-soft: #1e293b;
    --ink: #f8fafc;
    --text: #f8fafc;
    --muted: #94a3b8;
    --primary: #38bdf8;
    --primary-hover: #7dd3fc;
    --primary-soft: rgba(56, 189, 248, 0.15);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, 0.15);
    --success: #34d399;
    --success-soft: rgba(52, 211, 153, 0.15);
    --warning: #fbbf24;
    --border: #334155;
    --border-soft: #1e293b;
    --input-bg: #0f172a;
    --input-border: #334155;
    --ghost-bg: #1e293b;
    --ghost-ink: #f1f5f9;
    --badge-bg: #1e293b;
    --badge-ink: #f8fafc;
    --stat-surface: #1e293b;
    --stat-border: #334155;
    --stat-value: #f8fafc;
    --stat-label: #cbd5e1;
    --focus-ring: rgba(56, 189, 248, 0.4);
    --panel-surface: rgba(15, 23, 42, 0.75);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 4px 10px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 25px 50px rgba(0, 0, 0, 0.8), 0 10px 20px rgba(0, 0, 0, 0.5);
    --glass-border: rgba(255, 255, 255, 0.05);
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--ink);
    background: linear-gradient(160deg, var(--bg-start), var(--bg-end));
    min-height: 100vh;
    transition: color 0.25s ease, background 0.25s ease;
}

.page-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 20% 10%, rgba(14, 116, 144, 0.15), transparent 35%),
        radial-gradient(circle at 80% 90%, rgba(30, 64, 175, 0.12), transparent 35%);
    transition: background 0.25s ease;
}

[data-theme="dark"] .page-bg {
    background:
        radial-gradient(circle at 14% 16%, rgba(56, 189, 248, 0.12), transparent 38%),
        radial-gradient(circle at 85% 88%, rgba(59, 130, 246, 0.16), transparent 35%);
}

.shell {
    position: relative;
    z-index: 1;
    max-width: 1320px;
    margin: 0 auto;
    padding: 24px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    transition: border-color 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
}

.topbar {
    padding: 20px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.topbar h1 {
    margin: 0;
    font-size: 1.25rem;
}

.topbar small {
    color: var(--muted);
}

.topbar-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    min-width: 0;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.topbar-actions>form {
    margin: 0;
}

.topbar-quick-scan {
    min-height: 42px;
    padding: 8px 14px;
}

.badge {
    background: var(--badge-bg);
    color: var(--badge-ink);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 0.85rem;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.content-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: 260px 1fr;
}

.sidebar {
    padding: 14px;
    align-self: start;
    position: sticky;
    top: 18px;
}

.nav-link {
    display: block;
    text-decoration: none;
    color: var(--ink);
    padding: 10px 12px;
    border-radius: 10px;
    margin-bottom: 6px;
    font-weight: 600;
}

.nav-link:hover,
.nav-link.active {
    background: var(--primary-soft);
    color: var(--primary);
}

.mobile-nav {
    display: none;
}

.main {
    padding: 20px;
}

.main>#network-status {
    margin-bottom: 12px;
}

.auth-shell {
    margin: 8vh auto 0;
    max-width: 520px;
    padding: 24px;
}

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

h2,
h3 {
    margin: 0 0 12px;
}

.stack-form {
    display: grid;
    gap: 10px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.grid-2 .full {
    grid-column: 1 / -1;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.grid-3 .full {
    grid-column: 1 / -1;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.grid-4 .full {
    grid-column: 1 / -1;
}

label {
    font-size: 0.9rem;
    font-weight: 600;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--input-border);
    border-radius: 10px;
    padding: 10px 12px;
    background: var(--input-bg);
    color: var(--ink);
    transition: border-color 0.2s ease, background 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--focus-ring);
    outline-offset: 1px;
}

textarea {
    resize: vertical;
}

.checkbox-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.checkbox-row input {
    width: auto;
}

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font: inherit;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 18px;
    min-height: 46px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    line-height: 1.4;
    user-select: none;
    box-shadow: var(--shadow-sm);
}

.btn:hover:not(:disabled) {
    border-color: var(--input-border);
    background: var(--surface-soft);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.btn:active:not(:disabled) {
    transform: translateY(1px) scale(0.98);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: var(--surface-soft);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 14px rgba(14, 165, 233, 0.25);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-hover), var(--primary));
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(14, 165, 233, 0.35);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #b91c1c);
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.25);
}

.btn-danger:hover:not(:disabled) {
    background: linear-gradient(135deg, #dc2626, #991b1b);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.35);
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    color: var(--muted);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--ghost-bg);
    color: var(--ghost-ink);
    border-color: transparent;
    transform: scale(1.02);
}

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
}

.btn-sm {
    font-size: 0.85rem;
    padding: 8px 14px;
    min-height: 38px;
    border-radius: 10px;
}

.hint {
    color: var(--muted);
    margin: 0;
    font-size: 0.9rem;
}

.stats-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 16px;
}

.stat-card {
    border-radius: 14px;
    padding: 16px;
    background: var(--stat-surface);
    border: 1px solid var(--stat-border);
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    animation: rise-in 0.35s ease both;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-card strong {
    display: block;
    font-size: 1.5rem;
    color: var(--stat-value);
}

.stat-card span {
    color: var(--stat-label);

    font-size: 0.9rem;
}

.stat-sub {
    display: block;
    margin-top: 6px;
}

.stats-grid-dashboard {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.panel {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    margin-bottom: 14px;
    background: var(--panel-surface);
    animation: rise-in 0.35s ease both;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.report-filters {
    display: grid;
    gap: 12px;
}

.report-filter-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.report-filter-grid .full {
    grid-column: 1 / -1;
}

.report-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.report-checkbox {
    margin: 2px 0;
}

.report-stats {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.logo-preview {
    display: flex;
    justify-content: flex-start;
}

.logo-preview img {
    width: auto;
    max-height: 80px;
    object-fit: contain;
}

.dashboard-head {
    margin-bottom: 14px;
}

.live-status {
    margin-top: 2px;
}

.scanner-panel {
    display: grid;
    gap: 12px;
}

.scanner-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    gap: 14px;
}

.scanner-box {
    border: 1px solid var(--input-border);
    border-radius: 12px;
    padding: 8px;
    background: var(--surface-soft);
}

.scanner-reader {
    min-height: 320px;
    border-radius: 16px;
    overflow: hidden;
    background: #020617;
    position: relative;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), 0 8px 24px rgba(2, 6, 23, 0.2);
}

.scanner-reader::after {
    content: '';
    position: absolute;
    inset: 20px;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    pointer-events: none;
}

.scanner-side {
    display: grid;
    gap: 10px;
    align-content: start;
}

.scanner-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.scanner-action {
    display: flex;
    justify-content: flex-start;
}

.scan-sticky-action {
    display: flex;
    justify-content: flex-start;
}

.scanner-submit {
    min-height: 44px;
}

.lane-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.lane-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    padding: 6px 10px;
    border: 1px solid var(--input-border);
    background: var(--surface-soft);
    font-size: 0.85rem;
    transition: transform 0.2s ease;
}

.lane-pill strong {
    font-weight: 700;
}

.lane-pill:hover {
    transform: translateY(-1px);
}

.lane-pill.lane-red {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fecaca;
}

.lane-pill.lane-orange {
    background: #ffedd5;
    color: #9a3412;
    border-color: #fed7aa;
}

.lane-pill.lane-yellow {
    background: #fef9c3;
    color: #854d0e;
    border-color: #fde68a;
}

.lane-pill.lane-green {
    background: #dcfce7;
    color: #166534;
    border-color: #bbf7d0;
}

.lane-pill.lane-blue {
    background: #dbeafe;
    color: #1e3a8a;
    border-color: #bfdbfe;
}

.timing-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.timing-card {
    border: 1px solid var(--input-border);
    border-radius: 12px;
    padding: 10px 12px;
    background: var(--surface-soft);
    transition: border-color 0.2s ease, background 0.2s ease;
}

.timing-card strong {
    display: block;
    margin-bottom: 4px;
    color: var(--ink);
}

.timing-card span {
    color: var(--muted);
    font-size: 0.9rem;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

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

.table th {
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 8px 10px;
    text-align: left;
    border-bottom: 2px solid var(--border);
}

.table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-soft);
    font-size: 0.88rem;
    vertical-align: middle;
    transition: background-color 0.2s ease;
}

.table tbody tr:hover td {
    background-color: var(--ghost-bg);
}

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

.table .btn,
.table .btn-sm,
.table .btn-primary,
.table .btn-ghost {
    min-height: 28px !important;
    padding: 3px 10px !important;
    font-size: 0.75rem !important;
    border-radius: 6px !important;
    box-shadow: none !important;
}

.table select {
    min-height: 28px !important;
    padding: 3px 10px !important;
    font-size: 0.75rem !important;
    border-radius: 6px !important;
}

.visits-page {
    display: grid;
    gap: 14px;
}

.visits-head {
    align-items: flex-start;
}

.visits-head-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.visits-summary-panel {
    display: grid;
    gap: 14px;
}

.visits-summary-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.visit-summary-card {
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 12px 14px;
    background: var(--surface-soft);
}

.visit-summary-card strong {
    display: block;
    margin-bottom: 4px;
    font-size: 1.2rem;
    color: var(--ink);
}

.visit-summary-card span {
    color: var(--muted);
    font-size: 0.85rem;
}

.visits-create-form {
    align-items: start;
}

.vitals-builder {
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 12px;
    background: var(--surface-soft);
}

.vitals-builder-title {
    margin: 0 0 8px;
}

.vitals-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.vitals-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
}

.visits-table th,
.visits-table td {
    white-space: nowrap;
}

.visits-table-organized td {
    vertical-align: top;
}

.visits-table-organized .actions-cell {
    min-width: 270px;
}

.visit-identity {
    display: grid;
    gap: 8px;
    min-width: 220px;
}

.visit-identity-primary {
    font-size: 1rem;
}

.visit-identity-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.visit-clinical {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: 240px;
}

.visit-status {
    display: grid;
    gap: 6px;
    max-width: 320px;
}

.visit-status-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.visit-alerts {
    display: grid;
    gap: 6px;
    min-width: 240px;
}

.visit-alert-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.visit-alert-label {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.visit-status-form {
    margin-top: 8px;
    width: 100%;
}

.visit-status-form select {
    flex: 1;
}

.visits-pagination {
    margin-top: 12px;
}

.visits-table td.actions-cell {
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: none;
    /* Flex on TD breaks bottom borders in some browsers, but let's see */
}

/* Fix Flex on TD */
.visits-table tbody tr {
    display: table-row;
}

.visits-table td.actions-cell {
    display: table-cell;
}

.actions-cell-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

[dir="rtl"] .table th,
[dir="rtl"] .table td {
    text-align: right;
}

.update-status-form {
    margin-top: 8px;
    border-top: 1px dashed var(--border-soft);
    padding-top: 8px;
}

.update-status-form .inline-form {
    display: flex;
    gap: 8px;
    width: 100%;
    align-items: center;
}

.update-status-form select {
    flex: 1;
}

.table-wrap::-webkit-scrollbar {
    height: 8px;
}

.table-wrap::-webkit-scrollbar-thumb {
    background-color: var(--input-border);
    border-radius: 4px;
}

.table-wrap::-webkit-scrollbar-track {
    background: transparent;
}

.triage {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.2), 0 2px 4px rgba(0, 0, 0, 0.05);
}

.triage.blue {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    color: #1e3a8a;
    border: 1px solid #bfdbfe;
}

.triage.green {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    color: #14532d;
    border: 1px solid #bbf7d0;
}

.triage.yellow {
    background: linear-gradient(135deg, #fefce8, #fef9c3);
    color: #713f12;
    border: 1px solid #fde047;
}

.triage.orange {
    background: linear-gradient(135deg, #fff7ed, #ffedd5);
    color: #9a3412;
    border: 1px solid #fed7aa;
}

.triage.red {
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
    color: #991b1b;
    border: 1px solid #fecaca;
}

[data-theme="dark"] .triage {
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.05), 0 2px 4px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .triage.blue {
    background: linear-gradient(135deg, rgba(30, 58, 138, 0.3), rgba(30, 58, 138, 0.1));
    color: #93c5fd;
    border-color: rgba(59, 130, 246, 0.2);
}

[data-theme="dark"] .triage.green {
    background: linear-gradient(135deg, rgba(20, 83, 45, 0.3), rgba(20, 83, 45, 0.1));
    color: #86efac;
    border-color: rgba(34, 197, 94, 0.2);
}

[data-theme="dark"] .triage.yellow {
    background: linear-gradient(135deg, rgba(113, 63, 18, 0.4), rgba(113, 63, 18, 0.1));
    color: #fde047;
    border-color: rgba(234, 179, 8, 0.2);
}

[data-theme="dark"] .triage.orange {
    background: linear-gradient(135deg, rgba(154, 52, 18, 0.4), rgba(154, 52, 18, 0.1));
    color: #fdba74;
    border-color: rgba(249, 115, 22, 0.2);
}

[data-theme="dark"] .triage.red {
    background: linear-gradient(135deg, rgba(153, 27, 27, 0.4), rgba(153, 27, 27, 0.1));
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.2);
}

.inline-form {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    margin-top: 6px;
}

.inline-form select {
    width: auto;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.action-row .inline-form {
    margin-top: 0;
}

.list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 10px;
}

.list li {
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    padding: 10px;
}

.alert {
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 12px;
}

.alert.success {
    background: var(--success-soft);
    color: var(--success);
    border: 1px solid #6ee7b7;
}

.alert.info {
    background: #e0f2fe;
    color: #0c4a6e;
    border: 1px solid #7dd3fc;
}

.alert.danger {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid #fca5a5;
}

.alert.warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.alert-chip {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 0.75rem;
    font-weight: 700;
}

.alert-chip.info {
    background: #e0f2fe;
    color: #0c4a6e;
}

.alert-chip.danger {
    background: #fee2e2;
    color: #b91c1c;
}

.alert-chip.muted {
    background: var(--ghost-bg);
    color: var(--ghost-ink);
}

.text-danger {
    color: #b91c1c;
}

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

.form-select-sm {
    min-height: 38px;
    padding: 6px 10px;
    font-size: 0.85rem;
    border-radius: 10px;
}

.app-footer {
    margin-top: 2rem;
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border-soft);
    padding-top: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.alert ul {
    margin: 0;
    padding-inline-start: 20px;
}

.password-wrapper {
    position: relative;
    width: 100%;
}

.password-wrapper input {
    padding-inline-end: 40px;
    width: 100%;
}

.password-toggle {
    position: absolute;
    inset-inline-end: 8px;
    top: 50%;
    transform: translateY(-50%);
    padding: 6px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: color 0.1s ease, background 0.1s ease;
}

.password-toggle:hover {
    color: var(--ink);
    background: var(--surface-soft);
}

.announcement-feed {
    display: grid;
    gap: 10px;
}

.announcement-item {
    border-radius: 12px;
    border: 1px solid var(--border-soft);
    padding: 12px;
    background: var(--surface-soft);
}

.announcement-item h4 {
    margin: 0 0 6px;
    font-size: 1rem;
}

.announcement-item p {
    margin: 0;
    color: var(--muted);
}

.announcement-banner {
    border-inline-start: 6px solid var(--primary);
}

.announcement-card {
    box-shadow: var(--shadow);
    border-color: var(--border);
    background: var(--surface);
}

.announcement-panel {
    border-color: #f59e0b;
    background: #fffbeb;
}

[data-theme="dark"] .announcement-panel {
    border-color: #fbbf24;
    background: #2a2110;
}

.value-updated {
    animation: value-pulse 0.45s ease;
}

@keyframes rise-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes value-pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    40% {
        transform: scale(1.03);
        opacity: 0.84;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Analytics Dashboard */
.analytics-page {
    animation: rise-in 0.35s ease both;
}

.analytics-kpis .stat-card {
    text-align: center;
}

.stat-danger {
    border-color: var(--danger) !important;
    background: var(--danger-soft) !important;
}

.stat-danger strong {
    color: var(--danger) !important;
}

.analytics-charts-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 14px;
    margin-bottom: 14px;
}

.analytics-chart-panel {
    min-height: 280px;
}

.analytics-chart-panel canvas {
    max-height: 240px;
}

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

@media print {
    body {
        background: #fff;
    }

    .page-bg,
    .topbar,
    .sidebar,
    .print-hide {
        display: none !important;
    }

    .shell {
        max-width: 100%;
        padding: 0;
    }

    .content-grid {
        display: block;
    }

    .main.card {
        box-shadow: none;
        border: none;
        padding: 0;
        background: #fff;
    }

    .panel {
        box-shadow: none;
        border-color: #d1d5db;
        background: #fff;
        break-inside: avoid;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (display-mode: standalone) {
    .shell {
        padding-top: max(20px, env(safe-area-inset-top));
        padding-bottom: max(20px, env(safe-area-inset-bottom));
        padding-left: max(14px, env(safe-area-inset-left));
        padding-right: max(14px, env(safe-area-inset-right));
    }
}

@media (prefers-reduced-motion: reduce) {

    .panel,
    .stat-card,
    .value-updated {
        animation: none !important;
    }

    .btn,
    .lane-pill {
        transition: none !important;
    }
}

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

    .sidebar {
        position: static;
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }

    .nav-link {
        margin: 0;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .timing-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 680px) {
    .shell {
        padding: 14px;
        padding-bottom: calc(94px + env(safe-area-inset-bottom));
    }

    .topbar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }

    .topbar-actions {
        width: 100% !important;
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 10px !important;
        align-items: center !important;
        justify-content: flex-start !important;
    }

    .topbar-actions .btn,
    .topbar-actions form {
        width: auto !important;
        flex: 0 0 auto !important;
    }

    .topbar-actions .btn {
        display: inline-flex;
        justify-content: center;
        align-items: center;
    }

    .topbar-user-badge {
        flex: 1 1 100% !important;
        width: 100% !important;
        order: -1 !important;
        text-align: center !important;
        margin-bottom: 4px !important;
    }

    .topbar-quick-scan {
        flex: 1 1 100% !important;
        width: 100% !important;
    }

    .topbar-install-btn {
        display: none;
    }

    .stats-grid,
    .grid-2,
    .grid-3,
    .grid-4,
    .visits-summary-grid {
        grid-template-columns: 1fr;
    }

    .visits-head {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }

    .section-head {
        flex-direction: column !important;
        align-items: flex-start !important;
    }

    .visits-head-actions {
        width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
    }

    .visits-head-actions .btn {
        width: 100% !important;
        min-width: 0 !important;
    }

    .lane-summary {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    .lane-pill {
        width: 100% !important;
        white-space: normal !important;
        text-align: left !important;
        justify-content: center !important;
        align-items: center !important;
        padding: 10px !important;
        font-size: 0.95rem !important;
    }

    .triage,
    .alert-chip {
        white-space: normal !important;
        text-align: center !important;
        display: inline-block !important;
        width: 100% !important;
    }

    .sidebar {
        display: none;
    }

    .content-grid {
        gap: 10px;
    }

    .main {
        padding: 14px;
        margin-bottom: 24px;
    }

    .mobile-nav {
        display: block;
        position: fixed;
        inset-inline: 16px;
        bottom: calc(16px + env(safe-area-inset-bottom));
        z-index: 50;
        border-radius: 24px;
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15), 0 1px 3px rgba(0, 0, 0, 0.1);
        transform: translateZ(0);
    }

    .mobile-nav-glass {
        position: absolute;
        inset: 0;
        background: var(--panel-surface);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border: 1px solid var(--glass-border);
        border-radius: inherit;
        z-index: -1;
    }

    .mobile-nav-items {
        display: flex;
        justify-content: space-around;
        align-items: center;
        padding: 8px 4px;
        position: relative;
    }

    .mobile-nav-link {
        text-decoration: none;
        color: var(--muted);
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 8px;
        min-width: 64px;
        border-radius: 16px;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        position: relative;
    }

    .nav-icon {
        display: flex;
        align-items: center;
        justify-content: center;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .mobile-nav-link:hover {
        color: var(--primary);
        background: var(--primary-soft);
    }

    .mobile-nav-link:active {
        transform: scale(0.92);
    }

    .mobile-nav-link.active {
        color: var(--primary);
    }

    .mobile-nav-link.active .nav-icon {
        transform: translateY(-2px);
    }

    .mobile-nav-label {
        font-size: 0.65rem;
        font-weight: 600;
        line-height: 1;
        transition: all 0.3s ease;
    }

    .mobile-nav-fab-wrapper {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 12px;
        margin-top: -32px;
    }

    .mobile-nav-fab {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 64px;
        height: 64px;
        background: linear-gradient(135deg, var(--primary), var(--primary-hover));
        color: white;
        border-radius: 50%;
        box-shadow: 0 12px 24px rgba(14, 165, 233, 0.35), inset 0 2px 4px rgba(255, 255, 255, 0.2);
        transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
        position: relative;
        z-index: 2;
    }

    .mobile-nav-fab::before {
        content: '';
        position: absolute;
        inset: -6px;
        border-radius: 50%;
        background: var(--primary-soft);
        z-index: -1;
        opacity: 0;
        transition: opacity 0.3s ease, transform 0.3s ease;
        transform: scale(0.8);
    }

    .mobile-nav-fab:hover {
        transform: translateY(-4px) scale(1.05);
        box-shadow: 0 16px 32px rgba(14, 165, 233, 0.45), inset 0 2px 4px rgba(255, 255, 255, 0.2);
    }

    .mobile-nav-fab:hover::before {
        opacity: 1;
        transform: scale(1);
    }

    .mobile-nav-fab:active {
        transform: translateY(2px) scale(0.95);
        box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
    }

    .mobile-nav-fab.active {
        background: linear-gradient(135deg, var(--ink), var(--muted));
        box-shadow: 0 12px 24px rgba(15, 23, 42, 0.3);
    }

    input,
    select,
    textarea {
        min-height: 48px;
        border-radius: 12px;
    }

    .btn {
        min-height: 48px;
    }

    .btn-sm {
        min-height: 40px;
        padding: 8px 12px;
    }


    .scanner-layout {
        grid-template-columns: 1fr;
    }

    .scan-workflow .scanner-reader {
        min-height: 230px;
    }

    .scan-workflow .scanner-buttons {
        display: grid;
        grid-template-columns: 1fr;
    }

    .scan-workflow .scanner-btn,
    .scan-workflow .scanner-submit {
        width: 100%;
        min-height: 46px;
    }

    .scan-sticky-action {
        position: sticky;
        bottom: calc(2px + env(safe-area-inset-bottom));
        z-index: 6;
        margin-top: 4px;
        padding-top: 10px;
        background: linear-gradient(180deg, rgba(255, 255, 255, 0), var(--surface) 36%);
    }

    .scan-primary-action {
        width: 100%;
    }

    .triage-page .section-head {
        align-items: flex-start;
    }

    .triage-page .timing-grid {
        grid-template-columns: 1fr;
    }

    .triage-submit-row {
        position: sticky;
        bottom: 0;
        padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
        background: linear-gradient(180deg, rgba(255, 255, 255, 0), var(--surface) 38%);
    }

    .triage-submit-btn {
        width: 100%;
        min-height: 48px;
        font-size: 1rem;
    }

    .report-filter-grid {
        grid-template-columns: 1fr;
    }

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

    .table {
        font-size: 0.85rem;
    }

    .table-mobile thead {
        display: none;
    }

    .table-mobile tbody,
    .table-mobile tr,
    .table-mobile td {
        display: block;
        width: 100%;
    }

    .table-mobile tr {
        border: 1px solid var(--border-soft);
        border-radius: 12px;
        padding: 10px 12px;
        margin-bottom: 10px;
        background: var(--surface-soft);
    }

    .table-mobile td {
        border: none !important;
        border-bottom: 1px dashed var(--border-soft) !important;
        padding: 14px 0 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
        text-align: start !important;
        overflow-wrap: break-word !important;
        word-break: break-word !important;
    }

    .table-mobile td::before {
        content: attr(data-label) !important;
        font-size: 0.85rem !important;
        font-weight: 700 !important;
        color: var(--muted) !important;
        margin-bottom: 2px !important;
        display: block !important;
        width: 100% !important;
        border-bottom: 1px solid var(--border-soft) !important;
        padding-bottom: 4px !important;
    }

    .table-mobile td:last-child {
        border-bottom: none;
    }

    .table-mobile td[colspan] {
        display: block;
        text-align: center;
        padding: 10px 4px;
    }

    .table-mobile td[colspan]::before {
        content: none;
    }

    .table-mobile .actions-cell {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
        align-items: stretch !important;
    }

    .table-mobile .actions-cell::before {
        display: block !important;
        margin-bottom: 0px !important;
    }

    .table-mobile .inline-form {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        gap: 12px !important;
    }

    .table-mobile .inline-form select,
    .table-mobile .inline-form button {
        width: 100% !important;
        min-height: 48px !important;
        font-size: 1rem !important;
    }

    .table-mobile .actions-cell-inner {
        display: flex !important;
        flex-direction: column !important;
        gap: 10px !important;
        width: 100% !important;
    }

    .table-mobile .actions-cell-inner .btn {
        width: 100% !important;
        text-align: center !important;
        justify-content: center !important;
        min-height: 48px !important;
        font-size: 1rem !important;
    }

    .table-mobile .visit-identity,
    .table-mobile .visit-clinical,
    .table-mobile .visit-status,
    .table-mobile .visit-alerts {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
    }

    .table-mobile .visit-alert-row {
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
    }

    [dir="rtl"] .table-mobile td {
        text-align: right;
    }

    [dir="rtl"] .table-mobile td::before {
        text-align: right;
    }
}

/* Pagination Styles (Fallback for default Tailwind markup) */
nav[role="navigation"] {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 20px;
    font-size: 0.9rem;
}

nav[role="navigation"] .hidden {
    display: none;
}

@media (min-width: 640px) {
    nav[role="navigation"] .sm\:hidden {
        display: none !important;
    }

    nav[role="navigation"] .sm\:flex {
        display: flex !important;
    }

    nav[role="navigation"] .sm\:items-center {
        align-items: center !important;
    }

    nav[role="navigation"] .sm\:justify-between {
        justify-content: space-between !important;
    }

    nav[role="navigation"] .sm\:flex-1 {
        flex: 1 !important;
    }
}

nav[role="navigation"] p {
    margin: 0;
    color: var(--muted);
}

nav[role="navigation"] .relative.z-0.inline-flex {
    display: inline-flex;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    border: 1px solid var(--border);
}

nav[role="navigation"] a,
nav[role="navigation"] span[aria-disabled="true"] span,
nav[role="navigation"] span[aria-disabled="true"],
nav[role="navigation"] span[aria-current="page"] span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    min-width: 40px;
    min-height: 40px;
    background: var(--surface);
    color: var(--ink);
    border-right: 1px solid var(--border);
    text-decoration: none;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
    margin: 0;
}

nav[role="navigation"] span[aria-disabled="true"] {
    padding: 0;
    border: none;
}

nav[role="navigation"] span.relative.z-0.inline-flex>*:last-child,
nav[role="navigation"] span.relative.z-0.inline-flex>*:last-child>span {
    border-right: none;
}

nav[role="navigation"] a:hover {
    background: var(--surface-soft);
    color: var(--primary);
}

nav[role="navigation"] span[aria-current="page"] span {
    background: var(--primary);
    color: white;
    font-weight: 700;
}

nav[role="navigation"] span[aria-disabled="true"] span {
    background: var(--surface-soft);
    color: var(--muted);
    cursor: not-allowed;
}

nav[role="navigation"] svg {
    width: 20px;
    height: 20px;
}

nav[role="navigation"] .w-5 {
    width: 1.25rem;
}

nav[role="navigation"] .h-5 {
    height: 1.25rem;
}