@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&display=swap");

:root {
  --lime: #b8d400;
  --lime-deep: #a3be00;
  --lime-soft: #eef6b8;
  --lime-wash: #f4f9d8;
  --forest: #14361a;
  --forest-mid: #1e4a24;
  --ink: #121212;
  --muted: #5a635c;
  --bg: #f7f7f5;
  --surface: #ffffff;
  --line: #e4e6df;
  --ok: #1e4a24;
  --err: #b42318;
  --debt: #b45309;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 10px 28px rgba(20, 54, 26, 0.08);
  --font: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  padding-bottom: 5.5rem;
  line-height: 1.55;
}

a { color: var(--forest-mid); text-decoration: none; }
.muted { color: var(--muted); }
.dim { opacity: 0.55; }
.debt { color: var(--debt); font-weight: 700; }
.credit { color: var(--ok); font-weight: 700; }

/* ——— Header / Hero shell ——— */
.app-shell {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 0.85rem 1rem 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.1rem;
  background: var(--lime);
  border-radius: var(--radius) var(--radius) 0 0;
  position: relative;
  z-index: 10;
}
.brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--forest);
  letter-spacing: -0.02em;
}
.nav {
  display: none;
  gap: 1.1rem;
  align-items: center;
}
.nav a {
  color: var(--forest);
  font-weight: 600;
  font-size: 0.95rem;
  opacity: 0.85;
}
.nav a.active,
.nav a:hover {
  opacity: 1;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.container {
  width: 100%;
  margin: 0;
  padding: 0 0 1.5rem;
  background: var(--surface);
  border-radius: 0 0 var(--radius) var(--radius);
  border: 1px solid var(--line);
  border-top: 0;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.container > .alert {
  margin: 1rem 1rem 0;
}

.container > .page-head,
.container > .tabs,
.container > .form,
.container > .list,
.container > .balance-card,
.container > .section-title,
.container > .muted,
.container > .quick-add,
.container > .stats {
  margin-left: 1rem;
  margin-right: 1rem;
}

.container > .page-head { margin-top: 1.1rem; }
.container > .section-title { margin-left: 1rem; margin-right: 1rem; }
.container > .stats { margin-bottom: 1rem; }
.container > .hero-home {
  margin: 0;
  border-radius: 0;
  box-shadow: none;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 1.1rem 0 1rem;
}
.page-head h1 {
  margin: 0;
  font-size: 1.45rem;
  color: var(--ink);
  font-weight: 700;
}

/* ——— Home hero (lime banner) ——— */
.hero-home {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 20%, rgba(255, 255, 255, 0.35), transparent 35%),
    radial-gradient(circle at 88% 70%, rgba(20, 54, 26, 0.12), transparent 40%),
    linear-gradient(135deg, #c5e000 0%, var(--lime) 45%, #a8c700 100%);
  border-radius: 0;
  padding: 1.6rem 1.35rem 1.5rem;
  margin: 0 0 1.25rem;
  color: var(--forest);
}
.hero-home::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(
      -28deg,
      transparent,
      transparent 18px,
      rgba(255, 255, 255, 0.07) 18px,
      rgba(255, 255, 255, 0.07) 19px
    );
  pointer-events: none;
}
.hero-home > * { position: relative; z-index: 1; }
.hero-home h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.55rem, 4vw, 2rem);
  font-weight: 700;
  color: var(--forest);
}
.hero-home .lead {
  margin: 0 0 1.15rem;
  max-width: 28rem;
  color: var(--forest-mid);
  font-weight: 500;
}
.hero-home .btn.primary {
  background: var(--forest);
  color: #fff;
  border-color: var(--forest);
  width: auto;
  min-width: 10rem;
  padding: 0.75rem 1.4rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 0.25rem;
}
.stat {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1rem 0.75rem;
  text-align: center;
  box-shadow: 0 4px 14px rgba(20, 54, 26, 0.05);
}
.stat::after {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  bottom: 0;
  width: 100%;
  height: 4px;
  background: var(--lime);
}
.stat span {
  display: block;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--forest);
}
.stat small {
  color: var(--muted);
  font-weight: 500;
}

/* ——— Buttons ——— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  background: var(--lime);
  color: var(--forest);
  border-radius: 999px;
  padding: 0.6rem 1.15rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.btn:hover { filter: brightness(0.97); }
.btn:active { transform: scale(0.98); }
.btn.primary {
  background: var(--forest);
  color: #fff;
  border-color: var(--forest);
}
.btn.secondary {
  background: var(--forest);
  color: #fff;
  border-color: var(--forest);
}
.btn.ghost {
  background: #fff;
  color: var(--forest);
  border-color: var(--line);
}
.btn.big {
  width: 100%;
  padding: 0.95rem 1rem;
  margin-top: 0.35rem;
  font-size: 1.05rem;
}
.btn.tiny {
  padding: 0.35rem 0.65rem;
  font-size: 0.82rem;
  border-radius: 999px;
}
.btn.danger {
  background: #fff;
  color: var(--err);
  border-color: #f0c9c4;
}

/* ——— Alerts ——— */
.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  margin: 1rem 0 0;
  font-weight: 600;
}
.alert.ok {
  background: var(--lime-wash);
  color: var(--forest);
  border: 1px solid #d7e86a;
}
.alert.err {
  background: #fef3f2;
  color: var(--err);
  border: 1px solid #f9d1cd;
}

