:root {
    color-scheme: dark;
    --app-bg: #070510;
    --app-bg-2: #0d0818;
    --app-surface: rgba(21, 15, 36, 0.86);
    --app-surface-strong: rgba(31, 22, 53, 0.92);
    --app-surface-soft: rgba(255, 255, 255, 0.055);
    --app-surface-hover: rgba(47, 34, 78, 0.94);
    --app-purple: #8b5cf6;
    --app-purple-2: #c026d3;
    --app-cyan: #38d5ff;
    --app-green: #65f0ad;
    --app-amber: #ffd166;
    --app-red: #ff4d6d;
    --app-text: #ffffff;
    --app-text-2: #c9c1d8;
    --app-text-3: #9287a6;
    --app-border: rgba(255, 255, 255, 0.105);
    --app-border-strong: rgba(255, 255, 255, 0.18);
    --app-radius: 14px;
    --app-radius-sm: 10px;
    --app-shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
    --app-shadow-soft: 0 18px 54px rgba(0, 0, 0, 0.24);
    --app-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

.app-shell,
.auth-shell {
    min-width: 320px;
    min-height: 100vh;
    background:
        radial-gradient(circle at 18% 0%, rgba(168, 85, 247, 0.18), transparent 28rem),
        radial-gradient(circle at 86% 12%, rgba(56, 213, 255, 0.09), transparent 24rem),
        linear-gradient(180deg, var(--app-bg), var(--app-bg-2) 48%, var(--app-bg));
    color: var(--app-text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

.app-shell::before,
.auth-shell::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.030) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.030) 1px, transparent 1px);
    background-size: 56px 56px;
    mask-image: linear-gradient(to bottom, black, transparent 76%);
}

.app-shell a,
.auth-shell a,
.app-shell button,
.auth-shell button {
    transition:
        color 180ms ease,
        background 180ms ease,
        border-color 180ms ease,
        box-shadow 220ms ease,
        transform 220ms var(--app-ease),
        opacity 180ms ease;
}

.app-shell :focus-visible,
.auth-shell :focus-visible {
    outline: 2px solid var(--app-cyan);
    outline-offset: 3px;
}

.app-main {
    position: relative;
    width: min(100%, 1280px);
    padding: clamp(24px, 3vw, 42px) clamp(16px, 3vw, 28px);
}

.app-shell .bg-white,
.auth-shell .bg-white {
    background:
        radial-gradient(circle at var(--app-card-x, 50%) 0%, rgba(168, 85, 247, 0.10), transparent 18rem),
        var(--app-surface) !important;
    border-color: var(--app-border) !important;
    color: var(--app-text);
    box-shadow: var(--app-shadow-soft);
}

.app-shell .bg-gray-50,
.app-shell .bg-gray-100,
.app-shell .bg-slate-50,
.app-shell .bg-slate-100,
.auth-shell .bg-gray-50,
.auth-shell .bg-gray-100,
.auth-shell .bg-slate-50,
.auth-shell .bg-slate-100 {
    background: rgba(13, 8, 24, 0.72) !important;
}

.app-shell .bg-indigo-50,
.app-shell .bg-purple-50,
.auth-shell .bg-indigo-50,
.auth-shell .bg-purple-50 {
    background: rgba(139, 92, 246, 0.12) !important;
    color: #ddd6fe !important;
    border-color: rgba(168, 85, 247, 0.22) !important;
}

.app-shell [class*="bg-gray-50"],
.app-shell [class*="bg-gray-100"],
.app-shell [class*="bg-slate-50"],
.app-shell [class*="bg-slate-100"],
.auth-shell [class*="bg-gray-50"],
.auth-shell [class*="bg-gray-100"],
.auth-shell [class*="bg-slate-50"],
.auth-shell [class*="bg-slate-100"] {
    background: rgba(13, 8, 24, 0.72) !important;
}

