:root {
    --color-bg: #eef2f6;
    --color-surface: #f7f9fc;
    --color-text: #0f172a;
    --color-muted: #5b6b82;
    --color-primary: #0f172a;
    --color-secondary: #3b82f6;
    --color-accent: #10b981;
    --color-danger: #ef4444;
    --shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

body.dark {
    --color-bg: #111827;
    --color-surface: #1f2937;
    --color-text: #f9fafb;
    --color-muted: #9ca3af;
    --color-primary: #f9fafb;
    --color-secondary: #60a5fa;
    --color-accent: #34d399;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

body {
    background: var(--color-bg);
    color: var(--color-text);
    font-family: "Inter", "Segoe UI", sans-serif;
}

.content-wrapper h1,
.content-wrapper h2,
.content-wrapper h3,
.content-wrapper h4,
.content-wrapper h5,
.content-wrapper h6,
.content-wrapper p,
.content-wrapper label {
    color: var(--color-text);
}

.sidebar {
    background: #e9eef5;
    color: #1f2937;
    min-height: 100vh;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

body.dark .sidebar {
    background: #0f172a;
    color: #e2e8f0;
}

.sidebar .user-meta {
    color: #1f2937;
    font-weight: 600;
}

.sidebar .user-meta small {
    color: #475569;
    font-weight: 500;
}

body.dark .sidebar .user-meta {
    color: #e2e8f0;
}

body.dark .sidebar .user-meta small {
    color: #cbd5f5;
}

.sidebar .nav-link {
    color: #1f2937;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 6px;
    transition: all 0.2s ease;
}

.sidebar .nav-link.active,
.sidebar .nav-link:hover {
    background: var(--color-secondary);
    color: #fff;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 12px;
}

.sidebar-footer .theme-toggle {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 12px;
}

.sidebar .nav-link.active,
.sidebar .nav-link:hover {
    background: var(--color-secondary);
    color: #fff;
}

body.dark .sidebar .nav-link {
    color: rgba(226, 232, 240, 0.85);
}

body.dark .sidebar .nav-link.active,
body.dark .sidebar .nav-link:hover {
    background: #1e40af;
    color: #fff;
}

.content-wrapper {
    padding: 24px;
}

.card {
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 16px;
    background: var(--color-surface);
    box-shadow: var(--shadow);
}

.card .table-responsive {
    overflow: visible;
}

#client-suggestions,
.product-suggestions {
    z-index: 30;
    max-height: 220px;
    overflow-y: auto;
    top: 100%;
    left: 0;
}
body.dark .card {
    background: #1e293b;
}

.card h1,
.card h2,
.card h3,
.card h4,
.card h5,
.card h6,
.card p {
    color: var(--color-text);
}

.card ul,
.card li {
    color: var(--color-text);
}

body.dark .card ul,
body.dark .card li {
    color: #e2e8f0;
}

.import-result-stats {
    color: var(--color-text);
}

body.dark .import-result-stats {
    color: #e2e8f0;
}

.detail-card {
    background: rgba(15, 23, 42, 0.08);
}

body.dark .detail-card {
    background: rgba(148, 163, 184, 0.12);
}

.detail-card strong {
    color: var(--color-text);
}

body.dark .detail-card strong {
    color: #e2e8f0;
}

.totals-summary {
    color: var(--color-text);
}

body.dark .totals-summary {
    color: #e2e8f0;
}

.detail-card {
    color: var(--color-text);
}

body.dark .detail-card {
    color: #e2e8f0;
}


.card-header {
    background: transparent;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    font-weight: 600;
}

body.dark .card-header {
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
}

.text-muted {
    color: var(--color-muted) !important;
}

body.dark .text-muted {
    color: #cbd5f5 !important;
}

.stat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.stat-card.centered {
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.stat-card.centered .icon {
    margin-top: 8px;
}

.stat-card h4 {
    color: var(--color-text);
    font-weight: 700;
}

body.dark .stat-card h4 {
    color: #f8fafc;
}

.stat-card small {
    color: var(--color-muted);
}

.stat-card .icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(59, 130, 246, 0.12);
    color: var(--color-secondary);
}

.kpi-help {
    position: absolute;
    right: 10px;
    bottom: 8px;
    font-size: 14px;
    color: var(--color-muted);
    cursor: help;
}

.kpi-help:hover {
    color: var(--color-secondary);
}

body.dark .kpi-help {
    color: #cbd5f5;
}

.tooltip .tooltip-inner {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(16, 185, 129, 0.12));
    color: var(--color-text);
    border: 1px solid rgba(59, 130, 246, 0.25);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.18);
    padding: 10px 12px;
    font-size: 0.85rem;
    border-radius: 10px;
}

.tooltip .tooltip-arrow::before {
    border-top-color: rgba(59, 130, 246, 0.4);
}

body.dark .tooltip .tooltip-inner {
    background: linear-gradient(135deg, rgba(30, 64, 175, 0.35), rgba(16, 185, 129, 0.25));
    border-color: rgba(148, 163, 184, 0.25);
    color: #f8fafc;
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.35);
}

