/* Premium CSS Design System for Cube Coffee Stock Tracker */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Color Tokens - Espresso & Cream Warm Palette */
    --bg-main: #f8faf7;
    --bg-surface: #ffffff;
    --bg-surface-glass: rgba(255, 255, 255, 0.75);
    --border-color: rgba(29, 78, 26, 0.08);
    --border-color-glass: rgba(255, 255, 255, 0.5);
    
    --color-text: #2c2520;
    --color-text-muted: #7d7268;
    
    --color-primary: #1d4e1a;
    --color-primary-light: #3a7535;
    --color-primary-dark: #0e290c;
    --color-accent: #2b6b27;
    --color-accent-light: #509e4a;
    --color-accent-bg: #f1fcf0;
    
    --color-success: #4e8d6f;
    --color-success-bg: #edf6f2;
    --color-warning: #d97706;
    --color-warning-bg: #fef3c7;
    --color-danger: #b91c1c;
    --color-danger-bg: #fee2e2;

    --font-sans: 'Outfit', sans-serif;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 30px;
    
    --shadow-sm: 0 2px 8px rgba(29, 78, 26, 0.04);
    --shadow-md: 0 8px 24px rgba(29, 78, 26, 0.06);
    --shadow-lg: 0 16px 40px rgba(29, 78, 26, 0.1);
    
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    
    --sidebar-width: 260px;
}

/* Dark Mode Override variables */
[data-theme="dark"] {
    --bg-main: #0c140b;
    --bg-surface: #121c11;
    --bg-surface-glass: rgba(18, 28, 17, 0.8);
    --border-color: rgba(235, 245, 234, 0.08);
    --border-color-glass: rgba(18, 28, 17, 0.5);
    
    --color-text: #ebf5ea;
    --color-text-muted: #95a394;
    
    --color-primary: #489942;
    --color-primary-light: #6ec467;
    --color-primary-dark: #1d4e1a;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--color-text);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    transition: background-color var(--transition-smooth), color var(--transition-smooth);
}

/* App shell wrapper */
.app-shell {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* Sidebar Layout */
aside {
    width: var(--sidebar-width);
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    padding: 2.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transition: transform var(--transition-smooth), background-color var(--transition-smooth);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 3rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--color-accent), var(--color-primary));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
    font-weight: 800;
    box-shadow: var(--shadow-sm);
}

.logo-text h1 {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--color-primary);
}

.logo-text p {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1.25rem;
    color: var(--color-text-muted);
    text-decoration: none;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.nav-item a:hover {
    color: var(--color-primary);
    background-color: rgba(92, 61, 46, 0.04);
}

.nav-item.active a {
    color: white;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
    box-shadow: var(--shadow-sm);
}

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: auto;
}

.theme-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background-color: rgba(92, 61, 46, 0.04);
    border: none;
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-weight: 500;
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.theme-toggle-btn:hover {
    background-color: rgba(92, 61, 46, 0.08);
}

/* Main Content Area */
main {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    padding: 2.5rem;
    min-width: 0;
}

header.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

.header-title h2 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.header-title p {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-accent), var(--color-primary));
    color: white;
    box-shadow: 0 4px 14px rgba(184, 92, 56, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(184, 92, 56, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--bg-surface);
    color: var(--color-text);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: rgba(92, 61, 46, 0.03);
}

/* Dashboard Widgets & Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

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

.stat-icon {
    width: 54px;
    height: 54px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background-color: rgba(92, 61, 46, 0.05);
    color: var(--color-primary);
}

.stat-card.out-of-stock .stat-icon {
    background-color: var(--color-danger-bg);
    color: var(--color-danger);
}

.stat-card.low-stock .stat-icon {
    background-color: var(--color-warning-bg);
    color: var(--color-warning);
}

.stat-card.healthy .stat-icon {
    background-color: var(--color-success-bg);
    color: var(--color-success);
}

.stat-info p {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
    font-weight: 600;
}

.stat-info h3 {
    font-size: 1.85rem;
    font-weight: 800;
    margin-top: 0.15rem;
}

/* Dashboard Split Grid (Charts & Lists) */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.grid-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
}

