/* ============================================================
   DTS CRM — ตราโซ่ทอง Field Sales CRM
   CI: Navy #0A1524 + White (main), Gold #D4A017 (accent)
   Font: Kittithada (PSL, licensed) — served from /public/fonts/
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700;800&display=swap');

/* Kittithada — Brian's licensed PSL font, self-hosted WOFF2 */
@font-face {
  font-family: 'Kittithada';
  src: url('/public/fonts/Kittithada-Light.woff2') format('woff2');
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Kittithada';
  src: url('/public/fonts/Kittithada-Regular.woff2') format('woff2');
  font-weight: 400 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Kittithada';
  src: url('/public/fonts/Kittithada-Bold.woff2') format('woff2');
  font-weight: 600 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --navy:       #0A1524;
  --navy-2:     #12203A;
  --navy-3:     #1A3050;
  --navy-4:     #254060;
  --gold:       #D4A017;
  --gold-light: #E8C47A;
  --gold-pale:  #FDF6E3;
  --white:      #FFFFFF;
  --bg:         #F4F6FB;
  --surface:    #FFFFFF;
  --border:     #E4E9F2;
  --border-2:   #D0D8EC;
  --text:       #0A1524;
  --text-2:     #4A5B7A;
  --text-3:     #8A98B4;
  --text-inv:   #FFFFFF;
  --success:    #059669;
  --warning:    #D97706;
  --error:      #DC2626;
  --info:       #2563EB;
  --success-bg: #D1FAE5;
  --warning-bg: #FEF3C7;
  --error-bg:   #FEE2E2;
  --info-bg:    #DBEAFE;
  --r-xs: 6px; --r-sm: 10px; --r-md: 16px; --r-lg: 22px; --r-pill: 999px;
  --e-1: 0 1px 2px rgba(10,21,36,.04), 0 1px 4px rgba(10,21,36,.06);
  --e-2: 0 2px 8px rgba(10,21,36,.07), 0 4px 12px rgba(10,21,36,.06);
  --e-3: 0 4px 16px rgba(10,21,36,.10), 0 8px 24px rgba(10,21,36,.07);
  --tab-h: 62px;
  --topbar-h: 56px;
  --font: 'Kittithada','SukhumvitSet','Sukhumvit Set','Sarabun','Noto Sans Thai',sans-serif;
  --t-fast: 140ms cubic-bezier(.4,0,.2,1);
  --t-base: 200ms cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: var(--font);
  font-size:18px; line-height: 1.55;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size:18px; color: var(--text); }
a { color: inherit; text-decoration: none; }

/* ── App Shell ─────────────────────────────── */
#app { width: 100%; height: 100%; overflow: hidden; }

/* ── Splash ────────────────────────────────── */
.splash {
  position: fixed; inset: 0;
  background: linear-gradient(150deg, var(--navy) 0%, var(--navy-3) 60%, #1A3A68 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 10000; transition: opacity .4s, visibility .4s;
}
.splash.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.splash__logo { margin-bottom: 20px; filter: drop-shadow(0 6px 16px rgba(0,0,0,.25)); }
.splash__brand { color: var(--gold-light); font-size: 24px; font-weight: 800; letter-spacing: -.3px; }
.splash__sub { color: rgba(255,255,255,.4); font-size:15px; margin-top: 8px; }
.splash__loading { margin-top: 24px; }
.splash__spinner {
  width: 28px; height: 28px; border: 3px solid rgba(212,160,23,.2);
  border-top-color: var(--gold); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Screen ────────────────────────────────── */
.screen { display: flex; flex-direction: column; height: 100%; background: var(--bg); overflow: hidden; }
.screen-body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 16px; padding-bottom: calc(var(--tab-h) + 20px);
}

/* ── Topbar ─────────────────────────────────── */
.topbar {
  height: var(--topbar-h); background: var(--white);
  display: flex; align-items: center; padding: 0 16px; gap: 8px;
  flex-shrink: 0; border-bottom: 1px solid var(--border);
}
.topbar__back {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; color: var(--navy);
  border-radius: var(--r-sm); margin-left: -4px; flex-shrink: 0;
}
.topbar__back:active { background: var(--bg); }
.topbar__back svg { width: 20px; height: 20px; }
.topbar__title {
  flex: 1; font-size:18px; font-weight: 700; letter-spacing: -.2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--navy);
}
.topbar__right { display: flex; align-items: center; gap: 4px; }
.topbar__btn {
  color: var(--navy); font-size:15px; font-weight: 700;
  padding: 6px 14px; border-radius: var(--r-pill); background: var(--bg);
}

