:root {
    --brand-primary: #465fff;
    --brand-hover: #3641f5;
    --brand-light: #ecf3ff;
    --bg-body-light: #f8fafc;
    --card-bg-light: #ffffff;
    --border-light: #e2e8f0;
    --text-main-light: #0f172a;
    --text-muted-light: #64748b;

    --bg-body-dark: #0f172a;
    --card-bg-dark: #1e293b;
    --border-dark: #334155;
    --text-main-dark: #f8fafc;
    --text-muted-dark: #94a3b8;

    --sidebar-width: 270px;
    --header-height: 72px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-body-light);
    color: var(--text-main-light);
    transition: background-color 0.25s ease, color 0.25s ease;
    -webkit-font-smoothing: antialiased;
}

html.dark body, body.dark {
    background-color: var(--bg-body-dark);
    color: var(--text-main-dark);
}

/* Layout Wrapper */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* TailAdmin Sidebar */
.app-sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 50;
    background: #ffffff;
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
}

html.dark .app-sidebar , body.dark .app-sidebar , .dark .app-sidebar {
    background: #111827;
    border-right-color: #1f2937;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.sidebar-header {
    height: var(--header-height);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-light);
}

html.dark .sidebar-header , body.dark .sidebar-header , .dark .sidebar-header {
    border-bottom-color: #1f2937;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
    text-decoration: none;
    letter-spacing: -0.02em;
}

html.dark .sidebar-brand , body.dark .sidebar-brand , .dark .sidebar-brand {
    color: #ffffff;
}

.sidebar-brand-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #465fff 0%, #3641f5 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 1.1rem;
    box-shadow: 0 4px 12px rgba(70, 95, 255, 0.35);
}

.sidebar-nav-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
}

.sidebar-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    padding: 12px 14px 6px;
    margin-top: 8px;
}

html.dark .sidebar-section-title , body.dark .sidebar-section-title , .dark .sidebar-section-title {
    color: #64748b;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-link-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.925rem;
    font-weight: 500;
    color: #475467;
    text-decoration: none;
    transition: all 0.2s ease;
}

html.dark .nav-link-item , body.dark .nav-link-item , .dark .nav-link-item {
    color: #98a2b3;
}

.nav-link-item:hover {
    background: #f1f5f9;
    color: var(--brand-primary);
}

html.dark .nav-link-item:hover , body.dark .nav-link-item:hover , .dark .nav-link-item:hover {
    background: #1f2937;
    color: #ffffff;
}

.nav-link-item.active {
    background: #ecf3ff;
    color: #465fff;
    font-weight: 600;
}

html.dark .nav-link-item.active , body.dark .nav-link-item.active , .dark .nav-link-item.active {
    background: rgba(70, 95, 255, 0.15);
    color: #7592ff;
}

.nav-link-item .nav-icon {
    font-size: 1.1rem;
    width: 20px;
    display: flex;
    justify-content: center;
}

/* Sidebar Footer / User Info */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-light);
}

html.dark .sidebar-footer , body.dark .sidebar-footer , .dark .sidebar-footer {
    border-top-color: #1f2937;
}

/* Main Content Area */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
    transition: margin-left 0.3s ease;
}

/* TailAdmin Top Header */
.app-header {
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 40;
}

html.dark .app-header , body.dark .app-header , .dark .app-header {
    background: rgba(17, 24, 39, 0.85);
    border-bottom-color: #1f2937;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.mobile-sidebar-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: #475467;
    padding: 8px;
    border-radius: 8px;
}

html.dark .mobile-sidebar-btn , body.dark .mobile-sidebar-btn , .dark .mobile-sidebar-btn {
    color: #98a2b3;
}

.header-page-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
    letter-spacing: -0.02em;
}

html.dark .header-page-title , body.dark .header-page-title , .dark .header-page-title {
    color: #ffffff;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Balance Pill Badge */
.balance-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, rgba(70, 95, 255, 0.08) 0%, rgba(54, 65, 245, 0.08) 100%);
    border: 1px solid rgba(70, 95, 255, 0.2);
    border-radius: 9999px;
    font-weight: 600;
    font-size: 0.925rem;
    color: #465fff;
    text-decoration: none;
    transition: all 0.2s;
}