.grid-card-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
}

.grid-card-title h3 {
    font-size: 1.2rem;
    font-weight: 700;
}

.grid-card-title a {
    font-size: 0.85rem;
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 600;
}

.grid-card-title a:hover {
    text-decoration: underline;
}

/* Charts Containers */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 0.5rem;
}

.chart-wrapper {
    position: relative;
    height: 250px;
    width: 100%;
}

/* Recent Lists (Dashboard Table & Items) */
.list-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    background-color: rgba(92, 61, 46, 0.02);
    border-radius: var(--radius-md);
    border: 1px solid rgba(92, 61, 46, 0.04);
    transition: transform var(--transition-fast);
}

.list-item:hover {
    transform: translateX(4px);
    background-color: rgba(92, 61, 46, 0.04);
}

.list-item-left {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.item-initials {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background-color: var(--color-primary);
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.list-item-info h4 {
    font-size: 0.9rem;
    font-weight: 600;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list-item-info span {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.list-item-right {
    text-align: right;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

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

.badge-out {
    background-color: var(--color-danger-bg);
    color: var(--color-danger);
}

.badge-location {
    background-color: rgba(92, 61, 46, 0.08);
    color: var(--color-primary);
}

/* History Logs Specific List */
.log-item {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    background-color: rgba(92, 61, 46, 0.01);
    border: 1px solid rgba(92, 61, 46, 0.03);
    margin-bottom: 0.5rem;
}

.log-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-bottom: 0.25rem;
}

.log-body {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.log-body-left {
    font-weight: 500;
    font-size: 0.9rem;
}

.log-body-right {
    font-weight: 700;
    font-size: 0.95rem;
}

.log-type-incoming { color: var(--color-success); }
.log-type-outgoing { color: var(--color-text-muted); }
.log-type-wastage { color: var(--color-danger); }
.log-type-adjustment { color: var(--color-warning); }
.log-type-transfer_in { color: var(--color-success); }
.log-type-transfer_out { color: var(--color-text-muted); }

/* Table View in Tabs */
.view-panel {
    display: none;
}

.view-panel.active {
    display: block;
}

/* Search and Filters Bar */
.filter-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    background-color: var(--bg-surface);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.search-input-wrapper {
    flex-grow: 1;
    position: relative;
    min-width: 240px;
}

.search-input-wrapper input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    background-color: rgba(92, 61, 46, 0.02);
    color: var(--color-text);
    transition: all var(--transition-fast);
}

.search-input-wrapper input::placeholder {
    color: var(--color-text-muted);
    opacity: 0.8;
}

.search-input-wrapper input:focus {
    outline: none;
    border-color: var(--color-primary);
    background-color: var(--bg-surface);
    box-shadow: 0 0 0 3px rgba(92, 61, 46, 0.1);
}

.search-input-wrapper svg {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-muted);
}

.filter-select {
    padding: 0.75rem 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    color: var(--color-text);
    background-color: var(--bg-surface);
    cursor: pointer;
    outline: none;
}

.filter-select:focus {
    border-color: var(--color-primary);
}

/* Inventory Table */
.table-wrapper {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    box-shadow: var(--shadow-sm);
}

.responsive-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.responsive-table th,
.responsive-table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.responsive-table th {
    background-color: rgba(92, 61, 46, 0.02);
    font-weight: 700;
    color: var(--color-primary);
    font-size: 0.9rem;
}

.responsive-table tbody tr {
    transition: background-color var(--transition-fast);
}

.responsive-table tbody tr:hover {
    background-color: rgba(92, 61, 46, 0.01);
}

.responsive-table tbody tr:last-child td {
    border-bottom: none;
}

.table-qty-badge {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 0.9rem;
}

.table-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background-color: var(--bg-surface);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text);
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background-color: rgba(92, 61, 46, 0.04);
    color: var(--color-primary);
}

.btn-icon.btn-adjust {
    border-color: rgba(184, 92, 56, 0.2);
    color: var(--color-accent);
}

.btn-icon.btn-adjust:hover {
    background-color: var(--color-accent-bg);
}

/* Modal Popup Window */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(27, 21, 19, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

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

.modal-container {
    background-color: var(--bg-surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 540px;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: transform var(--transition-fast);
    overflow: hidden;
}

.modal-overlay.active .modal-container {
    transform: translateY(0);
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
}

.btn-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--color-text-muted);
}

.modal-body {
    padding: 2rem;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    background-color: rgba(92, 61, 46, 0.02);
    color: var(--color-text);
    outline: none;
    transition: all var(--transition-fast);
}

.form-control:focus {
    border-color: var(--color-primary);
    background-color: var(--bg-surface);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.radio-group {
    display: flex;
    gap: 0.5rem;
}

.radio-btn {
    flex-grow: 1;
}

.radio-btn input {
    display: none;
}

.radio-btn label {
    display: block;
    text-align: center;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
}

.radio-btn input:checked + label {
    background-color: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.modal-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Order List / Restock Screen styling */
.order-layout {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 1.5rem;
}

.order-items-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
}

.order-items-group {
    margin-bottom: 2rem;
}

.order-items-group h4 {
    border-bottom: 2px solid var(--color-accent);
    padding-bottom: 0.5rem;
    color: var(--color-primary);
    font-weight: 700;
    margin-bottom: 1rem;
}

.order-items-table {
    width: 100%;
    border-collapse: collapse;
}

.order-items-table th,
.order-items-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.order-preview-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    height: fit-content;
}

.order-text-preview {
    font-family: monospace;
    font-size: 0.85rem;
    background-color: rgba(92, 61, 46, 0.03);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    white-space: pre-wrap;
    overflow-y: auto;
    max-height: 400px;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-color);
    line-height: 1.5;
}

