:root {
    --color-primary: #4D148C;
    --color-primary-hover: #5C1BA6;
    --color-accent: #FF6600;
    --color-accent-hover: #E65C00;
    --color-bg: #0C0818;
    --color-surface: #1A1230;
    --color-surface-elevated: #221A3C;
    --color-border: #362D4A;
    --color-text-primary: rgba(255, 255, 255, 0.92);
    --color-text-secondary: rgba(255, 255, 255, 0.55);
}

@media (prefers-color-scheme: light) {
    :root:not(.dark) {
        --color-bg: #FAFAFA;
        --color-surface: #FFFFFF;
        --color-surface-elevated: #FFFFFF;
        --color-border: #E5E5E5;
        --color-text-primary: #0D0D0D;
        --color-text-secondary: rgba(13, 13, 13, 0.60);
    }
}

html.dark {
    --color-bg: #0C0818;
    --color-surface: #1A1230;
    --color-surface-elevated: #221A3C;
    --color-border: #362D4A;
    --color-text-primary: rgba(255, 255, 255, 0.92);
    --color-text-secondary: rgba(255, 255, 255, 0.55);
}

html.light {
    --color-bg: #FAFAFA;
    --color-surface: #FFFFFF;
    --color-surface-elevated: #FFFFFF;
    --color-border: #E5E5E5;
    --color-text-primary: #0D0D0D;
    --color-text-secondary: rgba(13, 13, 13, 0.60);
}

/* Atmospheric purple glow background — dark mode */
body {
    background:
        radial-gradient(ellipse 130% 70% at 50% -10%, rgba(77, 20, 140, 0.55) 0%, rgba(77, 20, 140, 0.18) 40%, transparent 75%),
        radial-gradient(ellipse 90% 60% at 100% 100%, rgba(255, 102, 0, 0.06) 0%, transparent 60%),
        var(--color-bg) !important;
    background-attachment: fixed !important;
}

html.light body,
html.light body {
    background: var(--color-bg) !important;
}

@media (prefers-color-scheme: light) {
    html:not(.dark) body {
        background: var(--color-bg) !important;
    }
}

[x-cloak] {
    display: none !important;
}

/* Bottom Navigation */
.btm-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    height: calc(64px + env(safe-area-inset-bottom, 0px));
    z-index: 50;
}

.btm-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 44px;
    min-width: 64px;
    padding: 6px 12px;
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: color 0.15s ease;
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
}

.btm-nav-item:hover,
.btm-nav-item:active {
    color: var(--color-text-primary);
}

.btm-nav-active {
    color: var(--color-accent) !important;
}

.btm-nav-label {
    font-size: 10px;
    font-weight: 500;
    line-height: 1;
}

/* More Menu */
.more-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    min-height: 44px;
    color: var(--color-text-primary);
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.15s ease;
}

.more-menu-item:hover,
.more-menu-item:active {
    background: var(--color-border);
}

/* Animations */
.fade-in {
    animation: fadeIn 0.2s ease-out;
}

.slide-up {
    animation: slideUp 0.25s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Toast transitions */
.toast-enter { transition: all 0.3s ease-out; }
.toast-enter-start { opacity: 0; transform: translateY(-12px); }
.toast-enter-end { opacity: 1; transform: translateY(0); }
.toast-leave { transition: all 0.2s ease-in; }
.toast-leave-start { opacity: 1; transform: translateY(0); }
.toast-leave-end { opacity: 0; transform: translateY(-12px); }

/* Status Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
    text-transform: capitalize;
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.badge-error {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.badge-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.badge-info {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

.badge-neutral {
    background: var(--color-border);
    color: var(--color-text-secondary);
}

/* Severity Indicators */
.severity-low {
    border-left: 3px solid #34d399;
}

.severity-medium {
    border-left: 3px solid #fbbf24;
}

.severity-high {
    border-left: 3px solid var(--color-accent);
}

.severity-critical {
    border-left: 3px solid #f87171;
}

/* Card tap effect */
.card-tap {
    transition: transform 0.1s ease;
}

.card-tap:active {
    transform: scale(0.97);
}

/* Form inputs */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="tel"],
textarea,
select {
    background: var(--color-surface-elevated);
    border: 1px solid var(--color-border);
    color: var(--color-text-primary);
    border-radius: 12px;
    padding: 12px 16px;
    width: 100%;
    font-size: 16px;
    min-height: 44px;
    outline: none;
    transition: border-color 0.15s ease;
    -webkit-appearance: none;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--color-accent);
    box-shadow: 0 0 0 2px rgba(255, 102, 0, 0.15);
}

input::placeholder,
textarea::placeholder {
    color: var(--color-text-secondary);
}

/* Button base */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 24px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--color-accent);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-accent-hover);
}

.btn-primary:active:not(:disabled) {
    transform: scale(0.97);
}

.btn-secondary {
    background: var(--color-surface-elevated);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--color-border);
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    color: var(--color-text-primary);
    background: var(--color-surface-elevated);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.btn-danger:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.25);
}

.btn-success {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.btn-success:hover:not(:disabled) {
    background: rgba(16, 185, 129, 0.25);
}

/* Pill selector */
.pill-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 8px 20px;
    border-radius: 9999px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    transition: all 0.15s ease;
}

.pill:hover {
    border-color: var(--color-text-secondary);
}

.pill-active {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: #fff;
}

/* Toggle switch */
.toggle-track {
    position: relative;
    width: 52px;
    height: 28px;
    border-radius: 14px;
    background: var(--color-border);
    cursor: pointer;
    transition: background 0.2s ease;
    flex-shrink: 0;
}

.toggle-track.active {
    background: #34d399;
}

.toggle-track.fail {
    background: #f87171;
}

.toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s ease;
}

.toggle-track.active .toggle-thumb,
.toggle-track.fail .toggle-thumb {
    transform: translateX(24px);
}

/* Loader spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Accordion */
.accordion-content {
    overflow: hidden;
    transition: max-height 0.25s ease, opacity 0.2s ease;
}

/* Modal overlay */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 60;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

@media (min-width: 640px) {
    .modal-overlay {
        align-items: center;
    }
}

.modal-content {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.25s ease-out;
}

@media (min-width: 640px) {
    .modal-content {
        border-radius: 16px;
        max-width: 480px;
    }
}

/* Page header */
.page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    padding-top: 16px;
    position: sticky;
    top: 0;
    background: var(--color-bg);
    z-index: 10;
}

.back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    color: var(--color-text-primary);
    text-decoration: none;
    transition: background 0.15s ease;
}

.back-btn:hover {
    background: var(--color-surface-elevated);
}

/* Print styles */
@media print {
    .btm-nav,
    .toast-enter,
    .modal-overlay {
        display: none !important;
    }

    body {
        background: #fff;
        color: #000;
    }

    main {
        padding-bottom: 0;
    }
}
