# cane agency (สถาบันอ้อย) — Design System

> A design system for **cane agency**, a sugar-cane management platform for Thai farmers, mills, and cooperatives. It powers three surfaces: a **public website**, an **admin/operations portal**, and a **field mobile app**. Brand language: trustworthy agribusiness co-op meets precision agriculture.

**"cane agency" (สถาบันอ้อย)** is the platform's official name — the registered brand at **cane.agency**. The Thai **อ้อย** (*òi*) — sugarcane — is the crop the whole platform revolves around: direct, descriptive, and instantly understood by Thai farmers, mills, and co-ops alike.

---

## 1. Product context

cane agency helps cane growers, sub-farmers, and mill operators coordinate the harvest-to-delivery cycle:

- **Public website** — marketing + farmer onboarding. Explains the platform, builds trust with co-ops/mills, drives sign-ups. Bilingual (Thai-first, English secondary).
- **Admin / operations portal** — desktop, **data-dense**. Back-office staff manage deliveries, weighbridge tickets, quotas, sub-farmer networks, plots, payments, and quality (CCS / sweetness). Lots of tables, filters, KPIs.
- **Mobile app** — for farmers and field agents outdoors on smartphones. Record deliveries, scan tickets, check quota and payment status, manage plots. Large hit targets, high contrast, glove/sun-friendly.

**Audience:** Thailand 🇹🇭. Primary language **Thai** (good literacy). Smartphone in the field, desktop in the back office. The type system is Thai-first with full Latin coverage.

### Sources
This system was authored **greenfield** — there was no attached codebase, Figma, or prior brand. All tokens, components, and kits originate here. Direction was set with the client:
- Brand color: **deep cane green** (`#1B5E3F`), warm **harvest-gold** accent.
- Personality: trustworthy/institutional + modern/techy (precision ag).
- Type: humanist, Thai-supporting, with a mono for data.
- Icons: thin-line (Lucide).
- Imagery: clean & flat with light illustration/hand-drawn touches.

> ⚠️ **CS PraJad (Thai/UI) is self-hosted** as `.otf` in `assets/fonts/`; **Roboto** (display) and **JetBrains Mono** (data) load from the Google Fonts CDN. For fully offline/production use, self-host the Roboto & JetBrains Mono `.woff2` and swap the CDN `@import` in `tokens/fonts.css` for local `@font-face` rules.

---

## 2. Content fundamentals (voice & copy)

cane agency's voice is **calm, plain-spoken, and respectful** — a knowledgeable co-op officer, not a hype startup.

- **Language:** Thai-first. Every UI string is written in Thai; English is a secondary/parallel label where useful (e.g. units, IDs). Real product copy in this system is in Thai on purpose.
- **Person:** Address the user directly and politely ("คุณ"). The platform speaks *for* the farmer, not down to them.
- **Tone:** Grounded and concrete. Talk about real things — ตัน (tonnes), ไร่ (plots), งวด (delivery rounds), CCS (ค่าความหวาน), โควตา (quota). Avoid abstract marketing fluff.
- **Casing:** Thai has no case. For Latin: **Sentence case** for UI labels and buttons; ALL-CAPS reserved only for tiny eyebrow/overline labels and stat labels (with letter-spacing). Never shout in body copy.
- **Numbers:** Always tabular/lining figures (JetBrains Mono) for weights, IDs, money, dates. Thai Buddhist-era years are acceptable in farmer-facing contexts (e.g. ฤดูกาล 2567/68).
- **Emoji:** **Not used** in product UI. (A flag emoji may appear in docs only.)
- **Length:** Short. Labels 1–3 words. Helper text one line. Empty states: one friendly sentence + one clear action.

**Examples**
- Button: `บันทึกการส่งมอบ` (Save delivery) — verb-first, concrete.
- Empty state: `ยังไม่มีการส่งมอบ` / "เริ่มบันทึกการส่งมอบงวดแรกของฤดูกาลนี้".
- Status: `ส่งมอบแล้ว` · `รอตรวจสอบ` · `ค้างชำระ` — past-tense facts, no exclamation.
- Marketing line: `ปลูกด้วยใจ ติดตามอย่างแม่นยำ` ("Grown with care, tracked with precision").

---

## 3. Visual foundations

