:root {
  --brand: #10b981;
  --brand-dark: #047857;
  --brand-darker: #065f46;
  --brand-light: #d1fae5;
  --brand-soft: #ecfdf5;
  --ink: #14312a;
  --muted: #6b8a80;
  --surface: #ffffff;
  --bg: #eef4f0;
  --ring: rgba(16, 185, 129, .18);
  --shadow-sm: 0 1px 2px rgba(6, 78, 59, .06), 0 2px 8px rgba(6, 78, 59, .05);
  --shadow-md: 0 6px 24px rgba(6, 78, 59, .10);
  --shadow-lg: 0 16px 48px rgba(6, 78, 59, .16);
  --radius: 16px;
  --radius-sm: 12px;
}

* { -webkit-tap-highlight-color: transparent; }

body {
  font-family: 'Cairo', system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 100% -10%, #d9f2e6 0%, transparent 55%),
    radial-gradient(900px 500px at -10% 0%, #e3f7ee 0%, transparent 50%),
    var(--bg);
  min-height: 100vh;
}

/* ---------- Navbar ---------- */
.app-navbar {
  background: linear-gradient(120deg, var(--brand-dark), var(--brand) 90%);
  box-shadow: var(--shadow-md);
  padding-top: .7rem;
  padding-bottom: .7rem;
  -webkit-backdrop-filter: saturate(1.2);
  backdrop-filter: saturate(1.2);
}
.app-navbar .navbar-brand {
  color: #fff;
  font-weight: 800;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  gap: .55rem;
}
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .18);
  font-size: 1.2rem;
  color: #fff;
}
.app-navbar .nav-link {
  color: rgba(255, 255, 255, .85) !important;
  font-weight: 600;
  border-radius: 10px;
  padding: .45rem .85rem !important;
  transition: background .18s, color .18s;
}
.app-navbar .nav-link:hover { background: rgba(255, 255, 255, .14); color: #fff !important; }
.app-navbar .nav-link.active { background: rgba(255, 255, 255, .22); color: #fff !important; }
.navbar-user { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.user-chip {
  display: inline-flex; align-items: center; gap: .4rem;
  color: #fff; font-weight: 600; font-size: .92rem;
  background: rgba(255, 255, 255, .14);
  padding: .35rem .7rem; border-radius: 999px;
}
.role-badge { background: #fbbf24; color: #7c2d12; font-weight: 700; }
.btn-logout {
  background: rgba(255, 255, 255, .95); color: var(--brand-dark);
  font-weight: 700; border: 0; border-radius: 999px; padding: .4rem .9rem;
}
.btn-logout:hover { background: #fff; color: var(--brand-darker); }
.navbar-toggler { border-color: rgba(255, 255, 255, .4); }

/* ---------- Layout ---------- */
.page-wrap { padding-top: 2rem; padding-bottom: 3.5rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-title { font-weight: 800; font-size: 1.5rem; margin: 0; display: flex; align-items: center; gap: .5rem; }
.page-title i { color: var(--brand-dark); }
.page-subtitle { color: var(--muted); margin: .1rem 0 0; font-size: .95rem; }

/* ---------- Cards ---------- */
.card {
  border: 1px solid rgba(6, 95, 70, .08);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
}
.card .card-body { padding: 1.35rem; }
.card-title { font-weight: 700; }

/* ---------- Stat cards ---------- */
.stat-card {
  border: 0; border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-sm); background: var(--surface);
  transition: transform .18s, box-shadow .18s;
  height: 100%;
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.stat-card .stat-body { display: flex; align-items: center; gap: 1rem; padding: 1.25rem; }
.stat-icon {
  flex: 0 0 auto; width: 54px; height: 54px; border-radius: 14px;
  display: grid; place-items: center; font-size: 1.5rem; color: #fff;
}
.stat-icon.green { background: linear-gradient(135deg, #34d399, #059669); }
.stat-icon.red   { background: linear-gradient(135deg, #fb7185, #e11d48); }
.stat-icon.blue  { background: linear-gradient(135deg, #38bdf8, #0284c7); }
.stat-icon.amber { background: linear-gradient(135deg, #fbbf24, #d97706); }
.stat-value { font-size: 1.8rem; font-weight: 800; line-height: 1; }
.stat-label { color: var(--muted); font-weight: 600; font-size: .9rem; margin-top: .25rem; }

/* ---------- Buttons ---------- */
.btn { font-weight: 700; border-radius: 10px; }
.btn-lg, .btn.w-100 { border-radius: 12px; }
.btn-success {
  background: linear-gradient(120deg, var(--brand), var(--brand-dark));
  border: 0; box-shadow: 0 4px 14px var(--ring);
}
.btn-success:hover { background: linear-gradient(120deg, var(--brand-dark), var(--brand-darker)); }
.btn-outline-success { color: var(--brand-dark); border-color: var(--brand); }
.btn-outline-success:hover { background: var(--brand); border-color: var(--brand); }

/* ---------- Forms ---------- */
.form-label { font-weight: 600; color: var(--ink); margin-bottom: .35rem; }
.form-control, .form-select {
  border-radius: 10px; border: 1px solid #d5e3dc; padding: .6rem .8rem;
  background: #fbfefc;
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand); box-shadow: 0 0 0 .22rem var(--ring);
}
.form-switch .form-check-input { width: 2.6em; height: 1.35em; cursor: pointer; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }

/* ---------- Tables ---------- */
.table-card { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); background: #fff; }
.table { margin: 0; }
.table > thead th {
  background: var(--brand-soft); color: var(--brand-darker);
  font-weight: 700; border-bottom: 2px solid var(--brand-light);
  padding: .9rem 1rem; white-space: nowrap;
}
.table > tbody td { padding: .85rem 1rem; vertical-align: middle; border-color: #eef4f0; }
.table-hover > tbody > tr:hover > * { background: var(--brand-soft); }

/* ---------- Badges ---------- */
.badge { font-weight: 700; padding: .4em .7em; border-radius: 8px; }
.badge.bg-success { background: var(--brand) !important; }

/* ---------- Alerts ---------- */
.alert { border: 0; border-radius: 12px; font-weight: 600; }
.alert-success { background: var(--brand-light); color: var(--brand-darker); }

/* ---------- List groups ---------- */
.list-group-item { border-color: #eef4f0; padding: .8rem 1rem; }

/* ---------- Auth / login ---------- */
.auth-wrap { min-height: 72vh; display: grid; place-items: center; }
.auth-card { width: 100%; max-width: 420px; }
.auth-logo {
  width: 68px; height: 68px; margin: 0 auto 1rem; border-radius: 20px;
  display: grid; place-items: center; font-size: 2rem; color: #fff;
  background: linear-gradient(135deg, #34d399, #059669);
  box-shadow: var(--shadow-md);
}

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state i { font-size: 3rem; opacity: .5; display: block; margin-bottom: .5rem; }

/* ---------- Soft highlighted box ---------- */
.soft-box { background: var(--brand-soft); border-radius: 12px; }

/* ---------- Result rows ---------- */
.result-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: .85rem 1rem; border-radius: 12px; background: var(--brand-soft);
  margin-bottom: .6rem;
}
.result-row .r-name { font-weight: 600; }
.result-row .r-qty { font-weight: 800; color: var(--brand-dark); }

/* ---------- Mobile ---------- */
@media (max-width: 767.98px) {
  .page-wrap { padding-top: 1.25rem; padding-bottom: 2.5rem; }
  .page-head { margin-bottom: 1rem; }
  .page-title { font-size: 1.25rem; }
  .card .card-body { padding: 1.1rem; }

  .page-head > a,
  .page-head > .btn { width: 100%; }

  /* Data tables collapse into stacked cards instead of scrolling sideways */
  table.table-stack { width: 100%; }
  table.table-stack thead { display: none; }
  table.table-stack, table.table-stack tbody, table.table-stack tr, table.table-stack td {
    display: block; width: 100%;
  }
  table.table-stack tr {
    padding: .85rem 1rem; border-bottom: 8px solid var(--bg);
  }
  table.table-stack tr:last-child { border-bottom: 0; }
  table.table-stack td {
    display: flex; align-items: center; justify-content: space-between;
    gap: .75rem; padding: .4rem 0; border: 0; text-align: left;
  }
  table.table-stack td[dir="ltr"] { text-align: left; }
  table.table-stack td::before {
    content: attr(data-label); font-weight: 700; color: var(--muted);
    font-size: .82rem; flex: 0 0 auto;
  }
  table.table-stack td.td-actions {
    justify-content: flex-start; flex-wrap: wrap; gap: .4rem; padding-top: .6rem;
  }
  table.table-stack td.td-actions::before { display: none; }

  /* Comfortable touch targets */
  .btn-sm { padding: .4rem .7rem; min-height: 36px; }
  .btn { min-height: 40px; }
  .form-check-input[role="switch"] { min-width: 2.6em; min-height: 1.35em; }

  .navbar-user { width: 100%; justify-content: flex-start; }
  .navbar-nav { gap: .25rem; }
  .app-navbar .nav-link { padding: .7rem .85rem !important; min-height: 44px; display: flex; align-items: center; }
  .btn-logout { min-height: 44px; display: inline-flex; align-items: center; }
}