.app-shell [class*="bg-indigo-50"],
.app-shell [class*="bg-purple-50"],
.auth-shell [class*="bg-indigo-50"],
.auth-shell [class*="bg-purple-50"] {
    background: rgba(139, 92, 246, 0.12) !important;
    color: #ddd6fe !important;
    border-color: rgba(168, 85, 247, 0.22) !important;
}

.app-shell [class*="from-indigo-50"],
.app-shell [class*="from-gray-50"],
.app-shell [class*="from-slate-50"],
.auth-shell [class*="from-indigo-50"],
.auth-shell [class*="from-gray-50"],
.auth-shell [class*="from-slate-50"] {
    --tw-gradient-from: rgba(168, 85, 247, 0.13) var(--tw-gradient-from-position) !important;
    --tw-gradient-to: rgba(168, 85, 247, 0) var(--tw-gradient-to-position) !important;
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to) !important;
}

.app-shell [class*="to-indigo-50"],
.app-shell [class*="to-gray-50"],
.app-shell [class*="to-slate-50"],
.auth-shell [class*="to-indigo-50"],
.auth-shell [class*="to-gray-50"],
.auth-shell [class*="to-slate-50"] {
    --tw-gradient-to: rgba(56, 213, 255, 0.055) var(--tw-gradient-to-position) !important;
}

.app-shell .bg-green-50,
.app-shell .bg-emerald-50,
.app-shell .bg-green-100,
.app-shell .bg-emerald-100 {
    background: rgba(101, 240, 173, 0.12) !important;
    color: #a7f3d0 !important;
    border-color: rgba(101, 240, 173, 0.22) !important;
}

.app-shell .bg-red-50,
.app-shell .bg-red-100,
.auth-shell .bg-red-50,
.auth-shell .bg-red-100 {
    background: rgba(255, 77, 109, 0.12) !important;
    color: #fecdd3 !important;
    border-color: rgba(255, 77, 109, 0.24) !important;
}

.app-shell .bg-yellow-50,
.app-shell .bg-amber-50,
.app-shell .bg-amber-100,
.app-shell .bg-orange-50 {
    background: rgba(255, 209, 102, 0.12) !important;
    color: #fde68a !important;
    border-color: rgba(255, 209, 102, 0.24) !important;
}

.app-shell .bg-indigo-600,
.app-shell .bg-indigo-700,
.app-shell .bg-purple-600,
.app-shell .bg-purple-700,
.auth-shell .bg-indigo-600,
.auth-shell .bg-indigo-700 {
    background: linear-gradient(135deg, var(--app-purple), var(--app-purple-2)) !important;
    color: #ffffff !important;
    border-color: rgba(216, 180, 254, 0.28) !important;
    box-shadow: 0 14px 38px rgba(168, 85, 247, 0.22);
}