### Color
- **Primary — Cane Green.** Anchor `#1B5E3F` (`--cane-600`). A deep, institutional forest-green that reads as "agriculture you can trust." Full 50–950 ramp in `tokens/colors.css`.
- **Accent — Harvest Gold.** `#D9A323` (`--gold-400`) — the sugar/sunlight counterpart. Used **sparingly**: primary CTAs on marketing, quota/harvest progress, premium tags. Never as a large fill in the portal.
- **Neutrals** carry a faint green tint (not pure gray) so the whole system feels of-a-piece.
- **Semantic:** success (green), warning (amber, distinct from accent gold by being deeper), danger (clay red `#D2453B`), info (cool blue-teal). Each has a `solid` and a `-soft` tinted background.
- **Both themes.** Light is the default for marketing & portal; dark is fully specified (`[data-theme="dark"]`) and is the expected default for the field app at night. In dark mode the primary lifts to `--cane-400` for contrast.
- Use **semantic aliases** (`--surface`, `--text`, `--primary`, `--border`) in product code — never raw scale steps — so theming Just Works.

### Typography
- **CS PraJad** — UI/body (Thai + Latin). **Roboto** — Latin display/headings. **JetBrains Mono** — numerals, IDs, metrics, tables.
- Chosen for: CS PraJad is a clean, highly legible Thai typeface with full Latin coverage and matching italics; paired with Roboto for Latin display and a matching monospace for dense data — which a cane-logistics platform lives on. CS PraJad ships Regular + Bold (+ italics), self-hosted as .otf (weight ranges 300–500 map to Regular, 600–700 to Bold).
- Scale is a major-third-ish ramp tuned **down** for density (`--fs-sm` 13px is a first-class table size). Headings use display family, tight tracking, semibold.
- Tabular lining figures everywhere numbers matter.

### Spacing, radius, elevation
- **4px base grid.** Dense portal UIs lean on `space-1…4`; marketing breathes with `space-12…24`.
- **Radius:** crisp and restrained — controls, badges & avatars `--radius-md` (2px); cards `--radius-lg` (3px). No half-circle edges on badges or avatars; fully rounded only switches, progress bars & presence dots.
- **Shadows** are soft, low-spread, and tinted with the dark green (`rgba(15,32,24,…)`) rather than pure black — keeps elevation feeling warm. Cards are **border-first** (1px `--border`) with shadow as a secondary cue; the portal uses mostly flat/hairline cards, marketing uses raised.

### Backgrounds & texture
- Mostly **clean flat surfaces**. App canvas is `--bg` (faint green-gray), panels are white.
- A single **cane-blade line motif** (`assets/cane-motif.svg`, `currentColor`) is the one recurring decorative texture — used at low opacity on hero/empty/marketing panels and dark feature blocks. No photographic textures, no noise, no heavy gradients.
- Gradients: only the deep cane→darker-cane diagonal on marketing/feature hero blocks. Never rainbow or blue-purple.

### Data display
- **Metrics are first-class.** `Stat` is the workhorse KPI block: a big tabular (JetBrains Mono) value with an uppercase label, optional unit, and a colored delta + trend arrow (up=success, down=danger, flat=muted). It scales `sm/md/lg` and has a bordered **card** variant (hover-lift, clickable) for dashboard grids.
- **Accent + icon chips.** Each `Stat` takes an `accent` (`primary/gold/success/danger/info/warning/neutral`) that tints a Lucide icon chip — one explicit chip rule per accent in `components.css`, built from the `-soft` semantic backgrounds so it themes in dark mode.
- **Sparklines.** `Sparkline` is a standalone SVG micro-chart (line + soft gradient area, marker dot, optional draw-in). It auto-colors by `trend`, or takes an explicit `color`. `Stat` embeds one via its `spark` array and resolves the line color from the stat's trend/accent.
- **Animation & real-time.** `Stat animate` count-ups the value with an ease-out tween (driven by `setInterval`, **not** `requestAnimationFrame`, so it still settles in backgrounded/thumbnail iframes), re-running on every value change so it doubles as a live ticker. A `live` flag adds a pulsing dot. Together these support real-time feeds (e.g. the crushing-control console) — streaming sparklines + count-up KPIs on a `setInterval`.
- **Tables.** The portal runs on the `Table` system (`components/tables.css` + the `Table` / `Pager` / `TableEmpty` React components): a `.sc-table-wrap` surface with default / striped / lined variants and comfortable→compact density, rich cell types (mono IDs, entity tiles, status badges, tabular `.sc-num`, inline quota meters, trend deltas), sortable headers (accent-gold arrow), checkbox selection with a dark bulk bar, hover row-actions, a search/select/tag toolbar, `.sc-table-foot` pagination, skeleton shimmer and an in-table empty state. The full reference is the **Tables chapter** in `guidelines/`.

### Motion
- **Calm and decisive.** Short ease-out (`--ease-standard` `cubic-bezier(.2,0,0,1)`), durations `--dur-fast`/`--dur-base`. Surfaces fade + rise a few px (Toast, Dialog).
- **Spring is reserved** for binary toggles only (Switch thumb, radio dot) — a small overshoot. No bouncing buttons, no infinite decorative loops in product UI.
- Hover = subtle background/border shift (and a 1px lift on interactive cards). Press = `scale(.99)` + slight translate. All respect `prefers-reduced-motion`.

