:root {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --text: #333;
    --text-secondary: #666;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #f59e0b;
    --border: #e2e8f0;
    --shadow: 0 2px 8px rgba(0,0,0,0.05);
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --card-radius: 12px;
    --transition: 0.3s;
}

body.dark {
    --bg: #0f172a;
    --surface: #1e293b;
    --text: #e2e8f0;
    --text-secondary: #94a3b8;
    --border: #334155;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
    --sidebar-bg: #0f172a;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: background var(--transition), color var(--transition);
}

.screen { display: none; }
.screen.active { display: flex; }

#login-screen {
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: linear-gradient(135deg, #1e3a8a, #2563eb);
}
.login-container {
    background: var(--surface);
    padding: 40px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    width: 350px;
    text-align: center;
}
.login-container h1 { margin-bottom: 24px; color: var(--primary); }
input, select, textarea, button {
    width: 100%; padding: 12px; margin: 8px 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    background: var(--surface);
    color: var(--text);
}
button {
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 600;
}
button:hover { background: var(--primary-hover); }
.error { color: var(--danger); font-size: 14px; }

/* Sidebar */
#main-screen {
    display: none;
    height: 100vh;
}
#main-screen.active {
    display: flex;
}
/* Hide all sidebar links initially; JS will show them based on role */
.nav-links li {
    display: none;
}
.sidebar {
    width: 250px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    transition: background var(--transition);
}
.sidebar .logo {
    font-size: 24px;
    font-weight: bold;
    padding: 0 20px 20px;
    border-bottom: 1px solid var(--border);
}
.nav-links { list-style: none; flex: 1; padding: 20px 0; }
.nav-links li {
    padding: 12px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.2s;
}
.nav-links li:hover, .nav-links li.active {
    background: rgba(255,255,255,0.1);
}
.user-info {
    padding: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    font-size: 14px;
}
.content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* Cards */
.card {
    background: var(--surface);
    border-radius: var(--card-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}
.card-header {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}
th, td {
    padding: 12px 8px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
th { background: var(--surface); font-weight: 600; }

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
}
.modal.active { display: flex; }
.modal-content {
    background: var(--surface);
    border-radius: var(--card-radius);
    padding: 24px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}
.close {
    position: absolute; top: 10px; right: 16px;
    font-size: 28px; cursor: pointer; color: var(--text-secondary);
}

.toast {
    position: fixed; bottom: 20px; right: 20px;
    background: var(--primary); color: white; padding: 12px 24px;
    border-radius: 8px; display: none; z-index: 2000; animation: slideUp 0.3s;
}
tr.low-stock td {
    background: rgba(220,38,38,0.05);
}
.metric-card {
    background: var(--surface);
    border-radius: var(--card-radius);
    padding: 16px 24px;
    box-shadow: var(--shadow);
    min-width: 150px;
}
.metric-card span { font-size: 14px; color: var(--text-secondary); }
.metric-card strong { display: block; font-size: 22px; margin-top: 4px; }
.report-controls select, .report-controls input { width: auto; }
/*setting */
.settings-tab {
    background: none;
    border: none;
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    font-weight: 600;
    color: var(--text-secondary);
    transition: 0.2s;
    white-space: nowrap;
}
.settings-tab:hover {
    color: var(--primary);
}
.settings-tab.active {
    border-bottom-color: var(--primary);
    color: var(--primary);
}
/* serach barcode */
.search-dropdown {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0 0 8px 8px;
    max-height: 150px;
    overflow-y: auto;
    position: absolute;
    width: calc(100% - 2px);
    z-index: 10;
    display: none;
}
.search-result-item {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.search-result-item:hover {
    background: var(--primary);
    color: white;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } }

/* POS specific */
.pos-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 20px;
}
@media (max-width: 900px) {
    .pos-layout { grid-template-columns: 1fr; }
    .sidebar { width: 70px; }
    .sidebar .nav-links li span { display: none; }
}