/* --- GROUP STATUS SYSTEM --- */
.row-offline {
    opacity: 0.55;
    filter: grayscale(0.85);
    background: var(--muted-light) !important;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.8rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 850;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
    border: 1px solid transparent;
}

.status-pill.active {
    background: #dcfce7;
    color: #166534;
    border-color: #bbf7d0;
}

.status-pill.offline {
    background: var(--destructive-soft);
    color: var(--destructive);
    border-color: rgba(var(--destructive-rgb), 0.2);
}

.status-pill:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    position: relative;
}

.status-pill.active .pulse-dot::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 50%;
    background: currentColor;
    animation: status-pulse 2s infinite;
}

@keyframes status-pulse {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(3); opacity: 0; }
}

:root {
    --radius: 10px;
    --radius-lg: 14px;
    --radius-full: 999px;
    --page-pad: 10px;
    --panel-pad: 1.25rem;
    --control-h: 2.75rem;
    --sidebar-w: 216px;
    --gap: 1.25rem;
    --text-sm: 0.875rem;
    --text-base: 0.95rem;
    --text-lg: 1.125rem;
    --text-xl: 1.5rem;
    --text-2xl: 2rem;
}

html[data-ui-size="compact"] {
    --page-pad: 1rem;
    --panel-pad: 1rem;
    --control-h: 2.35rem;
    --sidebar-w: 220px;
    --gap: 0.8rem;
    --text-sm: 0.78rem;
    --text-base: 0.86rem;
    --text-lg: 1rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.65rem;
}

html[data-ui-size="large"] {
    --page-pad: 2.5rem;
    --panel-pad: 1.6rem;
    --control-h: 3rem;
    --sidebar-w: 280px;
    --gap: 1.5rem;
    --text-sm: 0.92rem;
    --text-base: 1rem;
    --text-lg: 1.25rem;
    --text-xl: 1.75rem;
    --text-2xl: 2.25rem;
}

html[data-ui-size="spacious"] {
    --page-pad: 3rem;
    --panel-pad: 2rem;
    --control-h: 3.25rem;
    --sidebar-w: 300px;
    --gap: 1.8rem;
    --text-sm: 0.95rem;
    --text-base: 1.05rem;
    --text-lg: 1.35rem;
    --text-xl: 2rem;
    --text-2xl: 2.6rem;
}

html[data-ui-size="presentation"] {
    --page-pad: 3.5rem;
    --panel-pad: 2.25rem;
    --control-h: 3.5rem;
    --sidebar-w: 320px;
    --gap: 2rem;
    --text-sm: 1rem;
    --text-base: 1.12rem;
    --text-lg: 1.5rem;
    --text-xl: 2.25rem;
    --text-2xl: 3rem;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--background);
    color: var(--foreground);
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: 1.55;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

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

img {
    max-width: 100%;
}

.container {
    width: min(1320px, calc(100% - 2rem));
    margin-inline: auto;
    padding-block: 1.25rem 3rem;
}

.header {
    min-height: 4.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 0;
}

.brand-wrap {
    min-width: 0;
    display: grid;
    gap: 0.15rem;
}

.brand,
.dash-logo,
.login-logo-text {
    font-weight: 800;
    font-size: var(--text-xl);
    line-height: 1.1;
}

.brand-lockup {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    min-width: 0;
}

.brand-tagline,
.dash-role {
    color: var(--muted-foreground);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.brand-logo-img {
    width: auto;
    max-width: 210px;
    max-height: 58px;
    object-fit: contain;
    display: block;
}

.nav {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.nav a,
.inline-btn {
    min-height: 2.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--foreground);
    font-weight: 700;
    font-size: var(--text-sm);
    cursor: pointer;
}

.inline-btn-xs {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--foreground);
    cursor: pointer;
    padding: 0;
    transition: all 0.2s;
    flex-shrink: 0;
}

.inline-btn-xs:hover {
    border-color: var(--primary);
    background: var(--muted-light);
}

.inline-btn-xs.danger-light {
    color: var(--danger);
}

.inline-btn-xs.danger-light:hover {
    background: var(--danger-soft);
    border-color: var(--danger);
}

.inline-btn-xs.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.visibility-toggle {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1.5px solid var(--border);
    background: var(--muted-light);
    color: var(--muted-foreground);
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}

.visibility-toggle:hover {
    background: var(--muted);
    transform: translateY(-1px);
}

.visibility-toggle.active {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary);
}

.visibility-toggle svg {
    width: 11px;
    height: 11px;
}

.page {
    min-width: 0;
}

.hero-shell {
    min-height: calc(100vh - 7rem);
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
    align-items: center;
    gap: clamp(2rem, 5vw, 4rem);
    padding: 2rem 0;
}

.dash-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-areas: "sidebar main";
    min-height: 100vh;
    width: 100%;
}

.dash-sidebar {
    grid-area: sidebar;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: var(--gap);
    padding: var(--panel-pad);
    background: var(--sidebar);
    border-inline-end: 1px solid var(--border);
}

.dash-brand {
    display: grid;
    justify-items: center;
    gap: 0.45rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    text-align: center;
}

.dash-brand-lockup {
    flex-direction: column;
    justify-content: center;
    gap: 0.75rem;
}

