:root {
    --primary: #E30613;
    --primary-dark: #C50511;
    --primary-light: #ff4d4d;
    --primary-bg: rgba(227, 6, 19, 0.08);
    --primary-bg-hover: rgba(227, 6, 19, 0.15);
    --dark: #1F1F1F;
    --gray-50: #FAFAFA;
    --gray-100: #F5F5F5;
    --gray-200: #E9ECEF;
    --gray-300: #DEE2E6;
    --gray-400: #CED4DA;
    --gray-500: #ADB5BD;
    --gray-600: #6C757D;
    --gray-700: #495057;
    --gray-800: #343A40;
    --white: #FFFFFF;
    --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.04);
    --shadow-xl: 0 16px 48px rgba(0,0,0,0.12), 0 8px 16px rgba(0,0,0,0.06);
    --ease-out: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background-color: var(--gray-50);
    font-family: var(--font-sans);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: var(--gray-800);
}

main { flex: 1; }

/* ── Navbar (Material) ── */
.navbar.bg-dark {
    background-color: var(--dark) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.navbar {
    padding: 0 1rem;
    min-height: 60px;
}

.navbar-brand {
    letter-spacing: 0.5px;
    font-size: 1.2rem;
    font-weight: 700;
    padding: 0.5rem 0;
}

.navbar .nav-link {
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.5rem 1rem !important;
    border-radius: var(--radius-sm);
    transition: background-color 0.2s var(--ease-out), color 0.2s var(--ease-out);
    position: relative;
}

.navbar .nav-link::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 60%;
    height: 2px;
    background: var(--primary);
    border-radius: 2px;
    transition: transform 0.2s var(--ease-out);
}

.navbar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.navbar .nav-link:hover::after {
    transform: translateX(-50%) scaleX(1);
}

.navbar .nav-link.active {
    background-color: rgba(227, 6, 19, 0.15);
    color: #fff !important;
}

.navbar .nav-link.active::after {
    transform: translateX(-50%) scaleX(1);
}

.navbar .dropdown-menu {
    border: none;
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-md);
    padding: 6px;
    margin-top: 8px;
    animation: dropdownIn 0.15s var(--ease-out);
}

@keyframes dropdownIn {
    from { opacity: 0; transform: translateY(-6px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.navbar .dropdown-item {
    border-radius: var(--radius-sm);
    padding: 0.6rem 0.9rem;
    font-size: 0.875rem;
    transition: background-color 0.15s var(--ease-out);
}

.navbar .dropdown-item:hover {
    background-color: var(--primary-bg);
}

/* ── Theme colors (Material refined) ── */
.bg-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark)) !important;
}

.btn {
    font-weight: 600;
    font-size: 0.875rem;
    padding: 0.55rem 1.25rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s var(--ease-out);
    letter-spacing: 0.2px;
    text-transform: none;
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0);
    transition: background 0.2s var(--ease-out);
}

.btn:hover::after {
    background: rgba(255,255,255,0.08);
}

.btn:active::after {
    background: rgba(255,255,255,0.15);
}

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 2px 8px rgba(227, 6, 19, 0.25);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 4px 16px rgba(227, 6, 19, 0.35);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(227, 6, 19, 0.25);
}

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

.btn-outline-primary:hover {
    background-color: var(--primary-bg);
    border-color: var(--primary);
    color: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--gray-200);
    border-color: var(--gray-300);
    color: var(--gray-700);
    box-shadow: none;
}

.btn-secondary:hover {
    background-color: var(--gray-300);
    border-color: var(--gray-400);
    color: var(--dark);
    transform: translateY(-1px);
}

.btn-outline-secondary {
    border-color: var(--gray-300);
    color: var(--gray-600);
}

.btn-outline-secondary:hover {
    background-color: var(--gray-100);
    border-color: var(--gray-400);
    color: var(--gray-800);
}

.btn-sm {
    font-size: 0.8rem;
    padding: 0.35rem 0.85rem;
}

.btn-lg {
    font-size: 1rem;
    padding: 0.7rem 1.8rem;
    border-radius: var(--radius-md);
}

