/* ============================================
   RAJ INFRA — Site Operations Portal
   Mobile-first: base = mobile, desktop via min-width: 1024px
   ============================================ */

:root {
  --blue: #2563eb;
  --blue-hover: #1d4ed8;
  --blue-light: #eff4ff;
  --blue-border: #cfe0ff;

  --green: #16a34a;
  --green-light: #e9f8ee;
  --red: #dc2626;
  --red-light: #fdecec;
  --orange: #d97706;
  --orange-light: #fffbeb;
  --purple: #7c3aed;
  --purple-light: #f3ecff;

  --amber: #2563eb;
  --amber-dim: #1d4ed8;
  --amber-glow: rgba(37,99,235,0.15);
  --amber-subtle: rgba(37,99,235,0.08);
  --green-bg: rgba(22,163,74,0.08);
  --red-bg: rgba(220,38,38,0.08);
  --blue-bg: rgba(37,99,235,0.08);
  --orange-bg: rgba(217,119,6,0.08);
  --purple-bg: rgba(124,58,237,0.08);
  --bg-base: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #f9fafb;
  --bg-elevated: #ffffff;
  --border: #eef1f4;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  --sidebar-w: 232px;
  --topbar-h: 56px;
  --radius: 12px;
  --radius-sm: 9px;
  --shadow: 0 1px 4px rgba(15,23,42,0.06);
  --shadow-lg: 0 4px 24px rgba(15,23,42,0.08);
  --transition: 150ms ease;
}

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

/* Remove focus outline on click/tap — keep it for keyboard navigation only */
*:focus { outline: none; }
*:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* Suppress iOS tap highlight globally */
a, button, div, span, input, select, textarea { -webkit-tap-highlight-color: transparent; }

/* Base font — mobile default */
html { font-size: 15px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ==============================
   LOGIN
   ============================== */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; }

.login-bg {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f3f5;
  padding: 24px;
}

.login-grid-overlay { display: none; }

.login-card {
  background: #ffffff;
  border: 1px solid rgba(15,23,42,0.07);
  border-radius: 14px;
  padding: 32px 20px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 4px 20px rgba(15,23,42,0.06);
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: fadeUp 0.4s ease both;
}

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

.login-brand { margin-bottom: 0; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 11px;
  background: var(--blue); color: #fff;
  font-weight: 800; font-size: 16px; letter-spacing: 0.5px;
  display: flex; align-items: center; justify-content: center;
}
.brand-mark.small { width: 32px; height: 32px; font-size: 12px; border-radius: 8px; flex-shrink: 0; }