/* ── Login ──────────────────────────────────── */
.login-screen {
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-3) 60%, #1A3A68 100%);
  display: flex; flex-direction: column; align-items: center;
  /* flex-start + min-height lets the page SCROLL when the iOS numeric
     keyboard opens (previously "center + height:100% + overflow:hidden"
     locked the layout so PIN dots + submit button got hidden behind the
     keyboard and the user couldn't see what they were typing). */
  justify-content: flex-start;
  padding: 40px 28px 50vh;   /* 50vh bottom padding = always room to scroll PIN row into view */
  min-height: 100%;
  position: relative; overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}
.login-screen::before {
  content: ''; position: absolute; top: -80px; right: -60px;
  width: 280px; height: 280px;
  background: radial-gradient(circle, rgba(212,160,23,.14) 0%, transparent 70%);
  border-radius: 50%; pointer-events: none;
}
.login-logo {
  width: 88px; height: 88px;
  background: linear-gradient(145deg, var(--gold-light), var(--gold));
  border-radius: 28px; display: flex; align-items: center; justify-content: center;
  margin-bottom: 22px;
  box-shadow: 0 8px 32px rgba(212,160,23,.40), 0 2px 8px rgba(0,0,0,.2);
}
.login-title { color: var(--text-inv); font-size:30px; font-weight: 800; text-align: center; }
.login-sub { color: rgba(255,255,255,.5); font-size:17px; margin-bottom: 44px; text-align: center; }
.btn-line-login {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; width: 100%; max-width: 280px; margin: 0 auto;
  padding: .95rem 1.25rem; border-radius: var(--r-sm);
  background: #06C755; color: #fff; font-size: 1rem; font-weight: 700;
  box-shadow: 0 4px 14px rgba(6,199,85,.38);
}
.btn-line-login:active { background: #05B34E; transform: scale(.98); }
.login-dev-section {
  margin-top: 32px; width: 100%; max-width: 340px;
}
.login-dev-label {
  color: rgba(255,255,255,.4); font-size:15px; font-weight: 600;
  letter-spacing: .4px; text-transform: uppercase; margin-bottom: 10px;
}
.login-dev-users { display: flex; flex-direction: column; gap: 8px; }
.login-dev-btn {
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--r-md); padding: 12px 16px;
  display: flex; align-items: center; gap: 12px; color: var(--text-inv); text-align: left;
}
.login-dev-btn:active { background: rgba(255,255,255,.16); transform: scale(.98); }
.login-dev-btn__avatar {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(145deg, var(--gold-light), var(--gold));
  display: flex; align-items: center; justify-content: center;
  font-size:22px; font-weight: 800; flex-shrink: 0;
}
.login-dev-btn__name { font-size:18px; font-weight: 700; }
.login-dev-btn__role { font-size:15px; color: rgba(255,255,255,.5); margin-top: 2px; }

