/* ================================================================
   ISHA HONEY SALES TRACKER — PREMIUM REDESIGN
   Aesthetic: Warm organic luxury — honeycomb gold meets earthy depth
   Fonts: Playfair Display (headings) + DM Sans (body)
   Mobile-first, touch-optimized, PWA-ready
================================================================ */

/* ===== GOOGLE FONTS IMPORT ===== */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700;800&family=DM+Sans:wght@300;400;500;600;700&display=swap');

/* ===== DESIGN TOKENS ===== */
:root {
    /* Core Palette */
    --honey-50:  #fffbeb;
    --honey-100: #fef3c7;
    --honey-200: #fde68a;
    --honey-300: #fcd34d;
    --honey-400: #fbbf24;
    --honey-500: #f59e0b;
    --honey-600: #d97706;
    --honey-700: #b45309;
    --honey-800: #92400e;
    --honey-900: #78350f;

    --earth-50:  #fafaf9;
    --earth-100: #f5f5f4;
    --earth-200: #e7e5e4;
    --earth-300: #d6d3d1;
    --earth-500: #78716c;
    --earth-700: #44403c;
    --earth-900: #1c1917;

    --teal-400: #2dd4bf;
    --teal-500: #14b8a6;
    --teal-600: #0d9488;
    --teal-700: #0f766e;

    --rose-400: #fb7185;
    --rose-500: #f43f5e;
    --rose-600: #e11d48;

    --emerald-400: #34d399;
    --emerald-500: #10b981;
    --emerald-600: #059669;

    /* Semantic */
    --primary:       var(--honey-600);
    --primary-dark:  var(--honey-700);
    --primary-light: var(--honey-400);
    --secondary:     var(--teal-600);
    --danger:        var(--rose-600);
    --success:       var(--emerald-500);
    --warning:       var(--honey-500);

    --bg-base:   #fdf8f0;
    --bg-card:   #ffffff;
    --text-900:  var(--earth-900);
    --text-500:  var(--earth-500);
    --border:    #e8e0d5;

    /* Elevation */
    --shadow-sm: 0 1px 3px rgba(120, 53, 15, 0.06), 0 1px 2px rgba(120, 53, 15, 0.04);
    --shadow-md: 0 4px 12px rgba(120, 53, 15, 0.08), 0 2px 4px rgba(120, 53, 15, 0.04);
    --shadow-lg: 0 12px 32px rgba(120, 53, 15, 0.12), 0 4px 8px rgba(120, 53, 15, 0.06);
    --shadow-glow: 0 0 0 3px rgba(217, 119, 6, 0.15);

    /* Geometry */
    --radius-xs: 6px;
    --radius-sm: 10px;
    --radius:    16px;
    --radius-lg: 24px;
    --radius-xl: 32px;

    /* Motion */
    --ease-out:  cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in:   cubic-bezier(0.7, 0, 0.84, 0);
    --ease-both: cubic-bezier(0.65, 0, 0.35, 1);
    --duration:  250ms;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-base);
    min-height: 100vh;
    color: var(--text-900);
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    line-height: 1.6;
}

/* Honeycomb ambient background */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(ellipse 80% 50% at 20% 10%, rgba(251, 191, 36, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 80% 90%, rgba(180, 83, 9, 0.06) 0%, transparent 60%),
        url("data:image/svg+xml,%3Csvg width='60' height='52' viewBox='0 0 60 52' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 2L58 17.5V34.5L30 50L2 34.5V17.5L30 2Z' fill='none' stroke='rgba(217,119,6,0.04)' stroke-width='1'/%3E%3Cpath d='M30 15L45 23.5V32.5L30 41L15 32.5V23.5L30 15Z' fill='none' stroke='rgba(217,119,6,0.03)' stroke-width='1'/%3E%3C/svg%3E");
    background-size: auto, auto, 60px 52px;
    pointer-events: none;
    z-index: 0;
}

