:root {
    color-scheme: light;
    --font-sans: 'Inter', sans-serif;
    --font-display: 'Rajdhani', 'Inter', sans-serif;

    --bg: #f8fafc;
    --bg-secondary: #eef2ff;
    --bg-accent: rgba(31, 116, 255, 0.08);
    --surface: rgba(255, 255, 255, 0.94);
    --surface-secondary: rgba(248, 250, 252, 0.92);
    --surface-muted: rgba(238, 242, 255, 0.88);
    --surface-glass: rgba(255, 255, 255, 0.78);
    --border: rgba(15, 23, 42, 0.08);
    --border-strong: rgba(15, 23, 42, 0.12);
    --text: #0f172a;
    --text-muted: #475569;
    --text-soft: #64748b;
    --primary: #1f74ff;
    --primary-strong: #1258d6;
    --accent: #e51e2a;
    --premium: #d4af37;
    --success: #0f9f68;
    --warning: #d97706;
    --danger: #dc2626;
    --focus-ring: 0 0 0 4px rgba(31, 116, 255, 0.16);
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 10px 30px rgba(15, 23, 42, 0.07), 0 2px 8px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 18px 40px rgba(15, 23, 42, 0.1), 0 6px 18px rgba(15, 23, 42, 0.06);
    --shadow-glow: 0 0 0 1px rgba(31, 116, 255, 0.12), 0 18px 36px rgba(31, 116, 255, 0.2);
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 20px;
    --radius-pill: 999px;
    --field-bg: rgba(255, 255, 255, 0.82);
    --field-bg-strong: rgba(255, 255, 255, 0.96);
    --field-text: var(--text);
    --header-bg: rgba(255, 255, 255, 0.76);
    --sidebar-bg: rgba(255, 255, 255, 0.82);
    --nav-hover: rgba(31, 116, 255, 0.08);
    --nav-active: rgba(31, 116, 255, 0.12);
    --nav-active-border: rgba(31, 116, 255, 0.18);
}

html[data-theme='dark'],
body[data-theme='dark'] {
    color-scheme: dark;
    --bg: #050816;
    --bg-secondary: #0c192c;
    --bg-accent: rgba(31, 116, 255, 0.14);
    --surface: rgba(17, 24, 39, 0.94);
    --surface-secondary: rgba(12, 25, 44, 0.92);
    --surface-muted: rgba(17, 24, 39, 0.82);
    --surface-glass: rgba(12, 25, 44, 0.76);
    --border: rgba(255, 255, 255, 0.06);
    --border-strong: rgba(255, 255, 255, 0.1);
    --text: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.72);
    --text-soft: rgba(255, 255, 255, 0.52);
    --primary: #1f74ff;
    --primary-strong: #5b97ff;
    --accent: #e51e2a;
    --premium: #ffd700;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #f87171;
    --focus-ring: 0 0 0 4px rgba(31, 116, 255, 0.22);
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.26);
    --shadow-sm: 0 20px 40px rgba(0, 0, 0, 0.24), 0 8px 24px rgba(0, 0, 0, 0.18);
    --shadow-md: 0 24px 54px rgba(0, 0, 0, 0.34), 0 10px 26px rgba(0, 0, 0, 0.24);
    --shadow-glow: 0 0 0 1px rgba(31, 116, 255, 0.22), 0 18px 42px rgba(31, 116, 255, 0.2);
    --field-bg: rgba(255, 255, 255, 0.03);
    --field-bg-strong: rgba(255, 255, 255, 0.05);
    --field-text: var(--text);
    --header-bg: rgba(5, 8, 22, 0.78);
    --sidebar-bg: rgba(8, 13, 28, 0.88);
    --nav-hover: rgba(31, 116, 255, 0.12);
    --nav-active: rgba(31, 116, 255, 0.18);
    --nav-active-border: rgba(31, 116, 255, 0.24);
}

html {
    background: var(--bg);
}

body,
body[data-theme] {
    font-family: var(--font-sans);
    background:
        radial-gradient(circle at top left, rgba(31, 116, 255, 0.12), transparent 28%),
        radial-gradient(circle at top right, rgba(229, 30, 42, 0.08), transparent 24%),
        linear-gradient(180deg, var(--bg) 0%, var(--bg-secondary) 100%);
    color: var(--text);
}

body[data-theme] * {
    box-sizing: border-box;
}

body[data-theme]::selection {
    background: rgba(31, 116, 255, 0.24);
    color: var(--text);
}

body[data-theme] ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

body[data-theme] ::-webkit-scrollbar-track {
    background: transparent;
}

body[data-theme] ::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.34);
    border: 2px solid transparent;
    border-radius: 999px;
    background-clip: padding-box;
}

body[data-theme='dark'] ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.14);
    background-clip: padding-box;
}

