/* ========================================
   Cupboard Companion - Full Interactive Edition
   With Checkout Modal & Order History
   ======================================== */

/* ----------------------------------------
   CSS Custom Properties
   ---------------------------------------- */
:root {
    --bg-body: #F9F9F4;
    --bg-card: #FFFFFF;
    --bg-input: #FFFFFF;
    --bg-input-hover: #FFFFFF;
    --bg-sidebar: #1C3B36;
    --bg-overlay: rgba(0, 0, 0, 0.6);

    --text-primary: #1C3B36;
    --text-secondary: #5C706B;
    --text-muted: #8A9A95;
    --text-inverse: #FFFFFF;

    --accent-primary: #2D6A4F;
    --accent-primary-hover: #245840;
    --accent-soft: #E8F3E8;
    --accent-soft-border: rgba(45, 106, 79, 0.15);

    --alert: #D64045;
    --alert-soft: #FDF2F2;
    --alert-border: rgba(214, 64, 69, 0.2);
    --alert-hover: #B8363A;

    --warning: #B45309;
    --warning-soft: #FEF9E7;
    --warning-border: rgba(180, 83, 9, 0.2);

    --success: #2D6A4F;
    --success-soft: #E8F3E8;

    --border-light: rgba(28, 59, 54, 0.08);
    --border-medium: #D1D9D6;
    --border-input: #D1D9D6;
    --border-focus: #2D6A4F;

    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.03);
    --shadow-elevated: 0 8px 30px rgba(0, 0, 0, 0.06);
    --shadow-dropdown: 0 10px 40px rgba(0, 0, 0, 0.08);
    --shadow-tooltip: 0 12px 40px rgba(0, 0, 0, 0.15);
    --shadow-modal: 0 25px 60px rgba(0, 0, 0, 0.25);

    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-pill: 50px;

    --sidebar-width: 250px;
    --header-height: 72px;
    --content-max-width: 1400px;

    --transition-fast: 120ms ease;
    --transition: 200ms ease;
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode */
.dark {
    color-scheme: dark;
    --bg-body: #0F1614;
    --bg-card: #1A2421;
    --bg-input: #1A2421;
    --bg-input-hover: #243330;
    --bg-sidebar: #0A0F0D;
    --bg-overlay: rgba(0, 0, 0, 0.8);

    --text-primary: #ECEFF1;
    --text-secondary: #B0BEC5;
    --text-muted: #90A4AE;
    --text-inverse: #0F1614;

    --accent-primary: #4ADE80;
    --accent-primary-hover: #22C55E;
    --accent-soft: rgba(74, 222, 128, 0.15);
    --accent-soft-border: rgba(74, 222, 128, 0.25);

    --alert: #F87171;
    --alert-soft: rgba(248, 113, 113, 0.15);
    --alert-border: rgba(248, 113, 113, 0.3);

    --warning: #FBBF24;
    --warning-soft: rgba(251, 191, 36, 0.15);
    --warning-border: rgba(251, 191, 36, 0.3);

    --success: #34D399;
    --success-soft: rgba(52, 211, 153, 0.15);

    --border-light: rgba(255, 255, 255, 0.08);
    --border-medium: #2F3D39;
    --border-input: #2F3D39;
    --border-focus: #4ADE80;

    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-elevated: 0 8px 30px rgba(0, 0, 0, 0.4);
    --shadow-modal: 0 25px 60px rgba(0, 0, 0, 0.6);
}

/* ----------------------------------------
   Reset & Base
   ---------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari/Opera */
}

body {
    font-family: 'DM Sans', 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    letter-spacing: -0.01em;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ----------------------------------------
   Typography
   ---------------------------------------- */
h1,
h2,
h3,
.heading {
    font-family: 'Fraunces', 'Playfair Display', Georgia, serif;
    font-weight: 400;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--text-primary);
}

h1 {
    font-size: 2rem;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.25rem;
}

/* ----------------------------------------
   Dashboard Layout
   ---------------------------------------- */
.dashboard {
    display: flex;
    min-height: 100vh;
}

/* ----------------------------------------
   Sidebar
   ---------------------------------------- */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: #FFFFFF;
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 100;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) 0;
    margin-bottom: var(--space-xl);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo svg {
    width: 28px;
    height: 28px;
    stroke: currentColor;
    stroke-width: 1.5;
}

.sidebar-logo h1 {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 1.25rem;
    font-weight: 400;
    color: #FFFFFF;
}

.sidebar-nav {
    flex: 1;
}

.nav-list {
    list-style: none;
}

.nav-item {
    margin-bottom: var(--space-xs);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: var(--transition);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
}