.badge-soft {
    background: rgba(16, 185, 129, 0.12);
    color: var(--color-accent);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.75rem;
}

.table {
    color: var(--color-text);
    --bs-table-bg: var(--color-surface);
    --bs-table-color: var(--color-text);
}

body.dark .table {
    color: #e2e8f0;
    --bs-table-bg: #1e293b;
    --bs-table-color: #e2e8f0;
}

.table thead th {
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    color: var(--color-text);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.table tbody tr {
    border-color: rgba(148, 163, 184, 0.12);
}

body.dark .table thead th {
    color: #e2e8f0;
}

body.dark .table tbody tr {
    border-color: rgba(148, 163, 184, 0.2);
}

.table td,
.table th {
    color: var(--color-text) !important;
}

body.dark .table td,
body.dark .table th {
    color: #e2e8f0 !important;
}

.table td *,
.table th * {
    color: inherit !important;
}

body.dark .table thead th {
    color: #f8fafc !important;
}

body.dark .table tbody td {
    color: #e2e8f0 !important;
}

body.dark .table,
body.dark .table thead,
body.dark .table tbody,
body.dark .table tr {
    background-color: #1e293b;
}

body.dark .table-hover tbody tr:hover {
    background-color: rgba(30, 64, 175, 0.25);
}

.table tbody tr td {
    vertical-align: middle;
}

.table-form {
    display: contents;
}

.category-card {
    border-radius: 16px;
    color: var(--color-text);
}

.category-title {
    font-weight: 600;
    letter-spacing: 0.4px;
    color: var(--color-text);
}

body.dark .category-card {
    color: #e2e8f0;
}

body.dark .category-title {
    color: #e2e8f0;
}

body.dark .modal-content {
    background: #0f172a;
    color: #e2e8f0;
    border: 1px solid #1f2a44;
}

body.dark .modal-header,
body.dark .modal-footer {
    border-color: #1f2a44;
}

body.dark .modal-title {
    color: #e2e8f0;
}

body.dark .modal .form-control,
body.dark .modal .form-select {
    background: #111827;
    color: #e2e8f0;
    border-color: #223046;
}

body.dark .modal .form-control::placeholder {
    color: #94a3b8;
}

.table-responsive.audit-scroll {
    max-height: 650px;
    overflow-y: auto !important;
    overflow-x: auto;
    display: block;
    scrollbar-gutter: stable both-edges;
    scrollbar-width: thin;
    -ms-overflow-style: scrollbar;
}

.table-responsive.audit-scroll::-webkit-scrollbar {
    width: 10px;
}

.table-responsive.audit-scroll::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.5);
    border-radius: 8px;
}

body.dark .table-responsive.audit-scroll::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.8);
}

.audit-card {
    max-height: none;
    overflow: hidden;
}

.audit-scroll thead th {
    position: sticky;
    top: 0;
    background: inherit;
    z-index: 2;
}

.products-scroll {
    max-height: calc(100vh - 360px);
}

 .product-toggle {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
 }

 .product-details-row td {
    background: rgba(148, 163, 184, 0.08);
 }

 body.dark .product-details-row td {
    background: rgba(30, 64, 175, 0.12);
 }

 .product-details {
    display: flex;
    gap: 16px;
    padding: 12px;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 180ms ease, transform 180ms ease;
 }

.product-details-wrap {
    max-height: 0;
    overflow: hidden;
    transition: max-height 220ms ease;
}

.product-details-row.is-collapsed {
    display: none;
}

