:root {
    --primary: #2E7D32;
    --primary-dark: #1B5E20;
    --secondary: #8D6E63;
    --secondary-dark: #6D4C41;
    --accent: #FBC02D;
    --accent-dark: #F9A825;
    --bg-base: #FAF7F0;
    --bg-alt: #F1F8E9;
    --text-main: #263238;
    --success: #4CAF50;
    --warning: #FFA000;
    --error: #D32F2F;
    --white: #FFFFFF;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-base);
    color: var(--text-main);
}

/* App Container (Mobile View Simulation) */
#app {
    max-width: 480px;
    margin: 0 auto;
    background-color: var(--bg-base);
    height: 100vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 15px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
}

main {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    background-color: var(--primary);
    color: var(--white);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
    z-index: 10;
}

header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.view-section {
    display: none;
    padding: 20px;
    width: 100%;
}

.view-section.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* Typography & Utilities */
h2 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: var(--primary-dark);
}

.text-muted { color: #666; font-size: 0.9rem; }
.text-danger { color: var(--error); font-weight: bold; }
.text-success { color: var(--success); font-weight: bold; }
.text-warning { color: var(--warning); font-weight: bold; }

/* Cards */
.card {
    background: var(--white);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    border-left: 4px solid var(--primary);
}

.card.warning-card { border-left-color: var(--warning); }
.card.error-card { border-left-color: var(--error); background-color: #fff9f9; }

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--white);
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    text-align: center;
}

.stat-card .value {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    margin-top: 5px;
}

/* Inventory List */
.item-card {
    background: var(--white);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    gap: 15px;
}

.item-image {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
    background-color: var(--bg-alt);
}

.item-details { flex: 1; }
.item-title { font-weight: 600; margin-bottom: 4px; }
.item-subtitle {
    font-size: 0.85rem;
    color: #666;
    display: flex;
    justify-content: space-between;
}

.badge {
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
    color: white;
}
.badge.safe { background-color: var(--success); }
.badge.low { background-color: var(--warning); color: black; }
.badge.out { background-color: var(--error); }

/* Buttons */
.btn {
    display: inline-block;
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--white);
}

.btn-primary:active { background-color: var(--primary-dark); }

.btn-secondary {
    background-color: transparent;
    color: var(--secondary-dark);
    border: 2px solid var(--secondary);
}

.btn-secondary:active { background-color: var(--secondary); color: white; }

.btn-accent {
    background-color: var(--accent);
    color: #000;
}

/* Forms */
.form-group { margin-bottom: 15px; }
label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 0.9rem; }
input, select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    background-color: #fff;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.2);
}

/* Bottom Nav */
.bottom-nav {
    background-color: var(--white);
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
    padding-bottom: env(safe-area-inset-bottom, 10px); /* Handle notch on newer phones */
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    z-index: 10;
    width: 100%;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #999;
    cursor: pointer;
    padding: 5px;
    transition: color 0.2s;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item i {
    font-size: 1.4rem;
    margin-bottom: 4px;
}

.nav-item span {
    font-size: 0.75rem;
    font-weight: 500;
}

/* PERFORMANCE & GPU ACCELERATION */
header, .bottom-nav, main, #app {
    transform: translateZ(0); 
    backface-visibility: hidden;
    perspective: 1000;
}

.view-section.active {
    display: block;
    animation: fadeIn 0.15s ease-out; /* Faster transition */
    will-change: opacity, transform;
}

header {
    will-change: transform;
}

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

/* Authentication & Admin UI */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(46, 125, 50, 0.95); /* Semi-transparent Primary */
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.auth-card {
    background: white;
    width: 100%;
    max-width: 400px;
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    text-align: center;
    animation: zoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes zoomIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.auth-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    border-radius: 12px;
}

.auth-card h2 {
    color: var(--primary-dark);
    margin-bottom: 10px;
}

.auth-card p {
    color: #666;
    margin-bottom: 20px;
    font-size: 0.95rem;
    line-height: 1.4;
}

.wa-link {
    display: inline-block;
    background: #25D366;
    color: white;
    padding: 10px 20px;
    border-radius: 30px;
    text-decoration: none;
    font-weight: 600;
    margin-top: 10px;
}

.key-display {
    background: var(--bg-alt);
    padding: 15px;
    border-radius: 8px;
    font-family: monospace;
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--primary-dark);
    margin-top: 15px;
    letter-spacing: 2px;
    border: 1px dashed var(--primary);
}

.admin-tool h3 {
    font-size: 1rem;
    margin-bottom: 10px;
    text-align: left;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: #999;
    padding: 5px;
}

.btn-close:hover {
    color: var(--error);
}

/* Admin Tabbed UI */
.admin-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

.admin-tab-btn {
    flex: 1;
    padding: 10px 5px;
    border: none;
    background: none;
    font-size: 0.85rem;
    font-weight: 600;
    color: #999;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    transition: all 0.3s;
}

.admin-tab-btn.active {
    color: var(--primary);
    border-bottom: 3px solid var(--primary);
    background: var(--bg-alt);
}

.admin-tab-pane {
    display: none;
    animation: slideIn 0.3s ease;
}

.admin-tab-pane.active {
    display: block;
}

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

.log-item {
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.log-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    margin-right: 8px;
}
.log-badge.login { background: #E3F2FD; color: #1976D2; }
.log-badge.register { background: #E8F5E9; color: #2E7D32; }
.log-badge.activate { background: #FFF3E0; color: #EF6C00; }

/* History Search & Settlement */
.history-search-container {
    position: relative;
    margin-bottom: 20px;
}

.history-search-container i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
}

.history-search-container input {
    padding-left: 35px;
}

.settle-btn {
    width: auto;
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 6px;
}

/* Animations */
@keyframes pulse-success {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.settled-badge {
    animation: pulse-success 2s infinite;
    display: inline-block;
}

