:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: #eff6ff;
    --secondary: #60a5fa;
    --accent: #2563eb;
    --accent-soft: #eff6ff;
    --bg-color: #f8fbff;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --text-main: #111827;
    --text-muted: #667085;
    --border: #d9e2ec;
    --border-strong: #b9c6d3;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --danger-light: #fef2f2;
    --success: #2563eb;
    --success-light: #eff6ff;
    --warning: #b45309;
    --warning-light: #fffbeb;
    --info: #158000;
    --info-light: #eef2ff;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow-md: 0 10px 24px rgba(16, 24, 40, 0.08);
    --shadow-lg: 0 18px 40px rgba(16, 24, 40, 0.12);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 8px;
    --transition: 180ms ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    letter-spacing: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html {
    min-width: 320px;
}

body {
    background:
        linear-gradient(180deg, rgba(37, 99, 235, 0.07), rgba(96, 165, 250, 0.04) 38%, transparent 80%),
        var(--bg-color);
    color: var(--text-main);
    line-height: 1.55;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--surface-muted);
}

::-webkit-scrollbar-thumb {
    background: #bdc8d6;
    border-radius: 999px;
    border: 2px solid var(--surface-muted);
}

::-webkit-scrollbar-thumb:hover {
    background: #98a6b8;
}

section:not(.hidden) {
    animation: viewEnter 260ms ease both;
}