/* ── Cards (Material) ── */
.card {
    border: 1px solid rgba(0,0,0,0.04);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
    background: var(--white);
}

.card-hoverable:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg) !important;
}

.card-header {
    background-color: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.card-header.bg-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark)) !important;
    color: #fff;
    border-bottom: none;
}

.card-header.bg-primary .btn-close {
    filter: brightness(0) invert(1);
}

.card-body {
    padding: 1.25rem;
}

.card-footer {
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    padding: 0.85rem 1.25rem;
}

.card.shadow-sm { box-shadow: var(--shadow-sm) !important; }
.card.shadow { box-shadow: var(--shadow-md) !important; }
.card.shadow-lg { box-shadow: var(--shadow-lg) !important; }

/* ── Dashboard cards ── */
.dashboard-card {
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-md);
    overflow: hidden;
}

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

.dashboard-card .display-6 {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--dark);
}

/* ── Tables (Material) ── */
.table {
    margin-bottom: 0;
    font-size: 0.875rem;
}

.table > thead th {
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--gray-600);
    border-bottom: 2px solid var(--gray-200);
    padding: 0.85rem 0.75rem;
}

.table > thead.table-dark {
    background-color: var(--dark) !important;
    color: var(--white);
}

.table > thead.table-dark th {
    color: rgba(255,255,255,0.85);
    border-bottom: none;
}

.table > thead.table-light th {
    color: var(--gray-700);
}

.table tbody tr {
    transition: background-color 0.15s var(--ease-out);
}

.table-hover tbody tr:hover {
    background-color: var(--primary-bg);
}

.table td {
    padding: 0.85rem 0.75rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--gray-100);
}

.table > :not(caption) > * > * {
    border-bottom-color: var(--gray-100);
}

.table-responsive {
    border-radius: var(--radius-md);
}

/* ── Badges (Material chips) ── */
.badge {
    font-weight: 500;
    font-size: 0.72rem;
    padding: 0.3em 0.75em;
    border-radius: 20px;
    letter-spacing: 0.2px;
}

.badge.bg-info { background-color: #0dcaf0 !important; color: #fff; }
.badge.bg-warning { background-color: #ffc107 !important; color: #000; }
.badge.bg-danger { background-color: var(--primary) !important; }
.badge.bg-success { background-color: #198754 !important; }

/* ── Forms (Material Outlined) ── */
.form-control, .form-select {
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.85rem;
    font-size: 0.875rem;
    transition: border-color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
    background: var(--white);
}

.form-control:hover, .form-select:hover {
    border-color: var(--gray-400);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(227, 6, 19, 0.12);
}

.form-control.is-invalid, .form-select.is-invalid {
    border-color: var(--primary);
    box-shadow: none;
}

.form-control.is-invalid:focus, .form-select.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(227, 6, 19, 0.12);
}

.form-label {
    font-weight: 500;
    font-size: 0.8rem;
    color: var(--gray-700);
    margin-bottom: 0.35rem;
}

.form-text {
    font-size: 0.75rem;
    color: var(--gray-600);
}

.input-group .form-control:focus {
    z-index: 3;
}

.input-group .btn {
    z-index: 2;
}

.form-switch .form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.form-check-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(227, 6, 19, 0.12);
}

/* ── Breadcrumb ── */
.breadcrumb {
    background-color: transparent;
    padding: 0.5rem 0;
    margin-bottom: 1rem;
}

.breadcrumb-item {
    font-size: 0.82rem;
}

.breadcrumb-item a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.breadcrumb-item a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: var(--gray-600);
}

/* ── Alerts (Material) ── */
.alert {
    border: none;
    border-radius: var(--radius-md);
    padding: 0.85rem 1.1rem;
    font-size: 0.875rem;
    box-shadow: var(--shadow-sm);
}

.alert-success {
    background-color: #e8f5e9;
    color: #1b5e20;
}

.alert-danger {
    background-color: #ffebee;
    color: #b71c1c;
}

.alert-dismissible .btn-close {
    padding: 1rem;
}