.app-shell .bg-green-600,
.app-shell .bg-emerald-600 {
    background: linear-gradient(135deg, #10b981, #65f0ad) !important;
    color: #06120d !important;
}

.app-shell .bg-red-600,
.app-shell .bg-red-700 {
    background: linear-gradient(135deg, #dc2626, var(--app-red)) !important;
    color: #ffffff !important;
}

.app-shell .bg-slate-900,
.app-shell .bg-gray-800,
.app-shell .bg-gray-900 {
    background: rgba(9, 6, 17, 0.94) !important;
    color: #ffffff !important;
    border-color: var(--app-border) !important;
}

.app-shell .text-gray-900,
.app-shell .text-slate-900,
.app-shell .text-gray-800,
.app-shell .text-slate-800,
.auth-shell .text-gray-900,
.auth-shell .text-slate-900,
.auth-shell .text-gray-800 {
    color: var(--app-text) !important;
}

.app-shell .text-gray-700,
.app-shell .text-slate-700,
.app-shell .text-gray-600,
.app-shell .text-slate-600,
.auth-shell .text-gray-700,
.auth-shell .text-gray-600 {
    color: var(--app-text-2) !important;
}

.app-shell .text-gray-500,
.app-shell .text-slate-500,
.app-shell .text-gray-400,
.app-shell .text-slate-400,
.auth-shell .text-gray-500,
.auth-shell .text-gray-400 {
    color: var(--app-text-3) !important;
}

.app-shell .text-indigo-600,
.app-shell .text-indigo-700,
.app-shell .text-purple-600,
.app-shell .text-purple-700,
.auth-shell .text-indigo-600,
.auth-shell .text-indigo-700 {
    color: #c4b5fd !important;
}

.app-shell .text-green-600,
.app-shell .text-green-700,
.app-shell .text-emerald-600,
.app-shell .text-emerald-700 {
    color: var(--app-green) !important;
}

.app-shell .text-red-500,
.app-shell .text-red-600,
.app-shell .text-red-700,
.auth-shell .text-red-500,
.auth-shell .text-red-600 {
    color: #fb7185 !important;
}

.app-shell .text-amber-700,
.app-shell .text-yellow-700,
.app-shell .text-orange-500,
.app-shell .text-yellow-400 {
    color: var(--app-amber) !important;
}

.app-shell [class*="border-gray"],
.app-shell [class*="border-slate"],
.app-shell [class*="border-indigo"],
.auth-shell [class*="border-gray"],
.auth-shell [class*="border-indigo"] {
    border-color: var(--app-border) !important;
}

.app-shell [class*="divide-gray"] > :not([hidden]) ~ :not([hidden]),
.app-shell [class*="divide-slate"] > :not([hidden]) ~ :not([hidden]) {
    border-color: var(--app-border) !important;
}

.app-shell .shadow,
.app-shell .shadow-sm,
.app-shell .shadow-md,
.app-shell .shadow-lg,
.app-shell .shadow-xl,
.auth-shell .shadow,
.auth-shell .shadow-sm,
.auth-shell .shadow-md,
.auth-shell .shadow-lg,
.auth-shell .shadow-xl {
    box-shadow: var(--app-shadow-soft) !important;
}

.app-shell .rounded-2xl,
.app-shell .rounded-3xl,
.auth-shell .rounded-xl,
.auth-shell .rounded-2xl {
    border-radius: var(--app-radius) !important;
}

.app-shell h1,
.app-shell h2,
.app-shell h3,
.auth-shell h1,
.auth-shell h2,
.auth-shell h3 {
    letter-spacing: 0;
}

.app-shell p,
.auth-shell p {
    color: inherit;
}

.app-shell input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.app-shell select,
.app-shell textarea,
.auth-shell input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.auth-shell select,
.auth-shell textarea {
    width: 100%;
    border: 1px solid var(--app-border) !important;
    border-radius: var(--app-radius-sm) !important;
    background: rgba(255, 255, 255, 0.065) !important;
    color: var(--app-text) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.app-shell input::placeholder,
.app-shell textarea::placeholder,
.auth-shell input::placeholder,
.auth-shell textarea::placeholder {
    color: rgba(201, 193, 216, 0.56) !important;
}

.app-shell input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):focus,
.app-shell select:focus,
.app-shell textarea:focus,
.auth-shell input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):focus,
.auth-shell select:focus,
.auth-shell textarea:focus {
    border-color: rgba(168, 85, 247, 0.72) !important;
    outline: 0;
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.18), 0 16px 38px rgba(0, 0, 0, 0.16) !important;
}

.app-shell select option,
.app-shell select optgroup,
.auth-shell select option,
.auth-shell select optgroup {
    background: #160f26;
    color: var(--app-text);
}

.app-shell select option:checked,
.auth-shell select option:checked {
    background: linear-gradient(135deg, var(--app-purple), var(--app-purple-2));
    color: #ffffff;
}

.app-shell input[type="checkbox"],
.app-shell input[type="radio"],
.auth-shell input[type="checkbox"],
.auth-shell input[type="radio"] {
    accent-color: var(--app-purple);
}

.app-shell input:disabled,
.app-shell select:disabled,
.app-shell textarea:disabled,
.auth-shell input:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

.app-shell label,
.auth-shell label {
    color: var(--app-text-2) !important;
}