/* ================================================================
   HEADER
================================================================ */
header {
    background: linear-gradient(135deg, var(--honey-700) 0%, var(--honey-600) 50%, var(--honey-500) 100%);
    color: white;
    padding: 0;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(120, 53, 15, 0.25);
    z-index: 10;
}

header::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 10% 50%, rgba(255,255,255,0.12) 0%, transparent 50%),
        radial-gradient(circle at 90% 20%, rgba(255,200,50,0.15) 0%, transparent 40%);
    pointer-events: none;
}

header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, 
        transparent 0%,
        rgba(255,255,255,0.3) 30%,
        rgba(255,255,255,0.5) 50%,
        rgba(255,255,255,0.3) 70%,
        transparent 100%
    );
}

.header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: 1280px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
    position: relative;
    z-index: 2;
}

.logo-container {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid rgba(255, 255, 255, 0.35);
    box-shadow: 0 0 0 1px rgba(255,255,255,0.1), 0 4px 16px rgba(0,0,0,0.2);
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(8px);
}

.logo-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.header-text { flex: 1; }

header h1 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: clamp(1.1rem, 3vw, 1.6rem);
    font-weight: 700;
    letter-spacing: 0.3px;
    line-height: 1.2;
    text-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

header p {
    font-size: 0.82rem;
    font-weight: 300;
    opacity: 0.85;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    margin-top: 0.2rem;
}

/* ================================================================
   MAIN LAYOUT
================================================================ */
main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    position: relative;
    z-index: 1;
}

@media (min-width: 1024px) {
    main {
        flex-direction: row;
        padding: 2rem 1.5rem;
        gap: 2rem;
        align-items: flex-start;
    }
}

/* Left column: full width on mobile, fixed on desktop */
.left-column {
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

@media (min-width: 1024px) {
    .left-column {
        flex: 0 0 320px;
        width: 320px;
    }
}

/* Right column: grows to fill all remaining space */
.right-column {
    flex: 1 1 0%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* ================================================================
   CARDS
================================================================ */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(217, 119, 6, 0.08);
    position: relative;
    overflow: hidden;
    animation: cardReveal 0.5s var(--ease-out) both;
    width: 100%;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--honey-400), var(--honey-600), var(--honey-400));
    background-size: 200% 100%;
    animation: shimmerBar 3s ease infinite;
}

@keyframes shimmerBar {
    0%, 100% { background-position: 0% 0%; }
    50%       { background-position: 100% 0%; }
}

@keyframes cardReveal {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.card h2 {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--honey-800);
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--honey-100);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card h2::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 1.1em;
    background: linear-gradient(to bottom, var(--honey-400), var(--honey-600));
    border-radius: 2px;
    flex-shrink: 0;
}

.mt-2 { margin-top: 0 !important; }

/* ================================================================
   FORMS
================================================================ */
.form-group {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
}

label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--earth-700);
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

input, select, textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px; /* Prevent iOS zoom */
    font-family: 'DM Sans', sans-serif;
    color: var(--text-900);
    background: #fdfaf6;
    transition: border-color var(--duration) ease, box-shadow var(--duration) ease, background var(--duration) ease;
    min-height: 48px; /* 48px touch target */
    -webkit-appearance: none;
    appearance: none;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--honey-500);
    background: #ffffff;
    box-shadow: var(--shadow-glow);
}

input[readonly] {
    background: var(--honey-50);
    border-color: var(--honey-200);
    color: var(--honey-800);
    font-weight: 600;
    cursor: default;
}

textarea { resize: vertical; min-height: 80px; }

/* Select custom arrow */
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23b45309' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
}