.show-mobile {
    display: none !important;
}
.hide-mobile {
    display: inline;
}

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

/* MOBILE TOP STICKY BAR */
.mobile-top-bar {
    display: none;
}

@media (max-width: 768px) {
    body {
        flex-direction: column;
        padding-bottom: 75px; /* Leave space for bottom nav bar */
        padding-top: 55px;    /* Leave space for top nav bar */
    }

    .app-shell {
        flex-direction: column;
        max-width: 100%;
    }
    
    .mobile-top-bar {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0 1.5rem;
        background-color: var(--bg-surface);
        border-bottom: 1px solid var(--border-color);
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 55px;
        z-index: 1000;
        box-shadow: var(--shadow-sm);
    }
    
    aside {
        position: fixed;
        bottom: 0;
        top: auto;
        left: 0;
        right: 0;
        width: 100%;
        height: 65px;
        background-color: var(--bg-surface);
        border-top: 1px solid var(--border-color);
        border-right: none;
        border-bottom: none;
        padding: 0;
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        z-index: 1000;
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.04);
    }
    
    .logo-container {
        display: none;
    }
    
    .nav-links {
        flex-direction: row;
        width: 100%;
        height: 100%;
        justify-content: space-around;
        align-items: center;
        gap: 0;
    }
    
    .nav-item {
        flex-grow: 1;
        text-align: center;
        height: 100%;
    }
    
    .nav-item a {
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 0.15rem;
        padding: 0.4rem 0;
        height: 100%;
        border-radius: 0;
        color: var(--color-text-muted);
        font-size: 0.65rem;
    }
    
    .nav-item a svg {
        width: 20px;
        height: 20px;
    }
    
    .nav-item.active a {
        background: none;
        color: var(--color-accent);
        box-shadow: none;
    }
    
    .sidebar-footer {
        display: none;
    }
    
    main {
        margin-left: 0;
        width: 100%;
        padding: 1.25rem;
    }
    
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .filter-bar {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .filter-select {
        width: 100%;
    }

    /* TABLE-CARD MOBILE RESPONSIVENESS */
    .responsive-table, 
    .responsive-table thead, 
    .responsive-table tbody, 
    .responsive-table th, 
    .responsive-table td, 
    .responsive-table tr {
        display: block;
    }
    
    .responsive-table thead {
        display: none; /* Hide header rows */
    }
    
    .show-mobile {
        display: inline !important;
    }
    .hide-mobile {
        display: none !important;
    }
    
    .responsive-table tbody tr {
        margin-bottom: 1rem;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        background-color: var(--bg-surface);
        padding: 1rem;
        box-shadow: var(--shadow-sm);
        border-left: 1px solid var(--border-color);
    }
    
    .responsive-table tbody tr.row-low {
        border-left: 5px solid #d97706 !important;
    }
    
    .responsive-table tbody tr.row-critical {
        border-left: 5px solid #ea580c !important;
    }
    
    .responsive-table tbody tr.row-out {
        border-left: 5px solid #b91c1c !important;
    }
    
    .responsive-table tbody tr td:first-child {
        box-shadow: none !important;
    }
    
    .responsive-table td {
        border-bottom: 1px solid rgba(92, 61, 46, 0.04);
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.65rem 0;
        text-align: right;
        font-size: 0.9rem;
    }
    
    .responsive-table td:last-child {
        border-bottom: none;
        padding-bottom: 0.25rem;
    }
    
    .responsive-table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--color-primary);
        text-align: left;
        font-size: 0.8rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    .table-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .table-inline-qty {
        width: 100px; /* Wider input for mobile fingers */
        padding: 0.45rem 0.5rem;
    }

    /* Stats 2x2 layout on mobile */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }
    
    .stat-card {
        padding: 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .stat-icon {
        width: 38px;
        height: 38px;
        font-size: 1.15rem;
    }
    
    .stat-info h3 {
        font-size: 1.35rem;
    }
}