/* ── Login v46 — dropdown + 4-digit PIN ─────── */
.login-or-divider {
  display: flex; align-items: center; gap: 12px;
  width: 100%; max-width: 300px; margin: 20px auto 4px;
  color: rgba(255,255,255,.35); font-size:16px; font-weight: 600;
}
.login-or-divider::before,
.login-or-divider::after {
  content: ''; flex: 1; height: 1px; background: rgba(255,255,255,.15);
}
.login-form {
  width: 100%; max-width: 320px; margin: 12px auto 0;
  display: flex; flex-direction: column; gap: 16px;
}
.login-field { display: flex; flex-direction: column; gap: 7px; }
.login-field__label {
  color: rgba(255,255,255,.6); font-size:16px; font-weight: 600;
  letter-spacing: .3px;
}
.login-select-wrap { position: relative; }
.login-select {
  width: 100%; appearance: none; -webkit-appearance: none;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: var(--r-sm);
  color: var(--text-inv); font-family: inherit;
  font-size: 18px; font-weight: 600;
  padding: 14px 44px 14px 16px;
}
.login-select:focus {
  outline: none; border-color: var(--gold);
  background: rgba(255,255,255,.14);
}
.login-select__chevron {
  position: absolute; right: 16px; top: 50%;
  transform: translateY(-50%); color: var(--gold);
  pointer-events: none; font-size:15px;
}
.login-pin-row {
  display: flex; justify-content: center; padding: 4px 0;
}
.login-pin-row.is-shake {
  animation: pinShake .45s cubic-bezier(.36,.07,.19,.97) both;
}
@keyframes pinShake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}
/* v63: visible password-style input — works on desktop LINE + iOS/Android LIFF.
   -webkit-text-security renders digits as dots; letter-spacing gives dots-apart feel. */
.login-pin-input-visible {
  width: 220px; max-width: 100%;
  font-family: inherit; font-size: 30px; font-weight: 700;
  text-align: center;
  letter-spacing: 16px; padding-left: 16px; /* visual offset because letter-spacing pushes right */
  padding: 14px 16px;
  border-radius: var(--r-sm);
  background: rgba(255,255,255,.10);
  border: 2px solid rgba(255,255,255,.22);
  color: var(--gold);
  caret-color: var(--gold);
  -webkit-text-security: disc;
  text-security: disc;
  cursor: text;
  transition: border-color .15s ease, background .15s ease;
}
.login-pin-input-visible::placeholder {
  color: rgba(255,255,255,.35); letter-spacing: 6px; font-weight: 400;
}
.login-pin-input-visible:focus {
  outline: none; border-color: var(--gold);
  background: rgba(255,255,255,.16);
  box-shadow: 0 0 0 3px rgba(212,160,23,.2);
}
.login-error {
  min-height: 18px; color: #ff9a9a; font-size:16px;
  text-align: center; font-weight: 600;
}
.login-submit { margin-top: 6px; font-size: 18px; }
.login-submit[disabled] { opacity: .45; cursor: not-allowed; }
.login-change-pin-row { text-align: center; margin-top: 4px; }
.login-change-pin-link {
  background: transparent; border: none; color: var(--gold-light);
  font-family: inherit; font-size:16px; font-weight: 600;
  padding: 8px 16px; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}
.login-change-pin-link:active { opacity: .6; }

/* Change-PIN modal (shared with Settings screen) */
.cp-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.70);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 9000; animation: fadeIn .18s ease;
  padding: 0;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.cp-modal__card {
  width: 100%; max-width: 420px; background: #0F1A2E;
  border-radius: 20px 20px 0 0;
  padding: 18px 20px calc(20px + env(safe-area-inset-bottom));
  color: var(--text-inv);
  max-height: 90vh; overflow-y: auto;
}
.cp-modal__head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.cp-modal__title { font-size:20px; font-weight: 800; color: var(--gold-light); }
.cp-modal__close {
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,.08); color: var(--text-inv);
  border: none; font-size: 24px; line-height: 1; cursor: pointer;
}
.cp-modal__body { display: flex; flex-direction: column; gap: 14px; }