/* ================================================================
   BUTTONS
================================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.75rem 1.25rem;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--duration) var(--ease-out);
    min-height: 48px;
    width: 100%;
    margin-bottom: 0.5rem;
    text-decoration: none;
    white-space: nowrap;
    letter-spacing: 0.2px;
    -webkit-user-select: none;
    user-select: none;
}

.btn:active { transform: scale(0.97); }

@media (min-width: 640px) {
    .btn { width: auto; margin-bottom: 0; }
}

/* Primary */
.btn-primary {
    background: linear-gradient(135deg, var(--honey-500) 0%, var(--honey-700) 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(217, 119, 6, 0.3);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--honey-400) 0%, var(--honey-600) 100%);
    box-shadow: 0 6px 20px rgba(217, 119, 6, 0.4);
    transform: translateY(-1px);
}

/* Secondary */
.btn-secondary {
    background: linear-gradient(135deg, var(--teal-500) 0%, var(--teal-700) 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(13, 148, 136, 0.25);
}
.btn-secondary:hover {
    background: linear-gradient(135deg, var(--teal-400) 0%, var(--teal-600) 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(13, 148, 136, 0.35);
}

/* Danger */
.btn-danger {
    background: linear-gradient(135deg, var(--rose-500) 0%, var(--rose-600) 100%);
    color: white;
    box-shadow: 0 4px 14px rgba(225, 29, 72, 0.25);
}
.btn-danger:hover {
    background: linear-gradient(135deg, var(--rose-400) 0%, var(--rose-500) 100%);
    transform: translateY(-1px);
}

/* Outline */
.btn-outline {
    background: transparent;
    border-color: var(--honey-500);
    color: var(--honey-700);
}
.btn-outline:hover {
    background: var(--honey-50);
    border-color: var(--honey-600);
    color: var(--honey-800);
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.15);
}

/* Small */
.btn-sm {
    padding: 0.45rem 0.9rem;
    font-size: 0.82rem;
    min-height: 36px;
    border-radius: var(--radius-xs);
}

.mb-2 { margin-bottom: 0.75rem !important; }

/* ================================================================
   DASHBOARD SUMMARY CARDS
================================================================ */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.dashboard-card {
    background: linear-gradient(135deg, var(--honey-50) 0%, var(--honey-100) 100%);
    border: 1px solid var(--honey-200);
    border-radius: var(--radius-sm);
    padding: 1rem 0.75rem;
    text-align: center;
    position: relative;
    overflow: hidden;
    transition: transform var(--duration) ease, box-shadow var(--duration) ease;
}

.dashboard-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--honey-300), var(--honey-500));
}

.dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.dashboard-card h3 {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--honey-700);
    text-transform: uppercase;
    letter-spacing: 0.7px;
    margin-bottom: 0.4rem;
}

.dashboard-card .amount {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: clamp(1rem, 3.5vw, 1.4rem);
    font-weight: 700;
    color: var(--earth-900);
    line-height: 1;
}

/* Right column: Sales History card fills full height, no competing siblings */
@media (min-width: 1024px) {
    .right-column {
        align-self: stretch;
    }

    .sales-history-card {
        position: sticky;
        top: 1rem;
        /* Stretch table area to viewport height minus header + card padding */
        display: flex;
        flex-direction: column;
    }

    .sales-history-card #salesSection {
        flex: 1;
        display: flex !important;
        flex-direction: column;
    }

    .sales-history-card #salesSection.show {
        display: flex !important;
    }

    /* Table container fills the remaining space inside the card */
    .sales-history-card .table-container {
        flex: 1;
        max-height: calc(100vh - 260px);
        overflow-y: auto;
        overflow-x: auto;
    }
}



/* Equal-width manager toggle buttons side by side */
.manager-toggle-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.manager-toggle-btn {
    width: 100% !important;
    margin: 0 !important;
    font-size: 0.8rem !important;
    padding: 0.6rem 0.5rem !important;
    min-height: 42px !important;
    text-align: center;
    white-space: normal;
    line-height: 1.2;
}

/* ================================================================
   COMPACT LEFT COLUMN — tighter inputs to minimize vertical length
================================================================ */
.left-column .form-group {
    margin-bottom: 0.65rem;
}