/* Klikable Headers & Sorting Indicators */
.sortable-header {
    cursor: pointer;
    position: relative;
    transition: background-color var(--transition-fast);
}

.sortable-header:hover {
    background-color: rgba(92, 61, 46, 0.06) !important;
}

.sort-icon {
    font-size: 0.75rem;
    margin-left: 0.35rem;
    display: inline-block;
    vertical-align: middle;
    color: var(--color-accent);
}

/* Stock Level Badges */
.stock-badge {
    display: inline-block;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    white-space: nowrap;
}

.stock-ok {
    background-color: rgba(78, 141, 111, 0.12);
    color: #2e7d56;
    border: 1px solid rgba(78, 141, 111, 0.25);
}

.stock-low {
    background-color: rgba(217, 119, 6, 0.12);
    color: #b45309;
    border: 1px solid rgba(217, 119, 6, 0.3);
}

.stock-critical {
    background-color: rgba(234, 88, 12, 0.12);
    color: #c2410c;
    border: 1px solid rgba(234, 88, 12, 0.3);
}

.stock-out {
    background-color: rgba(185, 28, 28, 0.1);
    color: #b91c1c;
    border: 1px solid rgba(185, 28, 28, 0.25);
}

/* Row tinting by stock status — subtle left border accent */
tr.row-low td:first-child {
    box-shadow: inset 3px 0 0 #d97706;
}

tr.row-critical td:first-child {
    box-shadow: inset 3px 0 0 #ea580c;
}

tr.row-out td:first-child {
    box-shadow: inset 3px 0 0 #b91c1c;
}

