:root {
    --tm-primary: #6C3AED;
    --tm-primary-light: #8B5CF6;
    --tm-primary-soft: #EDE9FE;
    --tm-accent: #06D6A0;
    --tm-accent-dark: #04B886;
    --tm-dark: #0F0A1E;
    --tm-gray: #6B7280;
    --tm-gray-light: #F3F4F6;
    --tm-white: #FFFFFF;
    --tm-off-white: #FAFAFE;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background: var(--tm-off-white);
    color: var(--tm-dark);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navbar */
.tm-navbar {
    background: linear-gradient(135deg, var(--tm-dark) 0%, #1a1030 100%);
    padding: 0.5rem 1rem;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

.tm-brand-text {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 1.4rem;
    letter-spacing: -0.5px;
}

.tm-navbar .nav-link {
    color: rgba(255,255,255,0.7) !important;
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.6rem 1rem !important;
    border-radius: 8px;
    transition: all 0.2s;
}

.tm-navbar .nav-link:hover,
.tm-navbar .nav-link.active {
    color: #fff !important;
    background: rgba(108, 58, 237, 0.3);
}

.tm-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--tm-primary), var(--tm-accent));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    text-transform: uppercase;
}

/* Main Content */
.tm-main {
    flex: 1;
    padding: 0;
}

/* Footer */
.tm-footer {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--tm-gray);
    border-top: 1px solid rgba(0,0,0,0.06);
}

/* Cards */
.tm-card {
    background: white;
    border: 1px solid rgba(0,0,0,0.06);
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: all 0.3s ease;
}

.tm-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}

.tm-card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tm-card-body {
    padding: 1.5rem;
}

/* Page Headers */
.tm-page-header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tm-page-title {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1.6rem;
    color: var(--tm-dark);
    margin: 0;
}

/* Buttons */
.btn-tm-primary {
    background: linear-gradient(135deg, var(--tm-primary), #5B2FCC);
    border: none;
    color: white;
    font-weight: 600;
    padding: 0.5rem 1.25rem;
    border-radius: 10px;
    transition: all 0.3s;
}

.btn-tm-primary:hover {
    background: linear-gradient(135deg, var(--tm-primary-light), var(--tm-primary));
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(108, 58, 237, 0.3);
}

.btn-tm-accent {
    background: var(--tm-accent);
    border: none;
    color: white;
    font-weight: 600;
    padding: 0.5rem 1.25rem;
    border-radius: 10px;
    transition: all 0.3s;
}

.btn-tm-accent:hover {
    background: var(--tm-accent-dark);
    color: white;
    transform: translateY(-1px);
}

.btn-tm-outline {
    background: transparent;
    border: 1px solid rgba(0,0,0,0.12);
    color: var(--tm-dark);
    font-weight: 500;
    padding: 0.5rem 1.25rem;
    border-radius: 10px;
    transition: all 0.2s;
}

.btn-tm-outline:hover {
    border-color: var(--tm-primary);
    color: var(--tm-primary);
    background: var(--tm-primary-soft);
}

/* Stat Cards */
.tm-stat-card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid rgba(0,0,0,0.06);
    transition: all 0.3s;
}

.tm-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.06);
}

.tm-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

.tm-stat-icon.purple { background: var(--tm-primary-soft); color: var(--tm-primary); }
.tm-stat-icon.green { background: #D1FAE5; color: #059669; }
.tm-stat-icon.blue { background: #DBEAFE; color: #2563EB; }
.tm-stat-icon.orange { background: #FED7AA; color: #EA580C; }

.tm-stat-value {
    font-family: 'Outfit', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--tm-dark);
    line-height: 1;
}

.tm-stat-label {
    font-size: 0.85rem;
    color: var(--tm-gray);
    font-weight: 500;
}

/* DataTables styling */
.dataTables_wrapper .dataTables_filter input {
    border-radius: 10px;
    border: 1px solid rgba(0,0,0,0.12);
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--tm-primary);
    box-shadow: 0 0 0 3px var(--tm-primary-soft);
    outline: none;
}

table.dataTable thead th {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--tm-gray);
    border-bottom: 2px solid rgba(0,0,0,0.06) !important;
}

table.dataTable tbody td {
    font-size: 0.9rem;
    padding: 0.75rem !important;
    vertical-align: middle;
}