.left-column input,
.left-column select,
.left-column textarea {
    padding: 0.6rem 0.85rem;
    min-height: 42px;
}

.left-column textarea { min-height: 60px; }

.left-column label {
    font-size: 0.76rem;
    margin-bottom: 0.28rem;
}

.left-column .card { padding: 1.1rem; }

.left-column .card h2 {
    margin-bottom: 0.85rem;
    padding-bottom: 0.55rem;
    font-size: 1rem;
}

/* Inline dashboard strip — replaces the separate dashboard card */
.dashboard-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.45rem;
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 2px solid var(--honey-100);
}

.dashboard-strip-item {
    background: linear-gradient(135deg, var(--honey-50) 0%, var(--honey-100) 100%);
    border: 1px solid var(--honey-200);
    border-radius: var(--radius-xs);
    padding: 0.55rem 0.3rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.dashboard-strip-item::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--honey-300), var(--honey-500));
}

.dashboard-strip-item h3 {
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--honey-700);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 0.2rem;
    line-height: 1.2;
}

.dashboard-strip-item .amount {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--earth-900);
    line-height: 1;
}

#salesSection { display: none; }
#salesSection.show { display: block; }

.sales-view-wrapper {
    position: relative;
    display: inline-block;
    margin-bottom: 0.75rem;
}

.sales-view-btn {
    background: var(--honey-50);
    border: 1.5px solid var(--honey-300);
    color: var(--honey-800);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-xs);
    cursor: pointer;
    width: auto;
    min-height: 40px;
    margin: 0;
    transition: all var(--duration) ease;
}
.sales-view-btn:hover {
    background: var(--honey-100);
    border-color: var(--honey-400);
}

.sales-view-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 220px;
    background: white;
    border-radius: var(--radius-sm);
    box-shadow: 0 12px 40px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.05);
    border: 1px solid var(--border);
    display: none;
    z-index: 9999;
    overflow: hidden;
}

.sales-view-menu button {
    width: 100%;
    background: transparent;
    border: none;
    text-align: left;
    padding: 0.7rem 1rem;
    font-size: 0.88rem;
    font-family: 'DM Sans', sans-serif;
    color: var(--earth-700);
    cursor: pointer;
    transition: background var(--duration) ease;
    min-height: 44px;
    margin: 0;
}
.sales-view-menu button:hover {
    background: var(--honey-50);
    color: var(--honey-800);
}
.sales-view-menu button:active { background: var(--honey-100); }

/* ================================================================
   FILTERS
================================================================ */
.filters-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    background: linear-gradient(135deg, #f0fdfa 0%, #e6fffa 100%);
    border: 1px solid var(--teal-400);
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}

@media (min-width: 480px) {
    .filters-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 768px) {
    .filters-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ================================================================
   TOTALS DISPLAY
================================================================ */
.totals-display {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border: 1px solid var(--emerald-400);
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin: 1rem 0;
}

@media (min-width: 480px) {
    .totals-display { grid-template-columns: repeat(4, 1fr); }
}

.totals-item { text-align: center; }

.totals-item .label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--teal-700);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 0.2rem;
}

.totals-item .value {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--teal-600);
}

/* ================================================================
   SALES TABLE
================================================================ */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    margin-top: 1rem;
    border: 1px solid var(--border);
    scrollbar-width: thin;
    scrollbar-color: var(--honey-400) var(--honey-100);
}

.table-container::-webkit-scrollbar { height: 5px; }
.table-container::-webkit-scrollbar-track { background: var(--honey-100); }
.table-container::-webkit-scrollbar-thumb {
    background: var(--honey-400);
    border-radius: 3px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    min-width: 820px;
    background: white;
}

thead {
    background: linear-gradient(135deg, var(--teal-600) 0%, var(--teal-700) 100%);
    color: white;
    position: sticky;
    top: 0;
    z-index: 2;
}

