/* Aegos Agro demo - shared tokens and components. Screen files add only screen-specific rules.
   Skin: Terracotta Editorial (Baron's pick, 7 Sep 2026). Variable names keep their original green-era
   names so the screen files did not need touching; the values are the terracotta palette. Spec: 02-work/design-options/design-spec.md */
:root {
  --green-900: #2F3A26;   /* olive: dark blocks, active chips, accent */
  --green: #B8452F;       /* terracotta primary */
  --green-600: #A03A26;
  --green-100: #F3DED6;   /* primary soft */
  --green-50: #FAF3EE;
  --amber: #2F3A26;       /* accent = olive */
  --amber-100: #F1E7D2;
  --paper: #F5EFE6;
  --white: #FFFDF9;
  --ink: #2B2A26;
  --muted: #7A7167;
  --faint: #9C948A;
  --line: #DDD4C5;        /* hairline on cream */
  --danger: #A8321F;
  --danger-100: #F6DDD7;
  --blue: #2F3A26;
  --blue-100: #E6E9DD;
  --radius: 8px;
  --radius-sm: 8px;
  --shadow: none;
  --topbar-h: 56px;
  --nav-h: 64px;
  --font-display: 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body); font-size: 15px; line-height: 1.5; color: var(--ink);
  background: #E6DFD3; -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: var(--green); text-decoration: none; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

/* App frame: full width on phones, a centred 480px column on larger screens */
#app { max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; background: var(--paper); position: relative; display: flex; flex-direction: column; }
@media (min-width: 520px) { #app { box-shadow: 0 0 0 1px var(--line), 0 20px 60px rgba(0,0,0,.12); } }

/* Top bar */
#topbar {
  position: sticky; top: 0; z-index: 20; height: var(--topbar-h);
  display: flex; align-items: center; gap: 8px; padding: 0 12px;
  background: var(--paper); border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
#topbar .tb-title { flex: 1; font-family: var(--font-display); font-weight: 800; font-size: 18px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#topbar .tb-brand { flex: 1; display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 800; font-size: 19px; letter-spacing: -0.02em; color: var(--green-900); }
#topbar .tb-brand svg { width: 22px; height: 22px; }
.iconbtn { width: 40px; height: 40px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; position: relative; color: var(--ink); }
.iconbtn:active { background: var(--green-100); }
.iconbtn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn .dot { position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--green); color: var(--white); font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.pill-demo { font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--green); background: var(--green-100); padding: 3px 7px; border-radius: 6px; }

/* View */
#view { flex: 1; padding: 16px 16px calc(var(--nav-h) + 24px); }
#view.no-nav { padding-bottom: 24px; }

/* Bottom nav */
#bottomnav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; z-index: 20;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--white); border-top: 1px solid var(--line); display: flex;
}
#bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--faint); }
#bottomnav a svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#bottomnav a { position: relative; z-index: 0; }
#bottomnav a.active { color: var(--green); }
#bottomnav a.active::before { content: ''; position: absolute; top: 6px; bottom: 6px; left: 6px; right: 6px; background: var(--green-100); border-radius: 10px; z-index: -1; }
#bottomnav a .dot { position: absolute; margin-left: 22px; margin-top: -18px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--green); color: var(--white); font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; }

