:root {
    --primary: #D4A373;
    --primary-dark: #C18B5E;
    --secondary: #FAEDCD;
    --accent: #E9EDC9;
    --background: #FDF8F5; /* Warm creamy background */
    --surface: #FFFFFF;
    --text-main: #333333;
    --text-muted: #7A7A7A;
    --danger: #E63946;
    --success: #2A9D8F;
    --border: #E8E8E8;
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 10px 20px rgba(212, 163, 115, 0.1);
    --shadow-float: 0 16px 30px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--background);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

.app-container {
    width: 100%;
    max-width: 600px; /* Mobile first, constrained on desktop */
    background: var(--background);
    min-height: 100vh;
    box-shadow: 0 0 40px rgba(0,0,0,0.03);
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    padding: 24px 20px;
    background: var(--surface);
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-dark);
}

.logo i {
    color: var(--primary);
    font-size: 28px;
}

/* Navigation */
.tabs {
    display: flex;
    padding: 20px 20px 10px;
    gap: 8px;
    overflow-x: auto;
    -ms-overflow-style: none; 
    scrollbar-width: none; 
}
.tabs::-webkit-scrollbar {
    display: none;
}

.compact-nav {
    padding: 16px 20px 12px;
}

.tab-btn {
    flex: 0 0 auto;
    padding: 10px 18px;
    border: 1px solid transparent;
    background: var(--surface);
    color: var(--text-muted);
    border-radius: 30px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    box-shadow: var(--shadow-sm);
}

.tab-btn:hover {
    color: var(--primary-dark);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(212, 163, 115, 0.3);
    border-color: var(--primary);
}

/* Main Content */
.content-area {
    flex: 1;
    padding: 10px 20px 30px;
    position: relative;
}

.view {
    display: none;
    animation: fadeIn 0.4s ease;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.view-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
}

/* Buttons */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: var(--radius-dm);
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 10px rgba(212, 163, 115, 0.3);
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary:active {
    transform: scale(0.96);
}

.btn-secondary {
    background: var(--border);
    color: var(--text-main);
    border: none;
    padding: 10px 16px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
}

.btn-icon-only {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: 0.2s;
}
.btn-icon-only:hover {
    background: var(--secondary);
    color: var(--primary-dark);
}
.btn-danger {
    color: var(--danger);
}
.btn-danger:hover {
    background: #ffe3e3;
    color: #c92a2a;
}

/* Search bar */
.search-bar {
    position: relative;
    margin-bottom: 20px;
}

.search-bar i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-bar input {
    width: 100%;
    padding: 14px 14px 14px 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    font-size: 15px;
    outline: none;
    transition: 0.3s;
}
.search-bar input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(212, 163, 115, 0.2);
}

/* Lists */
.list-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    transition: 0.3s;
    border: 1px solid transparent;
}

.card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--secondary);
    transform: translateY(-2px);
}

.card-info h4 {
    font-size: 16px;
    margin-bottom: 4px;
    color: var(--text-main);
}

.card-info p {
    font-size: 14px;
    color: var(--text-muted);
}

.card-price {
    font-weight: 700;
    color: var(--primary-dark);
}

.card-actions {
    display: flex;
    gap: 4px;
}

/* Product Card Specific */
.product-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 20px;
}
.product-card-top {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}
.product-stats {
    display: flex;
    gap: 16px;
    width: 100%;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}
.p-stat {
    flex: 1;
}
.p-stat span {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.p-stat strong {
    font-size: 15px;
}
.text-green { color: var(--success); }
.text-orange { color: var(--primary-dark); }


/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: flex-end; /* Bottom sheet on mobile */
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--surface);
    width: 100%;
    max-width: 600px;
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
    padding: 24px;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

/* Centered modal on desktop */
@media (min-width: 600px) {
    .modal-overlay {
        align-items: center;
    }
    .modal-content {
        border-radius: var(--radius-lg);
        transform: scale(0.9);
        opacity: 0;
    }
    .modal-overlay.active .modal-content {
        transform: scale(1);
        opacity: 1;
    }
}
@media (max-width: 599px) {
    .modal-overlay.active .modal-content {
        transform: translateY(0);
    }
}


.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 20px;
}

.btn-close {
    background: var(--secondary);
    border: none;
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-main);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-main);
}