body[data-theme] h1,
body[data-theme] h2,
body[data-theme] h3,
body[data-theme] h4,
body[data-theme] .logo-text,
body[data-theme] #pageTitleDisplay,
body[data-theme] [class*='tracking-tight'] {
    font-family: var(--font-display);
    letter-spacing: 0.01em;
}

body[data-theme] a,
body[data-theme] button,
body[data-theme] input,
body[data-theme] select,
body[data-theme] textarea {
    transition:
        background-color 0.18s ease,
        border-color 0.18s ease,
        color 0.18s ease,
        box-shadow 0.18s ease,
        transform 0.18s ease,
        opacity 0.18s ease;
}

body[data-theme] button:active,
body[data-theme] .btn-submit:active,
body[data-theme] a:active {
    transform: scale(0.98);
}

body[data-theme] input,
body[data-theme] select,
body[data-theme] textarea {
    background: var(--field-bg) !important;
    color: var(--field-text) !important;
    border-color: var(--border) !important;
    border-radius: 14px !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

body[data-theme='dark'] input,
body[data-theme='dark'] select,
body[data-theme='dark'] textarea {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

body[data-theme] input::placeholder,
body[data-theme] textarea::placeholder {
    color: var(--text-soft) !important;
}

body[data-theme] input:focus,
body[data-theme] select:focus,
body[data-theme] textarea:focus {
    outline: none !important;
    border-color: rgba(31, 116, 255, 0.38) !important;
    box-shadow: var(--focus-ring) !important;
    background: var(--field-bg-strong) !important;
}

body[data-theme] [class*='bg-white'],
body[data-theme] .login-card,
body[data-theme] .downloader-card,
body[data-theme] .copy-row {
    background: var(--surface) !important;
    color: var(--text);
}

body[data-theme='dark'] #createPanel,
body[data-theme='dark'] #modalPanel,
body[data-theme='dark'] #qrPanel,
body[data-theme='dark'] #detailsPanel,
body[data-theme='dark'] .glass-panel,
body[data-theme='dark'] #createModal > div[class*='bg-white'],
body[data-theme='dark'] #planModal > div[class*='bg-white'],
body[data-theme='dark'] #dnsModal > div[class*='bg-white'],
body[data-theme='dark'] #modalCrop > div div[class*='bg-white'],
body[data-theme='dark'] #publicLinksModal > div[class*='bg-white'] {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent), var(--surface-secondary) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

body[data-theme] [class*='bg-slate-50'],
body[data-theme] [class*='bg-slate-50/50'],
body[data-theme] [class*='bg-slate-100'] {
    background: var(--surface-muted) !important;
}

body[data-theme='dark'] [class*='bg-white/95'],
body[data-theme='dark'] [class*='bg-white/90'],
body[data-theme='dark'] [class*='bg-white/80'],
body[data-theme='dark'] [class*='bg-white/70'],
body[data-theme='dark'] [class*='bg-white/60'],
body[data-theme='dark'] [class*='bg-white/50'],
body[data-theme='dark'] [class*='bg-white/40'],
body[data-theme='dark'] [class*='bg-white/30'],
body[data-theme='dark'] [class*='bg-white/20'] {
    background: rgba(12, 25, 44, 0.94) !important;
}

body[data-theme] [class*='bg-blue-50'] {
    background: rgba(31, 116, 255, 0.14) !important;
}

body[data-theme] [class*='bg-red-50'] {
    background: rgba(229, 30, 42, 0.14) !important;
}

body[data-theme] [class*='bg-green-50'],
body[data-theme] [class*='bg-emerald-50'] {
    background: rgba(34, 197, 94, 0.12) !important;
}

body[data-theme] [class*='bg-amber-50'],
body[data-theme] [class*='bg-orange-50'] {
    background: rgba(245, 158, 11, 0.14) !important;
}

body[data-theme] [class*='bg-purple-50'],
body[data-theme] [class*='bg-indigo-50'] {
    background: rgba(139, 92, 246, 0.14) !important;
}

body[data-theme] [class*='text-slate-900'],
body[data-theme] [class*='text-slate-800'],
body[data-theme] [class*='text-slate-700'],
body[data-theme] [class*='text-slate-600'] {
    color: var(--text) !important;
}

body[data-theme] [class*='text-slate-500'],
body[data-theme] [class*='text-slate-400'],
body[data-theme] [class*='text-slate-300'] {
    color: var(--text-muted) !important;
}

body[data-theme='dark'] [class*='text-white'] {
    color: #ffffff !important;
}

body[data-theme] [class*='text-blue-600'],
body[data-theme] [class*='text-blue-500'],
body[data-theme] .text-blue-600 {
    color: var(--primary) !important;
}

body[data-theme] [class*='text-red-600'],
body[data-theme] [class*='text-red-500'] {
    color: var(--accent) !important;
}

body[data-theme] [class*='text-green-600'],
body[data-theme] [class*='text-emerald-600'] {
    color: var(--success) !important;
}

body[data-theme] [class*='border-slate-50'],
body[data-theme] [class*='border-slate-100'],
body[data-theme] [class*='border-slate-200'],
body[data-theme] [class*='border-slate-300'] {
    border-color: var(--border) !important;
}

body[data-theme] [class*='rounded-xl'],
body[data-theme] [class*='rounded-2xl'],
body[data-theme] [class*='rounded-lg'],
body[data-theme] .login-card,
body[data-theme] .btn-action,
body[data-theme] .downloader-card {
    box-shadow: var(--shadow-sm);
}

body[data-theme] .bg-white,
body[data-theme] .login-card,
body[data-theme] .downloader-card,
body[data-theme] [class*='border '] {
    border-color: var(--border) !important;
}

body[data-theme] .bg-white:hover,
body[data-theme] .dns-card:hover,
body[data-theme] .group:hover > .bg-white {
    box-shadow: var(--shadow-md) !important;
}

body[data-theme] [class*='bg-blue-600'],
body[data-theme] .btn-submit,
body[data-theme] .theme-toggle {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%) !important;
    color: #fff !important;
}

body[data-theme] [class*='bg-blue-600']:hover,
body[data-theme] .btn-submit:hover,
body[data-theme] .theme-toggle:hover {
    filter: brightness(1.06);
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow) !important;
}