.app-shell button:not([disabled]):hover,
.app-shell a[class*="bg-"]:hover,
.auth-shell button:not([disabled]):hover,
.auth-shell a[class*="bg-"]:hover {
    transform: translateY(-1px);
}

.app-shell button[disabled],
.auth-shell button[disabled] {
    cursor: not-allowed;
    opacity: 0.58;
}

.app-shell table {
    border-collapse: separate;
    border-spacing: 0;
}

.app-shell thead,
.app-shell thead tr,
.app-shell thead .bg-white,
.app-shell thead .bg-gray-50\/50,
.app-shell thead .bg-slate-50\/50 {
    background: rgba(255, 255, 255, 0.045) !important;
}

.app-shell th {
    color: var(--app-text-3) !important;
}

.app-shell tbody tr {
    transition: background 160ms ease;
}

.app-shell tbody tr:hover {
    background: rgba(168, 85, 247, 0.075) !important;
}

.app-shell code {
    border: 1px solid var(--app-border);
    border-radius: 6px;
    padding: 2px 5px;
    background: rgba(255, 255, 255, 0.06);
    color: #ddd6fe;
}

.dashboard-zaph-metrics {
    z-index: 40 !important;
    mix-blend-mode: normal !important;
}

.dashboard-zaph-metrics img {
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 22px 34px rgba(0, 0, 0, 0.48)) drop-shadow(0 0 18px rgba(168, 85, 247, 0.18));
}

.app-shell .prose {
    color: var(--app-text-2) !important;
}

.app-shell .prose strong,
.app-shell .prose h1,
.app-shell .prose h2,
.app-shell .prose h3,
.app-shell .prose h4 {
    color: var(--app-text) !important;
}

.app-shell .prose a {
    color: #c4b5fd !important;
}

.app-shell .app-message {
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    padding: 14px 16px;
    background: var(--app-surface);
    color: var(--app-text-2);
    box-shadow: var(--app-shadow-soft);
}

.app-shell .app-message-success {
    border-color: rgba(101, 240, 173, 0.24);
    background: rgba(101, 240, 173, 0.10);
    color: #d1fae5;
}

.app-shell .app-message-error {
    border-color: rgba(255, 77, 109, 0.24);
    background: rgba(255, 77, 109, 0.10);
    color: #ffe4e6;
}

.app-shell .app-message-info {
    border-color: rgba(56, 213, 255, 0.22);
    background: rgba(56, 213, 255, 0.10);
    color: #cffafe;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid var(--app-border);
    background: rgba(7, 5, 16, 0.78);
    box-shadow: 0 18px 56px rgba(0, 0, 0, 0.30);
    backdrop-filter: blur(18px);
}

.app-nav {
    width: min(1280px, calc(100% - 24px));
    min-height: 68px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    position: relative;
}

.app-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--app-text);
    font-weight: 850;
}

.app-brand-mark,
.app-user-avatar {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid rgba(168, 85, 247, 0.48);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 0 28px rgba(168, 85, 247, 0.22);
}

.app-brand-mark img {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

.app-user-avatar {
    overflow: hidden;
    border-radius: 999px;
    color: var(--app-purple);
    font-size: 12px;
}

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

.app-nav-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: none;
}

.app-nav-actions::-webkit-scrollbar {
    display: none;
}

.app-nav-toggle {
    display: none;
    place-items: center;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(168, 85, 247, 0.26);
    border-radius: 12px;
    background: rgba(168, 85, 247, 0.10);
    color: #ffffff;
    font-size: 16px;
}

.app-nav-toggle:hover,
.app-nav-toggle[aria-expanded="true"] {
    border-color: rgba(168, 85, 247, 0.46);
    background: rgba(168, 85, 247, 0.18);
}

.app-nav-link,
.app-logout-button {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 9px 11px;
    color: var(--app-text-2);
    font-size: 14px;
    font-weight: 700;
}

.app-nav-link:hover,
.app-nav-link.is-active {
    border-color: rgba(168, 85, 247, 0.24);
    background: rgba(168, 85, 247, 0.12);
    color: #ffffff;
}

