/* ============================================================
   OneCliq CRM — Prototype design system
   Mobile-first, calm professional palette, dark-mode aware
   ============================================================ */

:root {
  /* Brand + neutrals */
  --bg:            #f6f8fb;
  --surface:       #ffffff;
  --surface-2:     #f2f5f9;
  --surface-3:     #e9eef4;
  --border:        #e8ecf2;
  --border-strong: #d3dae4;

  --text:      #0e1626;
  --text-2:    #4a5568;
  --text-3:    #97a2b4;

  --primary:      #2563eb;
  --primary-600:  #1d4ed8;
  --primary-tint: #eaf1fe;

  --accent:       #0ea5a4;
  --accent-tint:  #d8f3f2;

  /* Interest / status colors */
  --hot:   #e11d48;  --hot-tint:  #fde7ec;
  --warm:  #f59e0b;  --warm-tint: #fef3d6;
  --cold:  #64748b;  --cold-tint: #eef1f5;
  --new:   #2563eb;  --new-tint:  #e8f0fe;
  --won:   #16a34a;  --won-tint:  #dcfce7;

  --todo-c: #64748b; --todo-tint: #eef1f5;
  --prog-c: #2563eb; --prog-tint: #e8f0fe;
  --done-c: #16a34a; --done-tint: #dcfce7;

  --danger: #dc2626;

  --shadow-sm: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.05);
  --shadow-md: 0 4px 16px rgba(16,24,40,.07), 0 2px 6px rgba(16,24,40,.04);
  --shadow-lg: 0 20px 48px rgba(16,24,40,.16), 0 6px 16px rgba(16,24,40,.08);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;

  --tab-h: 62px;
  --header-h: 56px;

  --font: "Inter", "Inter var", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Dark palette. Applied when the system is dark AND the user hasn't forced
   light, OR when the user explicitly chooses Dark in Settings. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:            #0b1120;
    --surface:       #131c2e;
    --surface-2:     #1a2436;
    --surface-3:     #223048;
    --border:        #26324a;
    --border-strong: #33425f;

    --text:   #f1f5f9;
    --text-2: #a9b6c9;
    --text-3: #6b7a92;

    --primary-tint: #17263f;
    --accent-tint:  #10302f;

    --hot-tint:  #3a1620;  --warm-tint: #3a2c10;
    --cold-tint: #20293a;  --new-tint:  #17263f;
    --won-tint:  #123324;
    --todo-tint: #20293a;  --prog-tint: #17263f;  --done-tint: #123324;

    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow-md: 0 4px 14px rgba(0,0,0,.45);
    --shadow-lg: 0 16px 40px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  --bg:            #0b1120;
  --surface:       #131c2e;
  --surface-2:     #1a2436;
  --surface-3:     #223048;
  --border:        #26324a;
  --border-strong: #33425f;

  --text:   #f1f5f9;
  --text-2: #a9b6c9;
  --text-3: #6b7a92;

  --primary-tint: #17263f;
  --accent-tint:  #10302f;

  --hot-tint:  #3a1620;  --warm-tint: #3a2c10;
  --cold-tint: #20293a;  --new-tint:  #17263f;
  --won-tint:  #123324;
  --todo-tint: #20293a;  --prog-tint: #17263f;  --done-tint: #123324;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 4px 14px rgba(0,0,0,.45);
  --shadow-lg: 0 16px 40px rgba(0,0,0,.6);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; height: 100%; max-width: 100%; overflow-x: clip; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.006em;
}
/* Premium data feel: aligned, tabular figures in numeric contexts. */
.num, .kpi .n, .detail-title, table.tbl td, table.tbl th { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1, "cv11" 1; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 16px; }

.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100%;
  background: var(--bg);
  position: relative;
}