/* Badge styles */
.badge-ad { background: var(--tm-primary-soft); color: var(--tm-primary); font-weight: 600; }
.badge-local { background: #D1FAE5; color: #059669; font-weight: 600; }
.badge-pending { background: #FEF3C7; color: #D97706; font-weight: 600; }
.badge-synced { background: #D1FAE5; color: #059669; font-weight: 600; }
.badge-removed { background: #FEE2E2; color: #DC2626; font-weight: 600; }

/* Login page */
.tm-login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--tm-dark) 0%, #1a1030 50%, var(--tm-dark) 100%);
    position: relative;
    overflow: hidden;
}

.tm-login-wrapper::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(108,58,237,0.15) 0%, transparent 70%);
    top: -200px;
    right: -200px;
}

.tm-login-wrapper::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(6,214,160,0.1) 0%, transparent 70%);
    bottom: -100px;
    left: -100px;
}

.tm-login-card {
    background: white;
    border-radius: 24px;
    padding: 3rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.3);
    position: relative;
    z-index: 1;
}

.tm-login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.tm-login-logo .tm-brand-text {
    font-size: 2rem;
}

.tm-login-tagline {
    font-family: 'Playfair Display', serif;
    font-style: italic;
    font-size: 0.9rem;
    color: var(--tm-gray);
    text-align: center;
    margin-top: 0.5rem;
}

.tm-form-control {
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.1);
    padding: 0.65rem 1rem;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.tm-form-control:focus {
    border-color: var(--tm-primary);
    box-shadow: 0 0 0 3px var(--tm-primary-soft);
}

/* Tabs */
.tm-tabs .nav-link {
    color: var(--tm-gray);
    font-weight: 600;
    border: none;
    padding: 0.75rem 1.25rem;
    border-bottom: 2px solid transparent;
    border-radius: 0;
}

.tm-tabs .nav-link.active {
    color: var(--tm-primary);
    border-bottom-color: var(--tm-primary);
    background: transparent;
}