/* Typography */
h1 { font-family: var(--font-display); font-size: 26px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.money { letter-spacing: -0.01em; }
h2 { font-family: var(--font-display); font-size: 17px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.25; }
h3 { font-family: var(--font-display); font-size: 15px; font-weight: 700; }
.section { margin-top: 22px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.section-head a { font-size: 13px; font-weight: 600; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.bold { font-weight: 700; }
.money { font-family: var(--font-display); font-weight: 800; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.flex { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 48px; padding: 0 18px; border-radius: 12px; font-weight: 700; font-size: 15px; transition: transform .05s; white-space: nowrap; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--green); color: var(--white); }
.btn-primary:disabled { background: #A8C7B3; }
.btn-secondary { background: var(--green-100); color: var(--green-900); }
.btn-outline { background: var(--white); border: 1px solid var(--line); color: var(--ink); }
.btn-amber { background: var(--amber); color: var(--white); }
.btn-danger { background: var(--danger-100); color: var(--danger); }
.btn-ghost { background: transparent; color: var(--green); }
.btn-block { width: 100%; }
.btn-sm { height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-lg { height: 54px; font-size: 16px; }
.btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Cards and rows */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.card + .card { margin-top: 10px; }
.card-flush { padding: 0; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.row + .row { border-top: 1px solid var(--line); }
.row-link { color: inherit; }
.row-link:active { background: var(--green-50); }
.row .chev { color: var(--faint); flex-shrink: 0; }
.row .chev svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }
.divider { height: 1px; background: var(--line); margin: 12px 0; }

/* Photo tile: background image over an emoji fallback, so a missing photo still looks intentional */
.ph { position: relative; background: var(--green-100) center / cover no-repeat; border-radius: var(--radius-sm); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.ph > svg { width: 36%; height: 36%; stroke: var(--green); opacity: .45; }
.ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ph-sm { width: 56px; height: 56px; flex-shrink: 0; }

.ph-md { width: 84px; height: 84px; flex-shrink: 0; }
.ph-hero { width: 100%; aspect-ratio: 4 / 3; border-radius: var(--radius); }


/* Product grid */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.product-card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; color: inherit; display: block; }
.product-card .ph { width: 100%; aspect-ratio: 1; }
.product-card .name { font-weight: 600; font-size: 14px; margin-top: 8px; line-height: 1.3; }
.product-card .price { margin-top: 4px; font-size: 15px; }
.product-card .unit { font-size: 12px; color: var(--muted); }
.product-card .meta { font-size: 12px; color: var(--faint); margin-top: 4px; display: flex; gap: 6px; align-items: center; }

/* Chips, badges, avatars */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex-shrink: 0; height: 34px; padding: 0 14px; border-radius: 17px; background: var(--white); border: 1px solid var(--line); font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; color: var(--ink); }
.chip.active { background: var(--green-900); border-color: var(--green-900); color: var(--white); }
.badge { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: 12px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge-placed { background: var(--amber-100); color: #8A5A0B; }
.badge-confirmed { background: var(--blue-100); color: var(--blue); }
.badge-dispatched { background: var(--green-100); color: var(--green); }
.badge-delivered { background: #EAECE8; color: var(--muted); }
.badge-verified { background: var(--green-100); color: var(--green); }
.badge-paid { background: var(--green-100); color: var(--green); }
.badge-pending { background: var(--amber-100); color: #8A5A0B; }
.badge-low { background: var(--danger-100); color: var(--danger); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--green-900); color: var(--white); font-family: var(--font-display); font-weight: 800; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 15px; position: relative; overflow: hidden; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 56px; height: 56px; border-radius: 8px; font-size: 18px; }
.avatar-amber { background: var(--amber); color: var(--ink); }
.stars { color: var(--amber); font-size: 13px; letter-spacing: 1px; }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; background: var(--green-50); color: var(--green-900); font-size: 12px; font-weight: 600; }

/* Forms */
.field { margin-top: 14px; }
.field label, .label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.hint { font-size: 12px; color: var(--faint); margin-top: 5px; }
.input, .select, .textarea { width: 100%; height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); font-size: 15px; }
.textarea { height: auto; min-height: 96px; padding: 12px 14px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--green); outline-offset: -1px; }
.select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235C6B62' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 40px; }
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-outer-spin-button, input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.search { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 14px; border-radius: 12px; background: var(--white); border: 1px solid var(--line); }
.search svg { width: 20px; height: 20px; stroke: var(--faint); fill: none; stroke-width: 2; flex-shrink: 0; }
.search input { flex: 1; border: none; background: none; height: 100%; font-size: 15px; min-width: 0; }
.search input:focus { outline: none; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--white); height: 40px; }
.stepper button { width: 40px; height: 100%; font-size: 18px; font-weight: 700; color: var(--green); }
.stepper .val { min-width: 36px; text-align: center; font-weight: 700; }
.radio-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); cursor: pointer; }
.radio-card + .radio-card { margin-top: 8px; }
.radio-card input { accent-color: var(--green); width: 18px; height: 18px; }
.radio-card.checked { border-color: var(--green); background: var(--green-50); }
.switch { position: relative; width: 44px; height: 26px; border-radius: 13px; background: #CDD3CF; flex-shrink: 0; transition: background .15s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--white); transition: transform .15s; }
.switch.on { background: var(--green); }
.switch.on::after { transform: translateX(18px); }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .k-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .k-value { font-family: var(--font-display); font-size: 22px; font-weight: 800; letter-spacing: -0.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: 12px; color: var(--faint); margin-top: 2px; }

/* Order stage tracker */
.stages { display: flex; flex-direction: column; gap: 0; }
.stage { display: flex; gap: 12px; position: relative; padding-bottom: 18px; }
.stage:last-child { padding-bottom: 0; }
.stage::before { content: ''; position: absolute; left: 11px; top: 24px; bottom: 0; width: 2px; background: var(--line); }
.stage:last-child::before { display: none; }
.stage .s-dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); background: var(--white); flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.stage .s-dot svg { width: 14px; height: 14px; stroke: var(--white); fill: none; stroke-width: 3; }
.stage.done .s-dot { background: var(--green); border-color: var(--green); }
.stage.done::before { background: var(--green); }
.stage.current .s-dot { border-color: var(--green); background: var(--white); }
.stage.current .s-dot::after { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--green); }
.stage .s-title { font-weight: 700; font-size: 14px; }
.stage .s-time { font-size: 12px; color: var(--faint); }
.stage.pending .s-title { color: var(--faint); font-weight: 600; }