thead th {
    padding: 0.8rem 0.6rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    white-space: nowrap;
}

thead th.num { text-align: right; }

tbody tr {
    border-bottom: 1px solid var(--earth-200);
    transition: background-color 150ms ease;
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover { background: var(--honey-50); }

tbody td {
    padding: 0.65rem 0.6rem;
    white-space: nowrap;
    vertical-align: middle;
    color: var(--text-900);
}

#salesTable td.num   { text-align: right; }
#salesTable td.owing { color: var(--rose-600); font-weight: 600; }
#salesTable td.overpay { color: var(--honey-700); font-weight: 600; }

tbody tr.credit-row {
    background: linear-gradient(to right, #fff1f2, #ffe4e6);
}

tbody tr.credit-row:hover {
    background: linear-gradient(to right, #ffe4e6, #fecdd3);
}

/* ================================================================
   PRODUCT MANAGER
================================================================ */
#productManager {
    background: var(--honey-50);
    border: 2px dashed var(--honey-400);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-top: 0.75rem;
}

.product-list-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    background: white;
    border-radius: var(--radius-xs);
    margin-bottom: 0.5rem;
    border: 1px solid var(--border);
    transition: border-color var(--duration) ease;
}

.product-list-item:hover { border-color: var(--honey-400); }

@media (min-width: 480px) {
    .product-list-item {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

/* ================================================================
   INVENTORY MANAGEMENT
================================================================ */
#inventoryManager {
    background: #f0fdf4;
    border: 2px solid var(--emerald-500);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-top: 0.75rem;
}

/* Low stock alert */
.low-stock-alert {
    background: linear-gradient(135deg, #fff1f2 0%, #ffe4e6 100%);
    border: 2px solid var(--rose-400);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 1rem;
}

.low-stock-alert h4 {
    color: var(--rose-600);
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.low-stock-alert ul { list-style: none; }

.alert-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.65rem 0.75rem;
    background: white;
    border-radius: var(--radius-xs);
    margin-bottom: 0.4rem;
    border-left: 4px solid var(--rose-400);
    flex-wrap: wrap;
    gap: 0.4rem;
}

.alert-item.out-of-stock-item { border-left-color: var(--rose-600); background: #fff1f2; }
.alert-item.low-stock-item    { border-left-color: var(--honey-500); background: var(--honey-50); }
.alert-item span { flex: 1; min-width: 150px; font-size: 0.85rem; }

/* Inventory item cards */
.inventory-item {
    background: white;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 0.75rem;
    transition: all var(--duration) ease;
}

.inventory-item:hover {
    border-color: var(--honey-400);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.inventory-item.low-stock  { border-color: var(--honey-400); background: var(--honey-50); }
.inventory-item.out-of-stock { border-color: var(--rose-400); background: #fff1f2; }

.inventory-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--earth-200);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.inventory-item-header h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-900);
}

.inventory-status-badge {
    padding: 0.3rem 0.7rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.in-stock-badge    { background: #d1fae5; color: #065f46; border: 1px solid var(--emerald-400); }
.low-stock-badge   { background: var(--honey-100); color: var(--honey-800); border: 1px solid var(--honey-400); }
.out-of-stock-badge { background: #fee2e2; color: #991b1b; border: 1px solid var(--rose-400); }

.inventory-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.6rem;
    margin-bottom: 0.75rem;
}

.inventory-stat {
    background: var(--earth-100);
    padding: 0.6rem;
    border-radius: var(--radius-xs);
}

.inventory-stat .label {
    font-size: 0.7rem;
    color: var(--text-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.2rem;
}

.inventory-stat .value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-900);
}

.inventory-stat .value.text-success { color: var(--emerald-500); }
.inventory-stat .value.text-warning { color: var(--honey-500); }
.inventory-stat .value.text-danger  { color: var(--rose-500); }

.inventory-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.inventory-actions .btn {
    flex: 1;
    min-width: 100px;
    padding: 0.55rem 0.8rem;
    font-size: 0.85rem;
    min-height: 40px;
}

.inventory-summary {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border: 1.5px solid var(--emerald-400);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    text-align: center;
    margin-top: 1rem;
}

.inventory-summary h3 {
    color: #065f46;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.4rem;
}

.inventory-summary-value {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--emerald-600);
    line-height: 1;
}

.inventory-summary-unit {
    font-size: 0.85rem;
    color: var(--emerald-600);
    font-weight: 500;
    margin-top: 0.25rem;
}

/* ================================================================
   DATA PROTECTION
================================================================ */
.data-protection-container { width: 100%; }

#dataProtectionMenu {
    display: none;
    margin-top: 1rem;
}

#dataProtectionMenu.show { display: block; }

.data-protection-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--earth-100);
    border-radius: var(--radius-sm);
    border: 1px solid var(--earth-200);
    box-sizing: border-box;
    width: 100%;
    overflow: hidden;
}