/* Resistor color classes */
.rc-0 { background-color: #000000 !important; color: #FFFFFF !important; }
.rc-1 { background-color: #A52A2A !important; color: #FFFFFF !important; }
.rc-2 { background-color: #FF0000 !important; color: #FFFFFF !important; }
.rc-3 { background-color: #FFA500 !important; color: #000000 !important; }
.rc-4 { background-color: #FFFF00 !important; color: #000000 !important; }
.rc-5 { background-color: #008000 !important; color: #FFFFFF !important; }
.rc-6 { background-color: #0000FF !important; color: #FFFFFF !important; }
.rc-7 { background-color: #EE82EE !important; color: #000000 !important; }
.rc-8 { background-color: #808080 !important; color: #FFFFFF !important; }
.rc-9 { background-color: #FFFFFF !important; color: #000000 !important; border: 1px solid #ccc; }

/* Modal styling */
.modal-content {
    border-radius: 16px;
    border: none;
    box-shadow: 0 24px 64px rgba(0,0,0,0.15);
}

.modal-header {
    border-bottom: 1px solid rgba(0,0,0,0.06);
    padding: 1.25rem 1.5rem;
}

.modal-title {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
}

/* Theme toggle */
.tm-theme-toggle {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.7);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.1rem;
}

.tm-theme-toggle:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

/* ===== DARK THEME ===== */
[data-theme="dark"] {
    --tm-dark: #E5E7EB;
    --tm-gray: #9CA3AF;
    --tm-gray-light: #1F2937;
    --tm-white: #111827;
    --tm-off-white: #0F172A;
    --tm-primary-soft: rgba(108,58,237,0.2);
}

[data-theme="dark"] body {
    background: #0F172A;
    color: #E5E7EB;
}

[data-theme="dark"] .tm-card,
[data-theme="dark"] .tm-stat-card {
    background: #1E293B;
    border-color: rgba(255,255,255,0.06);
}

[data-theme="dark"] .tm-card:hover,
[data-theme="dark"] .tm-stat-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

[data-theme="dark"] .tm-card-header {
    border-bottom-color: rgba(255,255,255,0.06);
}

[data-theme="dark"] .tm-page-title {
    color: #F3F4F6;
}

[data-theme="dark"] .tm-stat-value {
    color: #F3F4F6;
}

[data-theme="dark"] .tm-footer {
    border-top-color: rgba(255,255,255,0.06);
    color: #6B7280;
}

/* Dark: Forms */
[data-theme="dark"] .tm-form-control,
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background: #1E293B;
    border-color: rgba(255,255,255,0.12);
    color: #E5E7EB;
}

[data-theme="dark"] .tm-form-control:focus,
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background: #1E293B;
    border-color: var(--tm-primary);
    color: #E5E7EB;
}

[data-theme="dark"] .form-control::placeholder {
    color: #6B7280;
}

[data-theme="dark"] .form-check-input {
    background-color: #374151;
    border-color: rgba(255,255,255,0.15);
}

/* Dark: Tables */
[data-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: #E5E7EB;
    --bs-table-hover-bg: rgba(255,255,255,0.04);
    --bs-table-border-color: rgba(255,255,255,0.06);
}

[data-theme="dark"] table.dataTable thead th {
    color: #9CA3AF;
    border-bottom-color: rgba(255,255,255,0.08) !important;
}

[data-theme="dark"] .dataTables_wrapper .dataTables_filter input {
    background: #1E293B;
    border-color: rgba(255,255,255,0.12);
    color: #E5E7EB;
}

[data-theme="dark"] .dataTables_wrapper .dataTables_info,
[data-theme="dark"] .dataTables_wrapper .dataTables_length label {
    color: #9CA3AF;
}

[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button {
    color: #9CA3AF !important;
}

[data-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--tm-primary) !important;
    border-color: var(--tm-primary) !important;
    color: #fff !important;
}

/* Dark: Modals */
[data-theme="dark"] .modal-content {
    background: #1E293B;
    border: 1px solid rgba(255,255,255,0.08);
}

[data-theme="dark"] .modal-header {
    border-bottom-color: rgba(255,255,255,0.06);
}

[data-theme="dark"] .modal-title {
    color: #F3F4F6;
}

[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Dark: Outline button */
[data-theme="dark"] .btn-tm-outline {
    border-color: rgba(255,255,255,0.15);
    color: #D1D5DB;
}

[data-theme="dark"] .btn-tm-outline:hover {
    border-color: var(--tm-primary-light);
    color: var(--tm-primary-light);
    background: rgba(108,58,237,0.15);
}

/* Dark: Tabs */
[data-theme="dark"] .tm-tabs .nav-link {
    color: #9CA3AF;
}

[data-theme="dark"] .tm-tabs .nav-link.active {
    color: var(--tm-primary-light);
    border-bottom-color: var(--tm-primary-light);
}

/* Dark: Alerts */
[data-theme="dark"] .alert {
    border: none;
}

/* Dark: Dropdown */
[data-theme="dark"] .dropdown-menu {
    background: #1E293B;
    border-color: rgba(255,255,255,0.08);
}

[data-theme="dark"] .dropdown-item {
    color: #D1D5DB;
}

[data-theme="dark"] .dropdown-item:hover {
    background: rgba(255,255,255,0.06);
    color: #F3F4F6;
}

[data-theme="dark"] .dropdown-divider {
    border-color: rgba(255,255,255,0.06);
}

/* Dark: Stat icon backgrounds */
[data-theme="dark"] .tm-stat-icon.purple { background: rgba(108,58,237,0.2); }
[data-theme="dark"] .tm-stat-icon.green { background: rgba(5,150,105,0.2); }
[data-theme="dark"] .tm-stat-icon.blue { background: rgba(37,99,235,0.2); }
[data-theme="dark"] .tm-stat-icon.orange { background: rgba(234,88,12,0.2); }

/* Dark: Login card */
[data-theme="dark"] .tm-login-card {
    background: #1E293B;
}

[data-theme="dark"] .tm-login-card .form-label {
    color: #D1D5DB;
}

/* Dark: misc text */
[data-theme="dark"] .text-muted {
    color: #6B7280 !important;
}

[data-theme="dark"] hr {
    border-color: rgba(255,255,255,0.06);
}

[data-theme="dark"] .form-label {
    color: #D1D5DB;
}

/* Responsive */
@media (max-width: 768px) {
    .tm-page-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    .tm-login-card {
        margin: 1rem;
        padding: 2rem;
    }
}