@keyframes viewEnter {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

h1,
h2,
h3,
h4 {
    color: var(--text-main);
    font-weight: 700;
    line-height: 1.2;
}

h1 {
    font-size: 2rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.125rem;
}

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

button,
input,
select,
textarea {
    font: inherit;
}
.password-wrapper { position: relative; display: flex; align-items: center; width: 100%; }
.password-wrapper input { padding-right: 40px !important; width: 100%; margin: 0; }
.password-toggle { position: absolute; right: 10px; background: none; border: none; cursor: pointer; color: #6b7280; display: flex; align-items: center; justify-content: center; padding: 0; outline: none; }
.password-toggle:hover { color: #111827; }
.hidden {
    display: none !important;
}

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

.text-sm {
    font-size: 0.875rem;
}

.font-medium {
    font-weight: 600;
}

.mt-1 {
    margin-top: 0.5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mt-4 {
    margin-top: 2rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mb-4 {
    margin-bottom: 2rem;
}

.flex {
    display: flex;
}

.flex-col {
    display: flex;
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-center {
    justify-content: center;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-4 {
    gap: 1rem;
}

.gap-6 {
    gap: 1.5rem;
}

.w-full {
    width: 100%;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 1.6rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
}

.badge-success {
    background: var(--success-light);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-light);
    color: var(--warning);
}

.badge-danger {
    background: var(--danger-light);
    color: var(--danger);
}

.badge-info {
    background: var(--info-light);
    color: var(--info);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.5rem;
    padding: 0.625rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    cursor: pointer;
    transition: background-color var(--transition), border-color var(--transition), box-shadow var(--transition), transform var(--transition), color var(--transition);
    border: 1px solid transparent;
    outline: none;
    font-size: 0.875rem;
    gap: 0.5rem;
    text-align: center;
    white-space: nowrap;
}

.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.auth-tab:focus-visible,
.sidebar-item:focus-visible,
.close-btn:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.22);
    outline-offset: 2px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

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

.btn-primary {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.18);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: 0 10px 26px rgba(37, 99, 235, 0.24);
}

.btn-danger {
    background: var(--danger);
    color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
    background: var(--danger-hover);
}

.btn-outline {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text-main);
}

.btn-outline:hover:not(:disabled) {
    border-color: var(--border-strong);
    background: var(--surface-muted);
}

.btn-compact {
    min-height: 2rem;
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
}

.btn-soft {
    background: var(--primary-soft);
    border-color: rgba(37, 99, 235, 0.22);
    color: var(--primary);
}

.btn-soft:hover:not(:disabled) {
    background: #dbeafe;
    border-color: rgba(37, 99, 235, 0.36);
}

.btn-danger-ghost {
    color: var(--danger);
    border-color: rgba(220, 38, 38, 0.35);
}

.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    border: 1px solid rgba(217, 226, 236, 0.9);
    transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.1rem;
}

.booking-patient-grid {
    display: grid;
    grid-template-columns: minmax(110px, 0.75fr) minmax(180px, 1.25fr);
    gap: 1rem;
}

.weekday-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.5rem;
}

.weekday-chip {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.6rem;
    background: var(--surface);
    font-size: 0.82rem;
    font-weight: 600;
}

.weekday-chip input {
    width: auto;
    min-height: auto;
    margin: 0;
}

.schedule-editor {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.schedule-editor-head,
.schedule-row {
    display: grid;
    grid-template-columns: minmax(130px, 1.2fr) minmax(110px, 1fr) minmax(110px, 1fr);
    gap: 0.75rem;
    align-items: center;
}

.schedule-editor-head {
    padding: 0 0.35rem;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.schedule-row {
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.schedule-day {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.86rem;
    font-weight: 700;
}

.schedule-day input {
    width: auto;
    min-height: auto;
    margin: 0;
}

.schedule-row select {
    min-height: 2.4rem;
}

label {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-main);
}

.label-optional,
.form-hint {
    color: var(--text-muted);
    font-weight: 500;
}

.form-hint {
    display: block;
    font-size: 0.78rem;
}

.custom-date-picker {
    position: relative;
}

.booking-date-intro {
    margin: 0 0 0.45rem;
    color: var(--text-muted);
    font-size: 0.84rem;
    line-height: 1.45;
}

.date-picker-trigger {
    width: 100%;
    min-height: 2.75rem;
    padding: 0.72rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
}

.date-picker-trigger:hover {
    border-color: var(--border-strong);
    background: var(--surface-muted);
}

.date-picker-panel {
    display: none;
    position: absolute;
    z-index: 20;
    top: calc(100% + 0.5rem);
    left: 0;
    width: min(22rem, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    padding: 0.85rem;
}

.custom-date-picker.is-open .date-picker-panel {
    display: block;
}

.custom-date-picker.is-open .date-picker-trigger {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.date-picker-header {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
}

.date-picker-month {
    text-align: center;
    font-weight: 800;
    font-size: 1rem;
    color: var(--text-main);
}

.date-picker-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.date-picker-day {
    min-height: 4rem;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 14px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--text-main);
}

.date-picker-day:hover:not(:disabled) {
    background: var(--primary-soft);
    border-color: rgba(37, 99, 235, 0.25);
}

.date-picker-day.is-outside {
    color: #c2c9d4;
    cursor: default;
}

.date-picker-day.is-disabled {
    color: #c2c9d4;
    background: #f7f9fc;
    cursor: not-allowed;
}

.date-picker-day.is-selected {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.2);
}

.date-picker-single {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 0.2rem;
    padding: 0.85rem 0.95rem;
    text-align: left;
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(16, 185, 129, 0.08));
    border-color: rgba(37, 99, 235, 0.16);
}

.date-picker-single strong {
    font-size: 0.94rem;
}

.date-picker-single span,
.date-picker-single small {
    font-size: 0.8rem;
    font-weight: 600;
    color: inherit;
    opacity: 0.92;
}

.date-picker-single small {
    opacity: 0.75;
}

.date-picker-day.is-today {
    border-color: rgba(37, 99, 235, 0.28);
}

input,
select,
textarea {
    width: 100%;
    min-height: 2.75rem;
    padding: 0.72rem 0.875rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    color: var(--text-main);
    transition: border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
}

textarea {
    min-height: 5.25rem;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: #98a2b3;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

input:disabled {
    color: var(--text-muted);
    background: var(--surface-muted);
    cursor: not-allowed;
}

.navbar {
    background: #ffffff;
    padding: 0.85rem 2rem;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(16, 24, 40, 0.04);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 40;
    gap: 1rem;
}

.logo {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    flex: 0 0 auto;
}

.nav-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.hamburger-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-main);
}

.logo svg {
    width: 1.5rem;
    height: 1.5rem;
}

.nav-links {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    min-width: 0;
    flex: 1;
}

#nav-user-name {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 18rem;
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.85rem 0.35rem 0.35rem;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-main);
    font-size: 0.875rem;
}

.user-avatar {
    width: 2rem;
    height: 2rem;
    background: var(--primary-soft);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
    width: 100%;
    flex: 1;
}

.table-container {
    overflow-x: auto;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th,
td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
    vertical-align: middle;
}

th {
    background: var(--surface-muted);
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
}

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

tbody tr:hover td {
    background: rgba(37, 99, 235, 0.04);
}

.row-subtle {
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 0.15rem;
}

.row-note {
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 0.25rem;
    max-width: 18rem;
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.compact-select {
    min-height: 2rem;
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
}

#auth-view {
    max-width: 440px;
    margin: 3rem auto;
    position: relative;
    padding: 2rem;
}