/* ---------------- Header ---------------- */
.header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
}
.header-row { display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
.brand-logo {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 15px;
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -.2px; }
.brand-sub { font-size: 11.5px; color: var(--text-3); margin-top: -2px; }

.user-chip {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 10px 4px 5px;
}
.avatar {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 11px;
}
.user-chip .who { font-size: 12.5px; font-weight: 600; line-height: 1; }
.user-chip .role { font-size: 10px; color: var(--text-3); line-height: 1.1; }

/* Product dropdown (project selector) */
.product-dd-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.product-dd-lead {
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .7px;
  color: var(--text-3); flex: none;
}
.product-dd { position: relative; flex: 1; }
.product-select {
  width: 100%; -webkit-appearance: none; appearance: none;
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text);
  font-weight: 700; font-size: 14.5px; letter-spacing: -.1px;
  padding: 11px 40px 11px 14px; border-radius: var(--r-md); box-shadow: var(--shadow-sm);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='22' height='22' fill='none' stroke='%232563eb' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l5 5 5-5'/></svg>");
  background-repeat: no-repeat; background-position: right 11px center;
}
.product-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint); }

/* Screen title + inline count */
.screen-head { display: flex; align-items: center; gap: 10px; }
.title-count {
  background: var(--surface-3); color: var(--text-2);
  font-size: 13px; font-weight: 800; border-radius: 999px; padding: 3px 11px; margin-top: 4px;
  min-width: 26px; text-align: center;
}

/* Category filter dropdown next to the title */
.cat-dd { margin-left: auto; margin-top: 4px; position: relative; }
.cat-select {
  -webkit-appearance: none; appearance: none;
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text);
  font-weight: 700; font-size: 13px; padding: 8px 32px 8px 12px; border-radius: 999px;
  box-shadow: var(--shadow-sm);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%232563eb' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l5 5 5-5'/></svg>");
  background-repeat: no-repeat; background-position: right 8px center;
}
.cat-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint); }

/* Profile & settings sheet header */
.profile-head { display: flex; align-items: center; gap: 12px; padding: 4px 0 2px; }
.profile-head .cn { font-weight: 700; }
.profile-head .cr { color: var(--text-3); font-size: 13px; }
#theme-seg button { font-size: 14px; }

/* Compact Type + Status dropdowns — always stay on the title line; they shrink
   (with ellipsis) rather than wrap, even under a large system font. */
.screen-head { flex-wrap: nowrap; gap: 6px; }
.hdr-filters { display: flex; gap: 5px; margin-left: auto; flex: 1 1 auto; min-width: 0; justify-content: flex-end; }
.title-count { flex: 0 0 auto; margin-top: 3px; font-size: 12px; padding: 2px 8px; min-width: 22px; }
.mini-select {
  -webkit-appearance: none; appearance: none;
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text);
  font-weight: 700; font-size: 11px; padding: 6px 19px 6px 8px; border-radius: 999px;
  flex: 1 1 0; min-width: 0; max-width: 104px; margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%232563eb' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l5 5 5-5'/></svg>");
  background-repeat: no-repeat; background-position: right 4px center;
}
.mini-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint); }

/* Nearby / Place row (below the search) with distance options */
.nearby-row { display: flex; gap: 7px; align-items: center; margin: 10px 0 2px; flex-wrap: wrap; }
.radius-chip { padding: 6px 11px; font-size: 12px; }
.radius-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-place { display: inline-flex; align-items: center; gap: 5px; border-color: var(--border-strong); }
.chip-place.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Place drill-down: State → District → City */
.place-row { display: flex; gap: 7px; flex-wrap: wrap; margin: 9px 0 2px; }
.place-sel { flex: 1 1 30%; min-width: 104px; width: auto; }
.place-sel:disabled { opacity: .5; }

/* Search clear + results note + commit row */
.search-clear { border: none; background: transparent; color: var(--text-3); width: 28px; height: 28px;
  display: grid; place-items: center; flex: none; }
.results-note { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 12.5px; color: var(--text-2); font-weight: 600; margin: 2px 0 12px; }
.results-note .link-btn { padding: 0; }
.ac-commit { background: var(--primary-tint); }
.ac-commit .ac-name { color: var(--primary-600); font-weight: 700; }

/* ---------------- Screen scaffold ---------------- */
.screen { padding: 14px 16px calc(var(--tab-h) + 90px); }
.screen-title { font-size: 20px; font-weight: 800; letter-spacing: -.4px; margin: 4px 0 2px; }
.screen-head .screen-title { font-size: 18px; flex: 0 0 auto; }
.screen-caption { color: var(--text-2); font-size: 13px; margin-bottom: 14px; }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.search {
  flex: 1; display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 10px 12px; box-shadow: var(--shadow-sm);
}
.search input { border: none; outline: none; background: transparent; color: var(--text); flex: 1; }
.search svg { color: var(--text-3); flex: none; }