.dash-brand-lockup .brand-logo-img {
    max-width: min(240px, 100%);
    max-height: 105px;
}

.dash-brand-lockup .dash-logo {
    font-size: calc(var(--text-xl) * 2);
}

.dash-nav {
    display: grid;
    gap: 0.35rem;
    align-content: start;
    flex: 1;
}

.dash-nav a {
    min-height: var(--control-h);
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 0.9rem;
    border-radius: var(--radius);
    color: var(--muted-foreground);
    font-weight: 750;
    font-size: var(--text-sm);
    transition: background 0.15s, color 0.15s;
}

.nav-icon {
    flex: 0 0 auto;
    width: 1.1rem;
    height: 1.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.75;
    transition: opacity 0.15s;
}

.nav-icon svg {
    width: 100%;
    height: 100%;
}

.dash-nav a:hover .nav-icon,
.dash-nav a.active .nav-icon {
    opacity: 1;
}

.dash-nav a.active {
    background: var(--primary) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.35);
    border: 1px solid rgba(255, 255, 255, 0.15);
    transform: translateX(4px);
    position: relative;
}

.dash-nav a.active::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 18px;
    background: var(--primary);
    border-radius: 0 4px 4px 0;
    box-shadow: 2px 0 8px var(--primary);
}

.dash-nav a.active .nav-icon {
    opacity: 1;
    color: #ffffff !important;
    filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.6));
}

.dash-nav a.active .nav-icon {
    opacity: 1;
    color: inherit;
}

.dash-side-foot {
    display: grid;
    gap: 0.35rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.sidebar-profile-link {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-height: var(--control-h);
    padding: 0.55rem 0.65rem;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    color: var(--foreground);
    font-weight: 850;
    transition: background 0.2s;
}

.sidebar-profile-link:hover {
    background: var(--muted-light);
}

.sidebar-profile-link.active {
    background: var(--primary) !important;
    color: var(--primary-foreground) !important;
    border-color: var(--primary) !important;
}

.avatar {
    width: 2.75rem;
    height: 2.75rem;
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    overflow: hidden;
    border: 2px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--primary);
    color: var(--primary-foreground);
    font-weight: 900;
}

.avatar-sm {
    width: 2.2rem;
    height: 2.2rem;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.topbar-avatar {
    width: 2.6rem;
    height: 2.6rem;
}

.dash-user-name {
    font-weight: 800;
}

.dash-user-role {
    color: var(--muted-foreground);
    font-size: var(--text-sm);
}

.dash-logout {
    width: 100%;
    min-height: var(--control-h);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--muted);
    color: var(--foreground);
    font-weight: 800;
    cursor: pointer;
}

.dash-main {
    grid-area: main;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--background);
    width: 100%;
}

.dash-topbar {
    min-height: 4rem;
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-inline: var(--page-pad);
    background: var(--topbar);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(16px);
}

.topbar-inner {
    width: 100%;
    max-width: 1400px;
    margin-inline-start: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dash-topbar span,
.dash-top-user {
    color: var(--muted-foreground);
    font-size: var(--text-sm);
}

.dash-top-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-inline-start: auto;
}

.dash-content {
    flex: 1;
    min-width: 0;
    width: 100%;
    max-width: 1400px;
    margin-inline-start: 0;
    padding: var(--page-pad);
}

.dash-content > * + * {
    margin-top: var(--gap);
}

/* Standardized Inline Buttons (Global Unity) */
.inline-btn-xs {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    height: 30px;
    padding: 0 0.75rem;
    font-size: 0.65rem;
    font-weight: 800;
    border-radius: 8px;
    background: var(--muted-light);
    color: var(--foreground);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    min-width: max-content;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.inline-btn-xs.active {
    background: var(--primary) !important;
    color: white !important;
    border-color: var(--primary) !important;
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.2);
}

.inline-btn-xs.danger-light {
    color: var(--destructive);
    background: #fef2f2;
    border-color: #fee2e2;
}

.inline-btn-xs:hover {
    transform: translateY(-1px);
    filter: brightness(0.95);
    box-shadow: var(--shadow-sm);
}

.inline-btn-xs svg {
    flex-shrink: 0;
}

.dash-page-head {
    margin: 0 0 var(--gap);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    text-align: start;
}

.dash-page-head h1 {
    margin: 0;
    font-size: var(--text-2xl);
    line-height: 1.1;
    font-weight: 900;
}

/* Status Pill System */
.status-line {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--muted-light);
    padding: 0.4rem 0.75rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    transition: all 0.2s ease;
}