body[data-theme] [class*='bg-blue-600'][class*='border'],
body[data-theme] .btn-submit {
    border-color: rgba(31, 116, 255, 0.26) !important;
}

body[data-theme] [class*='hover:bg-slate-50']:hover,
body[data-theme] [class*='hover:bg-slate-100']:hover,
body[data-theme] [class*='hover:bg-white']:hover,
body[data-theme] .nav-item:hover,
body[data-theme] tbody tr:hover,
body[data-theme] .btn-action:hover {
    background: var(--nav-hover) !important;
}

body[data-theme='dark'] #createPanel .filter-btn,
body[data-theme='dark'] #createPanel #tabNew,
body[data-theme='dark'] #createPanel #tabLink,
body[data-theme='dark'] #detailsPanel button[class*='bg-white'],
body[data-theme='dark'] #detailsPanel button[class*='hover:bg-slate-50'],
body[data-theme='dark'] #modalPanel button[class*='bg-white'],
body[data-theme='dark'] #createPanel button[class*='bg-white'],
body[data-theme='dark'] #publicLinksModal button[class*='bg-white'] {
    color: var(--text) !important;
    border-color: var(--border) !important;
    background: var(--surface-muted) !important;
}

body[data-theme='dark'] #createPanel .filter-btn.active,
body[data-theme='dark'] #createPanel #tabNew.border-b-2,
body[data-theme='dark'] #createPanel #tabLink.border-b-2 {
    background: var(--nav-active) !important;
    color: var(--primary) !important;
    border-color: var(--nav-active-border) !important;
}

body[data-theme='dark'] #createPanel .bg-green-100,
body[data-theme='dark'] #createPanel .bg-blue-100,
body[data-theme='dark'] #createPanel .bg-red-100,
body[data-theme='dark'] #detailsPanel .bg-green-100,
body[data-theme='dark'] #detailsPanel .bg-blue-100,
body[data-theme='dark'] #detailsPanel .bg-red-100,
body[data-theme='dark'] #modalPanel .bg-green-100,
body[data-theme='dark'] #modalPanel .bg-blue-100,
body[data-theme='dark'] #modalPanel .bg-red-100 {
    background: var(--surface-muted) !important;
}

body[data-theme='dark'] #createPanel [class*='text-green-600'],
body[data-theme='dark'] #detailsPanel [class*='text-green-600'],
body[data-theme='dark'] #modalPanel [class*='text-green-600'] {
    color: var(--success) !important;
}

body[data-theme='dark'] #createPanel [class*='text-red-600'],
body[data-theme='dark'] #detailsPanel [class*='text-red-600'],
body[data-theme='dark'] #modalPanel [class*='text-red-600'] {
    color: var(--accent) !important;
}

body[data-theme='dark'] #detailsPanel [class*='bg-slate-50'],
body[data-theme='dark'] #detailsPanel [class*='bg-slate-100'],
body[data-theme='dark'] #detailsPanel .dynamic-playlist-item,
body[data-theme='dark'] #detailsPanel .p-4.bg-white,
body[data-theme='dark'] #detailsPanel .p-4.bg-slate-50 {
    background: var(--surface-muted) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

body[data-theme='dark'] #detailsPanel [class*='border-slate-50'],
body[data-theme='dark'] #detailsPanel [class*='border-slate-100'],
body[data-theme='dark'] #detailsPanel [class*='border-slate-200'],
body[data-theme='dark'] #detailsPanel [class*='border-slate-300'],
body[data-theme='dark'] .glass-panel {
    border-color: var(--border) !important;
}