#auth-view::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.auth-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
    color: var(--primary);
    font-weight: 800;
}

.auth-logo svg {
    margin-bottom: 0.55rem;
}

.auth-logo span {
    display: block;
    margin-top: 0.15rem;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
}

.auth-tabs {
    display: flex;
    background: var(--surface-muted);
    border-radius: var(--radius-md);
    padding: 0.25rem;
    margin-bottom: 1.5rem;
    gap: 0.25rem;
    border: 1px solid var(--border);
}

.auth-tab {
    flex: 1;
    min-height: 2.25rem;
    padding: 0.55rem 0.75rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 800;
    color: var(--text-muted);
    transition: background-color var(--transition), color var(--transition), box-shadow var(--transition);
}

.auth-tab:hover {
    color: var(--text-main);
}

.auth-tab.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.auth-link {
    color: var(--primary);
    cursor: pointer;
    font-weight: 700;
}

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

.auth-demo-box {
    margin-top: 1.25rem;
    padding: 0.9rem 1rem;
    background: var(--primary-soft);
    border: 1px dashed rgba(37, 99, 235, 0.35);
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.7;
}

.auth-demo-box code {
    background: var(--surface);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--primary);
    border: 1px solid var(--border);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.action-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-height: 12rem;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    background: var(--surface);
}

.action-card:hover {
    border-color: rgba(37, 99, 235, 0.45);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.action-card svg {
    width: 3rem;
    height: 3rem;
    color: var(--primary);
    margin-bottom: 1.1rem;
    background: var(--primary-soft);
    padding: 0.65rem;
    border-radius: var(--radius-md);
}

.filter-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    background: var(--surface);
    padding: 1rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.doctor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.doctor-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 17rem;
}

.doctor-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: rgba(37, 99, 235, 0.35);
}

.doc-header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 1rem;
}

.doc-avatar {
    width: 3.25rem;
    height: 3.25rem;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    font-weight: 800;
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.18);
    flex: 0 0 auto;
}

.doc-title h3 {
    font-size: 1.05rem;
}

.doc-title p {
    color: var(--primary);
    font-weight: 800;
    font-size: 0.86rem;
}

.doc-info p {
    font-size: 0.875rem;
    margin-bottom: 0.45rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
}

.doc-info svg {
    width: 1rem;
    height: 1rem;
    color: var(--text-main);
    flex: 0 0 auto;
}

.availability-pill {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    max-width: 100%;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent) !important;
    font-weight: 800;
    font-size: 0.78rem !important;
}

.admin-layout {
    display: flex;
    gap: 1.5rem;
    min-height: 70vh;
    align-items: flex-start;
}

.admin-content {
    flex: 1;
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}

#admin-nav-tabs {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-right: auto;
    margin-left: 1rem;
}

.sidebar-item {
    padding: 0.5rem 0;
    border-radius: 0;
    cursor: pointer;
    font-weight: 600;
    transition: color var(--transition), border-color var(--transition);
    color: var(--text-muted);
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 0.95rem;
    white-space: nowrap;
}

.sidebar-item:hover {
    background: transparent;
    color: var(--text-main);
}

.sidebar-item.active {
    background: transparent;
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(17, 24, 39, 0.48);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition), visibility var(--transition);
    padding: 1rem;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 540px;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
    padding: 1.5rem;
    transform: translateY(10px) scale(0.98);
    transition: transform var(--transition);
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.pdf-modal-content {
    max-width: 860px;
}

.pdf-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.pdf-frame {
    display: block;
    width: 100%;
    height: min(68vh, 720px);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-muted);
}

.close-btn {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: background-color var(--transition), color var(--transition), transform var(--transition);
    flex: 0 0 auto;
    font-size: 1.25rem;
}

.close-btn:hover {
    background: var(--border);
    color: var(--text-main);
    transform: rotate(90deg);
}

.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 100;
    max-width: min(24rem, calc(100vw - 2rem));
}

.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    padding: 0.9rem 1rem;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transform: translateX(105%);
    opacity: 0;
    transition: transform 240ms ease, opacity 240ms ease;
    font-weight: 700;
    font-size: 0.9rem;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.success svg {
    color: var(--success);
    flex: 0 0 auto;
}

.toast.error svg {
    color: var(--danger);
    flex: 0 0 auto;
}