.nav-link svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 1.5;
    flex-shrink: 0;
}

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

.nav-link.active {
    background: rgba(255, 255, 255, 0.1);
    color: #FFFFFF;
}

.sidebar-footer {
    padding-top: var(--space-lg);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
    line-height: 1.8;
}

/* ----------------------------------------
   Main Container
   ---------------------------------------- */
.main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ----------------------------------------
   Header
   ---------------------------------------- */
.header {
    background: var(--bg-body);
    padding: 0 var(--space-xl);
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid var(--border-light);
}

.header-title {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.dark .header-title {
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

/* Theme Toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
}

.theme-toggle:hover {
    background: var(--accent-soft);
    color: var(--accent-primary);
    transform: translateY(-1px);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 1.5;
}

.theme-toggle .icon-sun {
    display: none;
}

.theme-toggle .icon-moon {
    display: block;
}

.dark .theme-toggle .icon-sun {
    display: block;
}

.dark .theme-toggle .icon-moon {
    display: none;
}

/* User Profile */
.user-profile {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: var(--transition);
}

.user-profile:hover {
    box-shadow: var(--shadow-card);
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--accent-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-inverse);
    font-weight: 600;
    font-size: 0.8rem;
}

.user-name {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
}

/* ----------------------------------------
   Main Content
   ---------------------------------------- */
.main-content {
    flex: 1;
    padding: var(--space-xl);
    max-width: var(--content-max-width);
}

.view {
    display: none;
}

.view.active {
    display: block;
}

/* Staggered Entrance Animation */
.view.active>* {
    opacity: 0;
    animation: smoothSlideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.view.active>*:nth-child(1) {
    animation-delay: 50ms;
}

.view.active>*:nth-child(2) {
    animation-delay: 150ms;
}

.view.active>*:nth-child(3) {
    animation-delay: 250ms;
}

.view.active>*:nth-child(4) {
    animation-delay: 350ms;
}

@keyframes smoothSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
        filter: blur(4px);
    }

    to {
        opacity: 1;
        transform: none;
        filter: none;
    }
}

/* ----------------------------------------
   Stats Grid
   ---------------------------------------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-xl);
    margin-bottom: var(--space-xl);
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-card);
    transition: var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-elevated);
}

.stat-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.stat-card-title {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.stat-card-icon {
    color: var(--text-secondary);
}

.stat-card-icon svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    stroke-width: 1.5;
}

.stat-card-value {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 2.25rem;
    font-weight: 400;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
    letter-spacing: -0.02em;
}

.stat-card-value.infinity {
    font-size: 2.5rem;
}

.stat-card-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.stat-card-meta.success {
    color: var(--accent-primary);
}

.stat-card-meta.danger {
    color: var(--alert);
}

.stat-card.over-budget {
    border-color: var(--alert-border);
    background: var(--alert-soft);
}

/* ----------------------------------------
   Content Grid
   ---------------------------------------- */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
}

/* ----------------------------------------
   Card Component
   ---------------------------------------- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-card);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-light);
}

.card-title {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 1.125rem;
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.card-title svg {
    width: 20px;
    height: 20px;
    stroke: var(--text-secondary);
    stroke-width: 1.5;
}

.card-body {
    padding: var(--space-lg);
}

.card-footer {
    padding: var(--space-lg);
    border-top: 1px solid var(--border-light);
    background: var(--bg-body);
}

/* ----------------------------------------
   Inventory List with CRUD Controls
   ---------------------------------------- */
.inventory-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.inventory-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-body);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    transition: var(--transition);
}

.inventory-item:hover {
    border-color: var(--border-medium);
}

.inventory-item-info {
    flex: 1;
    min-width: 0;
}

.inventory-item-name {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.inventory-item-qty {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.inventory-item-progress {
    flex: 1;
    display: flex;
    align-items: center;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-light);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s var(--transition-slow);
}

.progress-fill.low {
    background: var(--alert);
}

.progress-fill.ok {
    background: var(--accent-primary);
}

/* Quantity Control Cluster */
.qty-controls {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.qty-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
}

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

.qty-btn svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2;
}

.qty-value {
    min-width: 32px;
    text-align: center;
    font-weight: 600;
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}

/* Delete Button */
.btn-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-muted);
}

.btn-delete:hover {
    background: var(--alert-soft);
    color: var(--alert);
    border-color: var(--alert);
}

.btn-delete svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 1.5;
}

/* Add Item Button */
.add-item-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    width: 100%;
    padding: var(--space-md);
    background: transparent;
    border: 2px dashed var(--border-medium);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    margin-top: var(--space-md);
}

