/* Typography settings */
body {
    font-family: 'Inter', sans-serif;
    font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

.tabular-nums {
    font-variant-numeric: tabular-nums;
}

/* Hide default number input arrows globally */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    appearance: textfield;
    -moz-appearance: textfield;
}

/* Custom scrollbar */
::-webkit-scrollbar,
.custom-scrollbar::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track,
.custom-scrollbar::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb,
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover,
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.dark ::-webkit-scrollbar-track,
.dark .custom-scrollbar::-webkit-scrollbar-track {
    background: #0f172a;
}

.dark ::-webkit-scrollbar-thumb,
.dark .custom-scrollbar::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}

.dark ::-webkit-scrollbar-thumb:hover,
.dark .custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* Firefox scrollbar support */
* {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

.dark * {
    scrollbar-color: #334155 #0f172a;
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Glassmorphism */
.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.dark .glass {
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Material 3 Card Shadow */
.m3-card {
    background: #ffffff;
    border-radius: 18px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 10px 40px -10px rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.02);
}

.dark .m3-card {
    background: #151f33;
    border: 1px solid #1e293b;
}

.m3-card:hover {
    box-shadow: 0 24px 48px -12px rgba(15, 23, 42, 0.08), 0 4px 16px -4px rgba(15, 23, 42, 0.03);
    border-color: rgba(16, 185, 129, 0.3);
    transform: translateY(-4px);
}

.dark .m3-card:hover {
    box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.4);
    border-color: #334155;
    transform: translateY(-4px);
}

/* Status Pulse Animation */
.status-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .5;
    }
}

/* Tab logic (for ops dashboard) */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.tab-btn.active {
    color: #059669;
    border-bottom-color: #059669;
}

/* ============================================================
   Theme toggle (light / dark / system)
   ============================================================ */
.theme-toggle {
    position: relative;
    overflow: hidden;
    isolation: isolate;
    cursor: pointer;
}

.theme-toggle::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(circle at center, rgba(251, 191, 36, 0.22), transparent 70%);
    opacity: 0;
    transition: opacity 300ms ease;
    z-index: 0;
    pointer-events: none;
}

.theme-toggle:hover::before {
    opacity: 1;
}

html.dark .theme-toggle::before {
    background: radial-gradient(circle at center, rgba(129, 140, 248, 0.28), transparent 70%);
}

html[data-theme-mode="system"] .theme-toggle::before {
    background: radial-gradient(circle at center, rgba(16, 185, 129, 0.22), transparent 70%);
}

.theme-toggle-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: rotate(-90deg) scale(0);
    opacity: 0;
    transition: transform 500ms cubic-bezier(0.4, 0, 0.2, 1),
                opacity 250ms ease;
    z-index: 1;
    pointer-events: none;
}

.theme-toggle-icon-light  { color: #f59e0b; }
.theme-toggle-icon-dark   { color: #6366f1; }
.theme-toggle-icon-system { color: #10b981; }

html[data-theme-mode="light"]  .theme-toggle-icon-light,
html[data-theme-mode="dark"]   .theme-toggle-icon-dark,
html[data-theme-mode="system"] .theme-toggle-icon-system {
    transform: rotate(0deg) scale(1);
    opacity: 1;
}

html[data-theme-mode="light"]  .theme-toggle:active .theme-toggle-icon-light,
html[data-theme-mode="dark"]   .theme-toggle:active .theme-toggle-icon-dark,
html[data-theme-mode="system"] .theme-toggle:active .theme-toggle-icon-system {
    transform: rotate(0deg) scale(0.85);
}

.theme-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.6);
    border-color: rgb(16, 185, 129);
}

/* Generic focus-visible ring for header icon buttons & sidebar controls */
.portal-focus-ring:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.6);
}

/* View Transitions: smooth crossfade between themes where supported.
   Browsers without support fall back to instant swap (still fine). */
@supports (view-transition-name: root) {
    ::view-transition-old(root),
    ::view-transition-new(root) {
        animation-duration: 250ms;
        animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    }
}