.status-pill .pill-label {
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-pill .pill-value {
    font-size: 1rem;
    font-weight: 800;
    color: var(--foreground);
}

.status-pill.success { background: #dcfce7; border-color: #bbf7d0; }
.status-pill.success .pill-label, .status-pill.success .pill-value { color: #166534; }

.status-pill.primary { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 20%, transparent); }
.status-pill.primary .pill-label, .status-pill.primary .pill-value { color: var(--primary); }

.dash-page-head p {
    margin: 0;
    color: var(--muted-foreground);
    text-align: start;
}

.panel,
.stat-card,
.table-wrap {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.panel {
    padding: var(--panel-pad);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--gap);
}

.stat-card {
    display: grid;
    gap: 0.45rem;
    padding: var(--panel-pad);
    border-left: 4px solid var(--border);
}

.stat-card.primary { border-left-color: var(--primary); }
.stat-card.primary strong { color: var(--primary); }

.stat-card.success { border-left-color: var(--success); }
.stat-card.success strong { color: var(--success); }

.stat-card.warning { border-left-color: var(--warning); }
.stat-card.warning strong { color: var(--warning); }

.stat-card.danger { border-left-color: var(--danger); }
.stat-card.danger strong { color: var(--danger); }

.stat-card.info { border-left-color: #06b6d4; }
.stat-card.info strong { color: #06b6d4; }

.stat-card h3 {
    margin: 0;
    color: var(--muted-foreground);
    font-size: var(--text-sm);
}

.stat-card strong {
    font-size: var(--text-2xl);
    line-height: 1;
}

.dash-split {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    gap: var(--gap);
}

.panel-stack {
    display: flex;
    flex-direction: column;
    gap: var(--gap);
}

.panel-stack > * + * {
    margin-top: var(--gap) !important;
}

.form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: var(--gap);
}

.form-section-title {
    margin: 0;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
    font-size: var(--text-lg);
}

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

.form-group {
    display: grid;
    gap: 0.45rem;
    min-width: 0;
}

.form-group.full {
    grid-column: 1 / -1;
}

.toggle-row {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--muted-light);
}

.toggle-row input[type="checkbox"] {
    width: 1.35rem;
    height: 1.35rem;
    accent-color: var(--primary);
    flex: 0 0 auto;
}

.toggle-row span {
    display: grid;
    gap: 0.25rem;
}

.toggle-row small {
    color: var(--muted-foreground);
    font-size: 0.78rem;
    line-height: 1.5;
}

.secure-mode-choice {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.secure-mode-choice label {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-height: 3.2rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--muted-light);
}

.secure-mode-choice input {
    width: auto;
    min-height: 0;
    accent-color: var(--primary);
}

.secure-fieldset-title {
    padding-top: 0.5rem;
    color: var(--foreground);
}

.form label {
    color: var(--muted-foreground);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* Reset form label overrides for toggle switch labels */
.form label.switch-field {
    color: var(--foreground);
    font-size: var(--text-base);
    font-weight: normal;
    letter-spacing: normal;
    text-transform: none;
}

.form input,
.form select,
.form textarea {
    width: 100%;
    min-height: var(--control-h);
    padding: 0.62rem 0.78rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--input);
    color: var(--foreground);
    outline: none;
}

/* Exclude switch toggle inputs from form input styling */
.form .switch-field input[type="checkbox"],
.form .switch-field input[type="hidden"] {
    width: 0;
    min-height: 0;
    padding: 0;
    border: 0;
    background: none;
}

.form input[type="file"] {
    padding: 0.5rem;
    cursor: pointer;
}

.form .secure-mode-choice input[type="radio"] {
    width: auto;
    min-height: 0;
    padding: 0;
}

.form textarea {
    min-height: 7rem;
    resize: vertical;
}

.form input:focus,
.form select:focus,
.form textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.btn-primary {
    min-height: var(--control-h);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1.25rem;
    border: 0;
    border-radius: var(--radius);
    background: var(--primary);
    color: var(--primary-foreground);
    font-weight: 850;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-outline, .btn-ghost {
    min-height: var(--control-h);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem 1.1rem;
    border-radius: var(--radius);
    font-weight: 800;
    font-size: var(--text-sm);
    cursor: pointer;
    transition: all 0.2s;
}

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

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

.btn-outline.active {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-ghost {
    background: transparent;
    border: 1px solid transparent;
    color: var(--muted-foreground);
}

.btn-ghost:hover {
    background: var(--muted-light);
    color: var(--foreground);
}

.btn-outline-sm {
    min-height: 2.2rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
}

.table-wrap {
    overflow: auto;
}

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

.table th,
.table td {
    padding: 0.85rem 1rem;
    border-top: 1px solid var(--border);
    text-align: start;
    vertical-align: top;
}

.table th {
    border-top: 0;
    background: var(--muted);
    color: var(--muted-foreground);
    font-size: 0.74rem;
    font-weight: 850;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.tree-badge {
    display: inline-flex;
    align-items: center;
    min-height: 1.55rem;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-full);
    background: var(--muted);
    color: var(--muted-foreground);
    font-size: 0.78rem;
    font-weight: 800;
}

.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-primary { background: var(--primary); color: var(--primary-foreground); }
.badge-accent { background: var(--accent); color: white; }
.badge-outline { border: 1px solid var(--border); background: transparent; color: var(--muted-foreground); font-weight: 700; }

.switch-field {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    cursor: pointer;
    user-select: none;
    background: var(--card);
    padding: 0.8rem 1.25rem;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    transition: all 0.2s ease;
}

.switch-field.switch-clean {
    display: inline-flex !important;
    background: none !important;
    border: none !important;
    padding: 0 !important;
    width: auto !important;
}

.switch-field:hover {
    background: var(--muted);
    border-color: var(--primary-soft);
}

.switch-field input[type="checkbox"],
.switch-field input[type="hidden"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0;
    height: 0;
    margin: 0;
}

.switch-ui {
    width: 48px;
    height: 26px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--muted);
    position: relative;
    flex: 0 0 auto;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.switch-ui::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    top: 2px;
    left: 2px;
    border-radius: 999px;
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.switch-field input[type="checkbox"]:checked ~ .switch-ui {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
}

.switch-field input[type="checkbox"]:checked ~ .switch-ui::after {
    transform: translateX(22px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* RTL Specific Fixes for Toggle Switch */
html[dir="rtl"] .switch-ui::after {
    left: auto;
    right: 2px;
}

html[dir="rtl"] .switch-field input[type="checkbox"]:checked ~ .switch-ui::after {
    transform: translateX(-22px);
}

.switch-field input[type="checkbox"]:focus-visible ~ .switch-ui {
    box-shadow: 0 0 0 3px var(--primary-soft);
}

/* RTL Support for Toggle */
html[dir="rtl"] .switch-field input[type="checkbox"]:checked ~ .switch-ui::after {
    transform: translateX(-22px);
}

.alert {
    width: 100%;
    max-width: 1400px;
    margin-block-start: var(--page-pad);
    margin-inline-start: 0;
    padding: 0.8rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--muted);
    color: var(--foreground);
    font-weight: 750;
}

.container > .alert {
    margin: 1rem 0;
}

.footer {
    padding: 1.25rem var(--page-pad) 2rem;
    color: var(--muted-foreground);
    font-size: var(--text-sm);
    text-align: center;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 1.5rem;
    padding: 2rem 0;
}

.login-card {
    width: min(560px, 100%);
    display: grid;
    gap: 1.25rem;
    padding: clamp(1.5rem, 4vw, 2.5rem);
    border-top: 7px solid var(--role-color);
    box-shadow: var(--shadow-lg);
}

.login-brand {
    display: flex;
    justify-content: center;
    justify-items: center;
    gap: 0.65rem;
    text-align: center;
}

.login-brand-lockup {
    justify-content: center;
    gap: 0.9rem;
}

.login-logo-img {
    max-width: 260px;
    max-height: 120px;
}

.login-brand-lockup .login-logo-text {
    font-size: calc(var(--text-xl) * 2);
}

.login-role-badge {
    display: flex;
    justify-content: center;
    margin-bottom: 1.25rem;
}

.role-pill {
    display: inline-flex;
    align-items: center;
    min-height: 1.8rem;
    padding: 0.4rem 1rem;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--role-color), color-mix(in srgb, var(--role-color) 80%, white));
    color: white;
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--role-color) 25%, transparent);
}

.login-title,
.login-copy {
    margin: 0;
    text-align: center;
}

.login-title {
    font-size: var(--text-xl);
}

.login-copy,
.login-footer,
.login-back {
    color: var(--muted-foreground);
}

.login-form {
    grid-template-columns: 1fr;
}

.login-submit {
    width: 100%;
    margin-top: 0.35rem;
    background: var(--role-color) !important;
    border-color: var(--role-color) !important;
    color: white !important;
    font-weight: 850;
}

.login-submit:hover {
    background: color-mix(in srgb, var(--role-color) 85%, black) !important;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px color-mix(in srgb, var(--role-color) 30%, transparent);
}

.login-footer {
    display: grid;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    text-align: center;
}

.login-footer p {
    margin: 0;
}

.login-footer a {
    color: var(--primary);
    font-weight: 850;
}

.login-security {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0.75;
}

.login-back {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 750;
}

.login-student { --role-color: #16a34a; --role-soft: color-mix(in srgb, #16a34a 13%, transparent); }
.login-teacher { --role-color: #7c3aed; --role-soft: color-mix(in srgb, #7c3aed 13%, transparent); }
.login-center { --role-color: #f59e0b; --role-soft: color-mix(in srgb, #f59e0b 16%, transparent); }
.login-admin { --role-color: #334155; --role-soft: color-mix(in srgb, #334155 13%, transparent); }

.settings-grid,
.settings-tabs {
    display: grid;
    gap: var(--gap);
}

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

.settings-toolbar {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: var(--gap);
}

.settings-toolbar .dash-page-head {
    margin: 0;
}

.settings-toolbar .btn-primary {
    flex: 0 0 auto;
}

.settings-tabs > input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.settings-tab-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.45rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--muted-light);
}

.settings-tab-list label {
    min-height: 2.55rem;
    display: inline-flex;
    align-items: center;
    padding: 0.65rem 0.9rem;
    border-radius: calc(var(--radius) - 2px);
    color: var(--muted-foreground);
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
    cursor: pointer;
}

.settings-tab-panel {
    display: none;
}

.settings-tab-head {
    display: grid;
    gap: 0.35rem;
    margin-bottom: 1.35rem;
}

.settings-tab-head h2,
.settings-tab-head p {
    margin: 0;
}

.settings-tab-head p {
    color: var(--muted-foreground);
}

#settings-tab-ui:checked ~ .settings-tab-list label[for="settings-tab-ui"],
#settings-tab-type:checked ~ .settings-tab-list label[for="settings-tab-type"],
#settings-tab-theme:checked ~ .settings-tab-list label[for="settings-tab-theme"],
#settings-tab-mode:checked ~ .settings-tab-list label[for="settings-tab-mode"],
#settings-tab-brand:checked ~ .settings-tab-list label[for="settings-tab-brand"],
#settings-tab-bunny:checked ~ .settings-tab-list label[for="settings-tab-bunny"],
#settings-tab-security:checked ~ .settings-tab-list label[for="settings-tab-security"],
#settings-tab-audit:checked ~ .settings-tab-list label[for="settings-tab-audit"],
#settings-tab-translate:checked ~ .settings-tab-list label[for="settings-tab-translate"] {
    background: var(--card);
    color: var(--primary);
    box-shadow: var(--shadow);
}

#settings-tab-ui:checked ~ form .settings-panel-ui,
#settings-tab-type:checked ~ form .settings-panel-type,
#settings-tab-theme:checked ~ form .settings-panel-theme,
#settings-tab-mode:checked ~ form .settings-panel-mode,
#settings-tab-brand:checked ~ form .settings-panel-brand,
#settings-tab-bunny:checked ~ form .settings-panel-bunny,
#settings-tab-security:checked ~ form .settings-panel-security,
#settings-tab-audit:checked ~ form .settings-panel-audit,
#settings-tab-translate:checked ~ .settings-panel-translate,
#settings-tab-translate:checked ~ form .settings-panel-translate {
    display: block !important;
}

.settings-section {
    display: grid;
    align-content: start;
    gap: 1rem;
}

.settings-section h2,
.settings-section p {
    margin: 0;
}

.settings-section p {
    color: var(--muted-foreground);
}

.section-kicker {
    width: 2rem;
    height: 2rem;
    display: grid;
    place-items: center;
    border-radius: var(--radius);
    background: var(--primary);
    color: var(--primary-foreground);
    font-weight: 900;
}

.settings-branding,
.settings-actions {
    grid-column: 1 / -1;
}

.settings-actions {
    position: sticky;
    bottom: 0;
    z-index: 15;
    display: flex;
    justify-content: flex-end;
    padding: 1rem 0;
    background: linear-gradient(to top, var(--background) 70%, transparent);
}

.logo-upload-field {
    align-content: start;
}

.logo-preview-box {
    min-height: 5.5rem;
    display: grid;
    place-items: center;
    padding: 0.8rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: var(--muted);
    color: var(--muted-foreground);
    font-size: var(--text-sm);
    font-weight: 800;
}

.logo-preview-box img {
    max-width: 190px;
    max-height: 64px;
    object-fit: contain;
}

.logo-preview-dark {
    background: #0f172a;
    color: #cbd5e1;
}

.profile-edit-layout {
    grid-template-columns: minmax(0, 2fr) minmax(280px, 0.8fr);
}

.profile-edit-layout h2,
.profile-preview-panel h2 {
    margin-top: 0;
}

.profile-preview-panel {
    display: grid;
    justify-items: center;
    align-content: start;
    gap: 1rem;
    text-align: center;
}

.profile-preview {
    width: min(220px, 70vw);
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 4px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--primary);
    color: var(--primary-foreground);
    font-size: 4rem;
    font-weight: 900;
}