### Hover / press / focus states
- **Hover:** primary → darker (`--primary-hover`); secondary/ghost → `--surface-2/3`; cards → +shadow, +1px lift.
- **Press/active:** darker still + `scale(0.99)`.
- **Focus (keyboard):** 2px ring offset on the surface + a soft cane-tinted glow (`--shadow-focus`). Always visible, never removed.
- **Disabled:** 50% opacity, no pointer events.

### Layout rules
- Portal: fixed 264px sidebar (collapsible to 64px), 60px top bar, dense content grid.
- Mobile: fixed bottom tab bar, large 44px+ targets.
- Marketing: centered max-width containers (`--container-lg/xl`).

---

## 4. Iconography

- **In-house set** (`components/core/icons.js`) — one centralized, hand-drawn library (~120 glyphs). Stroke-only, monochrome via `currentColor`, drawn on a **24px grid** with an optically-tuned ~1px feel (base stroke **1.5**). No external library, no CDN.
- Access via the **`<Icon name="…" />`** component (kebab-case names). Vanilla pages use `<i data-sc-icon="…"></i>` + `ScIcons.paint(root)`. Both render inline SVG so glyphs inherit `currentColor` and theme correctly. Load `icons.js` before the DS bundle.
- **Compatibility:** legacy `<i data-lucide="…">` markup + `lucide.createIcons()` calls keep working through a built-in shim — they now render cane agency glyphs. Names mirror the common kebab-case vocabulary, so migration was a one-line `<script>` swap per page.
- **Stroke:** 1.5 default; corner style (round / mixed / square terminals) is tuned globally on `.sc-icon`, never per-glyph.
- **Sizing:** 16px in dense UI, 18px default, 20px+ for primary nav / mobile.
- **No emoji** as icons. No PNG/raster icons. Bespoke SVGs are limited to the **logo mark** and the **cane-blade motif** (`assets/`) — everything else comes from the icon set.
- Domain glyphs include: `truck`, `cane`, `leaf`, `sprout`, `wheat`, `map`, `map-pin`, `weight`, `scale`, `banknote`, `droplet`, `flask-conical`, `factory`, `warehouse`, `clipboard-list`, `qr-code`.

> See the full gallery (with corner & weight toggles) in **Components → Icon**. Add a glyph by appending one `name: '<inner svg>'` line to `icons.js`.

---

## 5. Brand assets (`assets/`)
Finalized mark: a folded, individually-shaded cane plume on a slim gold-jointed stalk (locked config — 5 leaves, 3 joints). Don't redraw by hand; use the SVGs.
- `logo-mark.svg` — full-colour cane-plant mark (for `<img>`).
- `logo-mark-reversed.svg` — light mark for dark / cane-green backgrounds and photography.
- `logo-mark-mono.svg` — single-colour (`#1B201C`) mark for one-colour print / stamping.
- `logo-tile.svg` — app icon: reversed mark on a rounded cane-green tile (favicon → app).
- `logo-lockup.svg` — horizontal lockup: mark + "cane agency / สถาบันอ้อย" wordmark.
- `cane-motif.svg` — decorative cane-blade line texture (`currentColor`).

Wordmark: two-tone &amp; joined — "cane" in cane green (`--cane-500`) and "agency" in gold (`--gold-500`), no space — with the Thai "สถาบันอ้อย" in `--text-muted`. Clearspace = one node-ring height on all sides. Minimum mark 20px, app tile 16px; below 16px use a single-cane simplification. On photography or dark green, use the reversed mark.

---

## 6. Index / manifest

**Foundations & entry**
- `styles.css` — global entry (consumers link this one file; `@import` manifest only).
- `tokens/` — `fonts.css`, `colors.css`, `typography.css`, `spacing.css`, `base.css`.
- `components/components.css` — class-based component styles (imported by `styles.css`).
- `components/forms-ext.css` — extended form-control classes: input groups & add-ons (`.sc-ig`), in-border affixes (`.sc-affix`), number stepper (`.sc-stepper`), segmented control (`.sc-seg`), choice cards (`.sc-choice`), tags input (`.sc-tags`), strength meter (`.sc-strength`), validation messages (`.sc-msg`), counters, and the `.sc-hfield` / `.sc-fieldset` / `.sc-formactions` layout helpers (imported by `styles.css`).
- `components/tables.css` — the data-table system: `.sc-table-wrap` surface + `.sc-table` (variants `--striped` / `--lined`, density `--compact` / `--relaxed`, `--hover` / `--clickable`), rich cell helpers (`.sc-cell__id`, `.sc-cell-entity` + `.sc-celltile`, `.sc-num`, `.sc-cell-meter`, `.sc-delta`), sortable headers (`.sc-th--sortable` + `.sc-sort`), selection + `.sc-bulkbar`, hover `.sc-cell-actions`, the `.sc-table-toolbar` / `.sc-filterbar` / `.sc-filtertag` filtering chrome, `.sc-table-foot` + `.sc-pager` pagination, `.sc-skel` shimmer and the in-table `.sc-table-empty` (imported by `styles.css`).