.add-item-btn:hover {
    background: var(--accent-soft);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.add-item-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 1.5;
}

/* ----------------------------------------
   Status Badges
   ---------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-xs) var(--space-sm);
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge-success {
    background: var(--success-soft);
    color: var(--success);
}

.badge-danger {
    background: var(--alert-soft);
    color: var(--alert);
}

.badge-warning {
    background: var(--warning-soft);
    color: var(--warning);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.status-badge.critical {
    background: var(--alert-soft);
    color: var(--alert);
}

.status-badge.warning {
    background: var(--warning-soft);
    color: var(--warning);
}

.status-badge.good {
    background: var(--success-soft);
    color: var(--success);
}

/* ----------------------------------------
   Shopping Table
   ---------------------------------------- */
.shopping-table {
    width: 100%;
    border-collapse: collapse;
}

.shopping-table th,
.shopping-table td {
    padding: var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.shopping-table th {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    background: var(--bg-body);
}

.shopping-table tbody tr {
    transition: var(--transition-fast);
}

.shopping-table tbody tr:hover {
    background: var(--bg-body);
}

.shopping-table .total-row {
    background: var(--bg-body);
}

.shopping-table .total-row td {
    border-bottom: none;
    padding: var(--space-lg) var(--space-md);
    font-family: 'Fraunces', Georgia, serif;
}

/* ----------------------------------------
   Buttons
   ---------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 1.5;
}

.btn-primary {
    background: var(--accent-primary);
    color: var(--text-inverse);
    border-radius: var(--radius-pill);
}

.btn-primary:hover {
    background: var(--accent-primary-hover);
}

.btn-primary:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-pill);
}

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

.btn-danger {
    background: var(--alert);
    color: var(--text-inverse);
    border-radius: var(--radius-pill);
}

.btn-danger:hover {
    background: var(--alert-hover);
}

.btn-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.btn-remove:hover {
    background: var(--alert-soft);
    color: var(--alert);
    border-color: var(--alert);
}

.btn-remove svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 1.5;
}

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: var(--space-lg) var(--space-xl);
    font-size: 0.95rem;
}

/* ----------------------------------------
   Inputs & Selects
   ---------------------------------------- */
input[type="text"],
input[type="number"],
input[type="email"],
select {
    width: 100%;
    padding: 12px 16px;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.95rem;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-input);
    border-radius: var(--radius-md);
    transition: var(--transition);
    appearance: none;
    -webkit-appearance: none;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(45, 106, 79, 0.1);
}

.select-wrapper {
    position: relative;
}

.select-wrapper select {
    padding-right: 40px;
    cursor: pointer;
}

.select-wrapper .select-chevron {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    pointer-events: none;
    color: var(--text-secondary);
}

.select-wrapper .select-chevron svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    stroke-width: 1.5;
}

/* ----------------------------------------
   Alerts
   ---------------------------------------- */
.alert {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    font-size: 0.875rem;
    font-weight: 500;
}

.alert svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 1.5;
    flex-shrink: 0;
}

.alert-danger {
    background: var(--alert-soft);
    color: var(--alert);
    border: 1px solid var(--alert-border);
}

.alert-warning {
    background: var(--warning-soft);
    color: var(--warning);
    border: 1px solid var(--warning-border);
}

.alert-info {
    background: var(--accent-soft);
    color: var(--accent-primary);
    border: 1px solid var(--accent-soft-border);
}

/* ----------------------------------------
   Empty State
   ---------------------------------------- */
.empty-state {
    text-align: center;
    padding: var(--space-2xl);
    color: var(--text-secondary);
}

.empty-state-icon {
    margin-bottom: var(--space-md);
    color: var(--text-muted);
}

.empty-state-icon svg {
    width: 48px;
    height: 48px;
    stroke: currentColor;
    stroke-width: 1.5;
}

.empty-state h3 {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 1.125rem;
    font-weight: 400;
    margin-bottom: var(--space-sm);
    color: var(--text-primary);
}

/* ----------------------------------------
   Form Groups
   ---------------------------------------- */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: var(--space-sm);
    color: var(--text-primary);
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

/* ----------------------------------------
   Modal / Overlay System
   ---------------------------------------- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-overlay);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-modal);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow: auto;
}

.modal-header {
    padding: var(--space-xl);
    border-bottom: 1px solid var(--border-light);
}

.modal-title {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.modal-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.modal-body {
    padding: var(--space-xl);
}

.modal-footer {
    padding: var(--space-xl);
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-md);
}

/* ----------------------------------------
   Checkout Modal
   ---------------------------------------- */
.checkout-summary {
    margin-bottom: var(--space-lg);
}