.filter-row { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 8px;
  scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); border-radius: 999px; padding: 6px 12px; font-size: 12.5px; font-weight: 600;
}
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip .count { opacity: .6; margin-left: 4px; font-weight: 700; }

/* ---------------- Cards ---------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  padding: 14px; margin-bottom: 12px; transition: transform .12s ease;
}
.card:active { transform: scale(.99); }

.hosp-top { display: flex; align-items: flex-start; gap: 10px; }
.hosp-name { font-weight: 700; font-size: 16px; letter-spacing: -.2px; }
.hosp-loc { color: var(--text-3); font-size: 12.5px; margin-top: 1px; }
.hosp-body { margin-top: 10px; display: grid; gap: 8px; }

.field-mini { background: var(--surface-2); border-radius: var(--r-sm); padding: 8px 10px; }
.field-mini .lbl {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-3); margin-bottom: 2px; display: flex; align-items: center; gap: 5px;
}
.field-mini .val { font-size: 13.5px; color: var(--text); }
.field-mini .val.empty { color: var(--text-3); font-style: italic; }

.hosp-foot { display: flex; align-items: center; gap: 10px; margin-top: 11px; flex-wrap: wrap; }
.meta { font-size: 11.5px; color: var(--text-3); display: flex; align-items: center; gap: 4px; }

/* ---------- Customer card (flat, single card) ---------- */
.cust-card { padding: 14px 15px; }
.cc-top { display: flex; align-items: flex-start; gap: 10px; }
.cc-headinfo { flex: 1; min-width: 0; }
.cust-name { font-weight: 700; font-size: 16px; letter-spacing: -.2px; }
.cust-meta { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.cc-right { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.cc-due { font-size: 11.5px; font-weight: 700; }
.cc-due.due { color: var(--hot); }
.cc-due.clear { color: var(--won); }
.cc-contact { display: flex; align-items: center; gap: 7px; margin-top: 11px; font-size: 13.5px; color: var(--text); font-weight: 600; }
.cc-contact svg { color: var(--text-3); flex: none; }
.cc-supplied { margin-top: 7px; font-size: 12.5px; color: var(--text-2); background: var(--surface-2); border-radius: var(--r-sm); padding: 6px 9px; }
.cc-landmark { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12.5px; color: var(--text-2); }
.cc-landmark svg { color: var(--accent); flex: none; }
.cc-dist { color: var(--primary); font-weight: 700; }

/* Nearby toggle chip */
.chip-nearby { display: inline-flex; align-items: center; gap: 5px; border-color: var(--border-strong); }
.chip-nearby svg { width: 13px; height: 13px; }
.chip-nearby.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.nearby-note { font-size: 12px; color: var(--text-2); background: var(--accent-tint); border-radius: var(--r-sm);
  padding: 8px 11px; margin-bottom: 12px; display: flex; align-items: center; gap: 6px; font-weight: 600; }
.nearby-note svg { flex: none; color: var(--accent); }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 999px;
  text-transform: capitalize; letter-spacing: .2px;
}
.dot { width: 7px; height: 7px; border-radius: 50%; }
.b-hot  { background: var(--hot-tint);  color: var(--hot); }
.b-warm { background: var(--warm-tint); color: var(--warm); }
.b-cold { background: var(--cold-tint); color: var(--cold); }
.b-new  { background: var(--new-tint);  color: var(--new); }
.b-won  { background: var(--won-tint);  color: var(--won); }
.b-todo { background: var(--todo-tint); color: var(--todo-c); }
.b-in_progress { background: var(--prog-tint); color: var(--prog-c); }
.b-done { background: var(--done-tint); color: var(--done-c); }

/* ---------------- Tasks ---------------- */
.task-card { display: flex; align-items: flex-start; gap: 12px; }
.check {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-strong);
  flex: none; margin-top: 1px; display: grid; place-items: center; background: var(--surface);
  transition: .15s;
}
.check.done { background: var(--done-c); border-color: var(--done-c); color: #fff; }
.check.done svg { display: block; }
.check svg { display: none; }
.task-main { flex: 1; min-width: 0; }
.task-title { font-weight: 650; font-size: 15px; }
.task-title.done { text-decoration: line-through; color: var(--text-3); }
.task-sub { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }

.assignee-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); font-weight: 600; }