.form-group input, .form-group select {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    outline: none;
    background: #fcfcfc;
    transition: 0.2s;
}
.form-group input:focus, .form-group select:focus {
    border-color: var(--primary);
    background: #fff;
}

.form-group.row {
    display: flex;
    gap: 12px;
}
.form-group.row .col {
    flex: 1;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* Stats Panel */
.stats-panel {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    background: var(--background);
    padding: 16px;
    border-radius: 12px;
}
.stat-box {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.stat-box span {
    font-size: 12px;
    color: var(--text-muted);
}
.stat-box strong {
    font-size: 18px;
    margin-top: 4px;
}
.cost-box strong { color: var(--danger); }
.margin-box strong { color: var(--success); }

/* Recipe Picker */
.section-title {
    font-size: 16px;
    margin-bottom: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.picker-row {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.picker-row select {flex: 2;}
.picker-row input {flex: 1;}

.recipe-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.recipe-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--background);
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
}

/* Scrollable body for large modal */
.scrollable {
    overflow-y: auto;
    max-height: 70vh;
    padding-bottom: 20px;
}
.sticky-bottom {
    position: sticky;
    bottom: -20px;
    background: var(--surface);
    padding: 16px 0;
    border-top: 1px solid var(--border);
    margin-bottom: -20px;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 14px;
}

/* Toast */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    background: var(--surface);
    border-left: 4px solid var(--primary);
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-float);
    color: var(--text-main);
    font-weight: 500;
    animation: slideInRight 0.3s forwards, slideOutRight 0.3s 2.7s forwards;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes slideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* ==================================
   SALES & POS STYLES
   ================================== */
@media (min-width: 600px) {
    .sales-layout {
        display: grid;
        grid-template-columns: 1fr 320px;
        gap: 20px;
    }
}
@media (max-width: 599px) {
    .sales-layout {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }
    /* Fixed cart on mobile or just flow below? Flow below is simpler. */
}

.sales-products .card {
    cursor: pointer;
}

.sales-cart {
    background: var(--surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    height: fit-content;
}

.cart-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.cart-items {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 40vh;
    overflow-y: auto;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--background);
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
}

.cart-item-info {
    flex: 1;
}

.cart-item-qty {
    display: flex;
    align-items: center;
    gap: 8px;
}
.cart-item-qty input {
    width: 50px;
    text-align: center;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.cart-summary {
    padding: 16px;
    border-top: 2px dashed var(--border);
    background: #fafafa;
    border-bottom-left-radius: var(--radius-md);
    border-bottom-right-radius: var(--radius-md);
}

.cart-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

/* ==================================
   REPORTS STYLES
   ================================== */
.reports-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 8px;
}

.filter-btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
    transition: 0.2s;
    white-space: nowrap;
}
.filter-btn.active, .filter-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.reports-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
}

.report-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.report-card span {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin: 8px 0 4px;
}

.report-card strong {
    font-size: 18px;
}

.report-card .card-icon {
    font-size: 24px;
    margin-bottom: 8px;
    opacity: 0.9;
}

.report-card.green {
    border-top: 4px solid var(--success);
}
.report-card.green strong { color: var(--success); }
.report-card.green .card-icon { color: var(--success); }

.report-card.orange {
    border-top: 4px solid #E76F51;
}
.report-card.orange strong { color: #E76F51; }
.report-card.orange .card-icon { color: #E76F51; }

.report-card.primary {
    border-top: 4px solid var(--primary-dark);
}
.report-card.primary strong { color: var(--primary-dark); }
.report-card.primary .card-icon { color: var(--primary-dark); }

.margin-badge {
    background: var(--background);
    color: var(--text-muted);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    margin-top: 6px;
}

/* ==================================
   LOGIN STYLES
   ================================== */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--background) 0%, #F5EAE0 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.login-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--radius-lg);
    padding: 40px 30px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-float);
    text-align: center;
    animation: fadeIn 0.6s ease;
}

.login-logo {
    width: 64px;
    height: 64px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin: 0 auto 16px;
    box-shadow: 0 8px 16px rgba(212, 163, 115, 0.3);
}

.login-card h2 {
    color: var(--primary-dark);
    font-size: 24px;
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 30px;
}

.login-card .form-group {
    text-align: left;
}