@media (min-width: 640px) {
    .data-protection-grid { grid-template-columns: repeat(3, 1fr); }
}

.data-protection-grid .btn {
    margin-bottom: 0;
    width: 100%;
    font-size: 0.80rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
    white-space: normal;
    word-break: break-word;
    min-height: 44px;
    text-align: center;
}

.data-stats {
    background: linear-gradient(135deg, #ecfeff 0%, #cffafe 100%);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin: 1rem 0;
    border: 1px solid #06b6d4;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #cffafe;
    font-size: 0.88rem;
}

.stat-label { color: var(--text-500); font-weight: 500; }
.stat-value { font-weight: 600; color: var(--secondary); }

.warning-box {
    background: #fff1f2;
    border: 1.5px solid #fecdd3;
    border-radius: var(--radius-xs);
    padding: 1rem;
    margin: 1rem 0;
    color: #9f1239;
    font-size: 0.88rem;
}

.warning-box ul { margin: 0.5rem 0; padding-left: 1.5rem; }
.warning-box li { margin-bottom: 0.3rem; }

/* ================================================================
   GOOGLE DRIVE SECTION
================================================================ */
.google-drive-section {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1.5px solid #7dd3fc;
    border-radius: var(--radius-sm);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.drive-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.drive-header h3 {
    color: #0369a1;
    font-size: 1rem;
    font-weight: 700;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    background: white;
    border-radius: 20px;
    border: 1px solid #bae6fd;
    box-shadow: var(--shadow-sm);
}

.status-indicator {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--rose-500);
    animation: pulse 2s infinite;
}

.status-indicator.connected {
    background: var(--emerald-500);
    animation: none;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.connection-status span {
    font-size: 0.82rem;
    font-weight: 600;
    color: #334155;
}

.drive-panel {
    background: white;
    border-radius: var(--radius-xs);
    padding: 1rem;
}

.info-text {
    color: #64748b;
    font-size: 0.88rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.drive-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: #f8fafc;
    border-radius: var(--radius-xs);
    flex-wrap: wrap;
    gap: 0.4rem;
}

.info-row .label { font-weight: 600; color: #475569; font-size: 0.82rem; }
.info-row .value { color: #0ea5e9; font-weight: 600; font-size: 0.82rem; word-break: break-all; }

.drive-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.drive-actions .btn {
    flex: 1;
    min-width: 100px;
    margin: 0;
    font-size: 0.85rem;
}

.backups-list {
    max-height: 380px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    padding: 0.5rem;
}

.backup-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem;
    background: #f9fafb;
    border-radius: var(--radius-xs);
    margin-bottom: 0.4rem;
    border: 1px solid var(--border);
    transition: all var(--duration) ease;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.backup-item:hover {
    background: white;
    border-color: #7dd3fc;
    box-shadow: var(--shadow-sm);
}

.backup-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    min-width: 180px;
}

.backup-info strong { color: #1e293b; font-size: 0.88rem; }
.backup-item button { margin: 0; }

@media (max-width: 768px) {
    .google-drive-section {
        margin-bottom: 1rem;
        border-radius: var(--radius-sm);
    }
    .drive-header { flex-direction: column; align-items: flex-start; }
    .connection-status { width: 100%; justify-content: center; }
    .drive-actions { flex-direction: column; }
    .drive-actions .btn { width: 100%; }
    .info-row { flex-direction: column; gap: 0.2rem; }
    .backup-item { flex-direction: column; align-items: stretch; }
    .backup-info { width: 100%; }
    .backup-item .btn { width: 100%; }
}

/* ================================================================
   EXPORT ACTIONS
================================================================ */
.export-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 1rem 0;
}

@media (min-width: 480px) {
    .export-actions { flex-direction: row; }
}

.export-btn { flex: 1; min-height: 52px; padding-top: 0.85rem; padding-bottom: 0.85rem; }

/* ================================================================
   SWIPE HINT
================================================================ */
.swipe-hint {
    text-align: center;
    color: var(--text-500);
    font-size: 0.78rem;
    padding: 0.5rem;
    background: var(--earth-100);
    border-radius: var(--radius-xs);
    margin-bottom: 0.5rem;
    border: 1px solid var(--earth-200);
    letter-spacing: 0.3px;
}

/* ================================================================
   MODALS
================================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(28, 25, 23, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 1rem;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 480px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s var(--ease-out);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h3 {
    font-family: 'Playfair Display', Georgia, serif;
    color: var(--honey-800);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

.modal-actions .btn { flex: 1; min-width: 100px; margin: 0; }

/* Inline modals (JS-generated fixed divs) */
div[style*="position:fixed"] > div {
    border-radius: var(--radius) !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
}

@media (max-width: 768px) {
    div[style*="position:fixed"] > div {
        width: 95% !important;
        padding: 1rem !important;
    }
    .modal-content { padding: 1.25rem; }
}

/* ================================================================
   INVENTORY CALCULATION
================================================================ */
.inventory-calculation {
    background: #f0fdf4;
    border: 1.5px solid var(--emerald-400);
    border-radius: var(--radius-xs);
    padding: 1rem;
    margin: 0.75rem 0;
}

.calc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    border-bottom: 1px solid #d1fae5;
}

.calc-row:last-child { border-bottom: none; }
.calc-row span { font-weight: 600; font-size: 0.88rem; }
.calc-value { font-size: 1.2rem; color: var(--emerald-500); font-weight: 700; }

/* ================================================================
   OWING / OVERPAYMENT SECTIONS
================================================================ */
#owingSection, #overpaymentSection {
    background: var(--honey-50);
    border: 1.5px solid var(--honey-300);
    border-radius: var(--radius-xs);
    padding: 0.75rem;
    margin-top: 0.5rem;
}

#overpaymentSection {
    background: #f0fdf4;
    border-color: var(--emerald-400);
}

