:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --accent: #06b6d4;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --border: #e2e8f0;
    --border-subtle: #f1f5f9;
    --text: #0f172a;
    --text-muted: #64748b;
    --text-faint: #94a3b8;
    --radius: 0.875rem;
    --radius-lg: 1.125rem;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.06), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 20px 40px -12px rgba(15, 23, 42, 0.12);
    --sidebar: #0f172a;
    --sidebar-hover: rgba(255, 255, 255, 0.06);
    --sidebar-active: rgba(99, 102, 241, 0.18);
}

* { box-sizing: border-box; }

body.theme-body {
    font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.theme-app-bg {
    background:
        radial-gradient(ellipse 80% 60% at 10% -10%, rgba(99, 102, 241, 0.12), transparent 50%),
        radial-gradient(ellipse 60% 50% at 90% 0%, rgba(6, 182, 212, 0.08), transparent 45%),
        var(--surface-muted);
    min-height: 100vh;
}

.theme-auth-bg {
    background:
        radial-gradient(ellipse 70% 60% at 20% 20%, rgba(99, 102, 241, 0.18), transparent 55%),
        radial-gradient(ellipse 50% 50% at 80% 80%, rgba(6, 182, 212, 0.12), transparent 50%),
        linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
    min-height: 100vh;
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card-hover:hover {
    box-shadow: var(--shadow);
    border-color: #cbd5e1;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s, transform 0.2s;
}

.stat-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.stat-card .stat-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.01em;
}

.stat-card .stat-value {
    font-size: 1.875rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    margin-top: 0.25rem;
}

/* Typography */
.page-title {
    font-size: 1.625rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text);
    line-height: 1.2;
}

.page-subtitle {
    font-size: 0.9375rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.section-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5625rem 1.125rem;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25rem;
    border-radius: 0.625rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    box-shadow: 0 1px 2px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
    filter: brightness(1.05);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    box-shadow: 0 1px 2px rgba(5, 150, 105, 0.3);
}

.btn-success:hover { filter: brightness(1.05); }

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #fff;
}

.btn-danger:hover { filter: brightness(1.05); }

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--surface-muted);
    border-color: #cbd5e1;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: transparent;
}

.btn-ghost:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-block { width: 100%; }

/* Form inputs */
.input,
.select,
.textarea,
.theme-app input[type="text"],
.theme-app input[type="email"],
.theme-app input[type="password"],
.theme-app input[type="number"],
.theme-app input[type="file"],
.theme-app select,
.theme-app textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    line-height: 1.4;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.625rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus,
.select:focus,
.textarea:focus,
.theme-app input:focus,
.theme-app select:focus,
.theme-app textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.input:read-only,
.theme-app input:read-only {
    background: var(--surface-muted);
    color: var(--text-muted);
}

.label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 0.375rem;
}

.form-hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 0.875rem;
    color: var(--text);
    cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary);
    border-radius: 0.25rem;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.625rem;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border-radius: 9999px;
}

.badge-primary { background: #eef2ff; color: #4338ca; }
.badge-success { background: #ecfdf5; color: #047857; }
.badge-warning { background: #fffbeb; color: #b45309; }
.badge-purple { background: #f5f3ff; color: #6d28d9; }
.badge-muted { background: #f1f5f9; color: #475569; }

/* Alerts */
.alert {
    padding: 0.875rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    border: 1px solid;
}

.alert-success {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #065f46;
}

.alert-warning {
    background: #fffbeb;
    border-color: #fde68a;
    color: #92400e;
}

.alert-info {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e40af;
}

/* Tables */
.table-wrap {
    overflow: hidden;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background: var(--surface);
}

.table-modern {
    width: 100%;
    font-size: 0.875rem;
    border-collapse: collapse;
}

.table-modern thead {
    background: var(--surface-muted);
    border-bottom: 1px solid var(--border);
}

.table-modern th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.table-modern td {
    padding: 0.875rem 1rem;
    border-top: 1px solid var(--border-subtle);
    color: var(--text);
}

.table-modern tbody tr {
    transition: background 0.12s;
}

.table-modern tbody tr:hover {
    background: #fafbfc;
}

.table-modern tbody tr.row-complete {
    background: #f0fdf4;
}

.table-modern tbody tr.row-complete:hover {
    background: #ecfdf5;
}

/* Progress bar */
.progress-track {
    width: 100%;
    height: 0.5rem;
    background: #e2e8f0;
    border-radius: 9999px;
    overflow: hidden;
}

.progress-track.lg { height: 0.625rem; }

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: 9999px;
    transition: width 0.4s ease;
}

/* Tenant nav pills */
.nav-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    padding: 0.375rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

.nav-pill {
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    border-radius: 0.625rem;
    text-decoration: none;
    transition: all 0.15s;
}

.nav-pill:hover {
    color: var(--text);
    background: var(--surface-muted);
}

.nav-pill.active {
    color: #fff;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

/* Admin sidebar */
.admin-sidebar {
    width: 16.5rem;
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.admin-brand {
    padding: 1.5rem 1.25rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.admin-brand-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.02em;
}

.admin-brand-sub {
    font-size: 0.6875rem;
    font-weight: 500;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 0.125rem;
}

.admin-nav {
    padding: 1rem 0.75rem;
    flex: 1;
}

.admin-nav-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.875rem;
    margin-bottom: 0.125rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #94a3b8;
    border-radius: 0.625rem;
    text-decoration: none;
    transition: all 0.15s;
}

.admin-nav-link:hover {
    color: #e2e8f0;
    background: var(--sidebar-hover);
}

.admin-nav-link.active {
    color: #fff;
    background: var(--sidebar-active);
}

.admin-nav-link svg {
    width: 1.125rem;
    height: 1.125rem;
    flex-shrink: 0;
    opacity: 0.85;
}

.admin-header {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0.875rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* App topbar */
.app-topbar {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 40;
}

.app-brand {
    font-size: 1.0625rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.75rem 0.375rem 0.375rem;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 9999px;
    font-size: 0.8125rem;
    font-weight: 500;
}

.user-avatar {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 9999px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Auth card */
.auth-card {
    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1.25rem;
    padding: 2rem;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 26rem;
}

.auth-card-light {
    border-color: var(--border);
}

/* Wizard step indicator */
.wizard-steps {
    display: flex;
    gap: 0.375rem;
    margin-bottom: 1.5rem;
}

.wizard-step-dot {
    flex: 1;
    height: 0.25rem;
    border-radius: 9999px;
    background: #e2e8f0;
    transition: background 0.3s;
}

.wizard-step-dot.done {
    background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
}

.wizard-step-dot.current {
    background: var(--primary);
}

/* Link */
.link {
    color: var(--primary);
    font-weight: 500;
    text-decoration: none;
}

.link:hover { color: var(--primary-dark); text-decoration: underline; }

/* Empty state */
.empty-state {
    padding: 2.5rem 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}