.product-details-row.is-expanding .product-details,
.product-details-row:not(.is-collapsed) .product-details {
    opacity: 1;
    transform: translateY(0);
}

.product-details-row.is-collapsed .product-details {
    opacity: 0;
    transform: translateY(-6px);
}

.product-toggle.is-open i {
    transform: rotate(180deg);
    transition: transform 180ms ease;
}

.product-toggle i {
    transition: transform 180ms ease;
}
 .product-details-image {
    width: 140px;
    min-width: 140px;
    height: 140px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    background: var(--color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
 }

 .product-details-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
 }

 .product-details-content {
    flex: 1;
 }


.product-search {
    position: relative;
}

.product-search-list {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--color-surface);
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 10px;
    box-shadow: var(--shadow);
    max-height: 240px;
    overflow-y: auto;
    display: none;
    z-index: 20;
}

.product-search-item,
.product-search-empty {
    padding: 8px 12px;
    cursor: pointer;
    color: var(--color-text);
}

.product-search-item:hover {
    background: rgba(148, 163, 184, 0.2);
}

body.dark .product-search-list {
    background: #1e293b;
    border-color: rgba(148, 163, 184, 0.25);
}

body.dark .product-search-item:hover {
    background: rgba(30, 64, 175, 0.2);
}

.product-search-empty {
    cursor: default;
    color: var(--color-muted);
}

body.dark .product-details-image {
    background: #1e293b;
    border-color: rgba(148, 163, 184, 0.25);
}

.table-hover tbody tr:hover {
    background: rgba(148, 163, 184, 0.12);
}

body.dark .table-hover tbody tr:hover {
    background: rgba(30, 64, 175, 0.15);
}

.btn-primary {
    background: var(--color-secondary);
    border: none;
}

body.dark .btn-primary {
    background: #2563eb;
}

.btn-outline-secondary,
.btn-outline-primary {
    border-radius: 10px;
}

.btn-outline-primary {
    color: var(--color-secondary);
    border-color: var(--color-secondary);
}

body.dark .btn-outline-primary {
    color: #93c5fd;
    border-color: #60a5fa;
}

.btn-outline-secondary {
    color: var(--color-muted);
    border-color: rgba(148, 163, 184, 0.4);
}

body.dark .btn-outline-secondary {
    color: #cbd5f5;
    border-color: rgba(148, 163, 184, 0.5);
}

.page-link {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: rgba(148, 163, 184, 0.4);
}

.page-link:hover {
    color: var(--color-text);
    background: rgba(148, 163, 184, 0.12);
}

.page-item.active .page-link {
    background: var(--color-secondary);
    border-color: var(--color-secondary);
    color: #ffffff;
}

body.dark .page-link {
    background: #1e293b;
    color: #f8fafc;
    border-color: rgba(148, 163, 184, 0.3);
}

body.dark .page-link:hover {
    background: rgba(148, 163, 184, 0.18);
}

body.dark .page-item.active .page-link {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}

.form-control,
.form-select {
    background: var(--color-surface);
    color: var(--color-text);
}

input[name="notes"],
#discount_type,
#discount_value {
    background: transparent;
    border: none;
    border-bottom: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 0;
    box-shadow: none !important;
}

input[name="notes"]:focus,
#discount_type:focus,
#discount_value:focus {
    border-bottom-color: var(--color-secondary);
}

body.dark input[name="notes"],
body.dark #discount_type,
body.dark #discount_value {
    border-bottom-color: rgba(148, 163, 184, 0.4);
}

body.dark .form-control,
body.dark .form-select {
    background: #1e293b;
    color: #f8fafc;
    border-color: rgba(148, 163, 184, 0.3);
}

body.dark .form-control::placeholder,
body.dark .form-select::placeholder {
    color: #94a3b8;
}

body.dark .form-check strong,
body.dark .form-check small {
    color: #e2e8f0;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    opacity: 0.7;
}

body.dark input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    opacity: 0.8;
}

.form-label {
    color: var(--color-text);
    font-weight: 600;
}

body.dark .form-label {
    color: #e2e8f0;
}

body.dark .form-control:focus,
body.dark .form-select:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 0.2rem rgba(96, 165, 250, 0.25);
}