.login-headline { font-size: 22px; font-weight: 800; color: #0f172a; margin-top: 16px; letter-spacing: -0.3px; }
.login-tagline { font-size: 13px; color: #94a3b8; margin-top: 4px; margin-bottom: 24px; text-align: center; }
.login-error { font-size: 13px; color: var(--red); background: var(--red-light); padding: 10px 14px; border-radius: 8px; }

/* ==============================
   FORMS
   ============================== */
.form-group { display: flex; flex-direction: column; gap: 7px; }
.form-group label { font-size: 13px; font-weight: 600; color: #334155; }

input[type=text], input[type=email], input[type=password],
input[type=number], input[type=tel], select, textarea {
  background: var(--bg-input);
  border: 1px solid #d7dde3;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  height: 44px;
  padding: 0 14px;
  font-family: inherit;
  font-size: 16px; /* prevents iOS zoom */
  outline: none;
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
select { -webkit-appearance: none; appearance: none; }
select option { background: #fff; }
textarea { resize: vertical; min-height: 88px; height: auto; padding: 12px 14px; line-height: 1.5; }

/* Single column by default (mobile) */
.form-row { display: grid; grid-template-columns: 1fr; gap: 14px; }
.form-row-narrow { display: grid; grid-template-columns: 1fr; gap: 14px; }

/* ==============================
   BUTTONS
   ============================== */
.btn-primary {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  height: 46px;
  padding: 0 20px;
  font-family: inherit;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
  display: inline-flex; align-items: center; gap: 8px;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary:active { transform: scale(0.98); opacity: 0.9; }
.btn-primary.full-width { width: 100%; justify-content: center; }

.btn-secondary {
  background: var(--blue-light);
  border: 1px solid var(--blue-border);
  color: var(--blue);
  border-radius: var(--radius-sm);
  height: 40px;
  padding: 0 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn-secondary:active { transform: scale(0.98); opacity: 0.9; }

.btn-ghost {
  background: #fff;
  border: 1px solid #d7dde3;
  color: #475569;
  height: 46px;
  padding: 0 20px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  display: inline-flex; align-items: center; gap: 6px;
  -webkit-tap-highlight-color: transparent;
}
.btn-ghost:active { transform: scale(0.98); opacity: 0.9; }

.btn-danger {
  background: var(--red-light);
  border: 1px solid #fecaca;
  color: var(--red);
  border-radius: var(--radius-sm);
  height: 46px;
  padding: 0 20px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex; align-items: center; gap: 6px;
  -webkit-tap-highlight-color: transparent;
}
.btn-danger:active { background: var(--red); color: #fff; transform: scale(0.98); }

.btn-success {
  background: var(--green);
  border: none;
  color: #fff;
  border-radius: var(--radius-sm);
  height: 46px;
  padding: 0 20px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  display: inline-flex; align-items: center; gap: 8px;
  -webkit-tap-highlight-color: transparent;
}
.btn-success:active { background: #15803d; transform: scale(0.98); }

.btn-sm { height: 36px; padding: 0 14px; font-size: 13px; }

.btn-icon {
  background: #f1f5f9;
  border: none;
  color: #64748b;
  width: 32px; height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.btn-icon:active { background: #e2e8f0; color: var(--red); }

/* ==============================
   APP SHELL
   ============================== */
#screen-app { display: none; flex-direction: row; min-height: 100vh; }
#screen-app.active { display: flex; }

/* ==============================
   SIDEBAR — hidden on mobile (overlay)
   ============================== */
.sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid #eef1f4;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 400;
  transition: transform var(--transition);
  /* Hidden by default on mobile */
  transform: translateX(calc(-1 * var(--sidebar-w)));
  box-shadow: none;
}
.sidebar.open {
  transform: translateX(0);
  box-shadow: var(--shadow-lg);
}
.sidebar.collapsed { transform: translateX(calc(-1 * var(--sidebar-w))); }

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 12px;
  flex-shrink: 0;
}
.sidebar-brand-text { flex: 1; min-width: 0; }
.sidebar .brand-name { font-weight: 700; font-size: 15px; color: #0f172a; line-height: 1.1; letter-spacing: 0; }
.sidebar-brand-sub { font-size: 11px; color: #94a3b8; margin-top: 2px; }

/* Close button — always shown on mobile */
.sidebar-close {
  background: none; border: none; color: #9ca3af;
  cursor: pointer; font-size: 16px; padding: 4px;
  border-radius: 6px; display: flex; align-items: center; justify-content: center;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.4);
  z-index: 399;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  pointer-events: none;
  display: none;
}
.sidebar-backdrop.active {
  display: block;
  pointer-events: all;
}

.sidebar-site-badge { display: none; }
.site-badge-label { font-size: 11px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.5px; }
.site-badge-name { font-weight: 700; font-size: 13px; color: var(--blue); margin-top: 2px; }
.site-badge-role { font-size: 12px; color: #64748b; margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 4px 10px; overflow-y: auto; }

.nav-section-label {
  font-size: 11px; font-weight: 600; color: #d1d5db;
  text-transform: uppercase; letter-spacing: 0.8px;
  padding: 14px 10px 5px;
}

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 13px 12px; border-radius: 9px;
  cursor: pointer; color: #475569; font-size: 15px; font-weight: 500;
  transition: all var(--transition); margin-bottom: 3px;
  border: 1px solid transparent; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.nav-item:active { background: #f0f4ff; color: var(--blue); }
.nav-item.active { background: var(--blue-light); color: var(--blue); border-color: transparent; font-weight: 600; }

.nav-icon { font-size: 17px; width: 22px; text-align: center; flex-shrink: 0; }

.nav-badge {
  margin-left: auto;
  background: var(--blue);
  color: #fff;
  font-size: 11px; font-weight: 700;
  padding: 1px 7px; border-radius: 100px; min-width: 20px; text-align: center;
}

.sidebar-user {
  padding: 12px 14px;
  border-top: 1px solid #eef1f4;
  flex-shrink: 0;
}
.user-info {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 9px; background: transparent;
  cursor: pointer; transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: #dbeafe; color: var(--blue);
  font-weight: 600; font-size: 13px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-details { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: #0f172a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.1; }
.user-role { font-size: 11px; color: #94a3b8; margin-top: 2px; }
.logout-btn {
  background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 8px;
  color: #475569; cursor: pointer;
  width: 32px; height: 32px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.logout-btn:active { background: #fff0f0; border-color: var(--red); color: var(--red); }

/* ==============================
   MAIN CONTENT — no sidebar offset on mobile
   ============================== */
.main-wrapper {
  flex: 1;
  margin-left: 0;
  display: flex; flex-direction: column; min-height: 100vh;
  transition: margin-left var(--transition);
}
.main-wrapper.inert-content { pointer-events: none; user-select: none; }

.topbar {
  height: var(--topbar-h); background: #fff;
  border-bottom: 1px solid #eef1f4;
  display: flex; align-items: center; padding: 0 14px; gap: 12px;
  position: sticky; top: 0; z-index: 300; flex-shrink: 0;
}
/* Hamburger always visible on mobile */
.hamburger {
  background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; gap: 4px; padding: 8px 6px;
  -webkit-tap-highlight-color: transparent;
}
.hamburger span { display: block; width: 18px; height: 2px; background: #6b7280; border-radius: 2px; }

.topbar-title { font-size: 17px; font-weight: 700; color: #0f172a; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
/* Hide name/role text on mobile — avatar is enough */
.topbar-user-name { display: none; }
.topbar-user-role { display: none; }

.notif-bell {
  position: relative; cursor: pointer; color: #94a3b8;
  font-size: 18px; line-height: 1; transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.notif-dot {
  position: absolute; top: -2px; right: -3px;
  width: 8px; height: 8px; background: #ef4444;
  border-radius: 50%; border: 2px solid #fff;
}
.topbar-user-block { display: flex; align-items: center; gap: 8px; }
.topbar-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: #dbeafe; color: var(--blue);
  font-weight: 600; font-size: 13px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  flex-shrink: 0; -webkit-tap-highlight-color: transparent;
}

.notif-panel {
  position: fixed; top: var(--topbar-h); right: 8px; left: 8px;
  width: auto;
  background: #fff; border: 1px solid #eef1f4; border-radius: 12px;
  box-shadow: 0 8px 24px rgba(15,23,42,0.12); z-index: 350;
  max-height: 360px; overflow-y: auto;
  animation: dropIn 0.15s ease both;
}
@keyframes dropIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.notif-panel-header {
  padding: 14px 16px; font-size: 13px; font-weight: 600; color: #0f172a;
  border-bottom: 1px solid #eef1f4;
}
.notif-item { padding: 14px 16px; border-bottom: 1px solid #f1f5f9; cursor: pointer; transition: background var(--transition); }
.notif-item:last-child { border-bottom: none; }
.notif-item-title { font-size: 13px; color: #0f172a; font-weight: 500; margin-bottom: 2px; }
.notif-item-sub { font-size: 12px; color: #94a3b8; }

/* ==============================
   CONTENT AREA — mobile padding
   ============================== */
.content-area {
  flex: 1;
  padding: 18px 14px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  overflow-y: auto;
  background: var(--bg-base);
  -webkit-overflow-scrolling: touch;
}

.view { display: none; }
.view.active { display: block; animation: viewEntry 0.2s ease both; }
@keyframes viewEntry { from { opacity: 0; } to { opacity: 1; } }

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 18px; flex-wrap: wrap; gap: 10px;
}
.page-title { font-size: 18px; font-weight: 700; color: #0f172a; }
.page-sub { font-size: 13px; color: #94a3b8; margin-top: 3px; }

/* ==============================
   STAT CARDS — 2 cols on mobile
   ============================== */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}
.stat-card {
  background: #fff; border: 1px solid rgba(15,23,42,0.08); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
}
.stat-card-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.stat-icon { font-size: 17px; }
.stat-value { font-size: 26px; font-weight: 700; color: #0f172a; line-height: 1; margin-bottom: 0; }
.stat-label { font-size: 12px; color: #64748b; }
.stat-card-link { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.stat-card-arrow { font-size: 13px; color: var(--text-muted); margin-top: 8px; transition: color var(--transition); }
.stat-card-link:active { transform: scale(0.97); }
.stat-card-link:active .stat-card-arrow { color: var(--blue); }

/* ==============================
   CARDS
   ============================== */
.card { background: #fff; border: 1px solid rgba(15,23,42,0.08); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* ==============================
   TABLES (new request items entry)
   ============================== */
.items-section { display: flex; flex-direction: column; gap: 14px; }
.items-header { display: flex; align-items: center; justify-content: space-between; }
.items-header h3 { font-size: 15px; font-weight: 600; color: #0f172a; }

/* Items table — horizontal scroll on mobile, it's a data-entry table */
.items-table-wrapper { overflow-x: auto; border: 1px solid #eef1f4; border-radius: var(--radius-sm); -webkit-overflow-scrolling: touch; max-width: 100%; width: 100%; }
.items-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 560px; }
.items-table thead { background: #f8fafc; }
.items-table th {
  padding: 10px 12px; text-align: left; font-size: 11px; font-weight: 600;
  color: #94a3b8; border-bottom: 1px solid #eef1f4; white-space: nowrap;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.items-table td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; color: #334155; }
.items-table tbody tr:last-child td { border-bottom: none; }
.items-table input, .items-table select {
  background: #fff; border: 1px solid #d7dde3; color: #0f172a;
  height: 38px; padding: 0 10px; font-size: 16px; border-radius: 7px;
  width: 100%; font-family: inherit;
}

/* Item row cards — replaces the table on new request form */
/* Inventory picker (item selection modal) */
.inv-picker-item {
  border: 1px solid #e2e8f0; border-radius: var(--radius-sm);
  padding: 14px; background: #fff; cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.inv-picker-item:active { background: var(--blue-light); border-color: var(--blue-border); }

/* Item row cards */
.item-row-card {
  border: 1px solid #e2e8f0; border-radius: var(--radius-sm);
  padding: 14px; background: #f8fafc;
  display: flex; flex-direction: column; gap: 10px;
  margin-bottom: 10px;
}
.item-row-header {
  display: flex; align-items: center; justify-content: space-between;
}
.item-row-num {
  font-size: 12px; font-weight: 700; color: var(--blue);
  background: var(--blue-light); padding: 2px 8px; border-radius: 999px;
}
.item-row-split {
  display: flex; gap: 10px; flex-wrap: wrap;
}
.item-row-split .form-group { flex: 1; min-width: 80px; }

.no-items-msg {
  text-align: center; color: #94a3b8; font-size: 14px; padding: 24px;
  border: 1px dashed #d7dde3; border-radius: var(--radius-sm);
}

/* Form actions — stacked on mobile */
.form-actions {
  display: flex; flex-direction: column-reverse; gap: 10px;
  padding-top: 16px; border-top: 1px solid #eef1f4;
}
.form-actions .btn-primary,
.form-actions .btn-ghost { width: 100%; justify-content: center; }

/* ==============================
   FILTER DROPDOWN
   ============================== */
.filter-bar { margin-bottom: 16px; }
.filter-dropdown-wrap { position: relative; display: block; }
.filter-dropdown-btn {
  display: flex; align-items: center; gap: 10px;
  background: #fff;
  border: 1.5px solid #d7dde3;
  color: #0f172a;
  padding: 0 16px;
  height: 44px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: all var(--transition);
  width: 100%; justify-content: space-between;
  -webkit-tap-highlight-color: transparent;
}
.filter-btn-left { display: flex; align-items: center; gap: 8px; }
.filter-btn-icon {
  width: 24px; height: 24px; background: var(--blue-light); border-radius: 6px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.filter-chevron { font-size: 11px; color: var(--text-muted); transition: transform var(--transition); }
.filter-dropdown-btn.open .filter-chevron { transform: rotate(180deg); }
.filter-dropdown-menu {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: #fff; border: 1px solid #eef1f4; border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(15,23,42,0.12);
  z-index: 150; overflow: hidden;
  animation: dropIn 0.12s ease both;
}
.filter-option {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 13px 16px; text-align: left;
  font-size: 14px; font-weight: 500; color: #475569;
  background: none; border: none; cursor: pointer;
  font-family: inherit; transition: background var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.filter-option.active { color: var(--blue); font-weight: 600; background: var(--blue-light); }
.filter-option-check { margin-left: auto; font-size: 13px; color: var(--blue); opacity: 0; }
.filter-option.active .filter-option-check { opacity: 1; }
.filter-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--blue); flex-shrink: 0; }

/* ==============================
   REQUEST CARDS — stacked on mobile
   ============================== */
.request-card {
  background: #fff; border: 1px solid rgba(15,23,42,0.08); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 12px;
  transition: box-shadow var(--transition), border-color var(--transition);
  cursor: pointer; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: flex-start; gap: 12px;
}
.request-card-left { flex: 1; min-width: 0; width: 100%; }
.request-title { font-size: 15px; font-weight: 600; color: #0f172a; }
.request-meta { display: flex; gap: 0; flex-wrap: wrap; }
.meta-item { font-size: 13px; color: #94a3b8; margin-top: 4px; }
.meta-item span { color: #64748b; font-weight: 500; }
.request-card-right { display: flex; align-items: center; gap: 10px; width: 100%; justify-content: space-between; flex-wrap: wrap; }
.request-card-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 12px; padding-top: 10px; border-top: 1px solid #f3f4f6;
  flex-wrap: wrap; gap: 8px;
}

/* ==============================
   BADGES
   ============================== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 24px; padding: 0 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-pending  { background: #fffbeb; color: #92400e; }
.badge-store    { background: #eff4ff; color: #2563eb; }
.badge-owner    { background: #f3ecff; color: #7c3aed; }
.badge-approved { background: #e9f8ee; color: #16a34a; }
.badge-po       { background: #eff4ff; color: #2563eb; }
.badge-partial  { background: #fffbeb; color: #92400e; }
.badge-rejected { background: #fdecec; color: #dc2626; }
.badge-urgent   { background: #fdecec; color: #dc2626; }
.badge-normal   { background: #f1f5f9; color: #64748b; }
.badge-critical { background: #f3ecff; color: #7c3aed; }

/* ==============================
   SECTION TITLE
   ============================== */
.section-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; color: #0f172a; }
.recent-section { margin-top: 4px; }

/* ==============================
   MODAL — bottom sheet on mobile
   ============================== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.45);
  display: flex; align-items: flex-end;
  z-index: 1000; padding: 0;
  animation: fadeIn 0.15s ease both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: #fff;
  border-radius: 18px 18px 0 0;
  width: 100%; max-width: 100%; max-height: 92vh;
  display: flex; flex-direction: column;
  box-shadow: 0 -4px 40px rgba(15,23,42,0.2);
  animation: sheetUp 0.25s cubic-bezier(0.32, 0.72, 0, 1) both;
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 18px 14px; border-bottom: 1px solid #eef1f4; flex-shrink: 0;
}
.modal-header h3 { font-size: 17px; font-weight: 700; color: #0f172a; }
.modal-header-sub { font-size: 12px; color: #94a3b8; margin-bottom: 3px; }
.modal-close {
  width: 32px; height: 32px; background: #f1f5f9; border: none; color: #64748b; cursor: pointer;
  font-size: 15px; border-radius: 8px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); -webkit-tap-highlight-color: transparent;
}
.modal-body { padding: 16px 18px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 14px; -webkit-overflow-scrolling: touch; }
.modal-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 14px 18px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid #eef1f4; flex-wrap: wrap;
}
.modal-actions .btn-primary,
.modal-actions .btn-ghost,
.modal-actions .btn-danger,
.modal-actions .btn-success { flex: 1; justify-content: center; min-width: 100px; }

/* ==============================
   STORE / OWNER TABLES (inside modals)
   ============================== */
.store-items-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.store-items-table th, .store-items-table td { padding: 10px 10px; border-bottom: 1px solid #f1f5f9; text-align: left; }
.store-items-table th { font-size: 11px; font-weight: 600; color: #94a3b8; background: #f8fafc; text-transform: uppercase; letter-spacing: 0.5px; }
.store-items-table tr:last-child td { border-bottom: none; }

.availability-input { width: 72px !important; text-align: center; }
.avail-toggle { display: flex; align-items: center; gap: 6px; }

.owner-adj-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.owner-adj-table th { padding: 10px 10px; text-align: left; font-size: 11px; font-weight: 600; color: #94a3b8; background: #f8fafc; border-bottom: 1px solid #eef1f4; text-transform: uppercase; letter-spacing: 0.5px; }
.owner-adj-table td { padding: 10px 10px; border-bottom: 1px solid #f1f5f9; }
.owner-adj-table tr:last-child td { border-bottom: none; }
.owner-adj-input { width: 80px !important; }

/* ==============================
   VENDOR CARDS — single col mobile
   ============================== */
.vendors-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.vendor-card { background: #fff; border: 1px solid rgba(15,23,42,0.08); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.vendor-name { font-size: 15px; font-weight: 600; color: #0f172a; margin-bottom: 3px; }
.vendor-cat { font-size: 12px; color: #94a3b8; margin-bottom: 10px; }
.vendor-contact { font-size: 13px; color: #64748b; margin-bottom: 3px; }
.vendor-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; padding-top: 10px; border-top: 1px solid #eef1f4; }

/* ==============================
   PURCHASE ORDER CARDS
   ============================== */
.po-card {
  background: #fff; border: 1px solid rgba(15,23,42,0.08); border-left: 4px solid var(--blue);
  border-radius: var(--radius); padding: 18px 16px; margin-bottom: 14px;
  box-shadow: 0 2px 10px rgba(15,23,42,0.04);
}
.po-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; flex-wrap: wrap; gap: 8px; }
.po-number { font-size: 18px; font-weight: 700; color: var(--blue); letter-spacing: 0.3px; }
.po-meta { font-size: 13px; font-weight: 500; color: #64748b; margin-top: 4px; }
.po-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.po-actions .btn-secondary, .po-actions .btn-ghost { flex: 1; justify-content: center; min-width: 120px; }

/* ==============================
   INVENTORY TABLE — card layout on mobile
   ============================== */
.inv-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.inv-table th { padding: 10px 12px; text-align: left; font-size: 11px; font-weight: 600; color: #94a3b8; background: #f8fafc; border-bottom: 1px solid #eef1f4; text-transform: uppercase; letter-spacing: 0.5px; }
.inv-table td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; color: #334155; }
.inv-table tr:last-child td { border-bottom: none; }

/* Mobile card layout for inv-table */
.inv-table thead { display: none; }
.inv-table, .inv-table tbody { display: block; width: 100%; }
.inv-table tr {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.inv-table td { display: block; padding: 0; border: none; font-size: 14px; }
.inv-table td:nth-child(1) { grid-column: 1; font-weight: 600; font-size: 15px; }
.inv-table td:nth-child(2) { grid-column: 2; grid-row: 1; }
.inv-table td:nth-child(3) { grid-column: 1; color: var(--text-primary); font-size: 14px; }
.inv-table td:nth-child(4) { display: none; } /* unit hidden, shown inline with qty */
.inv-table td:nth-child(5) { grid-column: 1; color: var(--text-muted); font-size: 12px; }
.inv-table td:nth-child(6) { grid-column: 1 / -1; }
.inv-table td:nth-child(7) { grid-column: 2; grid-row: 3; }
.inv-table td:nth-child(8) { grid-column: 1 / -1; }
.inv-table td:nth-child(9) { grid-column: 1 / -1; margin-top: 4px; }

.stock-bar { width: 100%; height: 5px; background: #e5e7eb; border-radius: 3px; overflow: hidden; }
.stock-fill { height: 100%; border-radius: 3px; }
.stock-good     { background: var(--green); }
.stock-low      { background: var(--orange); }
.stock-critical { background: var(--red); }

/* ==============================
   TEAM & SITE CARDS
   ============================== */
.team-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.team-card {
  background: #fff; border: 1px solid rgba(15,23,42,0.08);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 14px;
}
.team-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; flex-shrink: 0;
}
.team-info { flex: 1; min-width: 0; }
.team-name { font-size: 15px; font-weight: 600; color: #0f172a; margin-bottom: 2px; }
.team-meta { font-size: 13px; color: #64748b; display: flex; gap: 8px; flex-wrap: wrap; }
.team-actions { display: flex; gap: 6px; flex-shrink: 0; }

.sites-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.site-card {
  background: #fff; border: 1px solid rgba(15,23,42,0.08);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
}
.site-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.site-name { font-size: 16px; font-weight: 700; color: #0f172a; }
.site-location { font-size: 13px; color: #64748b; margin-bottom: 10px; }
.site-stats { display: flex; gap: 16px; flex-wrap: wrap; }
.site-stat { display: flex; flex-direction: column; gap: 2px; }
.site-stat-val { font-size: 20px; font-weight: 700; color: #0f172a; }
.site-stat-lbl { font-size: 11px; color: #94a3b8; }

/* ==============================
   EMPTY STATES
   ============================== */
.empty-state {
  text-align: center; padding: 48px 20px;
  background: #fff; border-radius: var(--radius); border: 1px solid rgba(15,23,42,0.08);
}
.empty-icon { font-size: 36px; margin-bottom: 12px; }
.empty-title { font-size: 15px; font-weight: 600; color: #334155; margin-bottom: 5px; }
.empty-sub { font-size: 13px; color: #94a3b8; line-height: 1.6; }

/* ==============================
   DETAIL GRID — single col mobile
   ============================== */
.detail-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.detail-item { display: flex; flex-direction: column; gap: 4px; }
.detail-label { font-size: 12px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; }
.detail-value { font-size: 14px; color: #0f172a; font-weight: 500; }

/* ==============================
   CHECKBOX
   ============================== */
.checkbox-wrap { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; }
.checkbox-wrap input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--blue); cursor: pointer; }

/* ==============================
   TOAST
   ============================== */
.toast {
  position: fixed; bottom: calc(16px + env(safe-area-inset-bottom));
  right: 12px; left: 12px; max-width: none;
  background: #fff; border: 1px solid #eef1f4;
  border-left: 3px solid var(--blue);
  border-radius: var(--radius); padding: 12px 16px;
  font-size: 14px; color: #334155;
  box-shadow: 0 8px 24px rgba(15,23,42,0.12); z-index: 9999;
  animation: toastIn 0.2s ease both;
}
.toast.success { border-left-color: var(--green); }
.toast.error   { border-left-color: var(--red); }
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ==============================
   UTILITIES
   ============================== */
.hidden { display: none !important; }
.divider { height: 1px; background: #f3f4f6; margin: 4px 0; }

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #d1d5db; }

/* ==============================
   PROFILE MODAL
   ============================== */
.profile-hero {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(135deg, #eff4ff 0%, #f8fafc 100%);
  border: 1px solid var(--blue-border);
  border-radius: 12px; padding: 16px 14px; margin-bottom: 4px;
}
.profile-avatar-ring {
  flex-shrink: 0; padding: 3px; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue) 0%, #60a5fa 100%);
}
.profile-avatar-lg {
  width: 52px; height: 52px; border-radius: 50%;
  background: #fff; color: var(--blue);
  font-weight: 700; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
}
.profile-hero-info { flex: 1; min-width: 0; }
.profile-hero-name { font-size: 15px; font-weight: 700; color: var(--text-primary); margin-bottom: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-hero-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.profile-role-chip { font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.profile-hero-email { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.profile-section { display: flex; flex-direction: column; gap: 8px; }
.profile-section-label {
  font-size: 11px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.8px;
  display: flex; align-items: center;
}
.profile-field-group {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-sm); overflow: hidden;
}
.profile-field-group .form-group { padding: 13px 14px; border-bottom: 1px solid #f1f5f9; gap: 5px; }
.profile-field-group .form-group:last-child { border-bottom: none; }
.profile-field-group .form-group label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.profile-field-group input { border: none; border-radius: 0; height: 36px; padding: 0; background: transparent; font-size: 15px; font-weight: 500; box-shadow: none !important; }
.profile-field-group input:focus { border: none; box-shadow: none !important; }
.profile-field-group input::placeholder { font-size: 14px; font-weight: 400; }

.profile-readonly-row { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-bottom: 1px solid #f1f5f9; }
.profile-readonly-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; width: 46px; flex-shrink: 0; }
.profile-readonly-value { flex: 1; font-size: 14px; font-weight: 500; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-lock { font-size: 13px; flex-shrink: 0; opacity: 0.5; }

/* ==============================
   BOTTOM NAV (unused — kept for safety)
   ============================== */
.bottom-nav { display: none; }
.bottom-nav-item { -webkit-tap-highlight-color: transparent; }
.bottom-nav-badge { display: none; }

/* ==============================
   RESPONSIVE — TABLET (768px–1023px)
   ============================== */
@media (min-width: 768px) and (max-width: 1023px) {
  .content-area { padding: 22px 24px; }
  .stats-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
  .form-row { grid-template-columns: 1fr 1fr; gap: 16px; }
  .form-row-narrow { grid-template-columns: 1fr 200px; gap: 16px; }
  .vendors-grid { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .po-actions .btn-secondary, .po-actions .btn-ghost { flex: none; }
  .modal { max-width: 560px; border-radius: 14px; align-self: center; }
  .modal-overlay { align-items: center; padding: 20px; }
  .request-card { flex-direction: row; align-items: center; }
  .request-card-right { width: auto; }

  /* Inv table back to standard table on tablet */
  .inv-table thead { display: table-header-group; }
  .inv-table { display: table; }
  .inv-table tbody { display: table-row-group; }
  .inv-table tr { display: table-row; grid-template-columns: unset; padding: 0; margin: 0; border: none; border-radius: 0; background: transparent; }
  .inv-table td { display: table-cell; padding: 10px 12px; border-bottom: 1px solid #f1f5f9; }
  .inv-table td:nth-child(4) { display: table-cell; }
  .inv-table td:nth-child(7) { grid-row: unset; }
  .inv-table tr:last-child td { border-bottom: none; }
  .inv-table tr:hover td { background: #f8fafc; }
  .stock-bar { width: 72px; }
}

/* ==============================
   RESPONSIVE — DESKTOP (1024px+)
   ============================== */
@media (min-width: 1024px) {
  --topbar-h: 68px;

  /* Sidebar always visible */
  .sidebar {
    transform: translateX(0) !important;
    z-index: 100;
  }
  .sidebar-close { display: none !important; }
  .hamburger { display: none !important; }
  .sidebar-backdrop { display: none !important; }

  /* Main wrapper offset for sidebar */
  .main-wrapper { margin-left: var(--sidebar-w); }
  .main-wrapper.full { margin-left: 0; }

  /* Wider content padding */
  .content-area { padding: 28px 32px; }
  .topbar { padding: 0 32px; height: 68px; }
  .topbar-title { font-size: 20px; }

  /* Name/role visible on desktop */
  .topbar-user-name { display: block; font-size: 13px; font-weight: 600; color: #0f172a; line-height: 1.1; }
  .topbar-user-role { display: block; font-size: 11px; color: #94a3b8; margin-top: 2px; }

  /* Notification panel anchored to topbar */
  .notif-panel { top: 68px; left: auto; right: 16px; width: 300px; }

  /* Layout */
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 28px; }
  .stat-card { padding: 18px 20px; }
  .stat-value { font-size: 30px; }
  .card-body { padding: 26px; gap: 20px; }

  /* Forms */
  .form-row { grid-template-columns: 1fr 1fr; gap: 16px; }
  .form-row-narrow { grid-template-columns: 1fr 240px; gap: 20px; }
  .form-actions { flex-direction: row; }
  .form-actions .btn-primary,
  .form-actions .btn-ghost { width: auto; }

  /* Page header */
  .page-header { margin-bottom: 24px; }
  .page-title { font-size: 20px; }

  /* Request cards — horizontal on desktop */
  .request-card {
    flex-direction: row; align-items: center; padding: 18px 20px;
    gap: 16px;
  }
  .request-card:hover { border-color: var(--blue-border); box-shadow: var(--shadow-lg); }
  .request-card-right { width: auto; gap: 16px; }

  /* Modal — centered dialog */
  .modal-overlay { align-items: center; padding: 20px; }
  .modal { max-width: 680px; border-radius: 14px; align-self: auto; max-height: 90vh; }
  @keyframes sheetUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
  .modal-header { padding: 22px 26px; }
  .modal-header h3 { font-size: 19px; }
  .modal-body { padding: 22px 26px; gap: 16px; }
  .modal-actions { padding: 18px 26px; }
  .modal-actions .btn-primary,
  .modal-actions .btn-ghost,
  .modal-actions .btn-danger,
  .modal-actions .btn-success { flex: none; }

  /* Detail grid — 2 cols */
  .detail-grid { grid-template-columns: 1fr 1fr; gap: 14px 24px; }

  /* PO card */
  .po-card { padding: 26px 28px; max-width: 760px; }
  .po-number { font-size: 22px; }
  .po-meta { font-size: 15px; }
  .po-actions { flex-wrap: nowrap; }
  .po-actions .btn-secondary, .po-actions .btn-ghost { flex: none; }

  /* Vendor grid */
  .vendors-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }

  /* Inv table — standard table on desktop */
  .inv-table thead { display: table-header-group; }
  .inv-table { display: table; }
  .inv-table tbody { display: table-row-group; }
  .inv-table tr { display: table-row; grid-template-columns: unset; padding: 0; margin: 0; border: none; border-radius: 0; background: transparent; }
  .inv-table td { display: table-cell; padding: 12px 18px; border-bottom: 1px solid #f1f5f9; }
  .inv-table td:nth-child(4) { display: table-cell; }
  .inv-table td:nth-child(7) { grid-row: unset; }
  .inv-table tr:last-child td { border-bottom: none; }
  .inv-table tr:hover td { background: #f8fafc; }
  .stock-bar { width: 72px; }

  /* Toast */
  .toast { right: 20px; left: auto; max-width: 320px; bottom: 20px; }

  /* Team / sites grids */
  .team-grid { grid-template-columns: 1fr 1fr; gap: 14px; }
  .sites-grid { grid-template-columns: 1fr 1fr; gap: 14px; }

  /* Hover states (desktop only — no sticky hover on touch) */
  .request-card:hover { border-color: var(--blue-border); box-shadow: var(--shadow-lg); }
  .stat-card:hover { box-shadow: var(--shadow-lg); }
  .nav-item:hover { background: #f8fafc; color: #0f172a; }
  .notif-bell:hover { color: var(--blue); }
  .btn-primary:hover { background: var(--blue-hover); }
  .btn-secondary:hover { background: #e0ebff; }
  .btn-ghost:hover { border-color: #94a3b8; color: #0f172a; }
  .btn-danger:hover { background: var(--red); color: #fff; border-color: var(--red); }
  .btn-success:hover { background: #15803d; }
  .btn-icon:hover { background: #e2e8f0; color: var(--red); }
  .vendor-card:hover { border-color: var(--blue-border); }
  .logout-btn:hover { background: #fff0f0; border-color: #fecaca; color: var(--red); }
  .user-info:hover { background: #f8fafc; }
  .notif-item:hover { background: #f8fafc; }
  .modal-close:hover { background: #e2e8f0; color: #0f172a; }
  .items-table tbody tr:hover { background: #f8fafc; }
  .filter-option:hover { background: #f8fafc; color: #0f172a; }
}