/* ── Pagination ── */
.pagination {
    gap: 3px;
}

.pagination .page-link {
    border-radius: var(--radius-sm);
    border: none;
    padding: 0.45rem 0.75rem;
    font-size: 0.85rem;
    color: var(--gray-700);
    transition: all 0.15s var(--ease-out);
}

.pagination .page-link:hover {
    background-color: var(--primary-bg);
    color: var(--primary);
}

.pagination .page-item.active .page-link {
    background-color: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(227, 6, 19, 0.25);
}

.pagination .page-item.disabled .page-link {
    color: var(--gray-400);
}

/* ── Footer ── */
footer {
    border-top: 3px solid var(--primary);
    background-color: var(--dark) !important;
}

footer a {
    color: var(--gray-400) !important;
    text-decoration: none;
    transition: color 0.15s var(--ease-out);
}

footer a:hover {
    color: var(--white) !important;
    text-decoration: underline !important;
}

footer h6 {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Product card (Material tile) ── */
.product-card-img {
    height: 180px;
    object-fit: cover;
}

.product-card-placeholder {
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--gray-100);
    color: var(--gray-500);
    font-size: 2.5rem;
}

.card-img-top {
    border-radius: calc(var(--radius-md) - 1px) calc(var(--radius-md) - 1px) 0 0;
}

.list-group-item {
    border-color: var(--gray-100);
    padding: 0.85rem 1.1rem;
    transition: background-color 0.15s var(--ease-out);
}

.list-group-item:hover {
    background-color: var(--gray-50);
}

.list-group-item-action:active {
    background-color: var(--primary-bg);
}

/* ── Hero ── */
.hero-section {
    background: linear-gradient(135deg, var(--primary) 0%, #a00000 100%);
    padding: 80px 0;
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 20% 50%, rgba(255,255,255,0.06) 0%, transparent 60%);
}

/* ── Designer / Konva (unchanged structure, refined) ── */
.konva-container {
    width: 100%;
    height: 80vh;
    background-color: var(--gray-100);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
}

.sidebar {
    background-color: #fff;
    border-right: 1px solid var(--gray-300);
}

.sidebar .nav-link {
    color: var(--dark);
    padding: 12px 16px;
    border-radius: 0;
    transition: all 0.15s var(--ease-out);
}

.sidebar .nav-link:hover {
    background-color: var(--gray-100);
}

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

/* ── Stats ── */
.stat-card {
    transition: all 0.2s var(--ease-out);
}

.stat-card:hover {
    transform: translateY(-2px);
}

/* ── Nav tabs (Material) ── */
.nav-tabs {
    border-bottom: 1px solid var(--gray-200);
}

.nav-tabs .nav-link {
    border: none;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--gray-600);
    padding: 0.7rem 1.2rem;
    position: relative;
    transition: color 0.2s var(--ease-out);
}

.nav-tabs .nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
    transform: scaleX(0);
    transition: transform 0.2s var(--ease-out);
}

.nav-tabs .nav-link:hover {
    color: var(--gray-800);
    border: none;
}

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

.nav-tabs .nav-link.active::after {
    transform: scaleX(1);
}

/* ── Modal (Material) ── */
.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
}

.modal-header {
    border-bottom: 1px solid var(--gray-200);
    padding: 1.1rem 1.25rem;
}

.modal-header .modal-title {
    font-weight: 600;
    font-size: 1rem;
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    border-top: 1px solid var(--gray-200);
    padding: 0.85rem 1.25rem;
}

.modal-backdrop.show {
    opacity: 0.4;
}

/* ── Progress bar (Material) ── */
.progress {
    border-radius: 20px;
    background-color: var(--gray-200);
    height: 6px;
}

.progress-bar {
    background-color: var(--primary);
    border-radius: 20px;
}

/* ── Tooltip ── */
.tooltip-inner {
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.75rem;
    font-size: 0.78rem;
}

/* ── Dropdown (Material) ── */
.dropdown-menu {
    border: none;
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-md);
    padding: 6px;
}