.badge.bg-secondary {
    background: rgba(100, 116, 139, 0.15) !important;
    color: var(--color-text) !important;
}

body.dark .badge.bg-secondary {
    background: rgba(148, 163, 184, 0.25) !important;
    color: #e2e8f0 !important;
}

.badge.bg-light {
    background: rgba(148, 163, 184, 0.15) !important;
    color: var(--color-text) !important;
}

body.dark .badge.bg-light {
    background: rgba(148, 163, 184, 0.25) !important;
    color: #e2e8f0 !important;
}

.list-group-item {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: rgba(148, 163, 184, 0.15);
}

body.dark .list-group-item {
    background: #1e293b;
    color: #e2e8f0;
    border-color: rgba(148, 163, 184, 0.2);
}

#client-suggestions,
.product-suggestions {
    z-index: 30;
    max-height: 220px;
    overflow-y: auto;
}


.alert {
    border-radius: 12px;
}

body.dark .alert {
    color: #e2e8f0;
}

.alert-success {
    background: rgba(16, 185, 129, 0.12);
    color: #0f766e;
    border: 1px solid rgba(16, 185, 129, 0.25);
}

body.dark .alert-success {
    background: rgba(16, 185, 129, 0.2);
    color: #d1fae5;
    border-color: rgba(16, 185, 129, 0.35);
}

.alert-danger {
    background: rgba(239, 68, 68, 0.12);
    color: #b91c1c;
    border: 1px solid rgba(239, 68, 68, 0.25);
}

body.dark .alert-danger {
    background: rgba(239, 68, 68, 0.2);
    color: #fee2e2;
    border-color: rgba(239, 68, 68, 0.35);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.15);
    color: #92400e;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

body.dark .alert-warning {
    background: rgba(245, 158, 11, 0.25);
    color: #fde68a;
    border-color: rgba(245, 158, 11, 0.4);
}

.text-muted {
    color: var(--color-muted) !important;
}

a {
    color: inherit;
}

body.dark a {
    color: #93c5fd;
}
.btn-accent {
    background: var(--color-accent);
    color: #fff;
    border: none;
}

.btn-compact {
    padding: 6px 14px;
    font-size: 0.85rem;
}

.alert-soft {
    background: rgba(59, 130, 246, 0.1);
    border: none;
    color: var(--color-secondary);
}

.greeting-card {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(16, 185, 129, 0.12));
    border: 1px solid rgba(59, 130, 246, 0.18);
}

.greeting-title {
    font-size: 1.1rem;
    font-weight: 600;
}

body.dark .greeting-card {
    background: linear-gradient(135deg, rgba(30, 64, 175, 0.25), rgba(16, 185, 129, 0.18));
    border-color: rgba(148, 163, 184, 0.2);
}

.form-control,
.form-select {
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.3);
}

.chart-mode-select {
    min-width: 120px;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
}

body.dark .login-page {
    position: relative;
    background: radial-gradient(circle at top, rgba(148, 163, 184, 0.2), rgba(15, 23, 42, 0.6)),
        linear-gradient(135deg, #1f2937 0%, #0f172a 100%);
    overflow: hidden;
}

body.dark .login-page::before {
    content: "";
    position: absolute;
    inset: -40px;
    background: radial-gradient(circle at 20% 20%, rgba(148, 163, 184, 0.25), transparent 45%),
        radial-gradient(circle at 80% 30%, rgba(148, 163, 184, 0.18), transparent 40%),
        radial-gradient(circle at 60% 80%, rgba(148, 163, 184, 0.2), transparent 45%);
    filter: blur(28px);
    opacity: 0.7;
    pointer-events: none;
}

body.dark .login-page .container {
    position: relative;
    z-index: 1;
}

.login-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(148, 163, 184, 0.4);
}

body.dark .login-card {
    background: rgba(15, 23, 42, 0.85);
    border-color: rgba(148, 163, 184, 0.2);
}

.login-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.08);
    color: var(--color-text);
    font-size: 28px;
}

body.dark .login-avatar {
    background: rgba(148, 163, 184, 0.18);
    color: #e2e8f0;
}

.input-icon {
    position: relative;
}

.input-icon i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-muted);
}

.input-icon .form-control {
    padding-left: 38px;
}

.footer-note {
    font-size: 0.8rem;
    color: var(--color-muted);
}
