@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
  --green: #10b981; /* Premium Mint Emerald */
  --green-dark: #047857;
  --green-soft: #ecfdf5;
  --red: #f43f5e; /* Rose Red */
  --red-soft: #fff1f2;
  --amber: #f59e0b; /* Warm Amber */
  --amber-soft: #fef3c7;
  --blue: #3b82f6; /* Modern Blue */
  --blue-soft: #eff6ff;
  --purple: #8b5cf6; /* Modern Violet */
  --purple-soft: #f5f3ff;
  --bg: #f8fafc; /* Cool Slate bg */
  --card: #ffffff;
  --text: #0f172a; /* Slate 900 */
  --muted: #64748b; /* Slate 500 */
  --line: #f1f5f9; /* Slate 100 */
  --border: #e2e8f0; /* Slate 200 */
  --radius: 16px;
  --radius-sm: 12px;
  --nav-h: 65px;
  --shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.04), 0 2px 8px -1px rgba(15, 23, 42, 0.02);
  --shadow-lg: 0 20px 40px -8px rgba(15, 23, 42, 0.08), 0 10px 20px -6px rgba(15, 23, 42, 0.04);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: linear-gradient(135deg, var(--green-dark) 0%, #064e3b 100%);
  color: #fff;
  padding: 0 16px;
  height: 56px;
  display: flex; align-items: center; gap: 8px;
  box-shadow: 0 4px 20px rgba(4, 120, 87, 0.15);
}
.topbar h1 { font-size: 1.15rem; font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 6px; }
.topbar .tb-btn {
  background: none; border: 0; color: #fff;
  width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  transition: all 0.2s ease;
}
.topbar .tb-btn:active { background: rgba(255,255,255,.15); transform: scale(0.92); }
.topbar .tb-sub { font-size: .75rem; opacity: .88; font-weight: 400; display: block; margin-top: 1px; }

/* ---- layout ---- */
.wrap { padding: 16px; max-width: 720px; margin: 0 auto; }
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px;
  border: 1px solid rgba(0, 0, 0, 0.025);
  transition: transform 0.2s ease;
}
.card h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: 12px; }
.card .card-link { color: var(--green-dark); font-size: .85rem; font-weight: 700; float: right; transition: opacity 0.2s; }
.card .card-link:hover { opacity: 0.8; }
.section-title { font-size: .82rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 20px 2px 10px; font-weight: 700; }