.checkout-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--border-light);
}

.checkout-item:last-child {
    border-bottom: none;
}

.checkout-item-name {
    font-weight: 500;
    color: var(--text-primary);
}

.checkout-item-qty {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.checkout-item-cost {
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.checkout-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg) 0;
    border-top: 2px solid var(--border-medium);
    margin-top: var(--space-md);
}

.checkout-total-label {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 1.125rem;
    color: var(--text-primary);
}

.checkout-total-value {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--accent-primary);
}

/* Success State */
.checkout-success {
    text-align: center;
    padding: var(--space-xl);
}

.checkout-success-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--space-lg);
    background: var(--success-soft);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: successPop 0.4s ease;
}

.checkout-success-icon svg {
    width: 40px;
    height: 40px;
    stroke: var(--success);
    stroke-width: 2;
}

@keyframes successPop {
    0% {
        transform: scale(0);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

.checkout-success h3 {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.checkout-success p {
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
}

/* ----------------------------------------
   Order History
   ---------------------------------------- */
.history-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.history-item {
    background: var(--bg-body);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: var(--transition);
}

.history-item:hover {
    border-color: var(--border-medium);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    cursor: pointer;
}

.history-item-date {
    font-weight: 600;
    color: var(--text-primary);
}

.history-item-meta {
    display: flex;
    gap: var(--space-lg);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.history-item-total {
    font-weight: 600;
    color: var(--accent-primary);
}

.history-item-details {
    display: none;
    padding: 0 var(--space-lg) var(--space-lg);
    border-top: 1px solid var(--border-light);
}

.history-item.expanded .history-item-details {
    display: block;
}

.history-detail-row {
    display: flex;
    justify-content: space-between;
    padding: var(--space-sm) 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ----------------------------------------
   Onboarding Wizard
   ---------------------------------------- */
.onboarding-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-overlay);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.onboarding-overlay.active {
    display: flex;
}

.onboarding-modal {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-modal);
    width: 100%;
    max-width: 420px;
    text-align: center;
    overflow: hidden;
}

.onboarding-slide {
    display: none;
    padding: var(--space-3xl) var(--space-xl);
}

.onboarding-slide.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

.onboarding-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto var(--space-lg);
    color: var(--accent-primary);
}

.onboarding-icon svg {
    width: 100%;
    height: 100%;
    stroke: currentColor;
    stroke-width: 1.5;
}

.onboarding-title {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 1.75rem;
    font-weight: 400;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}

.onboarding-text {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-xl);
    line-height: 1.7;
}

.onboarding-form {
    text-align: left;
    margin-bottom: var(--space-lg);
}

.onboarding-footer {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
}

.onboarding-dots {
    display: flex;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-lg);
    border-top: 1px solid var(--border-light);
}

.onboarding-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-medium);
    transition: var(--transition);
}

.onboarding-dot.active {
    background: var(--accent-primary);
    width: 24px;
    border-radius: 4px;
}

/* ----------------------------------------
   Tutorial Overlay - Commander Pattern
   ---------------------------------------- */

/* Dark overlay covering entire viewport */
.tutorial-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 10001;
    pointer-events: auto;
    /* Block clicks on underlying elements */
}

.tutorial-overlay.active {
    display: block;
}

/* Spotlight highlight on target element */
.tutorial-highlight {
    position: relative !important;
    z-index: 10002 !important;
    box-shadow:
        0 0 0 4px var(--accent-primary),
        0 0 20px rgba(45, 106, 79, 0.4);
    border-radius: var(--radius-md);
    pointer-events: auto;
    animation: tutorialPulse 2s ease-in-out infinite;
}

/* Boost modal z-index to sit above tutorial overlay */
.tutorial-modal-boost {
    z-index: 10002 !important;
}

/* Disable non-highlighted buttons inside boosted modal */
.tutorial-modal-boost .btn:not(.tutorial-highlight) {
    pointer-events: none;
    opacity: 0.5;
}

@keyframes tutorialPulse {

    0%,
    100% {
        box-shadow: 0 0 0 4px var(--accent-primary), 0 0 20px rgba(45, 106, 79, 0.4);
    }

    50% {
        box-shadow: 0 0 0 6px var(--accent-primary), 0 0 30px rgba(45, 106, 79, 0.6);
    }
}

/* Fixed position card at bottom center */
#tutorial-card {
    display: none;
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 480px;
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: var(--space-xl);
    box-shadow: var(--shadow-modal);
    z-index: 10003;
    border: 1px solid var(--border-light);
    pointer-events: auto;
    animation: slideUp 0.4s ease;
}

