/* ============================================================
   SENTRA SAYUR — Design Tokens
   Brand: senada www.sentrasayur.com (hijau tua + krem hangat)
   ============================================================ */
:root {
  /* Warna utama — forest green */
  --green-900: #163F29;
  --green-800: #1F5E3B;   /* header, tombol primary */
  --green-700: #2D6A4F;   /* hover, elemen aktif */
  --green-500: #40916C;   /* aksen segar */
  --green-100: #D8F3DC;   /* badge sukses bg */
  --green-050: #EAF6EC;

  /* Background krem hangat — bukan putih murni, bukan abu-abu */
  --cream: #F5F1E8;
  --cream-dark: #EAE4D3;
  --surface: #FDFBF5;     /* kartu */

  /* Teks kontras tinggi */
  --ink: #21251E;
  --ink-soft: #55594E;
  --muted: #83867A;

  /* Warning kuning hangat (badge "harga belum diset") */
  --amber-bg: #FBEED0;
  --amber-border: #E8C775;
  --amber-ink: #8A5A0B;

  /* Bahaya / batal */
  --red-ink: #A23B27;
  --red-bg: #F9E4DE;

  --radius-pill: 999px;
  --radius-card: 14px;
  --radius-input: 12px;
  --shadow-card: 0 1px 3px rgba(33, 37, 30, .08), 0 4px 14px rgba(33, 37, 30, .05);
  --font-sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--cream);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
}

/* ---------- Tipografi ---------- */
h1, h2, h3, .heading {
  text-transform: uppercase;
  letter-spacing: .09em;
  font-weight: 700;
  color: var(--green-900);
  margin: 0 0 .5rem;
}
h1 { font-size: 1.35rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .9rem; letter-spacing: .12em; color: var(--ink-soft); }
.subtle { color: var(--muted); font-size: .85rem; }
.price, .num {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- Logo ---------- */
.brand { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; }
.brand-box {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--green-800); color: #fff;
  display: grid; place-items: center;
  font-weight: 800; font-size: 1.05rem; letter-spacing: .02em;
}
.brand-word { font-weight: 800; font-size: 1.02rem; letter-spacing: .1em; color: var(--ink); }
.brand-word em { font-style: normal; color: var(--green-700); }
.brand--onGreen .brand-box { background: #fff; color: var(--green-800); }
.brand--onGreen .brand-word { color: #fff; }
.brand--onGreen .brand-word em { color: var(--green-100); }

/* ---------- Header / Nav ---------- */
.app-header {
  background: var(--green-800); color: #fff;
  padding: calc(.6rem + env(safe-area-inset-top)) 1rem .6rem;
  display: flex; align-items: center; gap: 1rem;
  position: sticky; top: 0; z-index: 40;
}
.app-header .spacer { flex: 1; }
.app-nav { display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none; }
.app-nav::-webkit-scrollbar { display: none; }
.app-nav a {
  color: #E4F0E7; text-decoration: none; font-size: .82rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .07em;
  padding: .45rem .85rem; border-radius: var(--radius-pill); white-space: nowrap;
}
.app-nav a.active, .app-nav a:hover { background: var(--green-700); color: #fff; }
.user-chip { font-size: .8rem; color: #DCEBDF; white-space: nowrap; }
.main { max-width: 1080px; margin: 0 auto; padding: 1rem; }
.main--narrow { max-width: 480px; }

/* ---------- Tombol (pill) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  font-family: inherit; font-size: .95rem; font-weight: 700;
  padding: .7rem 1.35rem;
  cursor: pointer; text-decoration: none; text-align: center;
  transition: background .12s, border-color .12s;
  min-height: 48px; /* ramah jempol */
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, .input:focus-visible, .tap:focus-visible { outline: 2px solid var(--green-500); outline-offset: 2px; }
.btn-primary { background: var(--green-800); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--green-700); }
.btn-outline { background: transparent; color: var(--green-800); border-color: var(--green-800); }
.btn-outline:hover:not(:disabled) { background: var(--green-050); }
.btn-ghost { background: transparent; color: var(--ink-soft); min-height: 40px; padding: .4rem .9rem; }
.btn-ghost:hover { background: var(--cream-dark); }
.btn-danger { background: transparent; color: var(--red-ink); border-color: var(--red-ink); }
.btn-sm { min-height: 38px; padding: .35rem .95rem; font-size: .85rem; }
.btn-lg { min-height: 56px; font-size: 1.05rem; width: 100%; }
.btn-block { width: 100%; }

/* ---------- Kartu & list ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 1rem;
  margin-bottom: .9rem;
}
.list-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .8rem .35rem;
  border-bottom: 1px solid var(--cream-dark);
  min-height: 56px;
}
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 700; }
.tap { cursor: pointer; -webkit-tap-highlight-color: rgba(45,106,79,.15); }
.tap:active { background: var(--green-050); }

/* ---------- Form ---------- */
label.field-label {
  display: block; font-size: .78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-soft); margin: 0 0 .3rem .15rem;
}
.input, select.input, textarea.input {
  width: 100%;
  font-family: inherit; font-size: 1rem; color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--cream-dark);
  border-radius: var(--radius-input);
  padding: .75rem .9rem;
  min-height: 48px;
}
.input:focus { outline: 2px solid var(--green-500); outline-offset: 0; border-color: var(--green-500); }
.input--lg { font-size: 1.25rem; min-height: 56px; text-align: center; }
.field { margin-bottom: .9rem; }
.error-text { color: var(--red-ink); font-size: .85rem; margin-top: .25rem; }

/* ---------- Badge & chip ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  border-radius: var(--radius-pill);
  font-size: .72rem; font-weight: 700; letter-spacing: .04em;
  padding: .22rem .6rem; white-space: nowrap;
}
.badge-green { background: var(--green-100); color: var(--green-900); }
.badge-amber { background: var(--amber-bg); color: var(--amber-ink); border: 1px solid var(--amber-border); }
.badge-red { background: var(--red-bg); color: var(--red-ink); }
.badge-gray { background: var(--cream-dark); color: var(--ink-soft); }
.badge-outline { border: 1.5px solid var(--green-700); color: var(--green-800); background: transparent; }

/* ---------- Tabel (desktop) ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th {
  text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-soft); font-weight: 700;
  padding: .55rem .6rem; border-bottom: 2px solid var(--cream-dark);
  white-space: nowrap;
}
.table td { padding: .6rem; border-bottom: 1px solid var(--cream-dark); vertical-align: middle; }
.table tr:hover td { background: var(--green-050); }
.table .num-cell { text-align: right; }

/* ---------- Qty pad ---------- */
.qty-quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin: .6rem 0; }
.qty-quick button {
  min-height: 52px; font-size: 1.05rem; font-weight: 700;
  border-radius: var(--radius-input);
  border: 1.5px solid var(--cream-dark); background: #fff; color: var(--ink);
  cursor: pointer;
}
.qty-quick button:active { background: var(--green-100); border-color: var(--green-500); }
.qty-stepper { display: flex; gap: .5rem; align-items: stretch; }
.qty-stepper .input { flex: 1; }
.qty-stepper button {
  width: 64px; min-height: 56px; font-size: 1.5rem; font-weight: 700;
  border-radius: var(--radius-input);
  border: 1.5px solid var(--green-800); background: var(--green-050); color: var(--green-800);
  cursor: pointer;
}