/* ---------------- Diary ---------------- */
.diary-day { margin-bottom: 6px; }
.diary-date {
  position: sticky; top: calc(var(--header-h) + 8px); z-index: 5;
  font-size: 12px; font-weight: 800; color: var(--text-2); text-transform: uppercase; letter-spacing: .5px;
  padding: 8px 2px 6px;
}
.tl-item { display: flex; gap: 12px; padding-bottom: 4px; }
.tl-rail { display: flex; flex-direction: column; align-items: center; flex: none; width: 30px; }
.tl-node {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; flex: none; box-shadow: var(--shadow-sm);
}
.tl-line { width: 2px; flex: 1; background: var(--border); margin: 3px 0; min-height: 8px; }
.tl-body { flex: 1; padding-bottom: 14px; min-width: 0; }
.tl-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 11px 12px; box-shadow: var(--shadow-sm); }
.tl-head { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); margin-bottom: 4px; }
.tl-actor { font-weight: 700; color: var(--text-2); }
.tl-text { font-size: 14px; }
.tl-ctx { font-size: 12px; color: var(--primary); font-weight: 600; margin-top: 5px; }
.vis-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 10.5px; font-weight: 600;
  color: var(--text-3); background: var(--surface-2); border-radius: 999px; padding: 2px 8px; }

/* ---------------- Comments log ---------------- */
.comment { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); }
.comment:first-child { border-top: none; }
.comment .c-body { flex: 1; }
.comment .c-meta { font-size: 11.5px; color: var(--text-3); margin-bottom: 2px; }
.comment .c-text { font-size: 14px; }

/* ---------------- Buttons / FAB ---------------- */
.btn {
  border: none; border-radius: var(--r-md); padding: 13px 16px; font-size: 15px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:active { background: var(--primary-600); }
.btn-ghost { background: var(--surface-2); color: var(--text); }
.btn-danger-ghost { background: var(--hot-tint); color: var(--danger); }
.btn-sm { padding: 9px 13px; font-size: 13.5px; width: auto; border-radius: var(--r-sm); }

.fab {
  position: fixed; right: max(16px, calc(50% - 260px + 16px)); bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px);
  width: 56px; height: 56px; border-radius: 18px; border: none; z-index: 45;
  background: linear-gradient(135deg, var(--primary), var(--primary-600));
  color: #fff; box-shadow: var(--shadow-lg); display: grid; place-items: center;
}
.fab:active { transform: scale(.94); }

/* Subtle, tucked-away link to edit rarely-changed profile info */
.profile-edit-link {
  display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%;
  margin: 18px 0 2px; background: transparent; border: none;
  color: var(--text-3); font-size: 12px; font-weight: 600; padding: 10px;
  text-decoration: underline; text-underline-offset: 3px;
}
.profile-edit-link svg { width: 13px; height: 13px; opacity: .8; }

/* Floating Edit / Add-task buttons on the customer detail screen */
.detail-fabs {
  position: fixed; z-index: 45;
  right: max(16px, calc(50% - 260px + 16px));
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px);
  display: flex; gap: 10px;
}
.mini-fab {
  border: none; border-radius: 999px; height: 50px; padding: 0 18px 0 16px;
  display: inline-flex; align-items: center; gap: 7px; font-weight: 700; font-size: 14.5px;
  box-shadow: var(--shadow-lg);
}
.mini-fab svg { flex: none; }
.mini-fab.edit { background: var(--surface); color: var(--primary); border: 1px solid var(--border-strong); }
.mini-fab.task { background: linear-gradient(135deg, var(--primary), var(--primary-600)); color: #fff; }
.mini-fab:active { transform: scale(.96); }

/* ---------------- Bottom tab bar ---------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 44;
  max-width: 520px; margin: 0 auto;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(180%) blur(16px); -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--border);
  display: flex;
}
.tab {
  flex: 1; border: none; background: transparent; color: var(--text-3);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 600; position: relative;
}
.tab.active { color: var(--primary); }
.tab .badge-num {
  position: absolute; top: 6px; left: 54%; background: var(--hot); color: #fff;
  font-size: 9px; font-weight: 800; min-width: 15px; height: 15px; border-radius: 999px;
  display: grid; place-items: center; padding: 0 3px;
}

/* ---------------- Sheet / Modal ---------------- */
.scrim {
  position: fixed; inset: 0; z-index: 50; background: rgba(15,23,42,.45);
  opacity: 0; pointer-events: none; transition: opacity .22s;
}
.scrim.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51;
  max-width: 520px; margin: 0 auto;
  background: var(--surface); border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-lg); transform: translateY(100%);
  transition: transform .28s cubic-bezier(.2,.9,.25,1);
  max-height: 92vh; display: flex; flex-direction: column;
}
.sheet.open { transform: translateY(0); }
.sheet-grip { width: 40px; height: 4px; border-radius: 999px; background: var(--border-strong);
  margin: 10px auto 2px; flex: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 18px 4px; }