#tutorial-card.position-top {
    bottom: auto;
    top: 30px;
    animation: slideDown 0.4s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

#tutorial-card.active {
    display: block;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Tutorial card content */
.tutorial-step-label {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-primary);
    margin-bottom: var(--space-md);
    background: var(--accent-soft);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
}

.tutorial-step-label svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    stroke-width: 2;
}

.tutorial-card-title {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 1.25rem;
    font-weight: 400;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}

.tutorial-card-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: var(--space-lg);
}

/* Typewriter effect */
.tutorial-card-text .typewriter {
    border-right: 2px solid var(--accent-primary);
    animation: blink 0.7s step-end infinite;
}

@keyframes blink {
    50% {
        border-color: transparent;
    }
}

/* Tutorial card actions */
.tutorial-card-actions {
    display: flex;
    gap: var(--space-md);
    justify-content: flex-end;
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-light);
}

/* Wait indicator */
.tutorial-wait-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

.tutorial-wait-indicator svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 1.5;
    animation: spin 1.5s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Progress dots */
.tutorial-progress {
    display: flex;
    justify-content: center;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
}

.tutorial-progress-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-medium);
    transition: var(--transition);
}

.tutorial-progress-dot.active {
    background: var(--accent-primary);
    width: 24px;
    border-radius: 4px;
}

.tutorial-progress-dot.completed {
    background: var(--accent-primary);
}

/* ----------------------------------------
   Settings Danger Zone
   ---------------------------------------- */
.danger-zone {
    margin-top: var(--space-xl);
    padding: var(--space-lg);
    background: var(--alert-soft);
    border: 1px solid var(--alert-border);
    border-radius: var(--radius-md);
}

.danger-zone-title {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--alert);
    margin-bottom: var(--space-sm);
}

.danger-zone-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
}

/* ----------------------------------------
   Responsive
   ---------------------------------------- */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .content-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .dashboard {
        flex-direction: column;
    }

    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
        min-height: auto;
    }

    .main-content {
        padding: var(--space-md);
    }

    /* Tutorial card - smaller on mobile */
    #tutorial-card {
        bottom: 10px;
        left: 10px;
        right: 10px;
        transform: none;
        max-width: none;
        padding: var(--space-md);
    }

    .tutorial-card-title {
        font-size: 1rem;
    }

    .tutorial-card-text {
        font-size: 0.85rem;
        line-height: 1.5;
        margin-bottom: var(--space-md);
    }

    .tutorial-step-label {
        font-size: 0.65rem;
        padding: 4px 8px;
    }

    .tutorial-card-actions {
        flex-wrap: wrap;
        gap: var(--space-sm);
    }

    .tutorial-wait-indicator {
        font-size: 0.75rem;
    }

    .tutorial-progress {
        margin-top: var(--space-md);
    }
}

@media (max-width: 480px) {

    /* Even smaller screens */
    #tutorial-card {
        bottom: 5px;
        left: 5px;
        right: 5px;
        padding: var(--space-sm) var(--space-md);
    }

    .tutorial-card-title {
        font-size: 0.95rem;
        margin-bottom: var(--space-sm);
    }

    .tutorial-card-text {
        font-size: 0.8rem;
        margin-bottom: var(--space-sm);
    }

    .tutorial-card-actions .btn {
        padding: var(--space-sm) var(--space-md);
        font-size: 0.8rem;
    }
}

/* ==========================================================================
   ROBUST TUTORIAL OVERLAY & INTERACTION LOGIC
   ========================================================================== */

/* 1. Hide the old global overlay - relies on outline dimming */
#tutorial-overlay {
    display: none !important;
}


/* 2. Highlighted Element - distinct and interactive */
.tutorial-highlight {
    position: relative;
    z-index: 10002 !important;
    outline: 200vmax solid rgba(0, 0, 0, 0.65);
    pointer-events: auto !important;
    border-radius: var(--radius-lg) !important;
    transition: outline-color 0.3s ease;
}

/* 3. Global Click Blocking when Tutorial is Active */
/* 3. Global Click Blocking when Tutorial is Active */
body.tutorial-active .sidebar,
body.tutorial-active .header,
body.tutorial-active .main-content {
    pointer-events: none;
}

/* 4. Exceptions for Tutorial Controls */
body.tutorial-active #tutorial-card,
body.tutorial-active #tutorial-card * {
    pointer-events: auto !important;
}

body.tutorial-active .tutorial-highlight,
body.tutorial-active .tutorial-highlight * {
    pointer-events: auto !important;
}

/* 5. Elevate View to be above Sidebar (Z-50) so shadow covers it */
.view.active {
    display: block;
    position: relative;
    z-index: 60;
}