body[data-theme='dark'] #detailsPanel .bg-blue-50,
body[data-theme='dark'] #detailsPanel .bg-green-50,
body[data-theme='dark'] #detailsPanel .bg-red-50,
body[data-theme='dark'] #detailsPanel .bg-amber-100,
body[data-theme='dark'] #detailsPanel .bg-slate-100 {
    background: var(--surface-muted) !important;
}

body[data-theme='dark'] #detailsPanel .bg-blue-50.text-blue-700,
body[data-theme='dark'] #detailsPanel .bg-green-50.text-green-700,
body[data-theme='dark'] #detailsPanel .bg-red-50.text-red-700,
body[data-theme='dark'] #detailsPanel .bg-amber-100.text-amber-700 {
    color: var(--text) !important;
}

body[data-theme] .btn-action,
body[data-theme] .copy-row,
body[data-theme] .downloader-header {
    border-color: var(--border) !important;
    color: var(--text) !important;
}

body[data-theme] .btn-download {
    background: var(--surface) !important;
    color: var(--text) !important;
    border-color: var(--border-strong) !important;
}

body[data-theme] .btn-whatsapp {
    background: rgba(34, 197, 94, 0.14) !important;
    border-color: rgba(34, 197, 94, 0.24) !important;
    color: var(--success) !important;
}

body[data-theme] table thead,
body[data-theme] [class*='sticky top-0'] {
    background: var(--surface-secondary) !important;
}

body[data-theme] table,
body[data-theme] td,
body[data-theme] th {
    border-color: var(--border) !important;
}

body[data-theme] .theme-toggle {
    min-width: 120px;
    height: 42px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-glow);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0 14px;
    position: relative;
    overflow: hidden;
}

body[data-theme] .theme-toggle::before {
    content: '';
    position: absolute;
    inset: 1px;
    border-radius: inherit;
    background: rgba(255, 255, 255, 0.08);
}

body[data-theme='light'] .theme-toggle::before,
body[data-theme='light'] .theme-toggle::before {
    background: rgba(255, 255, 255, 0.12);
}

body[data-theme] .theme-toggle > * {
    position: relative;
    z-index: 1;
}

body[data-theme] .theme-toggle-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

body[data-theme] .theme-toggle-icons {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

body[data-theme] .theme-toggle .icon-sun,
body[data-theme] .theme-toggle .icon-moon {
    opacity: 0.5;
    transform: scale(0.92);
}

body[data-theme='dark'] .theme-toggle .icon-moon,
body[data-theme='light'] .theme-toggle .icon-sun {
    opacity: 1;
    transform: scale(1);
}

body[data-theme] #app-sidebar,
body[data-theme] #app-header {
    background: var(--surface-glass) !important;
    backdrop-filter: blur(18px) saturate(1.2);
    border-color: var(--border) !important;
    box-shadow: var(--shadow-sm);
}

body[data-theme] #app-sidebar {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent),
        var(--sidebar-bg) !important;
}

body[data-theme] .nav-item {
    color: var(--text-muted) !important;
    border: 1px solid transparent;
    border-radius: 14px !important;
}

body[data-theme] .nav-item:hover {
    color: var(--text) !important;
}

body[data-theme] .nav-item.active {
    color: var(--primary) !important;
    background: var(--nav-active) !important;
    border-color: var(--nav-active-border) !important;
    box-shadow: 0 8px 18px rgba(31, 116, 255, 0.14);
}

body[data-theme] .category-title {
    color: var(--text-soft) !important;
}

body[data-theme] .login-wrapper {
    max-width: 460px;
}

body[data-theme] .login-card {
    border: 1px solid var(--border) !important;
    border-radius: 24px !important;
    box-shadow: var(--shadow-md) !important;
}

body[data-theme] .login-theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 30;
}

body[data-theme] .brand-section {
    padding-top: 10px;
}

body[data-theme] .logo-img {
    filter: drop-shadow(0 12px 24px rgba(31, 116, 255, 0.18));
}

body[data-theme] .copy-btn:hover,
body[data-theme] a:hover {
    color: var(--primary);
}

body[data-theme] .custom-scrollbar {
    scrollbar-color: rgba(148, 163, 184, 0.4) transparent;
}

@media (max-width: 1023px) {
    body[data-theme] .theme-toggle-label {
        display: none;
    }

    body[data-theme] .theme-toggle {
        min-width: 44px;
        padding: 0 12px;
    }
}

@media (max-width: 767px) {
    body[data-theme] .login-theme-toggle {
        top: 14px;
        right: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    body[data-theme] *,
    body[data-theme] *::before,
    body[data-theme] *::after {
        transition: none !important;
        animation: none !important;
    }
}
