:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-soft: #dbeafe;
  --danger: #dc2626;
  --success: #059669;
  --shadow: 0 12px 25px rgba(17, 24, 39, 0.08);
  --radius: 16px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Inter", sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
button, input, select { font: inherit; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 260px;
  background: #0f172a; color: #e2e8f0;
  padding: 22px 14px; transform: translateX(-100%);
  transition: transform 0.25s ease; z-index: 30;
  display: flex; flex-direction: column;
}
.sidebar.show { transform: translateX(0); }

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; padding: 10px 12px; }
.brand i { font-size: 1.6rem; color: #60a5fa; }
.brand-title { font-size: 1.1rem; font-weight: 700; color: #f1f5f9; }
.brand-sub { font-size: 0.8rem; color: #94a3b8; }

.sidebar-nav { display: grid; gap: 6px; }

.nav-link {
  border: 1px solid transparent; border-radius: 12px; background: transparent;
  color: #cbd5e1; text-align: left; padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; transition: 0.2s ease; text-decoration: none;
  font-size: 0.9rem; font-weight: 500;
}
.nav-link:hover, .nav-link.active {
  background: rgba(59,130,246,0.18); color: #ffffff;
  border-color: rgba(59,130,246,0.3);
}
.nav-link i { width: 18px; text-align: center; }

.sidebar-footer { margin-top: auto; padding: 12px; border-top: 1px solid #1e293b; }
.user-email { font-size: 0.78rem; color: #64748b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px 8px; display: block; }
.logout-link {
  display: block; text-align: center; padding: 8px; border-radius: 10px;
  border: 1px solid rgba(239,68,68,0.3); color: #f87171; text-decoration: none;
  font-size: 0.85rem; font-weight: 500; transition: background 0.2s;
}
.logout-link:hover { background: rgba(239,68,68,0.12); }

.main-content { flex: 1; padding: 14px; min-width: 0; }

.topbar {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 18px; display: flex; gap: 12px;
  align-items: center; margin-bottom: 20px;
}
.topbar-text h2 { font-size: 1.2rem; font-weight: 700; }
.topbar-text .subtitle { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }

#menuToggle {
  width: 36px; height: 36px; display: inline-flex;
  align-items: center; justify-content: center;
  background: #e2e8f0; border: none; border-radius: 10px;
  cursor: pointer; color: #334155; flex-shrink: 0;
}

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 16px;
}

.kpi-grid { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 16px; }
.kpi-card { padding: 18px 20px; margin-bottom: 0; }
.kpi-card .kpi-label { color: var(--muted); margin-bottom: 6px; font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.kpi-card .kpi-value { font-size: 1.6rem; font-weight: 700; }
.kpi-profit { border-color: #bbf7d0 !important; background: #f0fdf4 !important; }
.kpi-income .kpi-value { color: #059669; }
.kpi-expense .kpi-value { color: #d97706; }
.kpi-salary .kpi-value { color: #4f46e5; }
.profit-positive { color: var(--success) !important; }
.profit-negative { color: var(--danger) !important; }

.section-actions { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 0 12px; box-shadow: var(--shadow);
}
.search-box i { color: var(--muted); font-size: 0.85rem; }
.search-box input { border: none; box-shadow: none; padding: 10px 4px; background: transparent; outline: none; width: 100%; }

.btn-primary {
  background: var(--primary); color: #fff; padding: 10px 18px;
  font-weight: 600; font-size: 0.88rem; border: none; border-radius: 10px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none; transition: transform 0.15s, opacity 0.15s; white-space: nowrap;
}
.btn-primary:hover { transform: translateY(-1px); opacity: 0.92; }

.btn-secondary {
  background: #e2e8f0; color: #1f2937; padding: 10px 18px;
  font-weight: 500; font-size: 0.88rem; border: none; border-radius: 10px;
  cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; gap: 6px; transition: transform 0.15s;
}
.btn-secondary:hover { transform: translateY(-1px); }

.btn-danger {
  background: #fee2e2; color: #991b1b; padding: 7px 10px;
  border: none; border-radius: 8px; cursor: pointer;
  font-size: 0.82rem; transition: transform 0.15s;
}
.btn-danger:hover { transform: translateY(-1px); }

.btn-small {
  border: 1px solid var(--line); background: #fff; color: #111827;
  border-radius: 8px; padding: 6px 10px; font-size: 0.8rem;
  cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; gap: 4px; transition: background 0.15s; white-space: nowrap;
}
.btn-small:hover { background: #f8fafc; }

.table-card { padding: 0; overflow: hidden; }
.table-responsive { width: 100%; overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 600px; }
thead { background: #f8fafc; }
th {
  text-align: left; border-bottom: 1px solid var(--line);
  padding: 12px 16px; font-size: 0.75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted);
}
td { text-align: left; border-bottom: 1px solid var(--line); padding: 12px 16px; font-size: 0.9rem; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
.td-right { text-align: right; }
.action-group { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.empty-state { text-align: center; color: var(--muted); padding: 28px; font-size: 0.9rem; }

.flash-success { padding: 10px 14px; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 10px; color: #166534; font-size: 0.88rem; margin-bottom: 14px; }
.flash-error { padding: 10px 14px; background: #fef2f2; border: 1px solid #fecaca; border-radius: 10px; color: #991b1b; font-size: 0.88rem; margin-bottom: 14px; }

.form-card { max-width: 520px; }
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 0.88rem; font-weight: 500; color: #374151; margin-bottom: 6px; }
.form-input, .form-select {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 13px; font-size: 0.9rem; outline: none;
  transition: border-color 0.2s, box-shadow 0.2s; background: #fff;
}
.form-input:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }

.page-header { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.page-header p { color: var(--muted); font-size: 0.88rem; margin-top: 4px; }
.page-header-left h1 { font-size: 1.5rem; font-weight: 700; }

.summary-grid { display: grid; gap: 14px; margin-bottom: 20px; }
.summary-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.summary-row:last-child { border-bottom: none; font-weight: 600; }
.summary-row .s-label { color: var(--muted); }

#sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.5); z-index: 20; }
#sidebar-overlay.show { display: block; }

@media (min-width: 640px) {
  .section-actions { flex-direction: row; justify-content: space-between; align-items: center; }
  .section-actions .search-box { flex: 1; max-width: 400px; }
  .page-header { flex-direction: row; align-items: flex-start; justify-content: space-between; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 768px) {
  .main-content { padding: 20px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .sidebar { transform: none; }
  .main-content { margin-left: 260px; padding: 24px; }
  #menuToggle { display: none !important; }
  .kpi-grid { grid-template-columns: repeat(5, 1fr); }
}

/* ── MODAL ── */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(15,23,42,0.6);
  display: grid; place-items: center; padding: 14px;
}
.modal-backdrop.hidden { display: none; }
.modal {
  width: min(100%, 480px); background: #fff;
  border-radius: 18px; padding: 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.18);
  animation: modalPop 0.2s ease;
  max-height: 90vh; overflow-y: auto;
}
@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 20px;
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px; display: inline-flex;
  align-items: center; justify-content: center;
  background: #e2e8f0; border: none; border-radius: 8px;
  cursor: pointer; color: #334155; font-size: 0.9rem;
  transition: background 0.15s;
}
.modal-close:hover { background: #cbd5e1; }

/* ── TABS ── */
.tab-bar {
  display: flex; gap: 4px; background: #f1f5f9;
  border-radius: 12px; padding: 4px;
  margin-bottom: 20px; overflow-x: auto;
}
.tab-btn {
  flex: 1; min-width: max-content; padding: 9px 16px;
  border: none; background: transparent; border-radius: 9px;
  font-size: 0.85rem; font-weight: 600; color: var(--muted);
  cursor: pointer; transition: 0.2s; white-space: nowrap;
  display: flex; align-items: center; gap: 6px; justify-content: center;
}
.tab-btn.active { background: #fff; color: var(--primary); box-shadow: 0 1px 4px rgba(0,0,0,0.1); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── INVENTORY ── */
.stock-badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 0.75rem; font-weight: 600;
}
.stock-ok { background: #dcfce7; color: #166534; }
.stock-low { background: #fef9c3; color: #854d0e; }
.stock-out { background: #fee2e2; color: #991b1b; }

/* ── REPORTS ── */
.report-kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.report-kpi { background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.report-kpi .r-label { font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.report-kpi .r-value { font-size: 1.2rem; font-weight: 700; }

/* ── SETTINGS / USERS ── */
.user-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); }
.user-row:last-child { border-bottom: none; }
.user-avatar { width: 36px; height: 36px; background: var(--primary-soft); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--primary); font-weight: 700; font-size: 0.9rem; flex-shrink: 0; }
.badge-admin { background: #ede9fe; color: #5b21b6; padding: 2px 9px; border-radius: 20px; font-size: 0.72rem; font-weight: 600; }
.badge-staff { background: #e0f2fe; color: #075985; padding: 2px 9px; border-radius: 20px; font-size: 0.72rem; font-weight: 600; }