.profile-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-preview-meta {
    display: grid;
    gap: 0.2rem;
}

.profile-preview-meta span {
    color: var(--muted-foreground);
    font-size: var(--text-sm);
    font-weight: 800;
}

.theme-choice-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}

.theme-choice {
    min-height: 3.1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    cursor: pointer;
    font-weight: 800;
}

.theme-choice input,
.segmented-control input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.theme-choice:has(input:checked),
.segmented-control label:has(input:checked) span {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.theme-swatch {
    width: 1.8rem;
    height: 1.8rem;
    flex: 0 0 auto;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--swatch);
}

.segmented-control {
    display: inline-grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 0.5rem;
}

.segmented-control span {
    min-height: var(--control-h);
    display: grid;
    place-items: center;
    padding: 0.65rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    font-weight: 850;
    cursor: pointer;
}

.color-setting-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.color-setting-item {
    padding: 1rem;
    background: var(--muted-light);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.color-setting-item label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--muted-foreground);
    text-transform: uppercase;
}

.color-setting-item input[type="color"] {
    width: 100%;
    height: 38px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: white;
    cursor: pointer;
}


@media (max-width: 980px) {
    .hero-shell,
    .dash-split,
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 1441px) {
    :root {
        --page-pad: 3.5rem;
        --sidebar-w: 280px;
    }
    .dash-content,
    .topbar-inner,
    .alert {
        max-width: 1600px;
    }
}