/* ——— Lists / cards ——— */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.7rem;
}
.list-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.95rem 1.05rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  box-shadow: 0 4px 14px rgba(20, 54, 26, 0.04);
  transition: border-color 0.15s ease;
}
.list-item:hover { border-color: var(--lime-deep); }
.list-item a {
  color: inherit;
  display: flex;
  justify-content: space-between;
  width: 100%;
  gap: 0.75rem;
  align-items: center;
}
.list-item .balance {
  font-weight: 700;
  white-space: nowrap;
}
.product-row { flex-wrap: wrap; }
.inline-price { display: flex; gap: 0.35rem; align-items: center; }
.inline-price input { width: 6.5rem; }

/* ——— Forms ——— */
.form {
  display: grid;
  gap: 0.9rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem;
  box-shadow: var(--shadow);
}
.form.compact {
  box-shadow: none;
  margin-top: 0.75rem;
  border-radius: var(--radius-sm);
}
.form label {
  display: grid;
  gap: 0.4rem;
  font-weight: 600;
  color: var(--forest);
}
.form input,
.form select,
.form textarea {
  font: inherit;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  width: 100%;
  color: var(--ink);
}
.form input:focus,
.form select:focus,
.form textarea:focus {
  outline: 2px solid rgba(184, 212, 0, 0.55);
  border-color: var(--lime-deep);
}
.check {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}
.check input { width: auto; }

/* ——— Balance card ——— */
.balance-card {
  background:
    radial-gradient(circle at 90% 20%, rgba(255, 255, 255, 0.28), transparent 35%),
    linear-gradient(135deg, var(--lime) 0%, #a8c400 100%);
  color: var(--forest);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.balance-card small {
  font-weight: 600;
  opacity: 0.85;
}
.balance-card strong {
  display: block;
  font-size: 1.75rem;
  margin: 0.3rem 0 0.9rem;
  color: var(--forest);
}
.balance-card .debt { color: #7a3e00; }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.row-actions .btn {
  background: rgba(255, 255, 255, 0.55);
  color: var(--forest);
  border-color: transparent;
}
.row-actions .btn.primary {
  background: var(--forest);
  color: #fff;
}

.section-title {
  font-size: 1.15rem;
  margin: 1.25rem 0 0.65rem;
  color: var(--ink);
  font-weight: 700;
}

/* ——— Tabs ——— */
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin-bottom: 1rem;
  background: var(--lime-wash);
  padding: 0.35rem;
  border-radius: 999px;
}
.tabs a {
  text-align: center;
  padding: 0.7rem;
  border-radius: 999px;
  color: var(--forest);
  font-weight: 700;
}
.tabs a.active {
  background: var(--lime);
  color: var(--forest);
  box-shadow: 0 2px 8px rgba(20, 54, 26, 0.12);
}

.lines-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.lines-head h2 { margin: 0; font-size: 1rem; color: var(--forest); }

.sale-line {
  display: grid;
  gap: 0.45rem;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 0.55rem;
  background: var(--lime-wash);
}
.qty-row { display: grid; gap: 0.35rem; }
.qty-btns { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.qty-btns .btn {
  background: #fff;
  border-color: var(--line);
  color: var(--forest);
}
.total-line {
  font-size: 1.15rem;
  margin: 0.35rem 0 0;
  color: var(--forest);
}
.quick-add {
  margin-top: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}
.quick-add summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--forest);
}
.qty-hints { font-size: 0.9rem; }

/* ——— Bottom nav + FAB ——— */
.bottom-nav {
  position: fixed;
  bottom: 0;
  inset-inline: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 0.45rem 0.4rem calc(0.45rem + env(safe-area-inset-bottom));
  z-index: 20;
}
.bottom-nav a {
  text-align: center;
  color: var(--muted);
  font-weight: 700;
  padding: 0.55rem 0.35rem;
  border-radius: 12px;
  font-size: 0.92rem;
}
.bottom-nav a.active {
  color: var(--forest);
  background: var(--lime-wash);
}

.fab-wa {
  position: fixed;
  bottom: calc(4.4rem + env(safe-area-inset-bottom));
  inset-inline-end: 1rem;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  background: #25d366;
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 8px 20px rgba(37, 211, 102, 0.45);
  z-index: 25;
  font-size: 1.45rem;
  line-height: 1;
}
.fab-wa:hover { filter: brightness(1.05); color: #fff; }

@media (min-width: 800px) {
  .nav { display: flex; }
  .bottom-nav { display: none; }
  .fab-wa { bottom: 1.5rem; }
  body { padding-bottom: 2rem; }
  .hero-home { padding: 2rem 1.75rem; }
}