/* ---- stat grid ---- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stats.g2 { grid-template-columns: repeat(2, 1fr); }
.stat {
  background: var(--card); border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 14px 10px; text-align: center;
  border: 1px solid rgba(0,0,0,0.015);
  position: relative; overflow: hidden;
  transition: transform 0.2s ease;
}
.stat:active { transform: translateY(-2px); }
.stat b { display: block; font-size: 1.25rem; font-weight: 800; margin-bottom: 2px; }
.stat span { font-size: .72rem; color: var(--muted); font-weight: 500; }
.stat.t-green b { color: var(--green-dark); }
.stat.t-red b { color: var(--red); }
.stat.t-amber b { color: var(--amber); }
.stat.t-blue b { color: var(--blue); }
.stat.t-purple b { color: var(--purple); }

.stat::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 3px; background: transparent;
}
.stat.t-green::after { background: var(--green); }
.stat.t-red::after { background: var(--red); }
.stat.t-amber::after { background: var(--amber); }
.stat.t-blue::after { background: var(--blue); }
.stat.t-purple::after { background: var(--purple); }

/* ---- progress ---- */
.progress { background: var(--line); border-radius: 99px; height: 8px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--green); border-radius: 99px; transition: width .4s cubic-bezier(0.4, 0, 0.2, 1); }
.progress.warn > i { background: var(--amber); }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--green-dark); color: #fff; border: 0;
  border-radius: var(--radius-sm); padding: 12px 18px;
  font-weight: 700; font-size: 0.95rem; width: 100%;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(4, 120, 87, 0.15);
}
.btn:active { background: #065f46; transform: scale(0.97); }
.btn.secondary { background: var(--green-soft); color: var(--green-dark); box-shadow: none; }
.btn.secondary:active { background: #d1fae5; }
.btn.danger { background: var(--red); box-shadow: 0 4px 12px rgba(244, 63, 94, 0.15); }
.btn.danger:active { background: #e11d48; }
.btn.outline { background: #fff; color: var(--text); border: 1.5px solid var(--border); box-shadow: none; }
.btn.outline:active { background: var(--line); }
.btn.small { padding: 8px 14px; font-size: .8rem; width: auto; border-radius: 10px; box-shadow: none; }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

/* ---- list rows ---- */
.list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 14px; border: 1px solid rgba(0,0,0,0.02); }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  background: var(--card); width: 100%; text-align: left; border-left: 0; border-right: 0; border-top: 0;
  transition: all 0.2s ease;
}
.row:last-child { border-bottom: 0; }
.row:active { background: var(--line); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 700; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.row .sub { font-size: .78rem; color: var(--muted); margin-top: 3px; font-weight: 500; }
.row .end { text-align: right; }
.row .amt { font-weight: 800; font-size: 0.95rem; color: var(--text); }
.avatar {
  width: 42px; height: 42px; border-radius: var(--radius-sm); flex-shrink: 0;
  background: var(--green-soft); color: var(--green-dark);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1rem;
}

/* ---- badges / chips ---- */
.badge { display: inline-block; padding: 4px 10px; border-radius: 99px; font-size: .72rem; font-weight: 700; text-transform: capitalize; }
.b0 { background: var(--amber-soft); color: var(--amber); }       /* pending / building */
.b1 { background: var(--blue-soft); color: var(--blue); }         /* confirmed / submitted */
.b2 { background: var(--purple-soft); color: var(--purple); }     /* loaded / ready */
.b3 { background: var(--green-soft); color: var(--green-dark); }  /* delivered / out */
.b4 { background: var(--green-soft); color: var(--green-dark); }
.b5 { background: var(--red-soft); color: var(--red); }           /* cancelled / partial */
.b6 { background: var(--red-soft); color: var(--red); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; padding: 8px 16px; border-radius: 99px;
  background: var(--card); border: 1px solid var(--border);
  font-size: .82rem; font-weight: 600; color: var(--muted);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.chip:active { transform: scale(0.95); }
.chip.on { background: var(--green-dark); border-color: var(--green-dark); color: #fff; box-shadow: 0 4px 10px rgba(4, 120, 87, 0.15); }

/* ---- forms ---- */
label.f { display: block; font-size: .8rem; font-weight: 700; color: var(--muted); margin: 14px 2px 6px; }
.input, select.input, textarea.input {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 0.95rem; background: #fff; color: var(--text);
  transition: all 0.2s ease;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.015);
}
.input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1), inset 0 1px 2px rgba(0,0,0,0.015); }

.qty-stepper { display: flex; align-items: center; gap: 0; border: 1.5px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.qty-stepper button { width: 44px; height: 44px; border: 0; background: var(--line); font-size: 1.25rem; font-weight: 700; color: var(--text); transition: background 0.2s; }
.qty-stepper button:active { background: var(--border); }
.qty-stepper input { width: 56px; height: 44px; border: 0; text-align: center; font-size: 1.05rem; font-weight: 800; color: var(--text); }
.qty-stepper input:focus { outline: none; }

/* ---- next-step suggestion card ---- */
.next-step {
  background: linear-gradient(135deg, var(--green) 0%, var(--green-dark) 100%);
  color: #fff; border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
  display: flex; align-items: center; gap: 14px; box-shadow: 0 8px 25px -4px rgba(16, 185, 129, 0.3);
  position: relative; overflow: hidden;
}
.next-step::before {
  content: ''; position: absolute; top: -50%; right: -20%; width: 120px; height: 120px;
  background: rgba(255,255,255,0.08); border-radius: 50%; pointer-events: none;
}
.next-step .grow { flex: 1; }
.next-step .ns-label { font-size: .72rem; opacity: .9; text-transform: uppercase; letter-spacing: .6px; font-weight: 800; }
.next-step .ns-text { font-weight: 800; font-size: 1rem; margin-top: 3px; }
.next-step .ns-go {
  background: #fff; color: var(--green-dark); border: 0;
  border-radius: 10px; padding: 10px 18px; font-weight: 800; font-size: .88rem; flex-shrink: 0;
  transition: all 0.2s;
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}
.next-step .ns-go:active { transform: scale(0.96); }

/* ---- bottom nav ---- */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(15, 23, 42, 0.06);
  display: flex; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.03);
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; font-size: .68rem; font-weight: 600; color: var(--muted); position: relative;
  transition: color 0.2s ease;
}
.bottomnav a svg { width: 22px; height: 22px; transition: transform 0.2s ease; }
.bottomnav a.on { color: var(--green-dark); }
.bottomnav a.on svg {
  transform: translateY(-2px);
  filter: drop-shadow(0 2px 4px rgba(4, 120, 87, 0.25));
}
.bottomnav .nbadge {
  position: absolute; top: 8px; left: calc(50% + 8px);
  background: var(--red); color: #fff; font-size: .62rem; font-weight: 800;
  min-width: 17px; height: 17px; border-radius: 99px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
  border: 2px solid #fff;
}

/* ---- toast / sheet ---- */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 20px); z-index: 100;
  background: var(--text); color: #fff; padding: 12px 20px; border-radius: 14px;
  font-size: .88rem; font-weight: 700; max-width: 90vw;
  box-shadow: 0 10px 30px rgba(15,23,42,0.15);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
  transform: translateX(-50%) translateY(10px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--red); box-shadow: 0 10px 30px rgba(244,63,94,0.25); }