.sheet-title { font-size: 18px; font-weight: 800; }
.sheet-close { border: none; background: var(--surface-2); color: var(--text-2); width: 32px; height: 32px;
  border-radius: 50%; display: grid; place-items: center; }
.sheet-body { padding: 8px 18px 18px; overflow-y: auto; }
.sheet-foot { padding: 12px 18px calc(env(safe-area-inset-bottom) + 14px); border-top: 1px solid var(--border);
  display: flex; gap: 10px; }

/* ---------------- Forms ---------------- */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12.5px; font-weight: 700; color: var(--text-2); margin-bottom: 6px; }
.field .hint { font-size: 11.5px; color: var(--text-3); font-weight: 500; margin-top: 4px; }
.locked-field { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 12px 13px; color: var(--text-2); font-weight: 600; font-size: 15px; }
.input, .textarea, select.input {
  width: 100%; border: 1px solid var(--border-strong); border-radius: var(--r-md);
  padding: 12px 13px; background: var(--surface); color: var(--text); outline: none; transition: .15s;
  -webkit-appearance: none; appearance: none;
}
.input:focus, .textarea:focus, select.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint); }
.textarea { resize: vertical; min-height: 74px; line-height: 1.5; }
select.input {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%2394a3b8' stroke-width='2'><path d='M6 8l4 4 4-4'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 38px;
}

.seg { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: var(--r-md); }
.seg button { flex: 1; border: none; background: transparent; color: var(--text-2); padding: 9px 6px;
  border-radius: var(--r-sm); font-weight: 700; font-size: 13px; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.people-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.person-pick {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong);
  background: var(--surface); border-radius: 999px; padding: 5px 11px 5px 5px; font-size: 12.5px; font-weight: 600;
  color: var(--text-2);
}
.person-pick.active { border-color: var(--primary); background: var(--primary-tint); color: var(--primary-600); }

.contact-row { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; }
.contact-row .grow { flex: 1; }
.icon-btn { border: none; background: var(--surface-2); color: var(--text-2); width: 40px; height: 40px;
  border-radius: var(--r-md); display: grid; place-items: center; flex: none; }
.link-btn { border: none; background: transparent; color: var(--primary); font-weight: 700; font-size: 13.5px;
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 0; }

/* ---------------- Detail view ---------------- */
.detail-hero { padding: 16px; background: var(--surface); border-radius: var(--r-lg);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm); margin-bottom: 14px; }
.detail-actions { display: flex; gap: 8px; margin-top: 14px; }
.detail-actions .btn { flex: 1; }
.section-label { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-3); margin: 20px 2px 10px; }
.detail-field { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 12px 13px; margin-bottom: 10px; }
.detail-field .lbl { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-3); margin-bottom: 4px; }
.detail-field .val { font-size: 15px; line-height: 1.5; }

.contact-card { display: flex; align-items: center; gap: 11px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-md); padding: 11px 12px; margin-bottom: 9px; }
.contact-card .ci { flex: 1; min-width: 0; }
.contact-card .cn { font-weight: 650; font-size: 14.5px; }
.contact-card .cr { font-size: 12px; color: var(--text-3); }
.call-btn { width: 40px; height: 40px; border-radius: 50%; border: none; background: var(--won-tint);
  color: var(--won); display: grid; place-items: center; flex: none; }