[data-theme="dark"] .stock-ok   { color: #4ade80; background-color: rgba(74,222,128,0.1); border-color: rgba(74,222,128,0.2); }
[data-theme="dark"] .stock-low  { color: #fbbf24; background-color: rgba(251,191,36,0.1); border-color: rgba(251,191,36,0.2); }
[data-theme="dark"] .stock-critical { color: #fb923c; background-color: rgba(251,146,60,0.1); border-color: rgba(251,146,60,0.2); }
[data-theme="dark"] .stock-out  { color: #f87171; background-color: rgba(248,113,113,0.1); border-color: rgba(248,113,113,0.2); }

/* Inline Edit count inputs */
.table-inline-qty {
    width: 90px;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-weight: 700;
    background-color: rgba(92, 61, 46, 0.02);
    color: var(--color-text);
    outline: none;
    transition: all var(--transition-fast);
    text-align: center;
}

.table-inline-qty:focus {
    border-color: var(--color-primary);
    background-color: var(--bg-surface);
    box-shadow: 0 0 0 2px rgba(92, 61, 46, 0.1);
}

/* Inline Input Saving Animations */
.table-inline-qty.save-success {
    animation: save-flash-success 1.2s ease;
}

.table-inline-qty.save-error {
    animation: save-flash-error 1.2s ease;
}

@keyframes save-flash-success {
    0% { border-color: var(--color-success); box-shadow: 0 0 0 3px rgba(78, 141, 111, 0.3); background-color: var(--color-success-bg); }
    100% { border-color: var(--border-color); box-shadow: none; background-color: rgba(92, 61, 46, 0.02); }
}

@keyframes save-flash-error {
    0% { border-color: var(--color-danger); box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.3); background-color: var(--color-danger-bg); }
    100% { border-color: var(--border-color); box-shadow: none; background-color: rgba(92, 61, 46, 0.02); }
}

/* Quick Search Autocomplete Results */
.quick-dropdown-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    max-height: 250px;
    overflow-y: auto;
    margin-top: 0.25rem;
}

.quick-dropdown-item {
    padding: 0.85rem 1.25rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background-color var(--transition-fast);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
}

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

.quick-dropdown-item:hover {
    background-color: rgba(92, 61, 46, 0.04);
    color: var(--color-primary);
}

.quick-dropdown-item .item-meta {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.btn-quick-val {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

/* Prototype Storage Layout Selection Buttons */
.btn-layout {
    background-color: var(--bg-surface);
    color: var(--color-text-muted);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.btn-layout:hover {
    background-color: rgba(29, 78, 26, 0.04);
    color: var(--color-text);
}
.btn-layout.active {
    background-color: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

/* Option 3: Appliance Columns Layout */
.appliance-columns-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.appliance-column-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.appliance-column-header {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--color-primary);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.appliance-column-count {
    font-size: 0.75rem;
    font-weight: 700;
    background-color: rgba(29, 78, 26, 0.08);
    color: var(--color-primary);
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
}

.appliance-column-items {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.appliance-item-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    background-color: var(--bg-main);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
    transition: all var(--transition-fast);
}

.appliance-item-card:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--color-primary);
}

.appliance-item-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--color-text);
}

.appliance-item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.appliance-sub-location-badge {
    background-color: rgba(29, 78, 26, 0.08);
    color: var(--color-primary);
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 700;
}

.badge-appliance-blue {
    background-color: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.2);
}
[data-theme="dark"] .badge-appliance-blue {
    background-color: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.badge-appliance-cyan {
    background-color: rgba(6, 182, 212, 0.1);
    color: #06b6d4;
    border: 1px solid rgba(6, 182, 212, 0.2);
}
[data-theme="dark"] .badge-appliance-cyan {
    background-color: rgba(6, 182, 212, 0.2);
    color: #22d3ee;
}


/* ===================================================
   SETTINGS PAGE: 2-Column Card Grid
   =================================================== */

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

.settings-col {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Settings summary card: icon + text block + CTA button stacked */
.settings-summary-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.settings-card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    flex-shrink: 0;
}

.settings-card-body {
    flex: 1;
}

.settings-card-body h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
}

.settings-card-body p {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin: 0 0 0.75rem;
    line-height: 1.5;
}

.settings-card-btn {
    width: 100%;
    justify-content: center;
    gap: 0.5rem;
    margin-top: auto;
}

/* Summary pills on settings cards */
.settings-summary-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.summary-pill {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    background: var(--bg-main);
    border: 1px solid var(--border-color);
    color: var(--color-text-muted);
    white-space: nowrap;
}

.summary-pill strong {
    color: var(--color-text);
    font-weight: 700;
    margin-left: 0.25rem;
}

/* Stack to single column on mobile */
@media (max-width: 768px) {
    .settings-grid {
        grid-template-columns: 1fr;
    }
}