/* ---------- Panel bawah (mobile sheet) ---------- */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -6px 30px rgba(33,37,30,.25);
  padding: 1rem 1rem calc(1.25rem + env(safe-area-inset-bottom));
  max-height: 88dvh; overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.sheet-backdrop { position: fixed; inset: 0; background: rgba(22,63,41,.45); z-index: 45; }
.sheet .grabber { width: 44px; height: 4px; border-radius: 4px; background: var(--cream-dark); margin: 0 auto .8rem; }

/* ---------- Banner / alert ---------- */
.banner { border-radius: var(--radius-card); padding: .8rem 1rem; margin-bottom: .9rem; font-size: .92rem; font-weight: 600; }
.banner-lock { background: var(--amber-bg); color: var(--amber-ink); border: 1px solid var(--amber-border); }
.banner-info { background: var(--green-050); color: var(--green-900); }
.banner-error { background: var(--red-bg); color: var(--red-ink); }

/* ---------- Progress bar ---------- */
.progress { background: var(--cream-dark); border-radius: var(--radius-pill); height: 12px; overflow: hidden; }
.progress > div { background: var(--green-500); height: 100%; border-radius: var(--radius-pill); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs button {
  border-radius: var(--radius-pill); border: 1.5px solid var(--cream-dark);
  background: var(--surface); color: var(--ink-soft);
  font-family: inherit; font-size: .82rem; font-weight: 700;
  padding: .5rem 1rem; cursor: pointer; min-height: 42px;
}
.tabs button.active { background: var(--green-800); border-color: var(--green-800); color: #fff; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem; }
.login-card { width: 100%; max-width: 400px; }
.login-ticker {
  text-align: center; margin-top: 1.1rem;
  font-size: .72rem; font-weight: 700; letter-spacing: .28em;
  text-transform: uppercase; color: var(--green-700);
}

/* ---------- Util ---------- */
.flex { display: flex; align-items: center; gap: .6rem; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mb-0 { margin-bottom: 0; }
.text-right { text-align: right; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divider { border: 0; border-top: 1px solid var(--cream-dark); margin: .9rem 0; }
.pagination { display: flex; align-items: center; gap: .8rem; justify-content: center; margin-top: 1rem; }

/* ---------- Bottom navigation (mobile) ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
  background: var(--green-800);
  display: flex; justify-content: space-around; align-items: stretch;
  padding: .3rem .4rem calc(.3rem + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 12px rgba(22, 63, 41, .25);
}
.bottom-nav a, .bottom-nav button {
  flex: 1; max-width: 140px;
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
  background: none; border: 0; cursor: pointer; text-decoration: none;
  color: #BFDCC7; font-family: inherit;
  font-size: .66rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  padding: .35rem .2rem; border-radius: 12px; min-height: 54px; justify-content: center;
  transition: background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav a:active, .bottom-nav button:active { background: rgba(255,255,255,.1); }
.bottom-nav .icon { font-size: 1.3rem; line-height: 1; transition: transform .15s; }
.bottom-nav a.active { background: var(--green-700); color: #fff; }
.bottom-nav a.active .icon { transform: translateY(-1px) scale(1.08); }

/* Menu "Lainnya"/"Akun" di atas bottom nav — bisa discroll bila menu panjang */
.nav-sheet {
  position: fixed; left: .6rem; right: .6rem; z-index: 56;
  bottom: calc(72px + env(safe-area-inset-bottom));
  background: var(--surface); border-radius: var(--radius-card);
  box-shadow: 0 8px 30px rgba(22, 63, 41, .35);
  padding: .5rem .9rem;
  max-height: calc(100dvh - 140px - env(safe-area-inset-bottom));
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.nav-sheet .list-item.tap { border-radius: 10px; padding-left: .6rem; padding-right: .6rem; }

/* ---------- Search overlay fullscreen (anti-keyboard, pola Gojek/Tokopedia) ----------
   Tinggi mengikuti visualViewport (--vvh di-set JS) sehingga input & hasil
   selalu berada DI ATAS keyboard. */
.search-overlay {
  position: fixed; top: 0; left: 0; right: 0; z-index: 70;
  height: var(--vvh, 100dvh);
  background: var(--cream);
  display: flex; flex-direction: column;
  padding: .7rem .9rem 0;
}
.search-overlay .search-head { display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.search-overlay .search-head .input { flex: 1; }
.search-overlay .btn-close {
  width: 48px; height: 48px; flex: none;
  border-radius: var(--radius-pill); border: 1.5px solid var(--cream-dark);
  background: var(--surface); color: var(--ink-soft);
  font-size: 1.3rem; font-weight: 700; cursor: pointer;
}
.search-overlay .results { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 1rem; }

/* ---------- Sticky submit bar (di atas bottom nav) ---------- */
.submit-bar {
  position: fixed; left: 0; right: 0; z-index: 60;
  bottom: calc(64px + env(safe-area-inset-bottom));
  padding: .6rem .9rem;
  background: linear-gradient(to top, var(--cream) 70%, transparent);
}
.submit-bar .btn { width: 100%; max-width: 480px; margin: 0 auto; display: flex; }

/* ---------- Layar sukses submit ---------- */
.success-screen { text-align: center; padding: 3rem 1rem 2rem; }
.success-screen .check {
  width: 84px; height: 84px; margin: 0 auto 1.2rem;
  border-radius: 50%; background: var(--green-100); color: var(--green-800);
  display: grid; place-items: center; font-size: 2.6rem; font-weight: 800;
}

/* Ikon hapus baris */
.line-delete {
  width: 40px; height: 40px; flex: none;
  border: 0; background: none; cursor: pointer;
  color: var(--red-ink); font-size: 1.15rem; border-radius: 50%;
}
.line-delete:active { background: var(--red-bg); }

/* Mobile: sembunyikan top-nav, beri ruang bottom nav + submit bar */
@media (max-width: 719px) {
  .app-nav { display: none; }
  .main { padding-bottom: calc(150px + env(safe-area-inset-bottom)); }
}

@media (min-width: 720px) {
  h1 { font-size: 1.6rem; }
  .main { padding: 1.5rem; }
  .bottom-nav, .nav-sheet { display: none; }
  .submit-bar { position: static; padding: .6rem 0; background: none; }
}

/* ---------- Halaman lebar (tabel data): sempit di HP, luas di desktop ---------- */
.page--wide { max-width: 760px; }

/* ---------- Desktop (≥1024px): sidebar kiri penuh ---------- */
.sidebar { display: none; }
@media (min-width: 1024px) {
  .app-header { display: none; }
  .bottom-nav, .nav-sheet { display: none !important; }

  .sidebar {
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0; width: 250px;
    background: linear-gradient(178deg, var(--green-900) 0%, var(--green-800) 34%);
    color: #fff;
    padding: 1.15rem .75rem 1rem; overflow-y: auto; z-index: 60;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.25) transparent;
  }
  .sidebar-brand {
    display: flex; align-items: center; gap: .6rem; text-decoration: none;
    color: #fff; font-weight: 800; letter-spacing: .09em; font-size: 1rem;
    padding: .25rem .55rem 1.05rem;
  }
  .sidebar-brand em { font-style: normal; color: #9FDCB4; }
  .sidebar-brand .brand-box {
    background: #fff; color: var(--green-800); width: 34px; height: 34px;
    border-radius: 10px; display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: .84rem; letter-spacing: 0; flex: none;
    box-shadow: 0 2px 8px rgba(0,0,0,.18);
  }
  .sidebar-sec {
    font-size: .64rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase;
    color: rgba(255,255,255,.42);
    padding: .95rem .7rem .3rem;
  }
  .sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
  .sidebar-nav a {
    position: relative;
    display: flex; align-items: center; gap: .65rem;
    padding: .5rem .7rem; border-radius: 10px;
    color: #CFE6D6; text-decoration: none; font-weight: 600; font-size: .9rem;
    transition: background .12s, color .12s;
  }
  .sidebar-nav a .ic {
    width: 1.35rem; text-align: center; font-size: .98rem; flex: none;
    filter: grayscale(28%); opacity: .9;
  }
  .sidebar-nav a:hover { background: rgba(255, 255, 255, .09); color: #fff; }
  .sidebar-nav a:hover .ic, .sidebar-nav a.active .ic { filter: none; opacity: 1; }
  .sidebar-nav a.active {
    background: rgba(255, 255, 255, .13); color: #fff;
    box-shadow: inset 3px 0 0 #9FDCB4;
  }
  .sidebar-foot {
    border-top: 1px solid rgba(255, 255, 255, .14);
    padding: .75rem .35rem 0; margin-top: .7rem;
    display: flex; align-items: center; gap: .6rem;
  }
  .sidebar-user { flex: 1; min-width: 0; }
  .sidebar-user .nm { font-weight: 700; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sidebar-user .rl { font-size: .72rem; color: #9FC4AC; text-transform: capitalize; }
  .sidebar-logout {
    flex: none; padding: .45rem .85rem; cursor: pointer;
    background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: var(--radius-pill);
    font: inherit; font-weight: 700; font-size: .78rem;
    transition: background .12s;
  }
  .sidebar-logout:hover { background: var(--red-ink); }

  /* Konten: digeser ke kanan sidebar, lega tapi tidak melar tanpa batas */
  .main {
    max-width: none; margin-left: 250px;
    padding: 2rem 2.4rem calc(2rem + env(safe-area-inset-bottom));
  }
  .main > * { max-width: 1240px; }
  h1 { font-size: 1.75rem; }
  .page--wide { max-width: 1240px; }

  /* Tabel data lebih lega & nyaman dibaca di layar besar */
  .table th { padding: .7rem .8rem; }
  .table td { padding: .7rem .8rem; }
  .table tbody tr:nth-child(even) td { background: rgba(45, 106, 79, .035); }
  .table tr:hover td { background: var(--green-050); }
  .card { padding: 1.25rem 1.4rem; }
}

/* ---------- Accordion (picking list) ---------- */
.accordion-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; cursor: pointer; }
.accordion-caret { font-size: .8rem; color: var(--muted); transition: transform .15s; }

/* ---------- Print (picking list / surat jalan) ---------- */
.print-only { display: none !important; }
.print-sheet { display: none; }
@media print {
  .app-header, .bottom-nav, .nav-sheet, .no-print, .screen-only { display: none !important; }
  body { background: #fff; color: #000; }
  .print-only { display: block !important; }
  .print-sheet { display: block !important; }
  /* Blok per customer jangan terpotong antar halaman */
  .print-cust { page-break-inside: avoid; }
}
