:root {
    /* Smollan Digital Colour Palette */
    --primary-dark: #002B4e;
    --primary: #0079c0;
    --primary-hover: #00bbf0;
    --primary-light: #dfe8f5;
    
    --accent-green: #005b5c;
    --accent-light-green: #8ac546;
    
    /* UI Colors */
    --bg-main: #f4f7fb;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

#app {
    width: 100%;
    max-width: 480px; 
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
    background-color: var(--bg-main);
    box-shadow: 0 0 20px rgba(0,0,0,0.05); /* Soft wrapper shadow */
}

/* Screens */
.screen {
    display: none;
    min-height: 100vh;
    animation: fadeIn 0.3s ease;
    flex-direction: column;
}
.screen.active { display: flex; }

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

/* Typography */
h1, h2, h3 { font-weight: 700; color: var(--primary-dark); }
.text-center { text-align: center; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 250px; }

/* Components */
.card {
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}

/* Login Screen */
.login-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
}

.logo-area { text-align: center; margin-bottom: 2.5rem; color: #fff; }
.brand-logo { 
    font-size: 32px; font-weight: 800; letter-spacing: 2px; 
    margin-bottom: 0.5rem; 
}
.logo-area p { opacity: 0.8; font-size: 0.9rem; }

.login-card { padding: 1.5rem; }

.input-group { margin-bottom: 1.25rem; }
.input-group label { display: block; margin-bottom: 0.4rem; font-size: 0.85rem; color: var(--text-muted); font-weight: 500;}
.input-group input {
    width: 100%; padding: 0.875rem; border-radius: 10px;
    background: var(--bg-main); border: 1px solid var(--border);
    color: var(--text-main); font-size: 1rem; transition: all 0.2s;
}
.input-group input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

.btn-primary {
    width: 100%; padding: 0.875rem; background: var(--primary); color: white;
    font-weight: 600; font-size: 1rem; border-radius: 10px; border: none; cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
.btn-primary:active { transform: scale(0.98); }
.btn-primary:hover { background: var(--primary-hover); }

.login-error { color: #ef4444; text-align: center; margin-top: 1rem; font-size: 0.85rem; min-height: 20px; }

/* Header Elements */
.app-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 1.25rem; background: var(--primary-dark); color: white;
    position: sticky; top: 0; z-index: 999;
}
.app-header h2 { color: white; margin: 0; }
.brand-logotext { font-size: 18px !important; font-weight: 800; letter-spacing: 1px; }

.detail-header { padding: 0.75rem 1rem; position: sticky; top: 0; z-index: 999; }
.store-info-header { flex: 1; display: flex; flex-direction: column; align-items: center; overflow: hidden; }
.store-info-header h2 { font-size: 1.1rem; line-height: 1.2; }
.store-meta-header { font-size: 0.75rem; color: #cbd5e1; margin-top: 2px; }

.btn-icon {
    color: white; padding: 0.5rem; border-radius: 8px; cursor: pointer;
    background: transparent; border: none; transition: background 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.btn-icon:hover { background: rgba(255,255,255,0.1); }

/* Search Area */
.search-bar-container { padding: 1rem 1.25rem; position: sticky; top: 62px; background: var(--bg-main); z-index: 998; }
.search-input-wrapper { position: relative; }
.search-icon { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-input-wrapper input {
    width: 100%; padding: 0.875rem 1rem 0.875rem 2.8rem; border-radius: 12px;
    background: var(--bg-card); border: 1px solid var(--border);
    color: var(--text-main); font-size: 0.95rem; box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    transition: all 0.2s;
}
.search-input-wrapper input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

/* Store List */
.store-list-container { padding: 0 1.25rem 2rem; flex: 1; }
.store-list { list-style: none; }
.store-card {
    padding: 1rem; margin-bottom: 0.75rem; cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.store-card:active { transform: scale(0.98); }
.store-card:hover { border-color: var(--primary); box-shadow: 0 8px 16px rgba(0,121,192,0.08); }

.store-code { display: inline-block; background: var(--primary-light); color: var(--primary-dark); padding: 0.2rem 0.5rem; border-radius: 6px; font-size: 0.75rem; font-weight: 700; margin-bottom: 0.5rem;}
.store-name { font-size: 1rem; font-weight: 600; margin-bottom: 0.25rem; color: var(--primary-dark); }
.store-meta { font-size: 0.8rem; color: var(--text-muted); display: flex; gap: 1rem;}

.loading-indicator, .empty-state { text-align: center; padding: 2rem; color: var(--text-muted); font-size: 0.9rem;}
.btn-secondary {
    display: block; width: 100%; padding: 0.875rem; background: var(--bg-card);
    border: 1px solid var(--border); color: var(--primary-dark); border-radius: 10px;
    font-weight: 600; margin-top: 1rem; cursor: pointer; transition: background 0.2s;
}
.btn-secondary:hover { background: var(--primary-light); border-color: var(--primary); }

/* Detail Screen */
.detail-content { padding: 1.25rem; }

.metric-card { padding: 1.25rem; margin-bottom: 1.5rem; border-left: 4px solid var(--primary); }
.metric-card h3 { font-size: 1rem; color: var(--text-muted); margin-bottom: 1rem; }
.metric-row { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 0; border-bottom: 1px dashed var(--border); }
.metric-row:last-child { border-bottom: none; padding-bottom: 0; }
.metric-label { color: var(--text-muted); font-weight: 500; }
.metric-value { font-weight: 700; font-size: 1.1rem; color: var(--text-main); }
.metric-value.highlight { color: var(--accent-light-green); font-size: 1.25rem; }

/* Grouped Inventory Styles */
.inventory-section h3 { margin-bottom: 1rem; font-size: 1.1rem; color: var(--primary-dark); }

.inv-category-group {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 1rem;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.inv-category-title {
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 0.75rem 1rem;
    font-weight: 700;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.inv-brand-group {
    border-bottom: 1px solid var(--border);
}
.inv-brand-group:last-child {
    border-bottom: none;
}

.inv-brand-title {
    padding: 0.5rem 1rem;
    background: #fafafa;
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
}

.inv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.inv-table th {
    background: #f8fafc;
    padding: 0.6rem 1rem;
    color: var(--text-muted);
    font-weight: 600;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.inv-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px dashed var(--border);
    color: var(--text-main);
}

.inv-table tr:last-child td { border-bottom: none; }
.inv-table tr:hover td { background: #f8fafc; }

.qty-inv {
    color: var(--primary);
    font-weight: 700;
    background: var(--primary-light);
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    display: inline-block;
    min-width: 40px;
}

.qty-sls {
    color: var(--accent-green);
    font-weight: 700;
    background: #e8f4ee;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    display: inline-block;
    min-width: 40px;
}

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

.loading-spinner {
    width: 24px; height: 24px;
    border: 3px solid var(--border);
    border-radius: 50%; border-top-color: var(--primary);
    animation: spin 1s linear infinite;
    margin: 1rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
