/* SEA Shop POS — Direction 2 (Square-like) tokens */
:root {
  /* === COLOR === */
  /* Primary (Account Green) */
  --c-primary:         #1A6E3F;
  --c-primary-hover:   #155932;
  --c-primary-pressed: #103F24;
  --c-primary-bg:      #E8F2EC;
  --c-primary-bg-2:    #C6DDCD;
  --c-primary-deep:    #00382A;

  /* Status */
  --c-danger:          #C42B22;
  --c-danger-hover:    #A22019;
  --c-danger-pressed:  #7A1812;
  --c-danger-bg:       #FCEEEC;

  --c-warning:         #A56B12;
  --c-warning-bg:      #FCF1DF;

  --c-info:            #1A5BA8;
  --c-info-bg:         #E8F0F9;

  --c-success:         var(--c-primary);
  --c-success-bg:      var(--c-primary-bg);

  /* Text */
  --c-text-primary:   #1B201D;
  --c-text-secondary: #4A524D;
  --c-text-tertiary:  #6A736E;
  --c-text-disabled:  #9AA39E;
  --c-text-inverse:   #FFFFFF;

  /* Surface */
  --c-bg:              #F1F3F2;
  --c-surface:         #FFFFFF;
  --c-surface-elev:    #FFFFFF;
  --c-surface-sunken:  #F8F9F8;
  --c-overlay:         rgba(10,14,11,0.45);

  /* Border */
  --c-border:        #E2E6E3;
  --c-divider:       #ECEEED;
  --c-border-strong: #C8CFCB;
  --c-border-focus:  var(--c-primary);

  /* Neutral ramp (raw, for swatches) */
  --n-0: #FFFFFF; --n-25:#F8F9F8; --n-50:#F1F3F2; --n-100:#E2E6E3;
  --n-200:#C8CFCB; --n-300:#9AA39E; --n-400:#6A736E; --n-500:#4A524D;
  --n-600:#2D332F; --n-700:#1B201D; --n-900:#0A0E0B;

  /* === TYPE === */
  --ff-sans: 'Inter', 'Noto Sans Khmer', 'Noto Sans Lao', 'Noto Sans Thai', 'Noto Sans Myanmar', 'Noto Sans SC', system-ui, -apple-system, sans-serif;
  --ff-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* font-size / line-height / weight */
  --t-amount-xxl: 64px / 1.0  / 700;
  --t-amount-xl:  40px / 1.05 / 700;
  --t-display-l:  28px / 1.15 / 700;
  --t-title-l:    22px / 1.3  / 600;
  --t-title-m:    18px / 1.4  / 600;
  --t-body-l:     16px / 1.5  / 500;
  --t-body-m:     14px / 1.5  / 500;
  --t-body-s:     13px / 1.55 / 400;
  --t-caption:    11px / 1.5  / 500;
  --t-label-mono: 11px / 1.5  / 500;

  /* === SPACING === */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;

  /* === RADIUS === */
  --r-xs: 4px;
  --r-s:  6px;
  --r-m:  8px;   /* default */
  --r-l:  12px;  /* max */
  --r-pill: 999px;

  /* === SHADOW === */
  --sh-card:    0 0 0 1px var(--c-border);
  --sh-pop:     0 1px 2px rgba(10,14,11,0.04), 0 2px 6px -2px rgba(10,14,11,0.08), 0 0 0 1px var(--c-border);
  --sh-overlay: 0 12px 32px -8px rgba(10,14,11,0.18), 0 4px 12px -4px rgba(10,14,11,0.10), 0 0 0 1px var(--c-border);

  /* Misc */
  --hit: 44px;
  --focus-ring: 0 0 0 3px rgba(26,110,63,0.25);
}

/* ===== Reset & base ===== */
* { box-sizing: border-box; }
html, body { margin:0; padding:0; }
body {
  font-family: var(--ff-sans);
  background: var(--c-bg);
  color: var(--c-text-primary);
  -webkit-font-smoothing: antialiased;
  font-size: 14px; line-height: 1.5;
}
.num, .tnum {
  font-feature-settings: "tnum", "zero";
  font-variant-numeric: tabular-nums slashed-zero;
}

/* ============================================================
   COMPONENTS
   ============================================================ */