.sheet-back {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.4); z-index: 90;
  display: none; align-items: flex-end;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.sheet-back.open { display: flex; }
.sheet {
  background: var(--card); width: 100%; max-height: 88vh; overflow-y: auto;
  border-radius: 24px 24px 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(15, 23, 42, 0.1);
  animation: sheetUp .24s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet .handle { width: 44px; height: 5px; background: var(--border); border-radius: 99px; margin: 0 auto 16px; }
.sheet h3 { font-size: 1.15rem; font-weight: 800; margin-bottom: 14px; color: var(--text); }

/* ---- login ---- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 10% 20%, rgba(16, 185, 129, 0.08) 0%, rgba(4, 120, 87, 0.03) 90%), linear-gradient(135deg, #0b1511 0%, #030705 100%);
  padding: 24px;
}
.login-card {
  background: rgba(255, 255, 255, 0.98); border-radius: 24px; padding: 36px 28px; width: 100%; max-width: 400px;
  box-shadow: 0 30px 60px -15px rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.1);
}
.login-card .logo {
  width: 64px; height: 64px; border-radius: var(--radius); background: var(--green-soft);
  color: var(--green-dark); display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px; font-size: 1.8rem; font-weight: 800;
  box-shadow: 0 8px 16px rgba(16, 185, 129, 0.1);
}
.login-card h1 { text-align: center; font-size: 1.4rem; font-weight: 800; margin-bottom: 4px; color: var(--text); }
.login-card p.sub { text-align: center; color: var(--muted); font-size: .88rem; margin-bottom: 24px; font-weight: 500; }
.err-box { background: var(--red-soft); color: var(--red); border-radius: var(--radius-sm); padding: 12px 14px; font-size: .85rem; font-weight: 700; margin-bottom: 14px; border: 1px solid rgba(244,63,94,0.15); }

/* ---- tables (reports, desktop-friendly) ---- */
.tbl-scroll { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); box-shadow: var(--shadow); }
table.tbl { width: 100%; border-collapse: collapse; font-size: .85rem; background: #fff; }
.tbl th { text-align: left; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; padding: 12px 10px; border-bottom: 2px solid var(--border); white-space: nowrap; font-weight: 700; background: var(--bg); }
.tbl td { padding: 12px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; color: var(--text); font-weight: 500; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }

/* searchable dropdown (attachSuggest) */
.suggestbox {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 70;
  background: var(--card); border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); max-height: 250px; overflow-y: auto;
}

.empty { text-align: center; color: var(--muted); padding: 40px 16px; font-size: .9rem; font-weight: 500; }
.empty .big { font-size: 2.2rem; margin-bottom: 8px; opacity: 0.8; }
.muted { color: var(--muted); }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }

@media (min-width: 720px) {
  .stats { grid-template-columns: repeat(6, 1fr); }
  .stats.g2 { grid-template-columns: repeat(4, 1fr); }
}

@media print {
  @page {
    size: A4;
    margin: 12mm;
  }
  body {
    background: #fff !important;
    color: #000 !important;
    padding: 0 !important;
    font-size: 11pt !important;
  }
  .topbar, .bottomnav, .toolbar, .chips, form, .btn, #toast, .sheet-back, .sheet-back.open, input, select, button {
    display: none !important;
  }
  .wrap {
    padding: 0 !important;
    max-width: 100% !important;
    margin: 0 !important;
  }
  .card {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    margin-bottom: 20px !important;
    page-break-inside: avoid;
    background: transparent !important;
  }
  table.tbl {
    font-size: 9.5pt !important;
    border: 1px solid #000 !important;
    width: 100% !important;
  }
  table.tbl th {
    background: #f1f5f9 !important;
    color: #000 !important;
    border-bottom: 2px solid #000 !important;
    padding: 8px 6px !important;
  }
  table.tbl td {
    border-bottom: 1px solid #cbd5e1 !important;
    padding: 8px 6px !important;
    background: transparent !important;
  }
  h1, h2, h3 {
    color: #000 !important;
    page-break-after: avoid;
  }
}