/* ================================================================
   TOGGLE BUTTONS (full width on mobile)
================================================================ */
#toggleSalesBtn,
#toggleProductManager,
#toggleInventoryManager,
#toggleDataProtection,
#toggleCreditViewBtn {
    width: 100%;
    margin-bottom: 0.5rem;
}

@media (min-width: 640px) {
    #toggleSalesBtn,
    #toggleProductManager,
    #toggleInventoryManager,
    #toggleDataProtection,
    #toggleCreditViewBtn {
        width: auto;
    }
}

#salesForm button[type="submit"] { width: 100%; margin-top: 1rem; }

#clearFiltersBtn { width: 100%; }
@media (min-width: 480px) { #clearFiltersBtn { width: auto; } }

/* ================================================================
   TABLE BUTTONS
================================================================ */
#salesTable button {
    padding: 0.35rem 0.6rem !important;
    font-size: 0.78rem !important;
    margin: 0 !important;
    min-height: 32px;
    border-radius: var(--radius-xs);
}

/* Delete bin icon button — overrides generic table button rule */
.btn-delete-icon {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 30px !important;
    height: 30px !important;
    padding: 0 !important;
    min-height: unset !important;
    border: 1.5px solid var(--earth-200);
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--earth-500);
    cursor: pointer;
    transition: background var(--duration) ease,
                border-color var(--duration) ease,
                color var(--duration) ease,
                transform 150ms ease;
}