/* ====================================================================
   RESPONSIVE: Tablet Landscape (≤1024px)
   Sidebar becomes an off-canvas drawer
   ==================================================================== */
@media (max-width: 1024px) {
    .dash-shell {
        grid-template-columns: 1fr;
    }

    .dash-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 1000;
        width: var(--sidebar-w);
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
        background: var(--sidebar);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    html[dir="rtl"] .dash-sidebar {
        left: auto;
        right: 0;
        transform: translateX(100%);
    }

    body.sidebar-open .dash-sidebar {
        transform: translateX(0);
        box-shadow: 8px 0 30px rgba(0,0,0,0.15);
    }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.45);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 999;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    body.sidebar-open .sidebar-backdrop {
        display: block;
        opacity: 1;
    }

    .mobile-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        padding: 0;
        border-radius: var(--radius);
        background: var(--muted-light);
        border: 1px solid var(--border);
        cursor: pointer;
        color: var(--foreground);
        flex: 0 0 auto;
    }

    .dash-topbar {
        padding-inline: var(--page-pad);
    }

    .dash-main {
        overflow-x: hidden;
    }

    /* Responsive grid overrides for inline styles in views */
    [style*="grid-template-columns: 1.5fr"],
    [style*="grid-template-columns: 1.2fr"],
    [style*="grid-template-columns: 2fr"] {
        grid-template-columns: 1fr !important;
    }
}