html.dark .balance-pill , body.dark .balance-pill , .dark .balance-pill {
    background: rgba(70, 95, 255, 0.15);
    border-color: rgba(70, 95, 255, 0.3);
    color: #7592ff;
}

.balance-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(70, 95, 255, 0.15);
}

/* Theme Toggle Button */
.theme-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border-light);
    background: #ffffff;
    color: #475467;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

html.dark .theme-btn , body.dark .theme-btn , .dark .theme-btn {
    background: #1f2937;
    border-color: #374151;
    color: #f9fafb;
}

.theme-btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

html.dark .theme-btn:hover , body.dark .theme-btn:hover , .dark .theme-btn:hover {
    background: #374151;
}

/* User Profile Dropdown Pill */
.user-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 6px 6px;
    border-radius: 9999px;
    border: 1px solid var(--border-light);
    background: #ffffff;
    cursor: pointer;
    position: relative;
}

html.dark .user-pill , body.dark .user-pill , .dark .user-pill {
    background: #1f2937;
    border-color: #374151;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

.user-email-text {
    font-size: 0.875rem;
    font-weight: 500;
    color: #344054;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

html.dark .user-email-text , body.dark .user-email-text , .dark .user-email-text {
    color: #f3f4f6;
}

/* Content Container */
.page-content-wrapper {
    padding: 32px;
    flex: 1;
}

/* TailAdmin Card Component */
.ta-card {
    background: #ffffff;
    border: 1px solid #e4e7ec;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.05);
    transition: all 0.2s ease;
}

html.dark .ta-card , body.dark .ta-card , .dark .ta-card {
    background: #111827;
    border-color: #1f2937;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.ta-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.ta-card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #101828;
    margin: 0;
    letter-spacing: -0.01em;
}

html.dark .ta-card-title , body.dark .ta-card-title , .dark .ta-card-title {
    color: #ffffff;
}

.ta-card-subtitle {
    font-size: 0.875rem;
    color: #667085;
    margin-top: 4px;
}

html.dark .ta-card-subtitle , body.dark .ta-card-subtitle , .dark .ta-card-subtitle {
    color: #98a2b3;
}

/* Stat Widgets / Metric Cards */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.metric-card {
    background: #ffffff;
    border: 1px solid #e4e7ec;
    border-radius: 16px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

html.dark .metric-card , body.dark .metric-card , .dark .metric-card {
    background: #111827;
    border-color: #1f2937;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
}

.metric-icon-box {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}

.metric-icon-box.brand {
    background: #ecf3ff;
    color: #465fff;
}

html.dark .metric-icon-box.brand , body.dark .metric-icon-box.brand , .dark .metric-icon-box.brand {
    background: rgba(70, 95, 255, 0.2);
    color: #7592ff;
}

.metric-icon-box.success {
    background: #ecfdf3;
    color: #12b76a;
}

html.dark .metric-icon-box.success , body.dark .metric-icon-box.success , .dark .metric-icon-box.success {
    background: rgba(18, 183, 106, 0.2);
    color: #32d583;
}

.metric-icon-box.warning {
    background: #fff6ed;
    color: #fb6514;
}

html.dark .metric-icon-box.warning , body.dark .metric-icon-box.warning , .dark .metric-icon-box.warning {
    background: rgba(251, 101, 20, 0.2);
    color: #feb273;
}

.metric-icon-box.purple {
    background: #f4f3ff;
    color: #7a5af8;
}

html.dark .metric-icon-box.purple , body.dark .metric-icon-box.purple , .dark .metric-icon-box.purple {
    background: rgba(122, 90, 248, 0.2);
    color: #9b8afb;
}

.metric-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: #667085;
    margin-bottom: 4px;
}

html.dark .metric-title , body.dark .metric-title , .dark .metric-title {
    color: #98a2b3;
}

.metric-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #101828;
    line-height: 1.2;
}

html.dark .metric-value , body.dark .metric-value , .dark .metric-value {
    color: #ffffff;
}

/* TailAdmin Tables */
.ta-table-container {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid #e4e7ec;
}

html.dark .ta-table-container , body.dark .ta-table-container , .dark .ta-table-container {
    border-color: #1f2937;
}

.ta-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.925rem;
}