.add-comment-bar { display: flex; gap: 8px; align-items: flex-end; margin-top: 8px; }
.add-comment-bar .textarea { min-height: 44px; }

/* ---------- Flattened detail info list ---------- */
.info-list { margin-top: 14px; border-top: 1px solid var(--border); }
.info-block { padding: 12px 0; border-bottom: 1px solid var(--border); }
.info-block .k {
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-3); margin-bottom: 5px;
}
.info-block .v { font-size: 15px; line-height: 1.5; color: var(--text); }
.info-block .v.muted, .muted { color: var(--text-3); }
.info-block .v.next { color: var(--primary-600); font-weight: 600; }

/* Tappable person name (opens the person popup) */
.cn-link { border: none; background: transparent; padding: 0; font: inherit; color: var(--primary);
  font-weight: 650; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
/* Linked-customer rows inside the person popup */
.person-head { display: flex; align-items: center; gap: 12px; padding: 2px 0 4px; }
.link-cust { display: flex; flex-direction: column; gap: 2px; width: 100%; text-align: left;
  border: 1px solid var(--border); background: var(--surface); border-radius: var(--r-md);
  padding: 11px 13px; margin-bottom: 8px; color: var(--text); }
.link-cust:active { background: var(--surface-2); }
.lc-name { font-weight: 650; font-size: 14.5px; }
.lc-meta { font-size: 12px; color: var(--text-3); }

.contact-line { display: flex; align-items: center; gap: 10px; padding: 5px 0; }
.contact-line + .contact-line { border-top: 1px dashed var(--border); }
.cl-info { flex: 1; min-width: 0; }
.cl-info .cn { font-weight: 650; font-size: 15px; }
.cl-info .cr { color: var(--text-3); font-weight: 500; font-size: 13px; }
.cl-info .cp { color: var(--text-2); font-size: 13.5px; margin-top: 1px; }
.cl-actions { display: flex; gap: 8px; flex: none; }

.wa-btn { width: 40px; height: 40px; border-radius: 50%; border: none; display: grid; place-items: center;
  flex: none; background: #25d36622; color: #25d366; text-decoration: none; }
.call-btn { text-decoration: none; }

/* Phone field + phone-book icon */
.phone-line { display: flex; gap: 8px; align-items: center; }
.phone-line .input { flex: 1; }
.phonebook-btn { flex: none; background: var(--primary-tint); color: var(--primary); }

/* Designation combobox dropdown */
.desig-ac { position: relative; }
.desig-suggest { display: none; position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 6;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg); overflow: hidden; max-height: 240px; overflow-y: auto; }
.desig-suggest.open { display: block; }
.desig-opt { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
  border: none; background: transparent; padding: 11px 13px; text-align: left; color: var(--text);
  border-bottom: 1px solid var(--border); }
.desig-opt:last-child { border-bottom: none; }
.desig-opt:active { background: var(--surface-2); }

/* Google-style address rows */
.ac-item.gplace { align-items: flex-start; }
.gtext { display: flex; flex-direction: column; min-width: 0; }
.gmain { font-weight: 650; font-size: 14px; }
.gsec { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-google-note { padding: 8px 12px; font-size: 10.5px; color: var(--text-3);
  border-top: 1px solid var(--border); background: var(--surface-2); }

/* ---------- Place autocomplete (simulated Elastic Search) ---------- */
.ac { position: relative; }
.ac-list {
  display: none; position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 5;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md);
  box-shadow: var(--shadow-lg); overflow: hidden; max-height: 260px; overflow-y: auto;
}
.ac-list.open { display: block; }
.ac-item {
  display: flex; align-items: center; gap: 9px; width: 100%; border: none; background: transparent;
  padding: 11px 13px; text-align: left; color: var(--text); border-bottom: 1px solid var(--border);
}
.ac-item:last-child { border-bottom: none; }
.ac-item:active { background: var(--surface-2); }
.ac-item svg { color: var(--primary); flex: none; }
.ac-name { font-weight: 600; font-size: 14.5px; flex: 1; }
.ac-state { font-size: 12px; color: var(--text-3); background: var(--surface-2); padding: 2px 9px; border-radius: 999px; }
.ac-empty { padding: 12px 13px; font-size: 13px; color: var(--text-3); }

/* ---------- Phone-book picker ---------- */
.contact-add-actions { display: flex; gap: 16px; margin-top: 4px; flex-wrap: wrap; }
.phonebook {
  margin-top: 10px; border: 1px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--surface-2); overflow: hidden;
}
.phonebook-head {
  display: flex; align-items: center; gap: 7px; padding: 10px 13px; font-size: 12px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .5px; color: var(--text-3); border-bottom: 1px solid var(--border);
}
.pb-item {
  display: flex; align-items: center; gap: 11px; width: 100%; border: none; background: transparent;
  padding: 10px 13px; text-align: left; color: var(--text); border-bottom: 1px solid var(--border);
}
.pb-item:last-child { border-bottom: none; }
.pb-item:active { background: var(--surface-3); }
.pb-ava { width: 38px; height: 38px; border-radius: 50%; background: var(--surface-3); color: var(--text-2);
  display: grid; place-items: center; flex: none; }
