/* bertih.my design system — "corn" palette
   Warm cream surfaces, deep husk-green for actions and text, corn yellow for highlights. Tabular numbers. */
:root {
  --bg: #fbf9f2;
  --surface: #ffffff;
  --subtle: #f6f3e8;
  --hover: #f0ecdd;
  --border: #e9e4d3;
  --border-strong: #d9d1b8;
  --text: #14231a;
  --text-2: #33473a;
  --muted: #6b7a6f;
  --faint: #a2ab9f;
  --ink: #14532d;            /* husk green — primary actions */
  --ink-text: #fffdf4;
  --brand: #17793f;          /* leaf green — links, focus, accents */
  --brand-2: #f5b800;
  --brand-soft: #fff4cc;     /* corn cream — highlights, brand badges */
  --corn: #f5b800;
  --corn-deep: #b98100;
  --corn-soft: #fff6d8;
  --leaf: #14532d;
  --leaf-soft: #e8f3eb;
  --ok: #15803d;  --ok-soft: #e9f6ee;
  --warn: #a16207; --warn-soft: #fef8e1;
  --bad: #b91c1c;  --bad-soft: #fef2f2;
  --info: #1d4ed8; --info-soft: #eff6ff;
  --chart: #17793f;
  --chart-2: #e9e4d3;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-xs: 0 1px 2px rgba(20, 35, 26, .05);
  --shadow-sm: 0 1px 2px rgba(20, 35, 26, .04), 0 4px 14px rgba(20, 35, 26, .05);
  --shadow-lg: 0 18px 50px rgba(20, 35, 26, .16), 0 2px 6px rgba(20, 35, 26, .06);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --ring: 0 0 0 3px rgba(245, 184, 0, .38);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b130e; --surface: #111c15; --subtle: #16231b; --hover: #1c2c22; --border: #233629; --border-strong: #2f4737;
    --text: #eef4ef; --text-2: #cddbd1; --muted: #93a597; --faint: #64776a; --ink: #ffc928; --ink-text: #14231a;
    --brand: #5ccf8a; --brand-2: #ffc928; --brand-soft: #2a2a12; --corn: #ffc928; --corn-deep: #ffd75e; --corn-soft: #2a2610; --leaf: #5ccf8a; --leaf-soft: #13281b;
    --ok: #4ade80; --ok-soft: #10261a; --warn: #fbbf24; --warn-soft: #2a2010; --bad: #f87171; --bad-soft: #2a1414; --info: #93c5fd; --info-soft: #121e33;
    --chart: #5ccf8a; --chart-2: #233629;
    --shadow-xs: none; --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 16px 48px rgba(0,0,0,.6);
    --ring: 0 0 0 3px rgba(255, 201, 40, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b130e; --surface: #111c15; --subtle: #16231b; --hover: #1c2c22; --border: #233629; --border-strong: #2f4737;
  --text: #eef4ef; --text-2: #cddbd1; --muted: #93a597; --faint: #64776a; --ink: #ffc928; --ink-text: #14231a;
  --brand: #5ccf8a; --brand-2: #ffc928; --brand-soft: #2a2a12; --corn: #ffc928; --corn-deep: #ffd75e; --corn-soft: #2a2610; --leaf: #5ccf8a; --leaf-soft: #13281b;
  --ok: #4ade80; --ok-soft: #10261a; --warn: #fbbf24; --warn-soft: #2a2010; --bad: #f87171; --bad-soft: #2a1414; --info: #93c5fd; --info-soft: #121e33;
  --chart: #5ccf8a; --chart-2: #233629;
  --shadow-xs: none; --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 16px 48px rgba(0,0,0,.6);
  --ring: 0 0 0 3px rgba(255, 201, 40, .35);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01"; }
a { color: inherit; text-decoration: none; }
p { margin: 0 0 .75em; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; letter-spacing: -.011em; color: var(--text); }
.num, td.num, .kpi-value { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.xs { font-size: 11.5px; }
.strong { font-weight: 600; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.icon.lg { width: 20px; height: 20px; }

/* Buttons */
.btn { --h: 34px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: var(--h); padding: 0 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 500 13.5px/1 var(--font); cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow-xs); transition: background .12s, border-color .12s, color .12s; }
.btn:hover { background: var(--subtle); border-color: var(--border-strong); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .chip:focus-visible { outline: none; box-shadow: var(--ring); border-color: var(--brand); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--ink-text); box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 1px 2px rgba(20,83,45,.25); }
.btn.primary:hover { filter: brightness(1.12); }
.btn.corn { background: var(--corn); border-color: var(--corn); color: #14231a; font-weight: 600; box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 1px 2px rgba(185,129,0,.3); }
.btn.corn:hover { filter: brightness(1.05); }
.btn.brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { color: var(--bad); }
.btn.sm { --h: 28px; padding: 0 10px; font-size: 12.5px; gap: 5px; }
.btn.lg { --h: 42px; padding: 0 18px; font-size: 14.5px; }
.btn.block { width: 100%; }
.btn.icon-only { width: var(--h); padding: 0; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* Form controls */
label, .label { display: block; font-size: 12.5px; font-weight: 500; color: var(--text-2); margin: 0 0 6px; }
input, select, textarea { width: 100%; font: 400 14px/1.4 var(--font); color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 10px; box-shadow: var(--shadow-xs); transition: border-color .12s, box-shadow .12s; }
input, select { height: 36px; }
select { padding-top: 0; padding-bottom: 0; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; padding: 0; margin: 0; box-shadow: none; accent-color: var(--brand); flex: none; }
.field { margin-bottom: 16px; }
.help { font-size: 12px; color: var(--muted); margin-top: 6px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; font-weight: 400; color: var(--text); margin: 0 0 10px; cursor: pointer; }
.check input { margin-top: 2px; }
.check .help { margin-top: 2px; }
.input-group { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-xs); overflow: hidden; }
.input-group:focus-within { border-color: var(--brand); box-shadow: var(--ring); }
.input-group > span { display: flex; align-items: center; padding: 0 10px; background: var(--subtle); color: var(--muted); font-size: 13px; border-right: 1px solid var(--border); white-space: nowrap; }
.input-group > span:last-child { border-right: 0; border-left: 1px solid var(--border); }
.input-group input { border: 0; box-shadow: none; border-radius: 0; }
.input-group input:focus-visible { box-shadow: none; }
.err { color: var(--bad); font-size: 12.5px; margin-top: 6px; min-height: 0; }

/* Surfaces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-xs); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 14px; }
.card-body { padding: 18px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--subtle); border-radius: 0 0 var(--radius) var(--radius); }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 500; background: var(--subtle); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge.brand { background: var(--brand-soft); color: var(--leaf); border-color: color-mix(in srgb, var(--corn) 35%, transparent); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11.5px; font-weight: 500; color: var(--muted); padding: 9px 14px; background: var(--subtle); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--subtle) 60%, transparent); }
td.num, th.num { text-align: right; white-space: nowrap; }
.table-wrap table.wide { min-width: 760px; }
td .sub { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }

/* Chips (selectable) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { height: 34px; padding: 0 13px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: 500 13px var(--font); cursor: pointer; box-shadow: var(--shadow-xs); }
.chip:hover { border-color: var(--border-strong); }
.chip.on { border-color: var(--ink); background: var(--ink); color: var(--ink-text); }
.chip[disabled] { opacity: .4; text-decoration: line-through; cursor: not-allowed; }

/* Segmented tabs */
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--subtle); border: 1px solid var(--border); border-radius: 9px; flex-wrap: wrap; }
.seg button { height: 28px; padding: 0 11px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font: 500 13px var(--font); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }
.seg .count { color: var(--faint); margin-left: 4px; font-variant-numeric: tabular-nums; }

/* Brand mark */
.logo { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; letter-spacing: -.025em; color: var(--leaf); }
.logo .mark { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(150deg, #1d6b3e 0%, #0f3f22 100%); display: grid; place-items: center; box-shadow: inset 0 1px 0 rgba(255,255,255,.14), 0 1px 3px rgba(15,63,34,.35); }
.logo .mark svg { width: 20px; height: 20px; }
.logo .tld { color: var(--corn-deep); font-weight: 600; }
.logo.on-dark { color: #fff; } .logo.on-dark .tld { color: var(--corn); }

/* Language switch */
.langtog { display: inline-flex; padding: 2px; gap: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--subtle); vertical-align: middle; }
.langtog button { height: 24px; min-width: 32px; padding: 0 7px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font: 600 11.5px var(--font); letter-spacing: .02em; cursor: pointer; }
.langtog button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }
.langtog button:focus-visible { outline: none; box-shadow: var(--ring); }
.langtog.float { position: fixed; right: 16px; top: 16px; z-index: 70; box-shadow: var(--shadow-sm); }
@media print { .langtog { display: none !important; } }

/* Modal, toast */
.modal-bg { position: fixed; inset: 0; background: rgba(12, 10, 9, .45); display: grid; place-items: center; z-index: 60; padding: 16px; animation: fade .12s ease-out; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: rise .16s ease-out; }
.modal.wide { width: min(760px, 100%); }
.modal-head { padding: 18px 20px 4px; }
.modal-head h2 { font-size: 16px; }
.modal-head p { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 80; background: var(--ink); color: var(--ink-text); padding: 10px 14px; border-radius: 9px; font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-lg); display: flex; gap: 8px; align-items: center; animation: rise .16s ease-out; max-width: calc(100vw - 40px); }
.toast.bad { background: var(--bad); color: #fff; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* Layout helpers */
.row { display: flex; gap: 12px; align-items: center; }
.row.flexwrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.stack > * + * { margin-top: 16px; }
.empty { text-align: center; padding: 44px 16px; color: var(--muted); }
.empty .icon { width: 28px; height: 28px; color: var(--faint); margin-bottom: 10px; }
.empty h4 { font-size: 14px; color: var(--text); margin-bottom: 4px; }
.demo-banner { background: var(--corn-soft); color: var(--text-2); font-size: 13px; padding: 8px 14px; text-align: center; border-bottom: 1px solid color-mix(in srgb, var(--corn) 40%, transparent); }
.demo-banner a { color: var(--leaf); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.chat-fab { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: inline-flex; align-items: center; gap: 8px; height: 46px; padding: 0 18px 0 16px; border-radius: 999px; background: #14532d; color: #fff; font: 600 14px var(--font); text-decoration: none; box-shadow: var(--shadow-lg); }
.chat-fab:hover { filter: brightness(1.08); } .chat-fab .icon { width: 18px; height: 18px; }
.chat-fab.whatsapp { background: #128c4b; } .chat-fab.messenger { background: #0a66e4; }
@media print { .chat-fab { display: none; } }
.paynote { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--corn-soft); border: 1px solid color-mix(in srgb, var(--corn) 40%, transparent); color: var(--text-2); font-size: 13.5px; }
.paynote .icon { color: var(--corn-deep); margin-top: 2px; }
.imgpick { display: flex; gap: 14px; align-items: flex-start; padding: 12px; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--subtle); }
.imgpick .prev { width: 92px; height: 92px; flex: none; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); display: grid; place-items: center; color: var(--faint); overflow: hidden; }
.imgpick .prev img { width: 100%; height: 100%; object-fit: cover; }
.imgpick .grow { flex: 1; min-width: 0; display: grid; gap: 8px; }
.imgpick .imgurl { height: 32px; font-size: 12.5px; }
.gwlist { display: grid; gap: 12px; }
.gwcard { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.gwcard.on { border-color: color-mix(in srgb, var(--leaf) 45%, var(--border)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--leaf) 25%, transparent); }
.gwcard.soon { background: var(--subtle); border-style: dashed; }
.gwhead { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.gwhead b { display: block; font-size: 14.5px; } .gwhead .small { display: block; }
.gwlogo { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--corn-soft); color: var(--leaf); font-weight: 700; font-size: 16px; border: 1px solid color-mix(in srgb, var(--corn) 40%, transparent); flex: none; }
.gwbody { padding: 0 16px 16px; border-top: 1px solid var(--border); padding-top: 14px; display: none; }
.gwcard.on .gwbody { display: block; }
.switch { position: relative; width: 40px; height: 22px; flex: none; margin: 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong); transition: background .15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-xs); transition: transform .15s; }
.switch input:checked + span { background: var(--leaf); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: var(--ring); }