.dropdown-item {
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.9rem;
    font-size: 0.85rem;
    transition: all 0.15s var(--ease-out);
}

.dropdown-item:hover {
    background-color: var(--primary-bg);
    color: var(--primary-dark);
}

.dropdown-item:active {
    background-color: var(--primary);
    color: #fff;
}

.dropdown-header {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    padding: 0.6rem 0.9rem 0.3rem;
}

.dropdown-divider {
    margin: 4px 0;
    border-color: var(--gray-200);
}

/* ── Display headings ── */
.display-1, .display-2, .display-3, .display-4, .display-5, .display-6 {
    font-weight: 700;
    letter-spacing: -0.02em;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--gray-800);
}

h2 {
    font-size: 1.5rem;
}

h5.h5 {
    font-weight: 600;
}

/* ── Section headings with underline accent ── */
.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid var(--primary);
    display: inline-block;
    margin-bottom: 1rem;
}

/* ── Responsive tweaks ── */
@media (max-width: 768px) {
    .display-4 { font-size: 2rem; }
    .product-panel { width: 100%; height: 40vh; }
    .navbar .nav-link::after { display: none; }
}

@media (max-width: 576px) {
    .table-responsive { font-size: 0.82rem; }
    .card-body { padding: 1rem; }
}

/* ── Product-panel (designer) ── */
.product-panel {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 25%;
    height: 50vh;
    max-height: 50vh;
    overflow-y: auto;
    background: #fff;
    border-top: 1px solid var(--gray-300);
    border-left: 1px solid var(--gray-300);
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    transition: transform 0.3s var(--ease-out);
    z-index: 1050;
    border-radius: var(--radius-lg) 0 0 0;
}

.product-panel.open {
    transform: translateX(0%);
}

.floating-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1060;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(227, 6, 19, 0.3);
}

/* ── Quick action cards (seller dashboard) ── */
.card.text-center .bi {
    font-size: 2.5rem;
}

.card.text-center h5 {
    margin-top: 0.5rem;
}

/* ── Btn-group refinement ── */
.btn-group .btn {
    border-radius: 0;
}

.btn-group .btn:first-child {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.btn-group .btn:last-child {
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ── Auth pages ── */
.auth-card {
    max-width: 420px;
    margin: 3rem auto;
}

.auth-card .card-body {
    padding: 2rem;
}

/* ── Empty states ── */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray-500);
}

.empty-state .bi {
    font-size: 3rem;
    display: block;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    font-size: 0.9rem;
}

/* ── Sidebar (Material slide-out) ── */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1080;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s var(--ease-out), visibility 0.25s var(--ease-out);
}

.sidebar-overlay.open {
    opacity: 1;
    visibility: visible;
}

.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    background: var(--white);
    z-index: 1090;
    box-shadow: var(--shadow-xl);
    transform: translateX(-100%);
    transition: transform 0.3s var(--ease-out);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.app-sidebar.open {
    transform: translateX(0);
}

.app-sidebar .sidebar-brand {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    background: var(--dark);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 0.3px;
    flex-shrink: 0;
    min-height: 60px;
}

.app-sidebar .sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.app-sidebar .sidebar-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--gray-500);
    font-weight: 600;
    padding: 1rem 1.25rem 0.35rem;
}

.app-sidebar .sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-700);
    text-decoration: none;
    transition: all 0.15s var(--ease-out);
    border-left: 3px solid transparent;
}

.app-sidebar .sidebar-link:hover {
    background: var(--primary-bg);
    color: var(--primary);
    border-left-color: var(--primary);
}

.app-sidebar .sidebar-link i {
    font-size: 1.1rem;
    width: 1.4rem;
    text-align: center;
    color: var(--gray-500);
    transition: color 0.15s var(--ease-out);
}

.app-sidebar .sidebar-link:hover i {
    color: var(--primary);
}

/* ── Main content shift on desktop ── */
@media (min-width: 992px) {
    .app-sidebar.open ~ main {
        margin-left: 280px;
        transition: margin-left 0.3s var(--ease-out);
    }
}