.pb-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pb-name { font-weight: 600; font-size: 14.5px; }
.pb-phone { font-size: 12.5px; color: var(--text-3); }
.pb-add { color: var(--primary); flex: none; }

/* Full-screen phone-book picker */
.pb-scrim { position: fixed; inset: 0; z-index: 70; background: rgba(15,23,42,.5);
  opacity: 0; pointer-events: none; transition: opacity .22s; }
.pb-scrim.open { opacity: 1; pointer-events: auto; }
.pb-picker {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 71; max-width: 520px; margin: 0 auto;
  background: var(--surface); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  transform: translateY(100%); transition: transform .28s cubic-bezier(.2,.9,.25,1);
}
.pb-picker.open { transform: translateY(0); }
.pb-head { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 14px; border-bottom: 1px solid var(--border); }
.pb-title { font-weight: 800; font-size: 16px; }
.pb-cancel { border: none; background: transparent; color: var(--text-2); font-weight: 600; font-size: 15px; padding: 4px; }
.pb-ok { border: none; background: transparent; color: var(--primary); font-weight: 800; font-size: 15px; padding: 4px 6px; }
.pb-ok:disabled { color: var(--text-3); opacity: .55; }
.pb-search { display: flex; align-items: center; gap: 8px; margin: 12px 16px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 12px; }
.pb-search svg { color: var(--text-3); flex: none; }
.pb-search input { flex: 1; border: none; outline: none; background: transparent; color: var(--text); }
.pb-list { flex: 1; overflow-y: auto; padding: 0 10px calc(env(safe-area-inset-bottom) + 20px); }
.pb-row { display: flex; align-items: center; gap: 12px; width: 100%; border: none; background: transparent;
  padding: 13px 8px; text-align: left; color: var(--text); border-bottom: 1px solid var(--border); }
.pb-row .pb-radio { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border-strong); flex: none; }
.pb-row.selected { background: var(--primary-tint); border-radius: var(--r-md); border-bottom-color: transparent; }
.pb-row.selected .pb-radio { border-color: var(--primary); background: var(--primary);
  box-shadow: inset 0 0 0 3px var(--surface); }

.back-btn { border: none; background: transparent; color: var(--primary); font-weight: 700;
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 0 12px; font-size: 15px; }

/* ---------------- Empty state ---------------- */
.empty { text-align: center; padding: 50px 24px; color: var(--text-3); }
.empty svg { margin-bottom: 12px; opacity: .5; }
.empty h3 { color: var(--text-2); font-size: 16px; margin: 0 0 4px; }
.empty p { font-size: 13px; margin: 0; }

/* ---------------- Toast ---------------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(20px);
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 20px); z-index: 60;
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 999px;
  font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow-lg); opacity: 0;
  transition: .25s; pointer-events: none; display: flex; align-items: center; gap: 8px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------------- Overview banner (Diary filter) ---------------- */