.app-logout-button {
    color: #fb7185;
}

.app-logout-button:hover {
    border-color: rgba(255, 77, 109, 0.24);
    background: rgba(255, 77, 109, 0.10);
    color: #ffe4e6;
}

.app-footer {
    border-top: 1px solid var(--app-border);
    background: rgba(7, 5, 16, 0.72);
    color: var(--app-text-3);
    backdrop-filter: blur(16px);
}

.app-footer-inner {
    width: min(1280px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.app-footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
}

.app-footer a:hover {
    color: #c4b5fd;
}

.auth-shell {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-card {
    position: relative;
    width: min(100%, 448px);
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    padding: clamp(28px, 5vw, 38px);
    overflow: hidden;
    background:
        radial-gradient(circle at 85% 10%, rgba(168, 85, 247, 0.20), transparent 16rem),
        var(--app-surface);
    box-shadow: var(--app-shadow);
}

.auth-card::after {
    content: "";
    position: absolute;
    right: -110px;
    bottom: -130px;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.24), rgba(56, 213, 255, 0.08) 48%, transparent 72%);
    pointer-events: none;
}

.auth-logo {
    position: relative;
    z-index: 1;
    display: grid;
    justify-items: center;
    gap: 12px;
    margin-bottom: 30px;
    text-align: center;
}

.auth-logo-mark {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border: 1px solid rgba(168, 85, 247, 0.48);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 0 34px rgba(168, 85, 247, 0.26);
}

.auth-logo-mark img {
    width: 34px;
    height: 34px;
    object-fit: contain;
}

.auth-card > * {
    position: relative;
    z-index: 1;
}

[data-app-reveal] {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 520ms var(--app-ease), transform 520ms var(--app-ease);
}

[data-app-reveal].is-visible {
    opacity: 1;
    transform: translateY(0);
}

@media (hover: hover) and (pointer: fine) {
    .app-shell .bg-white:hover {
        --app-card-x: 78%;
    }

    .app-shell a[class*="rounded"]:hover,
    .app-shell button[class*="rounded"]:not([disabled]):hover {
        box-shadow: 0 16px 44px rgba(168, 85, 247, 0.16);
    }
}

@media (max-width: 760px) {
    .app-nav {
        width: calc(100% - 20px);
        min-height: 64px;
        padding: 10px 0;
    }

    .app-nav-toggle {
        display: grid;
        flex: 0 0 auto;
    }

    .app-nav-actions {
        position: absolute;
        top: calc(100% + 10px);
        right: 0;
        width: min(300px, calc(100vw - 20px));
        display: grid;
        align-items: stretch;
        gap: 4px;
        padding: 8px;
        border: 1px solid var(--app-border);
        border-radius: 16px;
        background: rgba(15, 10, 28, 0.98);
        box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
        backdrop-filter: blur(18px);
        opacity: 0;
        transform: translateY(-8px);
        visibility: hidden;
        pointer-events: none;
        overflow: visible;
        transition: opacity 180ms var(--app-ease), transform 180ms var(--app-ease), visibility 180ms var(--app-ease);
    }

    .app-nav-actions.is-open {
        opacity: 1;
        transform: translateY(0);
        visibility: visible;
        pointer-events: auto;
    }

    .app-nav-actions .hidden {
        display: inline !important;
    }

    .app-nav-actions form,
    .app-nav-link,
    .app-logout-button {
        width: 100%;
    }

    .app-nav-link,
    .app-logout-button {
        justify-content: flex-start;
        min-height: 44px;
    }

    .app-nav-link .truncate {
        max-width: 190px;
    }

    .app-logout-button {
        justify-content: space-between;
    }

    .app-footer-inner {
        align-items: flex-start;
        flex-direction: column;
    }

    .app-main {
        padding-inline: 14px;
    }

    .app-shell table {
        min-width: 620px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    [data-app-reveal] {
        opacity: 1;
        transform: none;
    }
}