/* Bars (reports) */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 120px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.bar i { display: block; width: 100%; background: var(--green); border-radius: 6px 6px 3px 3px; min-height: 4px; }
.bar.current i { background: var(--amber); }
.bar b { font-size: 11px; color: var(--faint); font-weight: 600; }

/* Chat bubbles */
.bubble { max-width: 80%; padding: 10px 14px; border-radius: 16px; font-size: 15px; line-height: 1.4; }
.bubble.me { background: var(--green); color: var(--white); margin-left: auto; border-bottom-right-radius: 4px; }
.bubble.them { background: var(--white); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble-time { font-size: 11px; color: var(--faint); margin-top: 3px; }

/* Empty state, banners, toast */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .e-icon { margin-bottom: 8px; }
.empty .e-icon svg { width: 44px; height: 44px; stroke: var(--faint); fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: var(--radius); background: var(--green-900); color: var(--white); }
.banner h3 { color: var(--white); }
.banner p { font-size: 13px; opacity: .85; margin-top: 2px; }
.banner .btn { margin-top: 10px; }
.banner-amber { background: var(--amber-100); color: var(--ink); }
.banner-amber h3 { color: var(--ink); }
.banner-amber p { opacity: 1; color: var(--muted); }
#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px); transform: translateX(-50%); background: var(--ink); color: var(--white); padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 600; z-index: 50; max-width: 90vw; box-shadow: var(--shadow); }
.sticky-cta { position: sticky; bottom: calc(var(--nav-h) + 8px); margin: 16px -16px 0; padding: 10px 16px 0; background: var(--paper); box-shadow: 0 -14px 12px -6px var(--paper); }
.sticky-cta.no-nav { bottom: 12px; }

/* Welcome */
.welcome { min-height: calc(100vh - var(--topbar-h)); min-height: calc(100dvh - var(--topbar-h)); display: flex; flex-direction: column; }
.welcome .w-hero { position: relative; margin: -16px -16px 18px; aspect-ratio: 4 / 4.6; background: var(--green-900) center / cover no-repeat; }
.welcome .w-ov { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; padding: 22px 20px; color: var(--white); background: linear-gradient(to top, rgba(28,22,16,.88) 0%, rgba(28,22,16,.35) 55%, transparent 100%); }
.welcome .w-hero h1 { color: var(--white); font-size: 30px; }
.welcome .w-hero p { margin-top: 10px; opacity: .88; font-size: 14px; }
.role-btn { display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); text-align: left; width: 100%; }
.role-btn + .role-btn { margin-top: 10px; }
.role-btn .r-icon { width: 48px; height: 48px; border-radius: 8px; background: var(--green-100); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.role-btn .r-icon svg { width: 24px; height: 24px; stroke: var(--green); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.role-btn .r-title { font-family: var(--font-display); font-weight: 800; font-size: 16px; }
.role-btn .r-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