.loader {
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top: 2px solid #ffffff;
    border-radius: 50%;
    width: 1.125rem;
    height: 1.125rem;
    animation: spin 800ms linear infinite;
    display: inline-block;
}

.btn-outline .loader {
    border-color: var(--border);
    border-top-color: var(--primary);
}

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

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--border-strong);
}

.empty-state svg {
    width: 4rem;
    height: 4rem;
    margin-bottom: 1rem;
    color: var(--border-strong);
}

@media (max-width: 900px) {
    .container {
        padding: 1.5rem 1rem;
    }

    .admin-layout {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
}

@media (max-width: 720px) {
    h1 {
        font-size: 1.65rem;
    }

    h2 {
        font-size: 1.3rem;
    }

    .navbar {
        align-items: stretch;
        padding: 0.8rem 1rem;
        flex-direction: column;
    }

    .nav-brand {
        width: 100%;
    }

    .hamburger-btn {
        display: block;
    }

    .nav-links {
        display: flex;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: #ffffff;
        box-shadow: var(--shadow-md);
        border-bottom: 1px solid rgba(217, 226, 236, 0.9);
        flex-direction: column;
        align-items: stretch;
        margin-top: 0;
        padding: 0 1rem;
        max-height: 0;
        opacity: 0;
        overflow: hidden;
        transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
        flex-wrap: nowrap;
    }

    .nav-links.active {
        max-height: 400px;
        opacity: 1;
        padding: 1rem;
    }

    #admin-nav-tabs {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        border-bottom: 1px solid var(--border);
        padding-bottom: 0.75rem;
        margin-bottom: 0.75rem;
        margin-left: 0;
        gap: 0.25rem;
    }

    .sidebar-item {
        padding: 0.75rem 1rem;
        border-bottom: none;
        border-left: 3px solid transparent;
        white-space: normal;
    }

    .sidebar-item.active {
        border-bottom-color: transparent;
        border-left-color: var(--primary);
        background: var(--primary-soft);
    }

    .user-profile-badge {
        background: transparent;
        border: none;
        padding: 0.5rem 0.25rem;
        border-radius: 0;
    }

    #nav-user-name {
        max-width: none;
    }

    .card,
    #auth-view {
        padding: 1.15rem;
    }

    #auth-view {
        margin: 1rem auto;
    }

    .filter-bar,
    .flex.justify-between.items-center.mb-4 {
        align-items: stretch;
        flex-direction: column;
    }

    .filter-bar .input-group {
        min-width: 0 !important;
    }

    .dashboard-grid,
    .doctor-grid {
        grid-template-columns: 1fr;
    }

    .schedule-editor-head {
        display: none;
    }

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

    .modal-content {
        padding: 1.15rem;
    }

    .toast-container {
        right: 1rem;
        bottom: 1rem;
        left: 1rem;
        max-width: none;
    }

    .toast {
        transform: translateY(100%);
    }

    .toast.show {
        transform: translateY(0);
    }
}

@media (max-width: 640px) {
    .booking-patient-grid {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .flex.gap-4,
    .flex.gap-2 {
        flex-wrap: wrap;
    }

    .flex.gap-4 > .input-group,
    .flex.gap-2 > .btn,
    .flex.gap-4 > .btn {
        flex-basis: 100% !important;
    }

    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block;
        width: 100%;
    }

    thead {
        display: none;
    }

    tbody tr {
        padding: 0.85rem;
        border-bottom: 1px solid var(--border);
    }

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

    td {
        display: grid;
        grid-template-columns: 8rem minmax(0, 1fr);
        gap: 0.75rem;
        align-items: start;
        border-bottom: none;
        padding: 0.5rem 0;
        word-break: break-word;
    }

    td::before {
        content: attr(data-label);
        color: var(--text-muted);
        font-size: 0.75rem;
        font-weight: 800;
        text-transform: uppercase;
    }

    td[colspan] {
        display: block;
        text-align: center;
    }

    td[colspan]::before {
        display: none;
    }

    .table-container {
        overflow-x: visible;
    }

    .table-actions {
        align-items: stretch;
    }

    .pdf-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .pdf-frame {
        height: 62vh;
    }

    .admin-sidebar .sidebar-item {
        white-space: normal;
        text-align: center;
    }
}

@media (max-width: 420px) {
    .btn {
        width: 100%;
        white-space: normal;
    }

    .nav-links .btn {
        width: auto;
    }

    td {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }

    .auth-logo {
        font-size: 1.55rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 1ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 1ms !important;
    }
}