/* ---------- Button ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px;
  border-radius: var(--r-m);
  font-family: var(--ff-sans); font-size: 14px; font-weight: 600;
  letter-spacing: -0.005em; line-height: 1;
  border: none; cursor: pointer;
  transition: background .12s, box-shadow .12s, transform .06s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn[disabled], .btn.is-disabled {
  cursor: not-allowed; opacity: 1; pointer-events: none;
}

/* sizes */
.btn-xs { height: 28px; padding: 0 10px; font-size: 12px; border-radius: var(--r-xs); }
.btn-sm { height: 36px; padding: 0 14px; font-size: 13px; }
.btn-md { height: 44px; padding: 0 18px; font-size: 14px; }
.btn-lg { height: 56px; padding: 0 24px; font-size: 16px; border-radius: var(--r-m); }

/* hierarchy */
.btn-primary { background: var(--c-primary); color: var(--c-text-inverse); box-shadow: 0 1px 0 var(--c-primary-pressed); }
.btn-primary:hover { background: var(--c-primary-hover); }
.btn-primary.is-pressed, .btn-primary:active { background: var(--c-primary-pressed); }
.btn-primary[disabled], .btn-primary.is-disabled { background: var(--c-primary-bg-2); color: rgba(255,255,255,0.85); box-shadow: none; }

.btn-secondary { background: var(--c-surface); color: var(--c-text-primary); box-shadow: 0 0 0 1px var(--c-border-strong); }
.btn-secondary:hover { background: var(--c-surface-sunken); }
.btn-secondary.is-pressed, .btn-secondary:active { background: var(--c-border); }
.btn-secondary[disabled], .btn-secondary.is-disabled { background: var(--c-surface-sunken); color: var(--c-text-disabled); box-shadow: 0 0 0 1px var(--c-border); }

.btn-danger { background: var(--c-danger); color: var(--c-text-inverse); box-shadow: 0 1px 0 var(--c-danger-pressed); }
.btn-danger:hover { background: var(--c-danger-hover); }
.btn-danger.is-pressed, .btn-danger:active { background: var(--c-danger-pressed); }
.btn-danger[disabled], .btn-danger.is-disabled { background: #E9B5B1; color: #fff; box-shadow: none; }

.btn-text { background: transparent; color: var(--c-primary); }
.btn-text:hover { background: var(--c-primary-bg); }
.btn-text.is-pressed, .btn-text:active { background: var(--c-primary-bg-2); }
.btn-text[disabled], .btn-text.is-disabled { color: var(--c-text-disabled); }

.btn-icon { width: 44px; padding: 0; }
.btn-icon.btn-sm { width: 36px; }
.btn-icon.btn-xs { width: 28px; }

/* ---------- Input ---------- */
.field { display: block; }
.field-label { display:block; font-size: 13px; font-weight: 600; color: var(--c-text-primary); margin-bottom: 6px; }
.field-help { display:block; font-size: 12px; color: var(--c-text-tertiary); margin-top: 6px; }
.field-error { display:block; font-size: 12px; color: var(--c-danger); margin-top: 6px; }

.input {
  display: block; width: 100%;
  height: 44px; padding: 0 14px;
  background: var(--c-surface);
  border: none; border-radius: var(--r-m);
  box-shadow: 0 0 0 1px var(--c-border-strong);
  font-family: var(--ff-sans); font-size: 14px; color: var(--c-text-primary);
  outline: none; transition: box-shadow .12s;
}
.input::placeholder { color: var(--c-text-disabled); }
.input:hover { box-shadow: 0 0 0 1px var(--c-text-tertiary); }
.input:focus, .input.is-focused { box-shadow: 0 0 0 2px var(--c-primary); }
.input.is-error { box-shadow: 0 0 0 2px var(--c-danger); }
.input[disabled], .input.is-disabled { background: var(--c-surface-sunken); color: var(--c-text-disabled); box-shadow: 0 0 0 1px var(--c-border); }

textarea.input { height: auto; min-height: 88px; padding: 12px 14px; resize: vertical; line-height: 1.5; }

.input-group { position: relative; }
.input-group .input { padding-left: 40px; }
.input-group-prefix {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-family: var(--ff-mono); font-size: 14px; color: var(--c-text-tertiary); pointer-events: none;
}
.input-group.input-search .input { padding-left: 38px; }
.input-group-search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--c-text-tertiary); pointer-events: none; line-height: 0;
}

/* numeric input — tabular */
.input.tnum { font-feature-settings: "tnum", "zero"; font-variant-numeric: tabular-nums slashed-zero; }

