:root {
    --primary: #6366f1;
    --primary-light: #e0e7ff;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --text-dim: #94a3b8;
    --border: #e2e8f0;
    --radius-lg: 16px;
    --radius-md: 12px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.er-admin-app {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    color: var(--text);
    padding: 20px;
    background: var(--bg);
    min-height: 100vh;
}

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

.er-top-bar-left {
    display: flex;
    flex-direction: column;
}

.er-brand-title {
    font-size: 28px;
    font-weight: 800;
    margin: 0 0 4px 0;
    color: var(--primary);
    letter-spacing: -0.5px;
}

.er-brand-tagline {
    font-size: 14px;
    color: var(--text-muted);
}

.er-btn-lifesaver {
    background: var(--primary);
    color: white;
    padding: 10px 18px;
    border-radius: 99px;
    text-decoration: none;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.er-btn-lifesaver:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
    color: white;
}

/* Layout */
.er-layout {
    display: flex;
    gap: 32px;
}

.er-sidebar {
    width: 260px;
    flex-shrink: 0;
}

.er-main {
    flex-grow: 1;
}

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

/* Nav */
.er-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.er-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 600;
    transition: var(--transition);
}

.er-nav-item:hover {
    background: white;
    color: var(--primary);
}

.er-nav-item.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* Cards */
.er-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    overflow: hidden;
}

.er-card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.er-card-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.er-card-body {
    padding: 24px;
}

/* Tables */
.er-table {
    width: 100%;
    border-collapse: collapse;
}

.er-table th {
    text-align: left;
    padding: 16px 24px;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: #f8fafc;
}

.er-table td {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    font-size: 14px;
}

/* Buttons */
.er-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.er-btn-primary { background: var(--primary); color: white; }
.er-btn-primary:hover { background: #4f46e5; }

.er-btn-secondary { background: white; border-color: var(--border); color: var(--text); }
.er-btn-secondary:hover { background: #f8fafc; }

.er-btn-danger { background: #fee2e2; color: #ef4444; }
.er-btn-danger:hover { background: #fecaca; }

/* Stats */
.er-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}

/* Uniform Settings Grid */
.er-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 24px;
    align-items: stretch;
}

.er-settings-grid .er-card {
    height: 100%;
    margin-bottom: 0 !important;
    display: flex;
    flex-direction: column;
}

.er-settings-grid .er-card-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* Modern Toggle Switch */
.er-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.er-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.er-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1; /* Clear 'Off' Gray */
    transition: .3s;
    border-radius: 34px;
}

.er-slider:before {
    position: absolute;
    content: "";
    height: 18px; width: 18px;
    left: 4px; bottom: 4px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .er-slider {
    background-color: var(--primary); /* Vibrant 'On' Color */
}

input:checked + .er-slider:before {
    transform: translateX(20px);
}

.er-stat-card {
    background: white;
    padding: 24px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.er-stat-label {
    display: block;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
}

.er-stat-value {
    display: block;
    font-size: 32px;
    font-weight: 800;
    margin-top: 8px;
}

/* Modals */
.er-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    align-items: flex-start;
    justify-content: center;
    z-index: 99999;
    overflow-y: auto;
    padding: 60px 20px;
}

.er-modal-container {
    background: white;
    width: 600px;
    max-width: 95%;
    max-height: 85vh;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#redirectFormMain {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

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

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

.er-modal-footer {
    padding: 20px 32px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: #f8fafc;
    flex-shrink: 0;
}

/* Forms */
.er-group {
    margin-bottom: 20px;
}

.er-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 14px;
}

.er-input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 14px;
    transition: var(--transition);
}

.er-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
}

.er-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* Badges */
.er-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
}

.er-badge-info { background: #eff6ff; color: #3b82f6; }
.er-badge-success { background: #ecfdf5; color: #10b981; }
.er-badge-warning { background: #fffbeb; color: #f59e0b; }

/* Tabs inside Modal */
.er-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

.er-tab {
    padding: 12px 24px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
}

.er-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Freemium / Pro UI Refinements */
.er-pro-inline-tag {
    background: #f1f5f9;
    color: #475569;
    font-size: 8px;
    font-weight: 900;
    padding: 2px 4px;
    border-radius: 3px;
    margin-left: 6px;
    border: 1px solid #e2e8f0;
    vertical-align: middle;
    letter-spacing: 0.5px;
    display: inline-block;
    line-height: 1;
}

.er-nav-pro {
    opacity: 0.95;
}

.er-tab-pro-locked {
    color: var(--text-dim) !important;
}

/* New Segmented Control UI */
.er-segmented-control {
    display: inline-flex;
    background: #f1f5f9;
    padding: 3px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    margin-bottom: 12px;
}

.er-segment-item {
    padding: 6px 16px;
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    border: none;
    background: transparent;
}

.er-segment-item.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.er-segment-item:not(.active):hover {
    color: var(--primary);
}

.er-upgrade-btn {
    background: linear-gradient(135deg, #6366f1, #4f46e5) !important;
    color: #fff !important;
    border: none !important;
    font-weight: 700 !important;
    padding: 10px 20px !important;
    border-radius: 8px !important;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none !important;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2) !important;
    transition: var(--transition) !important;
}

.er-upgrade-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(99, 102, 241, 0.3) !important;
}

.er-no-scroll {
    overflow: hidden !important;
}

@media (max-width: 782px) {
    .er-layout { flex-direction: column; }
    .er-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); }
}

/* --- Premium Loading States --- */

.er-skeleton {
    background: #f1f5f9;
    background-image: linear-gradient(
        90deg, 
        #f1f5f9 0px, 
        #f8fafc 40px, 
        #f1f5f9 80px
    );
    background-size: 200% 100%;
    animation: er-shimmer 1.5s infinite linear;
    border-radius: 4px;
    display: inline-block;
}

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

.er-skeleton-text {
    height: 12px;
    width: 100%;
    margin: 4px 0;
}

.er-skeleton-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

/* Spinner Backup */
.er-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--primary-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: er-spin 0.8s infinite linear;
}

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

.er-loading-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 12px;
    color: var(--text-muted);
    font-weight: 600;
}