/* ── Customer-Add Screen (v50) ───────────────── */
.ca-type-row {
  display: flex; gap: 8px; margin-bottom: 4px;
}
.ca-type-btn {
  flex: 1; padding: 10px 12px;
  background: var(--card-bg, #fff);
  border: 1.5px solid var(--border, #E2E8F0);
  border-radius: 10px;
  font-family: inherit; font-size:17px; font-weight: 600;
  color: var(--text, #1A1A2E); cursor: pointer;
}
.ca-type-btn.is-active {
  background: var(--navy, #122040);
  border-color: var(--navy, #122040);
  color: #fff;
}
.ca-chip-row {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.ca-chip {
  padding: 6px 12px;
  background: rgba(18,32,64,.05);
  border: 1px solid rgba(18,32,64,.12);
  border-radius: 14px;
  font-family: inherit; font-size:16px; font-weight: 500;
  color: var(--text, #1A1A2E); cursor: pointer;
}
.ca-chip.is-active {
  background: var(--gold, #C6AA6E);
  border-color: var(--gold, #C6AA6E);
  color: var(--navy, #122040); font-weight: 700;
}
.ca-loc {
  display: flex; flex-direction: column; gap: 8px;
}
.ca-loc-preview {
  background: rgba(198,170,110,.12);
  border: 1px solid rgba(198,170,110,.3);
  border-radius: 8px; padding: 10px 14px;
  font-size:16px; color: var(--text, #1A1A2E);
}
.ca-loc-preview a {
  color: var(--gold, #C6AA6E); font-weight: 700;
  text-decoration: underline; text-underline-offset: 2px;
  display: inline-block; margin-top: 4px;
}
.ca-error {
  min-height: 20px; color: #EF4444; font-size:16px;
  font-weight: 600; text-align: center; margin-top: 8px;
}

/* ── Trip plan customer typeahead (v57) ────── */
.trip-cust-list {
  position: absolute; left: 0; right: 0; top: 100%;
  margin-top: 4px; z-index: 210;
  background: #fff;
  border: 1px solid var(--border, #E2E8F0);
  border-radius: 10px;
  max-height: 240px; overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,.14);
}
.trip-cust-list__item {
  display: block; width: 100%;
  padding: 10px 14px;
  background: transparent; border: none;
  font-family: inherit; font-size:17px; text-align: left;
  color: var(--text, #1A1A2E); cursor: pointer;
  border-bottom: 1px solid var(--border-light, #F1F5F9);
}
.trip-cust-list__item:last-child { border-bottom: none; }
.trip-cust-list__item:hover,
.trip-cust-list__item:active { background: rgba(18,32,64,.04); }
.trip-cust-list__name { font-weight: 600; }
.trip-cust-list__meta {
  font-size:15px; color: var(--text-3, #94A3B8); margin-top: 2px;
}
.trip-cust-list__empty {
  padding: 14px; text-align: center;
  color: var(--text-3, #94A3B8); font-size:16px;
}

/* ── Customer Detail — info tab (v51) ────────── */
.cd-section { margin: 14px 0; }
.cd-section__title {
  font-size:15px; font-weight: 700; letter-spacing: 1px;
  color: var(--text-3); text-transform: uppercase;
  padding: 0 14px; margin-bottom: 8px;
}
.cd-chip {
  display: inline-block; padding: 5px 12px;
  background: rgba(18,32,64,.06);
  border: 1px solid rgba(18,32,64,.1);
  border-radius: 14px;
  font-size:16px; font-weight: 600; color: var(--navy);
}

/* ── Map Picker modal (Leaflet) ────────────── */
.mp-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.70);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 9500;
}
.mp-modal__card {
  width: 100%; max-width: 540px; background: #0F1A2E;
  border-radius: 20px 20px 0 0;
  padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
  color: var(--text-inv, #fff);
  display: flex; flex-direction: column; gap: 10px;
  max-height: 92vh;
}
.mp-modal__head {
  display: flex; align-items: center; justify-content: space-between;
}
.mp-modal__title { font-size: 18px; font-weight: 800; color: var(--gold-light, #E8D2A0); }
.mp-modal__close {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,.08); color: #fff; border: none;
  font-size: 22px; line-height: 1; cursor: pointer;
}
.mp-search-wrap { position: relative; }
.mp-search-row { display: flex; gap: 6px; }
/* Autocomplete dropdown — anchored under the search input */
.mp-suggest {
  margin-top: 6px;
  background: #1A2540;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px;
  max-height: 220px; overflow-y: auto;
  box-shadow: 0 8px 20px rgba(0,0,0,.35);
}
.mp-suggest__item {
  display: flex; gap: 10px; align-items: flex-start;
  width: 100%; padding: 10px 14px;
  background: transparent; border: none;
  color: var(--text-inv, #fff);
  font-family: inherit; font-size:17px; text-align: left;
  cursor: pointer; border-bottom: 1px solid rgba(255,255,255,.06);
}
.mp-suggest__item:last-child { border-bottom: none; }
.mp-suggest__item:active,
.mp-suggest__item:focus { background: rgba(255,255,255,.06); outline: none; }
.mp-suggest__icon {
  width: 16px; height: 16px; flex-shrink: 0;
  color: var(--gold-light, #E8D2A0); margin-top: 1px;
}
.mp-suggest__text { flex: 1; min-width: 0; }
.mp-suggest__main { font-weight: 700; color: #fff; }
.mp-suggest__sub {
  font-size:15px; color: rgba(255,255,255,.55);
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mp-suggest__empty {
  padding: 14px; text-align: center;
  color: rgba(255,255,255,.55); font-size:16px;
}
.mp-search {
  flex: 1; padding: 10px 14px; border-radius: 10px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18);
  color: #fff; font-family: inherit; font-size:18px;
}
.mp-search::placeholder { color: rgba(255,255,255,.35); }
.mp-search:focus { outline: none; border-color: var(--gold, #C6AA6E); }
.mp-gps {
  padding: 10px 14px; border-radius: 10px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18);
  color: #fff; font-family: inherit; font-size:16px; font-weight: 600;
  white-space: nowrap; cursor: pointer;
}
.mp-map {
  width: 100%; height: 50vh; min-height: 320px;
  border-radius: 12px; overflow: hidden;
  background: #0A1524;
}

/* Minimal pin marker (gold dot with pulse ring, no drop shadow, no outline) */
.mp-pin { background: transparent; border: none; }
.mp-pin__dot {
  width: 16px; height: 16px; border-radius: 50%;
  background: #C6AA6E;                       /* gold */
  box-shadow: 0 0 0 4px rgba(198,170,110,.28),
              0 0 0 1px rgba(10,21,36,.25);   /* soft ring + thin dark edge */
  position: relative; left: 3px; top: 3px;
}

/* Override Leaflet's default chunky zoom buttons for a more minimal look */
.leaflet-control-zoom {
  border: none !important;
  box-shadow: none !important;
}
.leaflet-control-zoom a {
  width: 28px !important; height: 28px !important;
  line-height: 28px !important;
  background: rgba(255,255,255,.95) !important;
  color: #122040 !important;
  border: none !important;
  border-radius: 6px !important;
  margin-bottom: 4px !important;
  font-size: 18px !important;
  box-shadow: 0 2px 6px rgba(0,0,0,.18);
}
.leaflet-control-zoom a:hover { background: #fff !important; }
.mp-coord {
  text-align: center; font-size:16px; color: rgba(255,255,255,.7);
  padding: 2px 0;
}
.mp-actions {
  display: grid; grid-template-columns: 1fr 1.3fr; gap: 8px;
}

/* ── Home Header ───────────────────────────── */
.home-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-3) 100%);
  color: var(--text-inv); padding: 20px 20px 32px;
  flex-shrink: 0; border-radius: 0 0 var(--r-lg) var(--r-lg);
  position: relative; overflow: hidden;
}
.home-header::after {
  content: ''; position: absolute; bottom: -48px; right: 24px;
  width: 140px; height: 140px; background: rgba(212,160,23,.12); border-radius: 50%;
}
.home-header__greeting { font-size:15px; color: rgba(255,255,255,.55); margin-bottom: 3px; }
.home-header__name { font-size: 22px; font-weight: 800; letter-spacing: -.4px; position: relative; z-index: 1; }
.home-header__area { font-size:14px; color: rgba(255,255,255,.45); margin-top: 3px; }

/* ── KPI Strip ─────────────────────────────── */
.header-kpi-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; position: relative; z-index: 1; margin-top: 16px; }
.header-kpi {
  background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--r-sm); padding: 12px 14px;
}
.header-kpi__label { font-size:13px; color: rgba(255,255,255,.5); margin-bottom: 4px; }
.header-kpi__value { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.header-kpi__unit { font-size:13px; color: rgba(255,255,255,.45); margin-top: 2px; }
.header-kpi--gold .header-kpi__value { color: var(--gold-light); }

/* ── Stat Cards ────────────────────────────── */
.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.stat-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 16px 14px; box-shadow: var(--e-1);
}
.stat-card__label { font-size:13px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.stat-card__value { font-size:30px; font-weight: 800; color: var(--navy); line-height: 1; }
.stat-card__unit { font-size:13px; color: var(--text-3); margin-top: 5px; }
.stat-card--gold .stat-card__value { color: var(--gold); }

/* ── Section Title ─────────────────────────── */
.section-title { font-size:17px; font-weight: 700; color: var(--text-2); margin: 20px 0 10px; letter-spacing: .2px; text-transform: uppercase; }

/* ── Activity / Plan Items ─────────────────── */
.activity-list, .plan-list { display: flex; flex-direction: column; gap: 8px; }
.activity-item, .plan-item {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 13px 14px; box-shadow: var(--e-1);
  display: flex; align-items: center; gap: 12px;
}
.activity-item__icon {
  width: 40px; height: 40px; border-radius: var(--r-sm); background: var(--bg);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--navy);
}
.activity-item__icon svg { width: 18px; height: 18px; }
.activity-item__body { flex: 1; min-width: 0; }
.activity-item__title { font-size:18px; font-weight: 700; }
.activity-item__sub { font-size:16px; color: var(--text-2); margin-top: 2px; }
.activity-item__time { font-size:15px; color: var(--text-3); background: var(--bg); padding: 4px 10px; border-radius: var(--r-pill); }
.plan-item__status { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.plan-item__status--pending { background: var(--warning); }
.plan-item__status--done { background: var(--success); }
.plan-item__body { flex: 1; min-width: 0; }
.plan-item__name { font-size:18px; font-weight: 700; color: var(--navy); }
.plan-item__type { font-size:16px; color: var(--text-2); margin-top: 2px; }
.plan-item__done-btn {
  padding: 6px 16px; border-radius: var(--r-pill); font-size:16px; font-weight: 700;
  background: var(--navy); color: var(--text-inv);
}

/* ── Buttons ───────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 13px 22px; border-radius: var(--r-sm); font-size:18px; font-weight: 700;
  transition: opacity var(--t-fast), transform var(--t-fast); cursor: pointer;
}
.btn:active { opacity: .78; transform: scale(.97); }
.btn--primary { background: var(--navy); color: var(--text-inv); }
.btn--secondary { background: var(--border); color: var(--navy); }
.btn--gold { background: linear-gradient(135deg, var(--gold-light), var(--gold)); color: var(--navy); box-shadow: 0 4px 14px rgba(212,160,23,.35); }
.btn--danger { background: var(--error); color: var(--text-inv); }
.btn--outline { background: transparent; border: 2px solid var(--navy); color: var(--navy); }
.btn--sm { padding: 8px 16px; font-size:17px; }
.btn--full { width: 100%; }
.btn:disabled { opacity: .38; pointer-events: none; }

/* ── Form ──────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size:17px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.form-input {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--border);
  border-radius: var(--r-sm); background: var(--white); outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.form-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(212,160,23,.14); }
.form-input::placeholder { color: var(--text-3); }
.form-input--textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
.form-required { color: var(--error); font-size: .85em; }

/* ── Chips ─────────────────────────────────── */
.chip { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: var(--r-pill); font-size:15px; font-weight: 700; }
.chip--A { background: #FEF3C7; color: #92400E; }
.chip--B { background: #DBEAFE; color: #1E40AF; }
.chip--C { background: var(--bg); color: var(--text-2); }
.chip--gold { background: var(--gold-pale); color: #7A5A20; }
.chip--green { background: var(--success-bg); color: #065F46; }
.chip--red { background: var(--error-bg); color: #991B1B; }
.chip--navy { background: var(--navy); color: var(--text-inv); }
.chip--overdue { background: var(--error-bg); color: #991B1B; }
.chip--warning { background: var(--warning-bg); color: #92400E; }
.chip--ok { background: var(--success-bg); color: #065F46; }

/* ── Tab Bar ───────────────────────────────── */
.tab-bar {
  height: var(--tab-h); background: var(--white);
  border-top: 1px solid var(--border); display: flex; flex-shrink: 0;
  box-shadow: 0 -4px 16px rgba(10,21,36,.06);
}
.tab-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--text-3); padding: 6px 2px; position: relative;
}
.tab-item--active { color: var(--navy); }
.tab-item--active::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 28px; height: 3px; background: var(--gold); border-radius: 0 0 4px 4px;
}
.tab-icon { width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; }
.tab-icon svg { width: 22px; height: 22px; }
.tab-label { font-size:13px; font-weight: 600; }

/* ── v68: Trip action button row (เริ่มเยี่ยม / เลื่อนนัด / แก้ไข / ยกเลิก) ──
   Equal-width 4-column grid so all buttons stay on one row on mobile.
   Used by home.js trip rows, trip-today.js cards, trip-calendar.js expanded day. */
.trip-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 12px;
}
.trip-actions__btn {
  padding: 9px 6px;
  border-radius: 8px;
  border: 1px solid var(--line, #CBD5E1);
  background: #fff;
  color: var(--navy-deep, #0A1524);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
}
.trip-actions__btn:active { transform: scale(0.97); }
.trip-actions__btn--primary {
  background: #0A1524; color: #fff; border: none; font-weight: 700;
}
.trip-actions__btn--danger {
  border-color: rgba(220,38,38,.35); color: #DC2626;
}
.trip-actions__btn--disabled {
  background: #F1F5F9; color: #94A3B8; border-color: #E2E8F0;
  cursor: not-allowed; pointer-events: none;
}
.trip-actions__icon {
  width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.trip-actions__label {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}
/* Slightly larger screen → tighten height, keep single-line intent */
@media (min-width: 480px) {
  .trip-actions__btn { padding: 10px 8px; }
}

/* ── Customer List ─────────────────────────── */
.cust-item {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 13px 14px; box-shadow: var(--e-1);
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  margin-bottom: 8px;
}
.cust-item:active { box-shadow: var(--e-2); transform: scale(.99); }
.cust-item__avatar {
  width: 46px; height: 46px; border-radius: var(--r-sm);
  background: linear-gradient(145deg, var(--navy-3), var(--navy));
  color: var(--text-inv); display: flex; align-items: center; justify-content: center;
  font-size:20px; font-weight: 800; flex-shrink: 0;
}
.cust-item__body { flex: 1; min-width: 0; }
.cust-item__name { font-size:18px; font-weight: 700; }
.cust-item__meta { font-size:16px; color: var(--text-2); margin-top: 2px; }

/* ── Filter Tabs ───────────────────────────── */
.filter-tabs {
  display: flex; gap: 6px; padding: 10px 16px;
  background: var(--white); border-bottom: 1px solid var(--border);
  overflow-x: auto; flex-shrink: 0; scrollbar-width: none;
}
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tab {
  padding: 7px 18px; border-radius: var(--r-pill); font-size:17px; font-weight: 600;
  background: var(--bg); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap;
}
.filter-tab--active { background: var(--navy); color: var(--text-inv); border-color: var(--navy); }

/* ── Search Bar ────────────────────────────── */
.search-bar { padding: 10px 16px; background: var(--white); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.search-input {
  width: 100%; padding: 10px 14px 10px 14px; border: 1.5px solid var(--border);
  border-radius: var(--r-pill); background: var(--bg); font-size:18px; outline: none;
}
.search-input:focus { border-color: var(--navy); background: var(--white); }

/* ── Staff Row (Manager) ───────────────────── */
.staff-row {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 14px; box-shadow: var(--e-1);
  margin-bottom: 8px; display: flex; align-items: center; gap: 12px; cursor: pointer;
}
.staff-row__avatar {
  width: 46px; height: 46px; border-radius: var(--r-sm);
  background: linear-gradient(145deg, var(--navy-3), var(--navy));
  color: var(--text-inv); display: flex; align-items: center; justify-content: center;
  font-size:20px; font-weight: 800; flex-shrink: 0;
}
.staff-row__body { flex: 1; min-width: 0; }
.staff-row__name { font-size:18px; font-weight: 800; color: var(--navy); }
.staff-row__area { font-size:16px; color: var(--text-2); margin-top: 1px; }
.staff-row__stats { display: flex; gap: 14px; margin-top: 5px; }
.staff-row__stat { font-size:16px; color: var(--text-2); }
.staff-row__stat strong { color: var(--navy); font-weight: 700; }

/* ── Card ──────────────────────────────────── */
.card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 16px; box-shadow: var(--e-1); margin-bottom: 10px;
}
.card__title { font-size:18px; font-weight: 700; color: var(--navy); }

/* ── Toast ─────────────────────────────────── */
.toast-container {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 9999; pointer-events: none;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: min(calc(100vw - 32px), 360px);
}
.toast {
  padding: 12px 20px; border-radius: var(--r-md);
  font-size:18px; font-weight: 700; box-shadow: var(--e-3);
  opacity: 0; transform: translateY(-12px) scale(.96);
  transition: opacity var(--t-base), transform var(--t-base);
  text-align: center;
}
.toast--show { opacity: 1; transform: none; }
.toast--info { background: var(--navy); color: var(--text-inv); }
.toast--success { background: var(--success); color: var(--text-inv); }
.toast--error { background: var(--error); color: var(--text-inv); }

/* ── Empty State ───────────────────────────── */
.empty-state { text-align: center; padding: 48px 16px; }
.empty-state__icon { width: 48px; height: 48px; margin: 0 auto 12px; opacity: .5; color: var(--text-3); }
.empty-state__text { font-size:18px; color: var(--text-2); }

/* ── Progress Bar ──────────────────────────── */
.progress-wrap { background: var(--border); border-radius: var(--r-pill); height: 5px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: var(--r-pill); background: var(--gold); transition: width .4s ease; }

/* ── FAB ───────────────────────────────────── */
.fab {
  position: fixed; bottom: calc(var(--tab-h) + 16px); right: 18px;
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(145deg, var(--navy-3), var(--navy));
  color: var(--text-inv); font-size:30px;
  box-shadow: 0 6px 20px rgba(10,21,36,.35);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.fab:active { transform: scale(.90); }

/* ── Summary Grid (Manager) ────────────────── */
.summary-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.summary-cell {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 14px 8px; box-shadow: var(--e-1); text-align: center;
}
.summary-cell__val { font-size: 24px; font-weight: 800; color: var(--navy); }
.summary-cell__label { font-size:15px; color: var(--text-3); margin-top: 4px; font-weight: 600; }

/* ── Visit Status Indicators ───────────────── */
.visit-status { display: inline-flex; align-items: center; gap: 4px; font-size:15px; font-weight: 700; }
.visit-dot { width: 8px; height: 8px; border-radius: 50%; }
.visit-dot--overdue { background: var(--error); }
.visit-dot--warning { background: var(--warning); }
.visit-dot--ok { background: var(--success); }

/* ── Responsive ────────────────────────────── */
@media (min-width: 480px) {
  #app { max-width: 440px; margin: 0 auto; box-shadow: 0 0 40px rgba(10,21,36,.15); }
  body { background: #DDE3EF; }
}
@media (min-width: 768px) {
  #app { max-width: 768px; }
}
@media (min-width: 1024px) {
  #app { max-width: 1024px; }
  .stat-row { grid-template-columns: 1fr 1fr 1fr 1fr; }
}