/* ---------- Card ---------- */
.card {
  background: var(--c-surface); border-radius: var(--r-m);
  padding: 20px; box-shadow: var(--sh-card);
}
.card-title { font-size: 13px; font-weight: 600; color: var(--c-text-secondary); margin: 0 0 6px; }
.card-pop  { box-shadow: var(--sh-pop); }
.card-hero    { background: var(--c-primary);   color: var(--c-text-inverse); box-shadow: none; }
.card-hero    .card-title { color: rgba(255,255,255,0.78); }
.card-warning { background: var(--c-warning-bg); box-shadow: inset 0 0 0 1px #E5C99A; }
.card-warning .card-title { color: var(--c-warning); }
.card-danger  { background: var(--c-danger-bg); box-shadow: inset 0 0 0 1px #E9C7C2; }
.card-danger  .card-title { color: var(--c-danger); }
.card-info    { background: var(--c-info-bg); box-shadow: inset 0 0 0 1px #C9D8EC; }
.card-info    .card-title { color: var(--c-info); }

/* ---------- Avatar ---------- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-m);
  font-weight: 600; flex: 0 0 auto;
  background: var(--c-primary-bg); color: var(--c-primary-deep);
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-32 { width: 32px; height: 32px; font-size: 12px; border-radius: var(--r-s); }
.avatar-40 { width: 40px; height: 40px; font-size: 14px; }
.avatar-48 { width: 48px; height: 48px; font-size: 16px; }
.avatar-tone-2 { background: #FCEEEC; color: #7A1812; }
.avatar-tone-3 { background: #FCF1DF; color: #6E4A0D; }
.avatar-tone-4 { background: #E8F0F9; color: #143F73; }
.avatar-tone-5 { background: #ECEEED; color: #2D332F; }

/* ---------- Badge ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: var(--r-xs);
  font-family: var(--ff-sans); font-size: 11px; font-weight: 600; line-height: 1.5;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; }
.badge-red    { background: var(--c-danger-bg); color: var(--c-danger); }
.badge-red    .dot { background: var(--c-danger); }
.badge-amber  { background: var(--c-warning-bg); color: var(--c-warning); }
.badge-amber  .dot { background: var(--c-warning); }
.badge-blue   { background: var(--c-info-bg); color: var(--c-info); }
.badge-blue   .dot { background: var(--c-info); }
.badge-green  { background: var(--c-primary-bg); color: var(--c-primary-deep); }
.badge-green  .dot { background: var(--c-primary); }
.badge-neutral{ background: var(--c-surface-sunken); color: var(--c-text-secondary); box-shadow: inset 0 0 0 1px var(--c-border); }
.badge-neutral .dot { background: var(--c-text-tertiary); }

/* count chip */
.count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 6px; border-radius: var(--r-pill);
  background: var(--c-danger); color: #fff; font-family: var(--ff-mono);
  font-size: 10px; font-weight: 700; letter-spacing: 0;
}

/* ---------- List ---------- */
.list { background: var(--c-surface); border-radius: var(--r-m); box-shadow: var(--sh-card); overflow: hidden; }
.li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; min-height: 56px;
  border-bottom: 1px solid var(--c-divider);
  background: var(--c-surface);
}
.li:last-child { border-bottom: none; }
.li:hover { background: var(--c-surface-sunken); }
.li-main { flex: 1; min-width: 0; }
.li-title { font-size: 14px; font-weight: 600; color: var(--c-text-primary); letter-spacing: -0.005em; }
.li-sub { font-family: var(--ff-mono); font-size: 11px; color: var(--c-text-tertiary); margin-top: 2px; }
.li-trail { text-align: right; flex: 0 0 auto; }
.li-amount { font-size: 16px; font-weight: 700; color: var(--c-text-primary); letter-spacing: -0.01em; font-feature-settings: "tnum", "zero"; font-variant-numeric: tabular-nums slashed-zero; }
.li-amount.is-danger { color: var(--c-danger); }
.li-date { font-family: var(--ff-mono); font-size: 11px; color: var(--c-text-tertiary); margin-top: 2px; }

/* alert row with left rule */
.li-alert { position: relative; padding-left: 16px; }
.li-alert::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 2px; background: var(--c-warning); }
.li-alert.is-danger::before { background: var(--c-danger); }
.li-alert.is-info::before   { background: var(--c-info); }
.li-alert.is-success::before{ background: var(--c-primary); }