**Foundation cards** (`guidelines/`) — render in the Design System tab:
`color-primary`, `color-accent`, `color-neutral`, `color-semantic`, `color-surfaces`, `type-scale`, `type-families`, `type-weights`, `spacing-scale`, `spacing-radii`, `spacing-shadows`, `motion`, `brand-logo`, `brand-motif`.

**Spec documentation** — every specimen card opens with a **brand header** (`.sc-cardhead` in `guidelines/spec-notes.css` — finalized cane mark + two-tone joined "caneagency" wordmark + the card's group/name, theme-aware) and ends in a compact **Usage / Design / Interaction spec footer** (shell: `guidelines/spec-notes.css`; per-card copy sourced from `guidelines/_spec-notes-content.json`) stating exact tokens, dimensions and state behavior. Each section additionally has a dedicated **“Usage & specs” card** (`guidelines/specs-{brand,colors,type,spacing,components,forms,tables}.*.card.html`) with design specs, do/don't rules and interaction contracts; the **Specifications** group at the bottom of the tab holds the master reference card (`guidelines/specifications.*.card.html`) — tokens at a glance, the global interaction contract, the mandate registry condensed, layout constants and language rules. If a surface disagrees with these cards, the surface is wrong.

**Forms chapter** (`guidelines/`, group `Forms`) — the comprehensive form-controls reference:
`form-input-groups` (add-ons & affixes), `form-selection-states` (checkbox / radio / switch / segmented / choice cards × all states), `form-input-states` (default → loading), `form-input-types` (13 field types), `form-validation-patterns` (live validation, strength meter, counters, error summary, sections, horizontal fields, actions row). Shared specimen shell: `guidelines/forms-card.css`.

**Tables chapter** (`guidelines/`, group `Tables`) — the comprehensive data-table reference:
`table-variants` (rich cell types · default / striped / lined · comfortable → compact density), `table-filters` (toolbar search + selects, removable filter tags, live result count, filtered empty state), `table-interactive` (clickable rows, checkbox selection + bulk-action bar, hover-revealed row actions), `table-pagination` (page-sliced rows, “Showing x–y of z” footer, Pager + rows-per-page switch), `table-sorting` (sortable headers cycle asc → desc → off, accent arrow on the sorted column), `table-loading-empty` (skeleton shimmer rows + TableEmpty with icon, copy & CTA). Shared specimen shell: `guidelines/tables-card.css`.

**Components** (`components/`) — React primitives (`window.SugarcaneDesignSystem_c153e7`):
- `core/` — Icon, Button, IconButton, Badge, Avatar, Card, Stat, Sparkline
- `data/` — Table (+ `Table.Head/Body/Row/HeaderCell/Cell`), Pager, TableEmpty
- `forms/` — Input, Select, Checkbox, Radio, Switch
- `feedback/` — Alert, Toast, Tooltip, EmptyState, ProgressBar
- `navigation/` — Tabs, Breadcrumb, Sidebar, TopBar, AppShell (mandated portal chrome — sidebar + top bar + content shell), MobileAppBar, MobileTabBar, MobileShell (mandated mobile chrome — app bar + content + bottom tabs), SiteHeader, SiteFooter, SiteShell (mandated public-web chrome — sticky header + content + footer)
- `overlay/` — Dialog, Offcanvas (edge panel from any side; blocking scrim or non-blocking)

**Templates** (`templates/`) — full-screen starting points consuming projects can copy:
- `website/` — public marketing site
- `portal/` — admin/operations portal (dense desktop)
- `mobile/` — field app (smartphone)

**Other**
- `SKILL.md` — Agent-Skill manifest for use in Claude Code.
- `readme.md` — this file.
- `guidelines/_measure.html` — card-viewport measurement harness (see CLAUDE.md card viewport policy).

---

## 7. Using the system
- **Prototypes / mocks / slides:** copy assets out, link `styles.css`, build static HTML. Use the `<Icon>` set and the component classes.
- **Production:** link `styles.css`, load `_ds_bundle.js`, read components from `window.SugarcaneDesignSystem_c153e7`, and build from the semantic tokens. Always go through aliases (`--surface`, `--text`, `--primary`) so light/dark themes work.