/* ====================================================================
   RESPONSIVE: Tablet Portrait (≤768px)
   Stack all multi-column layouts, shrink typography
   ==================================================================== */
@media (max-width: 768px) {
    :root {
        --page-pad: 1.25rem;
        --panel-pad: 1rem;
        --gap: 1rem;
    }

    .mkt-container h1 { font-size: 2.5rem !important; }
    .mkt-grid { grid-template-columns: 1fr; }
    .mkt-container { padding: 0 1.25rem; }
    .mkt-section { padding: 3rem 0; }

    /* Hide topbar welcome text, keep avatar */
    .dash-top-user span { display: none; }

    /* Force marketing 2-col grids to stack */
    .mkt-container > div {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
    }

    /* Hero stats row — wrap instead of fixed gaps */
    .hero-stats {
        flex-wrap: wrap;
        gap: 1.5rem !important;
    }

    .hero-stats > div {
        border-left: none !important;
        padding-left: 0 !important;
    }

    /* Settings tabs scroll horizontally */
    .settings-tab-list {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .settings-tab-list::-webkit-scrollbar {
        display: none;
    }

    .settings-tab-list label {
        white-space: nowrap;
        flex: 0 0 auto;
    }

    /* Profile layout */
    .profile-edit-layout {
        grid-template-columns: 1fr !important;
    }

    /* Stat cards — 2x2 on small tablets, 4 columns on large */
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Split layouts */
    .dash-split {
        grid-template-columns: 1fr !important;
    }

    /* Forms — allow single column when space is tight */
    .form {
        grid-template-columns: 1fr;
    }

    /* Course form and similar 2-panel layouts */
    [style*="grid-template-columns: 1.5fr"],
    [style*="grid-template-columns: 1.2fr"],
    [style*="grid-template-columns: 2fr"],
    [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Settings toolbar */
    .settings-toolbar {
        display: grid;
        grid-template-columns: 1fr;
    }

    .settings-toolbar .btn-primary,
    .form .btn-primary,
    .inline-btn {
        width: auto !important;
        min-width: 160px;
        margin-inline: auto;
    }

    .secure-mode-choice {
        grid-template-columns: 1fr;
    }

    /* Bunny.net infrastructure panel toggle layout */
    [style*="justify-content: space-between"][style*="gap: 2rem"] {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 1rem !important;
    }

    /* Tables scroll */
    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table {
        min-width: 600px;
    }

    /* Topbar */
    .dash-topbar {
        min-height: 3.5rem;
        gap: 0.5rem;
    }

    /* Glass card less padding */
    .glass-card {
        padding: 1.75rem;
    }

    /* Login */
    .login-card {
        padding: clamp(1.25rem, 4vw, 2rem);
    }
}

/* ====================================================================
   RESPONSIVE: Mobile (≤480px)
   Aggressive space optimization, single-column everything
   ==================================================================== */
@media (max-width: 480px) {
    :root {
        --page-pad: 1rem;
        --panel-pad: 0.85rem;
        --gap: 0.85rem;
        --text-2xl: 1.5rem;
        --text-xl: 1.25rem;
    }

    .container {
        width: calc(100% - 0.75rem);
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        padding: 0.5rem 0;
        min-height: auto;
    }

    .nav {
        width: 100%;
        justify-content: flex-start;
    }

    .hero-shell {
        padding: 1rem 0;
        gap: 1.5rem;
    }

    .dash-content {
        padding: 0.85rem;
    }

    /* Stat grid — 2 columns on small mobile */
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.65rem;
    }

    .stat-card {
        padding: 0.75rem;
    }

    .stat-card strong {
        font-size: 1.35rem;
    }

    /* Panel padding reduction */
    .panel {
        padding: var(--panel-pad);
        border-radius: var(--radius);
    }

    /* Glass cards */
    .glass-card {
        padding: 1.25rem;
        border-radius: 16px;
    }

    /* Buttons - ensure touch targets */
    .btn-primary,
    .btn-outline,
    .btn-ghost,
    .inline-btn,
    .nav a {
        min-height: 44px;
    }

    /* Table cells */
    .table th,
    .table td {
        padding: 0.65rem 0.5rem;
        font-size: 0.82rem;
    }

    /* Marketing section */
    .mkt-section {
        padding: 2rem 0;
    }

    .mkt-container h1 {
        font-size: 2rem !important;
    }

    /* CTA flex buttons wrap */
    [style*="display: flex"][style*="justify-content: center"] {
        flex-wrap: wrap;
    }

    /* Footer */
    .footer {
        padding: 1rem var(--page-pad);
    }

    /* Settings actions */
    .settings-actions {
        justify-content: stretch;
    }

    .settings-actions .btn-primary {
        width: 100%;
    }

    /* Form inputs touch sizing */
    .form input,
    .form select,
    .form textarea {
        min-height: 44px;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    /* Segmented control */
    .segmented-control {
        grid-template-columns: 1fr 1fr;
    }

    /* Theme grid */
    .theme-choice-grid {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }

    /* Login */
    .login-card {
        width: 100%;
        border-radius: 0;
        border-left: 0;
        border-right: 0;
    }

    .login-brand-lockup .login-logo-text {
        font-size: var(--text-xl) !important;
    }

    /* Quiz / assessment intro */
    [style*="max-width: 800px"] {
        max-width: 100% !important;
        margin: 1rem auto !important;
    }

    [style*="max-width: 1000px"] {
        max-width: 100% !important;
    }

    /* Page head */
    .dash-page-head h1 {
        font-size: var(--text-xl);
    }
}

/* ====================================================================
   TOUCH & ACCESSIBILITY
   ==================================================================== */
@media (hover: none) and (pointer: coarse) {
    /* Larger tap targets on touch devices */
    .dash-nav a {
        min-height: 44px;
        padding: 0.75rem 0.9rem;
    }

    .switch-ui {
        width: 48px;
        height: 26px;
    }

    .switch-ui::after {
        width: 20px;
        height: 20px;
        top: 2px;
        left: 2px;
    }

    .switch-field input[type="checkbox"]:checked ~ .switch-ui::after {
        transform: translateX(22px);
    }

    html[dir="rtl"] .switch-field input[type="checkbox"]:checked ~ .switch-ui::after {
        transform: translateX(-22px);
    }

    /* Disable hover transforms on touch */
    .glass-card:hover {
        transform: none;
    }
}

/* Safe area for notched phones */
@supports (padding: env(safe-area-inset-top)) {
    .dash-topbar {
        padding-top: env(safe-area-inset-top);
    }

    .dash-sidebar {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .footer {
        padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
    }
}

/* ====================================================================
   PREMIUM ANIMATIONS
   ==================================================================== */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 20px var(--primary-light); }
    50% { box-shadow: 0 0 40px var(--primary-light); }
}

.animate-fade-up { animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .animate-fade-up,
    .glass-card,
    .switch-ui,
    .switch-ui::after,
    .btn-primary,
    .feature-icon {
        animation: none !important;
        transition: none !important;
    }
}

/* ====================================================================
   MARKETING COMPONENTS
   ==================================================================== */
.mkt-section {
    padding: 6rem 0;
    position: relative;
    overflow: hidden;
}

.mkt-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--page-pad);
}