/* ---------- Product grid item ---------- */
.ptile {
  background: var(--c-surface); border-radius: var(--r-m); overflow: hidden;
  box-shadow: var(--sh-card); position: relative; cursor: pointer;
  transition: box-shadow .15s, transform .08s;
}
.ptile:hover { box-shadow: var(--sh-pop); transform: translateY(-1px); }
.ptile:active { transform: translateY(0); }
.ptile-img {
  aspect-ratio: 1; position: relative;
  background: var(--c-surface-sunken);
}
.ptile-img-inner {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--ff-mono); font-size: 11px; font-weight: 500; color: var(--c-text-tertiary);
  background-image:
    linear-gradient(135deg, var(--c-surface-sunken) 0%, var(--c-border) 100%);
}
.ptile-meta { padding: 8px 10px 10px; }
.ptile-name { font-size: 12px; font-weight: 600; color: var(--c-text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.005em; }
.ptile-price { font-size: 13px; font-weight: 700; color: var(--c-text-primary); margin-top: 2px; font-feature-settings: "tnum", "zero"; font-variant-numeric: tabular-nums slashed-zero; }
.ptile-stock {
  position: absolute; top: 6px; right: 6px;
  background: rgba(255,255,255,0.95); color: var(--c-text-secondary);
  padding: 2px 7px; border-radius: var(--r-xs);
  font-family: var(--ff-mono); font-size: 10px; font-weight: 700;
  backdrop-filter: blur(4px);
}
.ptile-stock.is-low { color: var(--c-warning); background: var(--c-warning-bg); }
.ptile-stock.is-out { color: #fff; background: var(--c-danger); }
.ptile.is-soldout .ptile-img { opacity: 0.45; }
.ptile.is-soldout .ptile-name { color: var(--c-text-disabled); }
.ptile-flag {
  position: absolute; top: 6px; left: 6px;
  padding: 2px 7px; border-radius: var(--r-xs);
  font-family: var(--ff-sans); font-size: 10px; font-weight: 700;
  background: var(--c-warning); color: #fff;
}

/* ---------- Bottom nav ---------- */
.tabbar {
  display: flex; height: 64px; background: var(--c-surface);
  box-shadow: 0 -1px 0 var(--c-border);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; font-weight: 500; color: var(--c-text-tertiary);
  cursor: pointer;
}
.tab .ico { width: 22px; height: 22px; display: inline-block; }
.tab.is-active { color: var(--c-primary); font-weight: 700; }

/* ---------- Top sub-tab (underline) ---------- */
.subtabs { display: flex; gap: 0; padding: 0 8px; background: var(--c-surface); box-shadow: 0 1px 0 var(--c-border); overflow-x: auto; }
.subtab { padding: 12px 14px; font-size: 13px; font-weight: 600; color: var(--c-text-tertiary); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.subtab.is-active { color: var(--c-text-primary); border-bottom-color: var(--c-primary); }

/* segmented (alt) */
.seg { display: inline-flex; padding: 3px; background: var(--c-surface-sunken); border-radius: var(--r-m); box-shadow: 0 0 0 1px var(--c-border); }
.seg-item { padding: 6px 12px; border-radius: var(--r-xs); font-size: 12px; font-weight: 600; color: var(--c-text-tertiary); cursor: pointer; }
.seg-item.is-active { background: var(--c-surface); color: var(--c-text-primary); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }

/* ---------- Dialog ---------- */
.dialog-scrim { position: relative; padding: 24px; background: var(--c-overlay); border-radius: var(--r-l); display: flex; align-items: center; justify-content: center; min-height: 220px; }
.dialog {
  background: var(--c-surface); border-radius: var(--r-l); padding: 24px;
  width: 100%; max-width: 320px; box-shadow: var(--sh-overlay);
}
.dialog h4 { margin: 0 0 8px; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.dialog p  { margin: 0 0 20px; font-size: 14px; color: var(--c-text-secondary); line-height: 1.55; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- Bottom sheet ---------- */
.sheet-wrap { background: var(--c-overlay); border-radius: var(--r-l); padding-top: 80px; height: 360px; overflow: hidden; display:flex; flex-direction: column; justify-content:flex-end; }
.sheet {
  background: var(--c-surface);
  border-radius: var(--r-l) var(--r-l) 0 0;
  padding: 16px 20px 20px;
  box-shadow: 0 -4px 16px -4px rgba(0,0,0,0.12);
}
.sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--c-border-strong); margin: 0 auto 12px; }
.sheet h4 { margin: 0 0 4px; font-size: 16px; font-weight: 700; }
.sheet .sheet-sub { font-family: var(--ff-mono); font-size: 11px; color: var(--c-text-tertiary); margin-bottom: 16px; }

/* ---------- Toast ---------- */
.toast {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--r-m);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--sh-pop);
  background: var(--c-surface);
}
.toast .toast-ico { width: 18px; height: 18px; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; }
.toast-success { background: #133E25; color: #fff; box-shadow: 0 4px 12px -4px rgba(10,14,11,0.20); }
.toast-success .toast-ico { color: #67D58E; }
.toast-error   { background: #5E1410; color: #fff; }
.toast-error   .toast-ico { color: #F0A6A0; }
.toast-info    { background: #1B201D; color: #fff; }
.toast-info    .toast-ico { color: #C8CFCB; }
.toast-offline { background: var(--c-info-bg); color: var(--c-info); box-shadow: var(--sh-card); }

/* ---------- Empty state ---------- */
.empty { padding: 32px 20px; text-align: center; }
.empty-ico {
  width: 56px; height: 56px; margin: 0 auto 14px;
  border-radius: var(--r-m); background: var(--c-surface-sunken);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--c-text-tertiary);
}
.empty h4 { font-size: 15px; font-weight: 600; margin: 0 0 4px; color: var(--c-text-primary); }
.empty p  { font-size: 13px; color: var(--c-text-tertiary); margin: 0; line-height: 1.5; }

/* ---------- Skeleton ---------- */
@keyframes skeleton-pulse { 0%,100% { opacity: 1 } 50% { opacity: 0.55 } }
.skel { background: var(--c-border); border-radius: var(--r-xs); animation: skeleton-pulse 1.4s ease-in-out infinite; }
.skel-text { height: 12px; }
.skel-line { height: 1px; background: var(--c-divider); animation: none; }

/* ---------- App bars ---------- */
.statusbar {
  height: 24px; padding: 0 14px;
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--ff-mono); font-size: 11px; font-weight: 600; color: var(--c-text-primary);
  background: var(--c-bg);
}
.appbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; min-height: 56px;
  background: var(--c-surface);
}
.appbar-back {
  width: 36px; height: 36px; border-radius: var(--r-s);
  background: var(--c-surface-sunken); color: var(--c-text-primary);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; flex: 0 0 auto;
}
.appbar-title { flex: 1; font-size: 16px; font-weight: 700; color: var(--c-text-primary); letter-spacing: -0.005em; }
.appbar-banner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 16px; font-size: 12px; font-weight: 600;
}
.appbar-banner.is-offline { background: var(--c-info-bg); color: var(--c-info); }
.appbar-banner.is-conflict { background: var(--c-warning-bg); color: var(--c-warning); }

/* ---------- Amount components ---------- */
.amount {
  font-family: var(--ff-sans);
  font-feature-settings: "tnum", "zero";
  font-variant-numeric: tabular-nums slashed-zero;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--c-text-primary);
}
.amount-xxl { font-size: 64px; line-height: 1.0; }
.amount-xl  { font-size: 40px; line-height: 1.05; }
.amount-l   { font-size: 28px; line-height: 1.15; }
.amount-m   { font-size: 18px; line-height: 1.3; font-weight: 700; }
.amount-sym {
  color: var(--c-text-tertiary); font-weight: 500;
  margin-right: 6px; font-size: 0.5em; vertical-align: 0.32em;
}
.amount-on-dark { color: #fff; }
.amount-on-dark .amount-sym { color: rgba(255,255,255,0.55); }

.amount-fx {
  font-family: var(--ff-mono); font-size: 11px;
  color: var(--c-text-tertiary); margin-top: 4px;
  font-feature-settings: "tnum", "zero"; font-variant-numeric: tabular-nums slashed-zero;
}
.amount-on-dark + .amount-fx, .amount-fx.on-dark { color: rgba(255,255,255,0.7); }

/* hero amount card */
.amount-hero {
  background: var(--c-primary); color: #fff; border-radius: var(--r-m);
  padding: 18px 20px;
}
.amount-hero .label {
  font-family: var(--ff-mono); font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  opacity: 0.78;
}
.amount-hero .amount-xxl,
.amount-hero .amount-xl { color: #fff; margin-top: 6px; }
.amount-hero .amount-sym { color: rgba(255,255,255,0.55); }

/* Multilingual: bump line-height a touch on script-bearing text */
.lang-vi, .lang-th, .lang-km, .lang-lo { line-height: 1.6 !important; }
.lang-km, .lang-lo { font-size: 1.08em; } /* visual size compensation */
