:root {
  --primary: #22c965;
  --primary-dark: #16a34a;
  --bg: #f6f8f7;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --field: #f8fafc;
  --danger: #dc2626;
  --success: #16a34a;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
#app { min-height: 100dvh; display: flex; flex-direction: column; }

/* --- Top nav: logo + name + share --- */
.nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 16px;
  background: rgba(255, 255, 255, .85); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10; border-bottom: 1px solid var(--line);
}
.nav-id { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo-tile {
  position: relative; width: 44px; height: 44px; border-radius: 12px; flex: none;
  background: rgba(34, 201, 101, .12); color: var(--primary); overflow: hidden;
}
.logo-tile .fallback { position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; }
.logo-tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.logo-tile svg { width: 26px; height: 26px; }
.nav-id h1 { font-size: 18px; font-weight: 700; line-height: 1.15; margin: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-id .tag { font-size: 12px; color: var(--muted); margin-top: 1px; }
.iconbtn {
  flex: none; width: 40px; height: 40px; border-radius: 999px; border: none;
  background: transparent; color: var(--ink); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.iconbtn:active { background: #eef2f0; }
.iconbtn svg { width: 22px; height: 22px; }

main { flex: 1; width: 100%; max-width: 448px; margin: 0 auto;
       padding: 24px 16px 40px; }
/* Signed-in shell renders <main> immediately followed by the fixed bottom
   nav; pad content clear of it. */
main.withnav { padding-bottom: calc(40px + 64px + env(safe-area-inset-bottom, 0px)); }

/* --- App bar: sticky top title bar (Home/History/Profile) --- */
.appbar {
  display: flex; align-items: center; padding: 16px;
  background: rgba(255, 255, 255, .85); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10; border-bottom: 1px solid var(--line);
}
.appbar h1 { font-size: 18px; font-weight: 700; margin: 0; }

/* --- Bottom nav: fixed, 3 equal tabs --- */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: rgba(255, 255, 255, .95); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.navtab {
  flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 4px 8px; color: var(--muted); text-decoration: none;
  font-size: 11px; font-weight: 600;
}
.navtab svg { width: 22px; height: 22px; }
.navtab.active { color: var(--primary); }

/* --- Sign-in gate card --- */
.signin-card { text-align: center; }
.signin-card p { color: var(--muted); font-size: 15px; line-height: 1.5; margin: 0 0 20px; }
.g-btn { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.g-btn svg { width: 20px; height: 20px; }
.g-btn:active { background: var(--field); }

/* --- Hero --- */
.hero {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  border-radius: 18px; overflow: hidden; margin-bottom: 26px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 6px 20px rgba(22, 163, 74, .18);
}
.hero .truck { position: absolute; inset: 0; width: 100%; height: 100%; }
.badge {
  position: absolute; top: 14px; right: 14px;
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(255, 255, 255, .95); border-radius: 999px;
  padding: 6px 12px; font-size: 12px; font-weight: 600; color: var(--ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
}
.dot { position: relative; width: 8px; height: 8px; }
.dot span { position: absolute; inset: 0; border-radius: 999px; background: var(--primary); }
.dot .ping { animation: ping 1.4s cubic-bezier(0,0,.2,1) infinite; }
@keyframes ping { 75%, 100% { transform: scale(2.2); opacity: 0; } }

/* --- Card --- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 22px; padding: 24px 20px; box-shadow: 0 4px 16px rgba(15, 23, 42, .04);
}
.card h2 { text-align: center; font-size: 18px; font-weight: 700; margin: 0 0 20px; }
.field + .field { margin-top: 16px; }
label { display: block; font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
input, textarea {
  width: 100%; padding: 13px 15px; font-size: 16px; font-family: inherit;
  color: var(--ink); background: var(--field);
  border: 1px solid var(--line); border-radius: 12px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input:focus, textarea:focus {
  outline: none; background: #fff; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(34, 201, 101, .18);
}
textarea { min-height: 64px; resize: vertical; }
.locmsg { display: flex; align-items: center; gap: 6px; font-size: 13px;
  color: var(--muted); margin-top: 8px; }
.locmsg svg { width: 15px; height: 15px; flex: none; }
.locmsg.ok { color: var(--success); font-weight: 600; }
.locmsg.warn { color: #b45309; }
.err { color: var(--danger); font-size: 14px; font-weight: 500; margin-top: 14px; }

/* --- Actions --- */
.actions { margin-top: 22px; display: flex; flex-direction: column; gap: 12px; }
button.cta {
  width: 100%; padding: 15px; font-size: 16px; font-weight: 700; font-family: inherit;
  border: none; border-radius: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: filter .15s, transform .05s, opacity .15s;
}
button.cta:active { transform: scale(.985); }
button.cta svg { width: 20px; height: 20px; }
.primary { background: var(--primary); color: #fff; box-shadow: 0 8px 20px rgba(34, 201, 101, .28); }
.primary:active { filter: brightness(.97); }
.primary[disabled] { opacity: .6; box-shadow: none; }
.ghost { background: #fff; color: var(--primary-dark); border: 2px solid var(--primary); }
.hint { text-align: center; font-size: 13px; color: var(--muted); margin: 4px 0 0; line-height: 1.5; }

.center { text-align: center; color: var(--muted); padding: 80px 24px; }

/* --- Success --- */
.done { text-align: center; padding: 12px 8px; }
.done .tick {
  width: 72px; height: 72px; border-radius: 999px; margin: 8px auto 18px;
  background: rgba(34, 201, 101, .14); color: var(--success);
  display: flex; align-items: center; justify-content: center;
}
.done .tick svg { width: 38px; height: 38px; }
.done h2 { font-size: 22px; margin: 0 0 8px; }
.done p { color: var(--muted); margin: 0; font-size: 15px; line-height: 1.5; }

/* --- Section title (Home) --- */
.section-title { font-size: 13px; font-weight: 700; letter-spacing: .02em;
  color: var(--muted); margin: 0 0 12px; }

/* --- Status pill --- */
.pill { flex: none; display: inline-flex; align-items: center; justify-content: center;
  padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700;
  letter-spacing: .02em; white-space: nowrap; }
.pill.pending { background: rgba(217, 119, 6, .14); color: #b45309; }
.pill.confirmed { background: rgba(34, 201, 101, .14); color: var(--primary-dark); }
.pill.rejected { background: rgba(100, 116, 139, .14); color: var(--muted); }

/* --- History list --- */
.history-row {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 14px 16px; box-shadow: 0 4px 16px rgba(15, 23, 42, .04);
}
.history-row + .history-row { margin-top: 12px; }
.history-row .logo-tile { width: 40px; height: 40px; border-radius: 10px; }
.history-row .logo-tile svg { width: 22px; height: 22px; }
.history-row-body { min-width: 0; flex: 1; }
.history-row-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.history-row-name { font-size: 15px; font-weight: 700; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.history-row-line { font-size: 13px; color: var(--muted); margin-top: 4px; line-height: 1.4; }
.history-row-date { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* --- Supplier cards (Home) --- */
.supplier-card {
  display: flex; align-items: center; gap: 14px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 14px 16px; box-shadow: 0 4px 16px rgba(15, 23, 42, .04);
  transition: transform .05s, filter .15s;
}
.supplier-card:active { transform: scale(.985); filter: brightness(.98); }
.supplier-card + .supplier-card { margin-top: 12px; }
.supplier-card .logo-tile { width: 48px; height: 48px; border-radius: 12px; }
.supplier-card .logo-tile svg { width: 26px; height: 26px; }
.supplier-card-body { min-width: 0; flex: 1; }
.supplier-card-name { font-size: 16px; font-weight: 700; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.supplier-card-last { font-size: 13px; color: var(--muted); margin-top: 3px; }

/* --- Sign-out text button (Profile) --- */
.signout {
  width: 100%; padding: 10px; font-size: 14px; font-weight: 600; font-family: inherit;
  background: none; border: none; color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.signout svg { width: 18px; height: 18px; }
.signout:active { color: var(--danger); }

/* --- Toast (bottom-anchored confirmation) --- */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: 14px; font-weight: 600;
  padding: 11px 20px; border-radius: 999px; box-shadow: 0 8px 20px rgba(15, 23, 42, .22);
  z-index: 30; max-width: calc(100% - 32px); text-align: center;
  animation: toast-in .18s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(6px); } to { opacity: 1; transform: translateX(-50%); } }