.filter-people { display: flex; gap: 7px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.filter-people::-webkit-scrollbar { display: none; }

.stat-row { display: flex; gap: 10px; margin-bottom: 16px; }
.stat { flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 12px; box-shadow: var(--shadow-sm); }
.stat .n { font-size: 22px; font-weight: 800; letter-spacing: -.5px; }
.stat .l { font-size: 11.5px; color: var(--text-3); font-weight: 600; margin-top: 1px; }

.divider-note { font-size: 12px; color: var(--text-3); text-align: center; padding: 6px 0 2px; }

/* ---------------- Team (attendance + expenses) ---------------- */
.region-group { margin-bottom: 14px; }
.region-label { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700;
  color: var(--text-2); margin: 4px 2px 8px; }
.region-label svg { color: var(--accent); }
.team-today { padding: 2px 12px 6px; }
.region-subhead { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .5px; color: var(--text-3); padding: 13px 2px 5px; }
.region-subhead svg { color: var(--accent); }
.rep-row { display: flex; align-items: center; gap: 11px; background: transparent; border: none;
  border-bottom: 1px solid var(--border); padding: 11px 2px; width: 100%; text-align: left; color: var(--text); }
.rep-row:last-child { border-bottom: none; }
.rep-row:active { background: var(--surface-2); }
.rep-row .rep-name { color: var(--primary); }
.rep-att-row { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--border); font-size: 13px; }
.rep-att-row .rar-date { flex: 1; color: var(--text-2); font-weight: 600; }
.rep-att-row .meta { color: var(--text-3); }
.rep-info { flex: 1; min-width: 0; }
.rep-name { font-weight: 650; font-size: 14.5px; }
.rep-sub { font-size: 12px; color: var(--text-3); }
.rep-right { text-align: right; flex: none; }
.rep-exp { font-size: 11px; color: var(--text-3); margin-top: 3px; }
.att-chip { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.att-chip.in { background: var(--won-tint); color: var(--won); }
.att-chip.done { background: var(--surface-3); color: var(--text-2); }
.att-chip.out { background: var(--hot-tint); color: var(--hot); }

.checkin-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 16px; box-shadow: var(--shadow-sm); margin-bottom: 14px; display: flex; flex-direction: column; gap: 12px; }
.checkin-card.in { border-color: var(--won); background: var(--won-tint); }
.checkin-card.done { background: var(--surface-2); }
.ci-status { font-size: 15px; color: var(--text); }

.exp-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 12px; margin-bottom: 9px; box-shadow: var(--shadow-sm); }
.exp-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.exp-cat { font-weight: 700; font-size: 14px; }
.exp-amt { font-weight: 800; font-size: 14px; color: var(--text); margin-left: 4px; }
.exp-note { font-size: 13px; color: var(--text-2); margin: 6px 0; }
.exp-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.exp-actions .btn { width: auto; }
.exp-top .meta { display: inline-flex; align-items: center; gap: 4px; }
.exp-thumb { display: block; margin-top: 8px; max-width: 140px; max-height: 110px; width: auto; height: auto;
  border-radius: var(--r-sm); border: 1px solid var(--border); object-fit: cover; }
.exp-noreceipt { font-size: 11.5px; color: var(--text-3); margin-top: 8px; font-style: italic; }

/* Receipt capture preview in the expense form */
.receipt-preview { margin-bottom: 8px; position: relative; display: inline-block; }
.receipt-preview:empty { display: none; }
.receipt-preview img { max-width: 180px; max-height: 150px; border-radius: var(--r-md); border: 1px solid var(--border); display: block; }
.rc-remove { position: absolute; top: -8px; right: -8px; width: 26px; height: 26px; border-radius: 50%;
  border: none; background: var(--danger); color: #fff; display: grid; place-items: center; box-shadow: var(--shadow-md); }
.receipt-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.receipt-actions .btn { width: auto; }

/* Full-screen image viewer */
.img-viewer { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.88);
  display: grid; place-items: center; padding: 20px; }
.img-viewer img { max-width: 100%; max-height: 100%; border-radius: var(--r-md); }

/* Quotations list on customer detail (P6.4) */
.quote-row { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 12px; border-bottom: 1px solid var(--border); }
.quote-row:last-child { border-bottom: none; }
.quote-row .q-num { font-weight: 600; font-size: 14px; color: var(--text); }
.quote-row .q-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.quote-row .q-total { font-weight: 700; font-size: 14px; color: var(--text);
  font-variant-numeric: tabular-nums; white-space: nowrap; }