.ta-table th {
    background: #f9fafb;
    padding: 12px 16px;
    font-weight: 600;
    color: #475467;
    border-bottom: 1px solid #e4e7ec;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

html.dark .ta-table th , body.dark .ta-table th , .dark .ta-table th {
    background: #1f2937;
    color: #98a2b3;
    border-bottom-color: #374151;
}

.ta-table td {
    padding: 16px;
    border-bottom: 1px solid #f2f4f7;
    color: #344054;
}

html.dark .ta-table td , body.dark .ta-table td , .dark .ta-table td {
    border-bottom-color: #1f2937;
    color: #e4e7ec;
}

.ta-table tr:last-child td {
    border-bottom: none;
}

.ta-table tr:hover td {
    background: #f8fafc;
}

html.dark .ta-table tr:hover td , body.dark .ta-table tr:hover td , .dark .ta-table tr:hover td {
    background: #1a2231;
}

/* Badges */
.ta-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 9999px;
    font-size: 0.775rem;
    font-weight: 600;
}

.ta-badge.success {
    background: #ecfdf3;
    color: #027a48;
}

html.dark .ta-badge.success , body.dark .ta-badge.success , .dark .ta-badge.success {
    background: rgba(18, 183, 106, 0.15);
    color: #32d583;
}

.ta-badge.warning {
    background: #fff6ed;
    color: #b93815;
}

html.dark .ta-badge.warning , body.dark .ta-badge.warning , .dark .ta-badge.warning {
    background: rgba(251, 101, 20, 0.15);
    color: #feb273;
}

.ta-badge.danger {
    background: #fef3f2;
    color: #b42318;
}

html.dark .ta-badge.danger , body.dark .ta-badge.danger , .dark .ta-badge.danger {
    background: rgba(240, 68, 56, 0.15);
    color: #fda29b;
}

.ta-badge.brand {
    background: #ecf3ff;
    color: #465fff;
}

html.dark .ta-badge.brand , body.dark .ta-badge.brand , .dark .ta-badge.brand {
    background: rgba(70, 95, 255, 0.15);
    color: #7592ff;
}

/* Modern Form Controls */
.ta-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #d0d5dd;
    border-radius: 10px;
    background: #ffffff;
    color: #101828;
    font-size: 0.925rem;
    transition: all 0.2s ease;
    outline: none;
}

html.dark .ta-input , body.dark .ta-input , .dark .ta-input {
    background: #1f2937;
    border-color: #374151;
    color: #f9fafb;
}

.ta-input:focus {
    border-color: #465fff;
    box-shadow: 0 0 0 3px rgba(70, 95, 255, 0.18);
}

.ta-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 0.925rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
}

.ta-btn-primary {
    background: #465fff;
    color: #ffffff;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}

.ta-btn-primary:hover {
    background: #3641f5;
    box-shadow: 0 4px 12px rgba(70, 95, 255, 0.25);
    transform: translateY(-1px);
}

.ta-btn-secondary {
    background: #ffffff;
    border: 1px solid #d0d5dd;
    color: #344054;
}

html.dark .ta-btn-secondary , body.dark .ta-btn-secondary , .dark .ta-btn-secondary {
    background: #1f2937;
    border-color: #374151;
    color: #f9fafb;
}

.ta-btn-secondary:hover {
    background: #f8fafc;
    border-color: #98a2b3;
}

html.dark .ta-btn-secondary:hover , body.dark .ta-btn-secondary:hover , .dark .ta-btn-secondary:hover {
    background: #374151;
}

.ta-btn-danger {
    background: #f04438;
    color: white;
}

.ta-btn-danger:hover {
    background: #d92d20;
}

.ta-btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: 8px;
}

/* Mobile Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(16, 24, 40, 0.5);
    backdrop-filter: blur(4px);
    z-index: 45;
}

/* Responsive Breakpoints */
@media (max-width: 1024px) {
    .app-sidebar {
        transform: translateX(-100%);
    }
    .app-sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.active {
        display: block;
    }
    .main-wrapper {
        margin-left: 0;
        width: 100%;
    }
    .mobile-sidebar-btn {
        display: block;
    }
    .page-content-wrapper {
        padding: 20px;
    }
    .app-header {
        padding: 0 20px;
    }
}