.mkt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2.5rem;
}

.glass-card {
    background: color-mix(in srgb, var(--card) 70%, transparent);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 2.5rem;
    transition: all 0.3s ease;
}

.glass-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    box-shadow: var(--shadow-xl);
}


.gradient-text {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.feature-icon {
    width: 60px;
    height: 60px;
    background: var(--muted);
    border-radius: 16px;
    display: grid;
    place-items: center;
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
    transition: all 0.3s ease;
}

.glass-card:hover .feature-icon {
    background: var(--primary);
    color: white;
    transform: scale(1.1) rotate(5deg);
}

/* ====================================================================
   RTL ADJUSTMENTS
   ==================================================================== */
html[dir="rtl"] .settings-tab-list {
    flex-direction: row;
    justify-content: flex-start;
}

/* ====================================================================
   RESPONSIVE UTILITY CLASSES (for view template use)
   ==================================================================== */
.hero-stats {
    display: flex;
    gap: 4rem;
}

.resp-grid-hero {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    align-items: center;
}

.resp-grid-shield {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 4rem;
    align-items: center;
}

@media (max-width: 768px) {
    .resp-grid-hero,
    .resp-grid-shield {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .hero-stats {
        gap: 1.5rem;
        flex-wrap: wrap;
    }

    .hero-stats > div {
        border-left: none !important;
        padding-left: 0 !important;
    }
}

.forced-logout-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.forced-logout-modal {
    background: var(--card);
    max-width: 420px;
    width: 100%;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 2.5rem;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: modal-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modal-pop {
    0% { transform: scale(0.9); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.logout-icon {
    width: 64px;
    height: 64px;
    background: var(--warning-light);
    color: var(--warning);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    font-size: 2rem;
}

.forced-logout-modal h2 {
    margin: 0 0 0.75rem;
    font-size: 1.5rem;
    font-weight: 850;
    color: var(--foreground);
}

.forced-logout-modal p {
    margin: 0 0 2rem;
    color: var(--muted-foreground);
    line-height: 1.6;
    font-size: 1rem;
}

.htmx-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: var(--primary);
    z-index: 2000000;
    transition: width 0.4s ease;
    pointer-events: none;
    opacity: 0;
}

.htmx-request .htmx-progress {
    width: 70%;
    opacity: 1;
}

.htmx-request.htmx-settling .htmx-progress {
    width: 100%;
}

.alert {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 9999999;
    min-width: 320px;
    max-width: 450px;
    padding: 1.25rem 1.75rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    animation: toast-in 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: var(--foreground);
    font-weight: 700;
}

[dir="rtl"] .alert {
    right: auto;
    left: 2rem;
    animation: toast-in-rtl 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.alert-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s;
    font-size: 1.2rem;
}

[dir="rtl"] .alert-close {
    right: auto;
    left: 0.5rem;
}

.alert-close:hover { opacity: 1; }

.alert-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    justify-content: flex-end;
}

.alert-actions button {
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 800;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: all 0.2s ease;
}

.btn-toast-yes {
    background: var(--primary);
    color: white;
    border: none !important;
}

.btn-toast-no {
    background: var(--muted-light);
    color: var(--foreground);
}

@keyframes toast-in {
    0% { transform: translateX(120%); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}

@keyframes toast-in-rtl {
    0% { transform: translateX(-120%); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}

/* ====================================================================
   DASHBOARD RESPONSIVENESS (MOBILE-FIRST RECOVERY)
   ==================================================================== */
@media (max-width: 1024px) {
    .dash-shell {
        grid-template-columns: 1fr;
        grid-template-areas: "main";
    }

    .dash-sidebar {
        position: fixed;
        inset-block: 0;
        inset-inline-start: 0;
        z-index: 10000;
        width: 100%;
        transform: translateX(-100%);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        border-inline-end: 1px solid var(--border);
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.2);
        gap: 0.5rem !important;
        padding: 1rem !important;
    }

    html[dir="rtl"] .dash-sidebar {
        transform: translateX(100%);
        box-shadow: -20px 0 50px rgba(0, 0, 0, 0.2);
    }

    body.sidebar-open .dash-sidebar {
        transform: translateX(0) !important;
    }

    .dash-brand {
        padding-bottom: 0.5rem !important;
        margin-bottom: 0.25rem !important;
    }

    .dash-nav a {
        padding: 0.5rem 0.75rem !important;
        font-size: 1rem !important;
        min-height: 2.4rem !important;
        font-weight: 800 !important;
    }

    .dash-side-foot {
        padding-top: 0.5rem !important;
        margin-top: 0.25rem !important;
    }

    .dash-logout {
        min-height: 2.6rem !important;
        font-size: 0.9rem !important;
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(4px);
        z-index: 9999;
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    body.sidebar-open .sidebar-backdrop {
        display: block;
        opacity: 1;
    }

    .mobile-toggle {
        display: grid !important;
        place-items: center;
        width: 42px;
        height: 42px;
        background: var(--muted-light);
        border: 1px solid var(--border);
        border-radius: 10px;
        color: var(--foreground);
        cursor: pointer;
    }

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

    .dash-split {
        grid-template-columns: 1fr;
    }

    .dash-topbar {
        padding-inline: 1rem;
    }

    .dash-topbar .dash-top-user span {
        display: none;
    }

    .dash-content {
        padding: 1rem;
    }

    .dash-page-head h1 {
        font-size: 1.5rem;
    }
}

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

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

    .brand-logo-img {
        max-width: 140px;
    }

    .settings-tab-list {
        display: flex;
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch;
        gap: 0.5rem;
        border-bottom: 1px solid var(--border);
    }

    .settings-tab-list::-webkit-scrollbar {
        height: 3px;
    }

    .settings-tab-list::-webkit-scrollbar-thumb {
        background: var(--border);
        border-radius: 10px;
    }

    .settings-tab-btn {
        flex: 0 0 auto;
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }

    .secure-mode-choice {
        grid-template-columns: 1fr;
    }
}

/* Fix for profile and cards in mobile */
.resource-card, .center-card, .teacher-card {
    grid-template-columns: 1fr !important;
    text-align: center;
}

.resource-icon, .avatar-lg {
    margin: 0 auto 1rem;
}

/* RTL Specific mirror fixes for dashboard elements */
html[dir="rtl"] .stat-card {
    border-left: none;
    border-right: 4px solid var(--border);
}
html[dir="rtl"] .stat-card.primary { border-right-color: var(--primary); }
html[dir="rtl"] .stat-card.success { border-right-color: var(--success); }
html[dir="rtl"] .stat-card.warning { border-right-color: var(--warning); }
html[dir="rtl"] .stat-card.danger { border-right-color: var(--danger); }
html[dir="rtl"] .stat-card.info { border-right-color: #06b6d4; }

/* --- MOBILE UTILITIES --- */
@media (max-width: 768px) {
    .hide-on-mobile {
        display: none !important;
    }
    
    /* Double-Scale Mobile Branding */
    .brand-lockup {
        flex-direction: column !important;
        align-items: center !important;
        gap: 0.5rem !important;
        text-align: center;
    }
    
    .brand-logo-img {
        max-width: 320px !important;
        max-height: 120px !important;
        margin: 0 auto;
    }
    
    .header {
        flex-direction: column;
        padding: 2rem 1rem !important;
        gap: 1.5rem !important;
    }
}

/* --- PILL BADGE SYSTEM --- */
.pill-badge {
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.5rem 1.25rem;
    border-radius: 100px;
    font-weight: 900;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    display: inline-block;
    border: 1px solid var(--primary-light);
    white-space: nowrap;
}

@media (max-width: 768px) {
    .pill-badge {
        padding: 0.35rem 0.85rem;
        font-size: 0.65rem;
        letter-spacing: 0.1em;
    }
    
    footer.footer {
        padding: 3rem 1.5rem 2rem !important;
        text-align: center;
    }
    
    .footer-brand {
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-bottom: 2rem;
    }
    
    .footer-nav {
        text-align: center;
    }
}