.btn-delete-icon:hover {
    background: #fff1f2;
    border-color: var(--rose-400);
    color: var(--rose-600);
    transform: scale(1.12);
}

.btn-delete-icon:active {
    transform: scale(0.95) !important;
    background: #ffe4e6;
}

/* ================================================================
   ANIMATIONS
================================================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50%       { opacity: 0.8; box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

/* ================================================================
   PRINT
================================================================ */
@media print {
    .no-print, .btn, button { display: none !important; }
    .card { box-shadow: none; border: 1px solid #ddd; }
    body::before { display: none; }
}

/* ================================================================
   MOBILE BREAKPOINTS — REFINED
================================================================ */
@media (max-width: 768px) {
    main { padding: 0.75rem; }

    .card {
        padding: 1rem;
        border-radius: var(--radius-sm);
    }

    .card h2 { font-size: 1rem; }

    /* Prevent iOS input zoom */
    input, select, textarea { font-size: 16px !important; }

    /* Better touch targets */
    .btn, button { min-height: 48px; }

    .table-container {
        margin: 0 -1rem;
        width: calc(100% + 2rem);
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .filters-grid { grid-template-columns: 1fr !important; }

    .dashboard-grid { gap: 0.5rem; }
    .dashboard-card { padding: 0.75rem 0.5rem; }
    .dashboard-card h3 { font-size: 0.65rem; }

    .export-actions { flex-direction: column; }
    .export-btn { width: 100% !important; }

    .totals-display { grid-template-columns: repeat(2, 1fr); }

    .inventory-item-header { flex-direction: column; }
    .inventory-details { grid-template-columns: 1fr 1fr; }
    .inventory-actions { flex-direction: column; }
    .inventory-actions .btn { width: 100%; }
    .alert-item { flex-direction: column; align-items: flex-start; }
    .alert-item span { width: 100%; }

    .data-protection-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }
}

@media (max-width: 480px) {
    main { padding: 0.5rem; }

    header h1 { font-size: 1rem; }
    header p  { font-size: 0.72rem; }

    .logo-container { width: 44px; height: 44px; }

    .dashboard-grid { grid-template-columns: 1fr; }
    .data-protection-grid { grid-template-columns: 1fr; }
    .totals-display { grid-template-columns: 1fr 1fr; }

    /* Hide less important table columns on tiny screens */
    #salesTable th:nth-child(8),
    #salesTable td:nth-child(8),
    #salesTable th:nth-child(11),
    #salesTable td:nth-child(11) { display: none; }

    .inventory-summary-value { font-size: 2rem; }
}

/* Landscape mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .table-container { max-height: 55vh; }
    .card { padding: 0.75rem; }
    header { padding: 0; }
    .header-content { padding: 0.6rem 1rem; }
    .logo-container { width: 40px; height: 40px; }
}

/* ================================================================
   FOCUS VISIBLE (accessibility)
================================================================ */
:focus-visible {
    outline: 2px solid var(--honey-500);
    outline-offset: 2px;
}

/* ================================================================
   CREDIT SECTION TOGGLE
================================================================ */
#salesSection { display: none; }
#salesSection.show { display: block !important; }

/* Touch active feedback */
.btn:active { transform: scale(0.97) !important; }
.card:active { transform: none !important; }
