/* ============================================================
   RetailOS — POS Billing & Inventory Dashboard
   ============================================================ */

:root {
  --bg: #f3f5fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --border: #e5e9f2;
  --border-strong: #d3dae8;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --primary: #d50f0f;
  --primary-strong: #a30a0a;
  --primary-soft: #fdecec;
  --primary-text: #a3141a;
  --brand-a: #d50f0f;
  --brand-b: #a30a0a;
  --brand-glow: rgba(213, 15, 15, .35);
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --info: #0284c7;
  --info-soft: #e0f2fe;
  --sidebar-bg: #0f172a;
  --sidebar-bg-2: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 7px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, .08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .14);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sidebar-w: 256px;
  --sidebar-w-collapsed: 76px;
}

html[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #111a2c;
  --surface-2: #16213a;
  --surface-3: #1b2742;
  --border: #22304d;
  --border-strong: #2f4165;
  --text: #e7ecf5;
  --text-2: #a3b1c9;
  --text-3: #64748b;
  --primary: #e0454b;
  --primary-strong: #ef6a6f;
  --primary-soft: #2c1416;
  --primary-text: #f5a3a6;
  --brand-a: #e0454b;
  --brand-b: #a3141a;
  --brand-glow: rgba(224, 69, 75, .35);
  --success: #4ade80;
  --success-soft: #123524;
  --warning: #fbbf24;
  --warning-soft: #3a2c10;
  --danger: #f87171;
  --danger-soft: #40151a;
  --info: #38bdf8;
  --info-soft: #0c2e44;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, .4);
  --shadow-lg: 0 14px 38px rgba(0, 0, 0, .5);
}

/* ---- Teclead Paper (matches the Teclead estimate/invoice PDF) ---- */
html[data-theme="teclead"] {
  --bg: #eceae7;
  --surface: #ffffff;
  --surface-2: #faf9f7;
  --surface-3: #f1f0ec;
  --border: #e2e0da;
  --border-strong: #cfccc2;
  --text: #080606;
  --text-2: #4e5357;
  --text-3: #8e959a;
  --primary: #d92027;
  --primary-strong: #b3171d;
  --primary-soft: #fbe9e9;
  --primary-text: #a3141a;
  --brand-a: #d92027;
  --brand-b: #a3141a;
  --brand-glow: rgba(217, 32, 39, .35);
  --sidebar-bg: #141416;
  --sidebar-bg-2: #222226;
  --sidebar-text: #9aa0a6;
  --sidebar-text-active: #ffffff;
  --shadow-sm: 0 1px 2px rgba(20, 20, 22, .05), 0 1px 3px rgba(20, 20, 22, .06);
  --shadow-md: 0 4px 12px rgba(20, 20, 22, .08);
  --shadow-lg: 0 12px 32px rgba(20, 20, 22, .14);
}

/* ---- Teclead Night (red on dark) ---- */
html[data-theme="teclead-dark"] {
  --bg: #0e0e10;
  --surface: #17171a;
  --surface-2: #1f1f23;
  --surface-3: #26262b;
  --border: #2e2e34;
  --border-strong: #3d3d45;
  --text: #f3f3f5;
  --text-2: #b0b0b8;
  --text-3: #71717a;
  --primary: #e0454b;
  --primary-strong: #ef6a6f;
  --primary-soft: #2c1416;
  --primary-text: #f5a3a6;
  --brand-a: #e0454b;
  --brand-b: #a3141a;
  --brand-glow: rgba(224, 69, 75, .35);
  --sidebar-bg: #0a0a0c;
  --sidebar-bg-2: #1b1b1f;
  --sidebar-text: #8d8d96;
  --sidebar-text-active: #ffffff;
  --success: #4ade80;
  --success-soft: #123524;
  --warning: #fbbf24;
  --warning-soft: #3a2c10;
  --danger: #f87171;
  --danger-soft: #40151a;
  --info: #38bdf8;
  --info-soft: #0c2e44;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, .4);
  --shadow-lg: 0 14px 38px rgba(0, 0, 0, .5);
}

/* ---- Ocean (teal) ---- */
html[data-theme="ocean"] {
  --bg: #eef4f6;
  --surface: #ffffff;
  --surface-2: #f6fafb;
  --surface-3: #e9f2f4;
  --border: #dce8ea;
  --border-strong: #c4d6d9;
  --text: #0c1a20;
  --text-2: #3f5a63;
  --text-3: #7d98a0;
  --primary: #0e7490;
  --primary-strong: #155e75;
  --primary-soft: #e0f2f7;
  --primary-text: #164e63;
  --brand-a: #0e7490;
  --brand-b: #155e75;
  --brand-glow: rgba(14, 116, 144, .35);
  --sidebar-bg: #082f3b;
  --sidebar-bg-2: #0f4252;
  --sidebar-text: #9fc4ce;
  --sidebar-text-active: #ffffff;
}

/* ---- Deep Ocean (teal on dark) ---- */
html[data-theme="ocean-dark"] {
  --bg: #09131c;
  --surface: #0e1b26;
  --surface-2: #132332;
  --surface-3: #182b3c;
  --border: #1e3547;
  --border-strong: #2b4a61;
  --text: #e2f3fa;
  --text-2: #9fc4d4;
  --text-3: #5f8396;
  --primary: #22d3ee;
  --primary-strong: #67e8f9;
  --primary-soft: #0c2f3d;
  --primary-text: #a5f3fc;
  --brand-a: #22d3ee;
  --brand-b: #0891b2;
  --brand-glow: rgba(34, 211, 238, .35);
  --sidebar-bg: #060f16;
  --sidebar-bg-2: #10222f;
  --sidebar-text: #7fa8ba;
  --sidebar-text-active: #ffffff;
  --success: #4ade80;
  --success-soft: #123524;
  --warning: #fbbf24;
  --warning-soft: #3a2c10;
  --danger: #f87171;
  --danger-soft: #40151a;
  --info: #38bdf8;
  --info-soft: #0c2e44;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, .4);
  --shadow-lg: 0 14px 38px rgba(0, 0, 0, .5);
}

/* ---- Forest (green) ---- */
html[data-theme="forest"] {
  --bg: #eef4ee;
  --surface: #ffffff;
  --surface-2: #f6faf6;
  --surface-3: #e9f2e9;
  --border: #dde8dd;
  --border-strong: #c5d9c5;
  --text: #10231a;
  --text-2: #3d5a49;
  --text-3: #7d9c8a;
  --primary: #15803d;
  --primary-strong: #166534;
  --primary-soft: #e6f5e9;
  --primary-text: #14532d;
  --brand-a: #15803d;
  --brand-b: #166534;
  --brand-glow: rgba(21, 128, 61, .35);
  --sidebar-bg: #0c2b1c;
  --sidebar-bg-2: #13432b;
  --sidebar-text: #9ec9ae;
  --sidebar-text-active: #ffffff;
}

/* ---- Pine Night (green on dark) ---- */
html[data-theme="forest-dark"] {
  --bg: #0a130d;
  --surface: #101c14;
  --surface-2: #152519;
  --surface-3: #1a2d1f;
  --border: #22392a;
  --border-strong: #2f4c3a;
  --text: #e6f5ea;
  --text-2: #a3c9b0;
  --text-3: #64866f;
  --primary: #4ade80;
  --primary-strong: #86efac;
  --primary-soft: #123524;
  --primary-text: #bbf7d0;
  --brand-a: #4ade80;
  --brand-b: #22c55e;
  --brand-glow: rgba(74, 222, 128, .35);
  --sidebar-bg: #060d08;
  --sidebar-bg-2: #11261a;
  --sidebar-text: #83ad90;
  --sidebar-text-active: #ffffff;
  --success: #4ade80;
  --success-soft: #123524;
  --warning: #fbbf24;
  --warning-soft: #3a2c10;
  --danger: #f87171;
  --danger-soft: #40151a;
  --info: #38bdf8;
  --info-soft: #0c2e44;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, .4);
  --shadow-lg: 0 14px 38px rgba(0, 0, 0, .5);
}

/* ---- Sunset (warm orange) ---- */
html[data-theme="sunset"] {
  --bg: #f7f2ec;
  --surface: #ffffff;
  --surface-2: #fbf7f1;
  --surface-3: #f4ece2;
  --border: #eadfd2;
  --border-strong: #dcc9b4;
  --text: #2b1a12;
  --text-2: #6b4f3e;
  --text-3: #a68b76;
  --primary: #ea580c;
  --primary-strong: #c2410c;
  --primary-soft: #fdeee2;
  --primary-text: #9a3412;
  --brand-a: #ea580c;
  --brand-b: #c2410c;
  --brand-glow: rgba(234, 88, 12, .35);
  --sidebar-bg: #241307;
  --sidebar-bg-2: #3a200c;
  --sidebar-text: #d9b594;
  --sidebar-text-active: #ffffff;
}

/* ---- Dusk (warm amber on dark) ---- */
html[data-theme="sunset-dark"] {
  --bg: #170d0a;
  --surface: #231511;
  --surface-2: #2b1b15;
  --surface-3: #34211a;
  --border: #46301f;
  --border-strong: #5a3d2a;
  --text: #fdeee6;
  --text-2: #d9b094;
  --text-3: #96694e;
  --primary: #fb923c;
  --primary-strong: #fdba74;
  --primary-soft: #3a2415;
  --primary-text: #fed7aa;
  --brand-a: #fb923c;
  --brand-b: #ea580c;
  --brand-glow: rgba(251, 146, 60, .35);
  --sidebar-bg: #120a07;
  --sidebar-bg-2: #2b1b15;
  --sidebar-text: #c49a7c;
  --sidebar-text-active: #ffffff;
  --success: #4ade80;
  --success-soft: #123524;
  --warning: #fbbf24;
  --warning-soft: #3a2c10;
  --danger: #f87171;
  --danger-soft: #40151a;
  --info: #38bdf8;
  --info-soft: #0c2e44;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, .4);
  --shadow-lg: 0 14px 38px rgba(0, 0, 0, .5);
}

/* theme toggle icon: show moon in light themes, sun in dark themes */
.icon-moon { display: none; }
html[data-mode="dark"] .icon-sun { display: none; }
html[data-mode="dark"] .icon-moon { display: block; }

* { box-sizing: border-box; margin: 0; padding: 0; }
/* Any component-level `display` outranks the browser's own [hidden] rule, which is
   how a hide button ends up doing nothing. This is the one place that wins. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--text); }
svg { display: block; }

.app { display: flex; min-height: 100vh; }

/* ============ SIDEBAR ============ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  z-index: 40;
  transition: width .2s ease;
}

.sidebar-brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 60px 22px 22px;
}

.brand-mark {
  height: auto;
  display: grid; place-items: center;
  flex-shrink: 0;
  overflow: hidden;
}
.brand-logo { max-width: 212px; max-height: 110px; width: auto; height: auto; object-fit: contain; display: block; }
.brand-logo-fallback { display: none; width: 18px; height: 18px; }
/* the sidebar is dark in every theme, so keep the (black+red) logo readable via luminance inversion */
.brand-logo { filter: invert(1) hue-rotate(180deg); }

.brand-name { color: #fff; font-weight: 800; font-size: 17.5px; letter-spacing: .3px; white-space: nowrap; }
/* logo present -> hide the store-name text; only show text when the logo is missing */
.brand-mark.has-logo ~ .brand-name { display: none; }

.sidebar-nav { flex: 1; padding: 6px 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 10.5px 12px;
  border: none; border-radius: var(--radius-sm);
  background: transparent;
  color: var(--sidebar-text);
  font-size: 13.5px; font-weight: 500;
  text-align: left;
  transition: background .15s ease, color .15s ease;
  position: relative;
  white-space: nowrap;
}

.nav-item svg { width: 19px; height: 19px; flex-shrink: 0; }

.nav-item:hover { background: rgba(255, 255, 255, .06); color: #e2e8f0; }

.nav-item.active {
  background: linear-gradient(90deg, rgba(99, 102, 241, .28), rgba(99, 102, 241, .12));
  color: var(--sidebar-text-active);
}

.nav-item.active::before {
  content: "";
  position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 3.5px; border-radius: 4px;
  background: var(--primary);
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10.5px; font-weight: 700;
  padding: 1.5px 6px;
  border-radius: 20px;
  min-width: 18px; text-align: center;
}
.nav-badge[hidden] { display: none !important; }

.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255, 255, 255, .07); }

.sidebar-collapse-btn {
  position: absolute;
  top: 20px;
  right: 14px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 50%;
  background: rgba(255, 255, 255, .10);
  color: #fff;
}
.sidebar-collapse-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.sidebar-collapse-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.sidebar-collapse-btn svg { width: 19px; height: 19px; }

/* Desktop icon rail. The state is user-controlled and intentionally does not alter the mobile drawer. */
@media (min-width: 993px) {
  .app.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
  .app.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 18px 10px; gap: 0; }
  .app.sidebar-collapsed .brand-name,
  .app.sidebar-collapsed .brand-mark,
  .app.sidebar-collapsed .nav-item > span:not(.nav-badge),
  .app.sidebar-collapsed .user-meta,
  .app.sidebar-collapsed #profileBtn { display: none; }
  .app.sidebar-collapsed .sidebar-collapse-btn { top: 18px; right: 10px; }
  .app.sidebar-collapsed .sidebar-nav { padding: 6px 10px; }
  .app.sidebar-collapsed .nav-item { justify-content: center; gap: 0; padding: 11px 0; }
  .app.sidebar-collapsed .nav-item.active::before { left: -10px; }
  .app.sidebar-collapsed .nav-badge:not([hidden]) {
    display: grid;
    position: absolute;
    top: 4px;
    right: 4px;
    min-width: 15px;
    height: 15px;
    padding: 0 3px;
    place-items: center;
    font-size: 8px;
    line-height: 1;
    border: 2px solid var(--sidebar-bg);
  }
  .app.sidebar-collapsed .sidebar-foot { padding: 10px 6px; }
  .app.sidebar-collapsed .user-card { justify-content: center; gap: 2px; padding: 7px 0; }
}

.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  background: var(--sidebar-bg-2);
}

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-a), var(--brand-b));
  color: #fff;
  display: grid; place-items: center;
  font-size: 12.5px; font-weight: 700;
  flex-shrink: 0;
}

.user-meta { flex: 1; min-width: 0; }
.user-meta strong { display: block; color: #e2e8f0; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta span { font-size: 11.5px; color: var(--sidebar-text); white-space: nowrap; }

.sidebar-scrim {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .5);
  z-index: 35;
}

/* ============ MAIN / TOPBAR ============ */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}

.topbar-title { min-width: 0; }
.topbar-title h1 { font-size: 17px; font-weight: 700; letter-spacing: -.2px; }
.topbar-title p { font-size: 12.5px; color: var(--text-3); }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.global-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  width: min(320px, 30vw);
  transition: border-color .15s ease, box-shadow .15s ease;
}

.global-search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.global-search svg { width: 16px; height: 16px; color: var(--text-3); flex-shrink: 0; }
.global-search input { border: none; background: transparent; outline: none; width: 100%; font-size: 13px; color: var(--text); }
.global-search input::placeholder { color: var(--text-3); }

.icon-btn {
  display: grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  transition: background .15s, color .15s, border-color .15s;
  position: relative;
}

.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.ghost { border-color: var(--border); }

/* Backend connection badge (topbar) */
.conn-badge {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12.5px; font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}
.conn-badge:hover { background: var(--surface-3); color: var(--text); }
.conn-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); flex-shrink: 0; }
.conn-dot.connected { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.conn-dot.signin { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }
.conn-dot.demo { background: var(--text-3); }
.conn-badge[data-state="connected"] { border-color: var(--success); color: var(--success); }
.conn-badge[data-state="signin"] { border-color: var(--warning); color: var(--warning); }

.notif-dot {
  position: absolute; top: 7px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--surface);
}

/* v4.75 — new-email count on the bell, and the email block in the panel */
.notif-count {
  position: absolute; top: 2px; right: 2px;
  min-width: 17px; padding: 1px 5px;
  border-radius: 20px;
  background: var(--danger); color: #fff;
  border: 2px solid var(--surface);
  font-size: 10px; font-weight: 700; line-height: 1.35;
  text-align: center;
}
.notif-count[hidden] { display: none; }
.notif-wrap.has-unread-mail .notif-dot { display: none; }
.notif-mail-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 11px; font-weight: 700; letter-spacing: .3px;
  text-transform: uppercase; color: var(--text-2);
}
.notif-item.is-mail { cursor: pointer; }
.notif-item.is-mail:hover { background: var(--surface-2); }
.notif-item.is-mail strong { display: block; }
.notif-item.is-mail .notif-subject { color: var(--text); }
.notif-item.is-read { opacity: .55; }

.notif-wrap { position: relative; }

.notif-panel {
  position: absolute; right: 0; top: calc(100% + 10px);
  width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  overflow: hidden;
}

.notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.link-btn { background: none; border: none; color: var(--primary); font-size: 12px; font-weight: 600; }
.link-btn:hover { text-decoration: underline; }

.notif-item { display: flex; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.notif-item:last-child { border-bottom: none; }
.notif-item p { font-size: 12.5px; color: var(--text-2); margin-top: 1px; }
.notif-item strong { font-size: 13px; }

.notif-dot-sm { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.notif-dot-sm.warning { background: var(--warning); }
.notif-dot-sm.success { background: var(--success); }
.notif-dot-sm.info { background: var(--info); }

.menu-btn { display: none; }

/* ============ CONTENT LAYOUT ============ */
.content { padding: 24px; max-width: 1600px; width: 100%; margin: 0 auto; }

.view { display: none; animation: fadeUp .25s ease; }
.view.active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-h h3 { font-size: 14px; font-weight: 650; }
.ag-task { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line, #e6e8f0); border-radius: 10px; margin-bottom: 8px; background: var(--card, #fff); }
.ag-task .ag-ico { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 14px; flex: none; }
.ag-task .ag-body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.ag-task .ag-body strong { font-size: 13px; }
.ag-task .ag-body span { font-size: 12px; color: var(--text-3, #8a90a3); }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }
.view-head h2 { font-size: 15px; font-weight: 600; }
.view-head .hint { font-size: 12.5px; color: var(--text-3); }

/* ============ CARDS ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 18px 0;
}

.card-head h3 { font-size: 14px; font-weight: 650; letter-spacing: -.1px; }
.card-head .sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.card-body { padding: 16px 18px 18px; }

.grid { display: grid; gap: 18px; }

/* ============ KPI CARDS ============ */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 18px; margin-bottom: 18px; }

.kpi-card { position: relative; overflow: hidden; }
.kpi-card .card-body { padding-top: 14px; }

.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.kpi-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }

.kpi-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
}
.kpi-icon svg { width: 18px; height: 18px; }
.kpi-icon.indigo { background: var(--primary-soft); color: var(--primary); }
.kpi-icon.amber { background: var(--warning-soft); color: var(--warning); }
.kpi-icon.green { background: var(--success-soft); color: var(--success); }
.kpi-icon.red { background: var(--danger-soft); color: var(--danger); }

.kpi-value { font-size: 25px; font-weight: 750; letter-spacing: -.5px; line-height: 1.15; }
.kpi-note { margin-top: 6px; font-size: 11.5px; line-height: 1.35; color: var(--text-3); }
.kpi-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--text-3); }

.trend { display: inline-flex; align-items: center; gap: 3px; font-weight: 650; padding: 1px 7px; border-radius: 20px; font-size: 11.5px; }
.trend.up { color: var(--success); background: var(--success-soft); }
.trend.down { color: var(--danger); background: var(--danger-soft); }
.trend svg { width: 11px; height: 11px; }

/* ============ CHARTS ============ */
.chart-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; margin-bottom: 18px; }
.chart-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }

.chart-box { position: relative; }
.chart-box svg { width: 100%; display: block; }

.chart-tip {
  position: fixed; z-index: 60;
  background: var(--text);
  color: var(--surface);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  pointer-events: none;
  box-shadow: var(--shadow-md);
  white-space: nowrap;
  max-width: 240px;
}

.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-top: 10px; }
.chart-legend .dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -1px; }

/* v4.75 — bar charts drawn as rounded bars on a pale full-height track,
   with the whole column as the hover and click target. */
.chart-bar { transition: opacity .15s ease; }
.chart-col.is-clickable { cursor: pointer; }
.chart-col.is-clickable:hover .chart-bar { opacity: .82; }
.chart-col.is-clickable:hover .chart-track { fill-opacity: .18; }

/* v4.75 — the floating detail card that replaces the plain text tip */
.chart-tip.is-card {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 10px 12px;
  white-space: normal;
  min-width: 176px;
  max-width: 260px;
}
.ct-card .ct-title { font-size: 11px; font-weight: 600; color: var(--text-3); margin-bottom: 7px; }
.ct-card .ct-row { display: flex; align-items:center; justify-content: space-between; gap: 16px; font-size: 12px; color: var(--text-2); }
.ct-card .ct-row + .ct-row { margin-top: 5px; }
.ct-card .ct-label { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ct-card .ct-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.ct-card .ct-row strong { color: var(--text); font-weight: 700; white-space: nowrap; }

/* v4.76 — dashboard report cards: best sellers, team, invoice mix, customers */
.report-total { font-size: 22px; font-weight: 750; letter-spacing: -.4px; margin-top: 2px; }
.rank-list { display: flex; flex-direction: column; }
.rank-row { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--border); }
.rank-list .rank-row:last-child { border-bottom: none; }
.rank-row[role="button"] { cursor: pointer; }
.rank-row[role="button"]:hover { background: var(--surface-2); }
.rank-main { min-width: 0; flex: 1; }
.rank-main .cell-strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-value { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank-thumb { width: 38px; height: 38px; border-radius: 10px; flex: none; display: grid; place-items: center; background: var(--surface-3); color: var(--text-3); overflow: hidden; }
.rank-thumb img { width: 100%; height: 100%; object-fit: contain; }
.rank-thumb svg { width: 18px; height: 18px; }
.rank-avatar { width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-size: 12px; font-weight: 700; }
.stat-legend { display: grid; gap: 10px; align-content: center; }
.stat-legend-row { display: grid; grid-template-columns: 10px 1fr auto auto; align-items: center; gap: 10px; font-size: 12.5px; color: var(--text-2); }
.stat-legend-row .dot { width: 9px; height: 9px; border-radius: 3px; }
.stat-legend-row strong { color: var(--text); font-variant-numeric: tabular-nums; }
.stat-legend-row em { font-style: normal; color: var(--text-3); font-size: 11.5px; min-width: 46px; text-align: right; }
.tier-bubbles { display: flex; align-items: flex-end; gap: 12px; padding: 6px 0 14px; flex-wrap: wrap; }
.tier-bubble { width: var(--size, 60px); height: var(--size, 60px); border-radius: 50%; display: grid; place-content: center; text-align: center; color: #fff; background: var(--tier, var(--primary)); line-height: 1.1; }
.tier-bubble strong { font-size: 15px; font-weight: 750; }
.tier-bubble small { font-size: 10px; opacity: .88; text-transform: uppercase; letter-spacing: .4px; }
.cell-line { display: flex; align-items: center; gap: 10px; }
.cell-line img { width: 30px; height: 30px; object-fit: contain; border-radius: 6px; border: 1px solid var(--border); background: #fff; flex: none; }

/* ----- internal team calls ----- */
.voip-dial { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.voip-dial[disabled] { opacity: .45; cursor: not-allowed; }
/* Icon-only dialler, for the tight rows of a table (users, technicians). */
.voip-dial-icon { width: 30px; height: 30px; padding: 0; justify-content: center; }
.voip-dial-icon svg { width: 15px; height: 15px; }
.rank-avatar { position: relative; }
.rank-avatar.is-online::after {
  content: ""; position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px;
  border-radius: 50%; background: var(--success); border: 2px solid var(--surface);
}
.rank-avatar.is-busy { box-shadow: 0 0 0 2px var(--warning-soft), 0 0 0 3px var(--warning); }
.voip-note { margin: 10px 0 0; font-size: 12px; line-height: 1.45; color: var(--text-2); background: var(--warning-soft); border: 1px solid color-mix(in srgb, var(--warning) 34%, var(--border)); border-radius: var(--radius-xs); padding: 8px 10px; }
.voip-cap { display: grid; grid-template-columns: auto 130px 1fr; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.voip-cap:last-child { border-bottom: none; }
.voip-cap-label { font-weight: 650; color: var(--text); }
.voip-cap-text { color: var(--text-2); line-height: 1.45; }
@media (max-width: 640px) { .voip-cap { grid-template-columns: auto 1fr; } .voip-cap-text { grid-column: 1 / -1; } }

.voip-card {
  position: fixed; left: 24px; bottom: 20px; z-index: 101; width: 306px;
  display: flex; flex-direction: column; gap: 12px; padding: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); animation: voipIn .22s ease;
}
.voip-card[hidden] { display: none; }
.voip-head { display: flex; align-items: center; gap: 11px; }
.voip-avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); font-size: 13px; font-weight: 700;
}
.voip-meta { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.voip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 700; color: var(--text); }
.voip-status { font-size: 12px; color: var(--text-2); }
.voip-timer { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-2); flex: none; }
.voip-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.voip-btn {
  flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 12.5px; font-weight: 650; cursor: pointer;
}
.voip-btn svg { width: 16px; height: 16px; }
.voip-btn[hidden] { display: none; }
.voip-btn:hover { background: var(--surface-3); }
.voip-btn.is-accept { background: var(--success); border-color: var(--success); color: #fff; }
.voip-btn.is-accept:hover { background: color-mix(in srgb, var(--success) 86%, #000); }
.voip-btn.is-decline, .voip-btn.is-hangup { background: var(--danger); border-color: var(--danger); color: #fff; }
.voip-btn.is-decline:hover, .voip-btn.is-hangup:hover { background: color-mix(in srgb, var(--danger) 86%, #000); }
.voip-btn.is-mic.is-muted { background: var(--warning-soft); border-color: var(--warning); color: var(--text); }
.voip-card.is-incoming, .voip-card.is-ringing { border-color: color-mix(in srgb, var(--primary) 34%, var(--border)); }
.voip-card.is-live { border-color: color-mix(in srgb, var(--success) 42%, var(--border)); }
.voip-card.is-live .voip-status { color: var(--success); }
.voip-card.is-incoming .voip-avatar { animation: voipPulse 1.5s ease-in-out infinite; }
@keyframes voipIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes voipPulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 45%, transparent); } 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--primary) 0%, transparent); } }
@media (max-width: 768px) {
  .voip-card { left: 12px; right: 12px; top: 12px; bottom: auto; width: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .voip-card, .voip-card.is-incoming .voip-avatar { animation: none; }
}

.seg-control {
  display: inline-flex; background: var(--surface-3); border-radius: 9px; padding: 3px;
  gap: 2px;
}
.seg-control button {
  border: none; background: transparent; color: var(--text-2);
  font-size: 12px; font-weight: 600;
  padding: 5px 11px; border-radius: 7px;
  transition: background .15s, color .15s;
}
.seg-control button:hover { color: var(--text); }
.seg-control button.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

/* ============ TABLES ============ */
.table-wrap { overflow-x: auto; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 640px; }

.data-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-3); font-weight: 650;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--surface-2);
}

.data-table th:first-child { border-radius: 0; }
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background .12s; }
.data-table tbody tr:hover { background: var(--surface-2); }

.cell-strong { font-weight: 650; }
.cell-sub { font-size: 12px; color: var(--text-3); display: block; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 650;
  padding: 3px 9px; border-radius: 20px;
  white-space: nowrap;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.paid, .chip.in-stock, .chip.active, .chip.completed { color: var(--success); background: var(--success-soft); }
.chip.pending, .chip.low-stock, .chip.warning { color: var(--warning); background: var(--warning-soft); }
.chip.overdue, .chip.refunded, .chip.out-stock, .chip.inactive { color: var(--danger); background: var(--danger-soft); }
.chip.info { color: var(--info); background: var(--info-soft); }
.chip.neutral { color: var(--text-2); background: var(--surface-3); }

.stock-bar { width: 90px; height: 6px; background: var(--surface-3); border-radius: 6px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 8px; }
.stock-bar > span { display: block; height: 100%; border-radius: 6px; }
.stock-bar.ok > span { background: var(--success); }
.stock-bar.warn > span { background: var(--warning); }
.stock-bar.bad > span { background: var(--danger); }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: none; border-radius: 10px;
  font-size: 13px; font-weight: 600;
  padding: 9px 16px;
  transition: background .15s, box-shadow .15s, transform .05s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }

.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(79, 70, 229, .3); }
.btn-primary:hover { background: var(--primary-strong); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }

.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); }
.btn-secondary:hover { background: var(--surface-3); }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }

.btn-danger-soft { background: var(--danger-soft); color: var(--danger); }
.btn-danger-soft:hover { filter: brightness(.96); }

.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ============ FORMS ============ */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field .req { color: var(--danger); }

.input, .select, textarea.input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input::placeholder { color: var(--text-3); }
.input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.field-error { font-size: 12px; color: var(--danger); margin-top: 4px; display: none; }
.field-error.show { display: block; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.switch-row:last-child { border-bottom: none; }
.switch-row .s-label strong { display: block; font-size: 13.5px; }
.switch-row .s-label span { font-size: 12px; color: var(--text-3); }

.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0;
  background: var(--surface-3); border: 1px solid var(--border-strong);
  border-radius: 24px; cursor: pointer;
  transition: background .18s, border-color .18s;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm);
  transition: transform .18s;
}
.switch input:checked + .track { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { box-shadow: 0 0 0 3px var(--primary-soft); }

/* ============ MODAL ============ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(15, 23, 42, .55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn .15s ease;
}

.modal-backdrop[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: min(560px, 100%);
  max-height: 88vh;
  display: flex; flex-direction: column;
  animation: popIn .18s ease;
}
@keyframes popIn { from { opacity: 0; transform: scale(.97) translateY(8px); } to { opacity: 1; transform: none; } }

.modal.wide { width: min(760px, 100%); }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 { font-size: 15.5px; font-weight: 700; }

.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ============ TOASTS ============ */
.toast-stack {
  position: fixed; bottom: 20px; right: 20px; z-index: 100;
  display: flex; flex-direction: column; gap: 10px;
}

.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  min-width: 280px; max-width: 380px;
  font-size: 13px;
  animation: toastIn .25s ease;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.out { animation: toastOut .25s ease forwards; }

.toast .t-icon { width: 18px; height: 18px; flex-shrink: 0; }
.toast.success .t-icon { color: var(--success); }
.toast.error .t-icon { color: var(--danger); }
.toast.warning .t-icon { color: var(--warning); }
.toast.info .t-icon { color: var(--primary); }

@keyframes toastIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(24px); } }

/* ============ LOADING SKELETON ============ */
.skeleton { position: relative; overflow: hidden; background: var(--surface-3); border-radius: 8px; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.2s infinite;
}
html[data-theme="dark"] .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .06), transparent); }
@keyframes shimmer { 100% { transform: translateX(100%); } }

.sk-kpi { height: 110px; }
.sk-chart { height: 280px; }
.sk-line { height: 16px; margin-bottom: 10px; }
.sk-line.w60 { width: 60%; }
.sk-line.w40 { width: 40%; }

/* ============ EMPTY STATE ============ */
.empty-state { text-align: center; padding: 44px 20px; color: var(--text-3); }
.empty-state .e-icon {
  width: 52px; height: 52px; margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--surface-3);
  display: grid; place-items: center;
}
.empty-state .e-icon svg { width: 24px; height: 24px; color: var(--text-3); }
.empty-state h4 { color: var(--text-2); font-size: 14px; margin-bottom: 4px; }
.empty-state p { font-size: 12.5px; }

/* ============ POS ============ */
.pos-layout { display: grid; grid-template-columns: 1fr 380px; gap: 18px; align-items: start; }

.pos-toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.maximize-btn .restore-icon { display: none; }
.maximize-btn[aria-pressed="true"] .maximize-icon { display: none; }
.maximize-btn[aria-pressed="true"] .restore-icon { display: block; }
html:fullscreen { background: var(--bg); }
body.app-maximized-fallback .app { min-height: 100vh; }
body.app-maximized-fallback .main { min-height: 100vh; }
.pos-search { flex: 1; min-width: 180px; }

.cat-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.cat-chip {
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text-2); font-size: 12.5px; font-weight: 600;
  padding: 6px 13px; border-radius: 20px;
  transition: all .15s;
}
.cat-chip:hover { border-color: var(--primary); color: var(--primary); }
.cat-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 12px; }

.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px;
  text-align: left;
  transition: border-color .15s, box-shadow .15s, transform .1s;
  position: relative;
}
.product-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.product-card:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

.product-card .p-cat { font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-3); font-weight: 700; }
.product-card .p-name { font-size: 13px; font-weight: 650; margin: 5px 0 8px; line-height: 1.35; min-height: 35px; }
.product-card .p-foot { display: flex; align-items: center; justify-content: space-between; }
.product-card .p-price { font-weight: 750; font-size: 14px; }
.product-card .p-stock { font-size: 11px; color: var(--text-3); }
.product-card .p-stock.low { color: var(--warning); font-weight: 650; }

.cart-card { position: sticky; top: 84px; }
.cart-head { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.cart-head h3 { font-size: 14.5px; }
.cart-count { font-size: 11.5px; color: var(--text-3); }

.cart-items { max-height: 340px; overflow-y: auto; padding: 6px 16px; }

.cart-item { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px dashed var(--border); }
.cart-item:last-child { border-bottom: none; }
.ci-info { flex: 1; min-width: 0; }
.ci-info strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-info span { font-size: 12px; color: var(--text-3); }

.qty-ctrl { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.qty-ctrl button { width: 26px; height: 26px; border: none; background: var(--surface-2); color: var(--text-2); font-size: 15px; display: grid; place-items: center; }
.qty-ctrl button:hover { background: var(--surface-3); color: var(--text); }
.qty-ctrl span { width: 30px; text-align: center; font-size: 12.5px; font-weight: 650; }

.ci-remove { border: none; background: none; color: var(--text-3); padding: 4px; border-radius: 6px; }
.ci-remove:hover { color: var(--danger); background: var(--danger-soft); }
.ci-remove svg { width: 15px; height: 15px; }

.cart-summary { padding: 12px 16px 0; }
.sum-row { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; color: var(--text-2); }
.sum-row.total { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; font-size: 16px; font-weight: 750; color: var(--text); }

.cart-actions { padding: 14px 16px 16px; display: grid; gap: 10px; }
.pay-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pay-row-four { grid-template-columns: repeat(4, 1fr); }

.pay-method {
  border: 1px solid var(--border-strong); background: var(--surface);
  border-radius: 10px; padding: 9px 6px;
  font-size: 12px; font-weight: 650; color: var(--text-2);
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  transition: all .15s;
}
.pay-method svg { width: 17px; height: 17px; }
.pay-method:hover { border-color: var(--primary); color: var(--primary); }
.pay-method.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }

/* ============ RECEIPT ============ */
.receipt-doc { font-size: 13px; color: var(--text); }

/* Receipt totals panel (right-aligned, matches invoice totals) */
.rcpt-totals { display: flex; justify-content: flex-end; margin: 16px 0 4px; }
.rcpt-totals-inner {
  width: 320px; max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}
.rcpt-totals .rt-row {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 9px 16px;
  font-size: 13px; color: var(--text-2);
  border-bottom: 1px solid var(--border);
}
.rcpt-totals .rt-row:last-child { border-bottom: none; }
.rcpt-totals .rt-row span:first-child { color: var(--text-2); }
.rcpt-totals .rt-row span:last-child { font-weight: 650; color: var(--text); }
.rcpt-totals .rt-grand { background: var(--surface-3); }
.rcpt-totals .rt-grand span { font-size: 15px; font-weight: 800; color: #d92027; }
.rcpt-totals .rt-method span:last-child { text-transform: capitalize; }
.rcpt-totals .rt-change span:last-child { color: #1a7f4b; }

/* Paid badge */
.rcpt-paid-badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11px; font-weight: 700; letter-spacing: .6px;
  color: #1a7f4b;
  background: var(--success-soft);
  border: 1px solid var(--border);
  padding: 4px 12px; border-radius: 999px;
}
.rcpt-paid-badge::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--success);
}


/* ============ INVENTORY / MISC ============ */
.stat-chips { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }

.mini-stat { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.mini-stat .m-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.mini-stat .m-icon svg { width: 18px; height: 18px; }
.mini-stat .m-label { font-size: 11.5px; color: var(--text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.mini-stat .m-value { font-size: 18px; font-weight: 750; letter-spacing: -.3px; }

.toolbar-row { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar-row .spacer { flex: 1; }

.badge-row { display: flex; gap: 6px; }
.badge-sm { font-size: 11px; font-weight: 650; padding: 2px 8px; border-radius: 20px; background: var(--surface-3); color: var(--text-2); }
.badge-sm.primary { background: var(--primary-soft); color: var(--primary); }
.badge-sm.green { background: var(--success-soft); color: var(--success); }
.badge-sm.amber { background: var(--warning-soft); color: var(--warning); }

.progress-wrap { margin-top: 14px; }
.progress-head { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 6px; color: var(--text-2); }
.progress-head strong { color: var(--text); }
.progress { height: 8px; background: var(--surface-3); border-radius: 8px; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 8px; background: var(--primary); transition: width .5s ease; }
.progress.warn > span { background: var(--warning); }
.progress.bad > span { background: var(--danger); }

/* ============ SETTINGS ============ */
.settings-layout { display: grid; grid-template-columns: 220px 1fr; gap: 18px; align-items: start; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; padding: 10px; }
.settings-nav button {
  text-align: left; padding: 9px 12px; border: none; border-radius: 9px;
  background: transparent; color: var(--text-2); font-size: 13px; font-weight: 600;
}
.settings-nav button:hover { background: var(--surface-3); }
.settings-nav button.active { background: var(--primary-soft); color: var(--primary); }

/* ============ PLUGINS & INTEGRATIONS ============ */
.addons-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 4px; }
.addon-card {
  display: flex; gap: 13px; padding: 16px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); transition: border-color .15s ease, box-shadow .15s ease;
}
.addon-card.on { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.addon-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--surface-3); display: grid; place-items: center; font-size: 20px; flex-shrink: 0; }
.addon-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.addon-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.addon-title strong { font-size: 13.5px; }
.addon-body p { font-size: 12px; color: var(--text-3); line-height: 1.45; margin: 6px 0 10px; }
.addon-foot { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.addon-path { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: var(--text-2); background: var(--surface-3); padding: 2px 7px; border-radius: 6px; }
.addon-setup { font-size: 11.5px; color: var(--text-3); line-height: 1.45; border-top: 1px dashed var(--border); padding-top: 8px; }

/* ============ USER PROFILE MODAL ============ */
.profile-head { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.avatar-lg { width: 64px; height: 64px; border-radius: 50%; font-size: 22px; background: linear-gradient(135deg, var(--brand-a), var(--brand-b)); }
.profile-head-meta { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.profile-head-meta strong { font-size: 15px; }
.profile-head-meta span { font-size: 12.5px; color: var(--text-3); margin-bottom: 6px; }
.pf-account-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }

@media (max-width: 992px) { .addons-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .addons-grid { grid-template-columns: 1fr; } }

/* ============ RESPONSIVE ============ */
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
  .chart-grid-2 { grid-template-columns: 1fr; }
  .stat-chips { grid-template-columns: repeat(2, 1fr); }
  .pos-layout { grid-template-columns: 1fr 330px; }
}

@media (min-width: 769px) and (max-width: 992px) {
  .sidebar-collapse-btn { display: none; }
}
@media (max-width: 992px) {
  .sidebar { width: var(--sidebar-w-collapsed); }
  .sidebar .brand-name, .sidebar .nav-item span, .sidebar .user-meta, .sidebar .nav-badge { display: none; }
  .brand-mark { width: auto; height: 44px; }
  .brand-logo { max-height: 30px; }
  .sidebar-brand { justify-content: center; padding: 18px 10px; }
  .sidebar-nav { padding: 6px 10px; }
  .nav-item { justify-content: center; padding: 11px 0; }
  .nav-item.active::before { left: -10px; }
  .sidebar-foot { padding: 10px; }
  .user-card { justify-content: center; padding: 8px 0; }
  .pos-layout { grid-template-columns: 1fr; }
  .cart-card { position: static; }
  .settings-layout { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .menu-btn { display: grid; }
  .sidebar-collapse-btn { display: none; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    width: var(--sidebar-w) !important;
    transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar .brand-name, .sidebar .nav-item span, .sidebar .user-meta, .sidebar .nav-badge { display: initial; }
  .sidebar .nav-badge { display: block; }
  .sidebar-brand { justify-content: flex-start; padding: 24px 60px 22px 22px; }
  .sidebar-nav { padding: 6px 12px; }
  .nav-item { justify-content: flex-start; padding: 10.5px 12px; }
  .nav-item.active::before { left: 0; }
  .sidebar-foot { padding: 12px; }
  .user-card { justify-content: flex-start; padding: 9px 10px; }

  .topbar { padding: 12px 16px; gap: 10px; }
  .topbar-title p { display: none; }
  .global-search { width: auto; flex: 1; min-width: 0; }
  .content { padding: 16px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-chips { grid-template-columns: 1fr 1fr; gap: 12px; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .notif-panel { width: min(320px, calc(100vw - 32px)); }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

@media (max-width: 520px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .stat-chips { grid-template-columns: 1fr; }
  .kpi-value { font-size: 21px; }
  .top-avatar { display: none; }
  .pay-row { grid-template-columns: 1fr; }
  .pay-row.pay-row-four { grid-template-columns: repeat(2, 1fr); }
  .toast-stack { left: 16px; right: 16px; }
  .toast { min-width: 0; width: 100%; }
}

/* ============ INVOICE DOCUMENT (Teclead-style) ============ */
.invoice-doc { font-size: 13px; color: var(--text); }

.inv-head { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }

.inv-brand { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.inv-logo {
  width: 48%;
  min-width: 220px;
  height: auto;
  object-fit: contain;
  margin-bottom: 8px;
}
/* dark themes use a dark invoice surface -> invert the logo so it stays readable there */
html[data-mode="dark"] .inv-logo { filter: invert(1) hue-rotate(180deg); }
/* logo present -> hide the company name/tag; only show text when the logo is missing */
.inv-brand-name, .inv-brand-tag { display: none; }
.inv-logo.failed ~ .inv-brand-name, .inv-logo.failed ~ .inv-brand-tag { display: block; }
.inv-brand-name { font-weight: 750; font-size: 15px; }
.inv-brand-tag { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .5px; }

.inv-right { text-align: right; }
.inv-doc-title { font-size: 30px; font-weight: 800; letter-spacing: 1px; color: var(--text); line-height: 1.1; }
.inv-company { margin-top: 10px; font-size: 11.5px; line-height: 1.55; color: var(--text-2); }
.inv-company strong { display: block; font-size: 12.5px; color: var(--text); }
.inv-company span { display: block; }
.inv-company .inv-site { font-size: 12.5px; font-weight: 650; color: var(--invoice-accent, #d92027); }

.inv-meta { display: flex; justify-content: space-between; gap: 16px; padding: 18px 0 14px; }
.inv-label { font-size: 10.5px; font-weight: 750; text-transform: uppercase; letter-spacing: 1px; color: var(--text-3); margin-bottom: 6px; }
.inv-billto { line-height: 1.6; }
.inv-billto strong { font-size: 13.5px; }
.inv-billto span { display: block; font-size: 12px; color: var(--text-2); }

.inv-facts { text-align: right; font-size: 12px; line-height: 1.9; }
.inv-facts > div { display: flex; gap: 10px; justify-content: flex-end; }
.inv-facts span { color: var(--text-3); }
.inv-facts .chip { margin-left: 8px; }
.inv-facts .inv-grand {
  background: var(--surface-3);
  padding: 3px 10px;
  border-radius: 8px;
  margin-top: 2px;
}
.inv-facts .inv-grand strong { font-size: 13px; color: var(--text); }

.inv-table { width: 100%; border-collapse: collapse; }
.inv-table th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .8px;
  color: #fff; font-weight: 700;
  background: var(--invoice-accent, #d92027);
  padding: 9px 10px;
  border: none;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.inv-table th:nth-child(2), .inv-table th:nth-child(3), .inv-table th:nth-child(4) { text-align: right; }
.inv-table td { padding: 10px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.inv-table td:nth-child(2), .inv-table td:nth-child(3), .inv-table td:nth-child(4) { text-align: right; }
.inv-table td:nth-child(3), .inv-table td:nth-child(4) { font-weight: 650; }

.inv-total-row {
  display: flex; justify-content: flex-end; gap: 12px;
  padding: 12px 10px;
  font-size: 13.5px;
  border-top: 2px solid var(--text);
}
.inv-total-row span { color: var(--text-2); font-weight: 600; }
.inv-total-row strong { font-size: 15px; color: var(--invoice-accent, #d92027); }

.inv-notes { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.inv-terms { font-size: 11.5px; color: var(--text-2); line-height: 1.6; }
.inv-terms p { margin-bottom: 2px; }
.inv-terms pre { font-family: inherit; white-space: pre-wrap; margin-top: 8px; color: var(--text-2); font-size: 11.5px; line-height: 1.6; }

.inv-footer { margin-top: 18px; padding-top: 14px; border-top: 2px solid var(--invoice-accent, #d92027); display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.inv-footer-main { display: flex; flex-direction: column; gap: 2px; font-size: 11px; color: var(--text-2); line-height: 1.5; }
.inv-footer-main strong { font-size: 12.5px; color: var(--text); }
.inv-footer-note { font-size: 11px; color: var(--text-2); font-style: italic; align-self: flex-end; text-align: right; max-width: 42%; }

/* ============ PRINT (invoice only) ============ */
@media print {
  body * { visibility: hidden !important; }
  .invoice-doc, .invoice-doc * { visibility: visible !important; }
  .invoice-doc { position: absolute; left: 0; top: 0; width: 100%; box-shadow: none; border: none; color: #000; }
  .modal-backdrop { position: static !important; padding: 0 !important; background: #fff !important; }
  .modal { max-height: none !important; overflow: visible !important; width: 100% !important; box-shadow: none !important; }
  .modal-head, .modal-foot { display: none !important; }
  .modal-body { overflow: visible !important; padding: 0 !important; }
  .inv-total-row { border-color: #000; }
  .inv-table th { background: var(--invoice-accent, #d92027) !important; color: #fff !important; }
}

/* ============ FOCUS VISIBILITY ============ */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

/* Scrollbars */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
::-webkit-scrollbar-track { background: transparent; }

/* ============ THEME PICKER (Settings → Appearance) ============ */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(152px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.theme-card {
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  padding: 8px 8px 10px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.theme-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.theme-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}
.theme-preview {
  position: relative;
  display: block;
  height: 64px;
  border-radius: 9px;
  overflow: hidden;
  padding: 10px;
}
.tp-surface {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 6px;
  padding: 9px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .14);
}
.tp-surface i {
  display: block;
  height: 7px;
  border-radius: 4px;
  margin-bottom: 5px;
}
.tp-surface i:first-child { width: 74%; }
.tp-surface i:nth-child(2) { width: 54%; opacity: .55; }
.tp-surface i:nth-child(3) { width: 38%; opacity: .3; }
.tp-check {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  opacity: 0;
  transform: scale(.6);
  transition: opacity .15s, transform .15s;
}
.theme-card.active .tp-check { opacity: 1; transform: scale(1); }
.theme-name {
  display: block;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.theme-mode {
  display: block;
  font-size: 10.5px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-top: 2px;
}

/* ============ APP FOOTER ============ */
.app-footer {
  margin-top: auto;
  padding: 16px 24px 20px;
  text-align: center;
  font-size: 12px;
  color: var(--text-3);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}
.app-footer strong { color: var(--text-2); font-weight: 650; }
.app-footer a { color: var(--text-3); text-decoration: none; }
.app-footer a:hover { color: var(--primary); }
.af-mark {
  width: 7px; height: 7px; border-radius: 2px;
  background: #d92027;
  display: inline-block;
  margin-right: 2px;
}

/* ============ LOGO UPLOAD (Settings → Store Profile) ============ */
.logo-upload {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.logo-preview {
  width: 170px;
  height: 68px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 8px;
}
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-upload-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.logo-upload .hint { font-size: 12px; color: var(--text-3); }
html[data-mode="dark"] .logo-preview img { filter: invert(1) hue-rotate(180deg); }

/* ============ WOOCOMMERCE ============ */
.wc-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 992px) { .wc-layout { grid-template-columns: 1fr; } }
.wc-card h3 { margin: 0 0 6px; font-size: 15px; }
.wc-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; flex-wrap: wrap; }
.wc-sub { color: var(--text-3); font-size: 12.5px; margin: 0 0 14px; line-height: 1.55; }
.wc-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.wc-pill { font-size: 11.5px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.wc-pill.live { background: rgba(22, 163, 74, .16); color: #16a34a; }
.wc-pill.demo { background: rgba(245, 158, 11, .16); color: #f59e0b; }
.wc-pill.fail { background: rgba(220, 38, 38, .16); color: #dc2626; }
.wc-note { font-size: 12px; color: var(--text-3); margin: 10px 0 0; line-height: 1.55; }
.wc-stack { display: flex; flex-direction: column; gap: 18px; }
.wc-log { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; max-height: 250px; overflow-y: auto; }
.wc-log-item { display: flex; gap: 10px; align-items: baseline; font-size: 12.5px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); color: var(--text-2); }
.wc-log-item.err { background: rgba(220, 38, 38, .09); color: var(--danger); }
.wc-log-t { color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.wc-log-empty { font-size: 12.5px; color: var(--text-3); padding: 10px; }

/* form helper hint (e.g. auto-selected tier) */
.field-hint { font-size: 11.5px; color: var(--text-3); margin-top: 5px; line-height: 1.45; }

/* ============ CRM ============ */
.crm-board-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 12px; }
.crm-board-head h3 { margin: 0; font-size: 15px; }
.crm-board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
@media (max-width: 1200px) { .crm-board { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .crm-board { grid-template-columns: 1fr; } }
.crm-col { background: var(--surface-2); border-radius: 12px; padding: 10px; min-height: 110px; }
.crm-col-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.crm-col-count { background: var(--surface-3); color: var(--text-2); border-radius: 999px; padding: 1px 8px; font-size: 11px; }
.crm-col-total { margin-left: auto; color: var(--text-3); font-weight: 650; font-size: 11.5px; }
.crm-col-body { display: flex; flex-direction: column; gap: 8px; }
.crm-empty { font-size: 12px; color: var(--text-3); text-align: center; padding: 14px 6px; border: 1px dashed var(--border-strong); border-radius: 10px; }
.crm-deal { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.crm-deal-top { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.crm-deal-title { font-size: 13px; font-weight: 700; color: var(--text); }
.crm-deal-val { font-size: 12.5px; font-weight: 750; color: var(--primary); white-space: nowrap; }
.crm-deal-meta { font-size: 11.5px; color: var(--text-3); margin-bottom: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crm-deal-actions { display: flex; gap: 4px; }
.crm-split { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 992px) { .crm-split { grid-template-columns: 1fr; } }
.crm-task-list, .crm-notes { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; max-height: 300px; overflow-y: auto; }
.crm-task { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 10px; background: var(--surface-2); }
.crm-task-check { width: 22px; height: 22px; flex-shrink: 0; border-radius: 7px; border: 1.5px solid var(--border-strong); background: transparent; color: transparent; display: grid; place-items: center; cursor: pointer; }
.crm-task-check svg { width: 14px; height: 14px; }
.crm-task.done .crm-task-check { background: var(--success); border-color: var(--success); color: #fff; }
.crm-task.done .crm-task-title { text-decoration: line-through; color: var(--text-3); }
.crm-task-body { flex: 1; min-width: 0; }
.crm-task-title { font-size: 13px; font-weight: 650; color: var(--text); }
.crm-task-meta { font-size: 11.5px; color: var(--text-3); }
.crm-note { background: var(--surface-2); border-radius: 10px; padding: 10px; }
.crm-note-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.crm-note-contact { font-weight: 700; font-size: 12.5px; color: var(--text); }
.crm-note-t { color: var(--text-3); font-size: 11px; }
.crm-note-head .icon-btn { flex-shrink: 0; }
.crm-note-text { font-size: 12.5px; color: var(--text-2); line-height: 1.5; }

/* small icon button for compact rows (CRM actions, table row actions) */
.icon-btn.sm { width: 26px; height: 26px; border-radius: 8px; }
.icon-btn.sm svg { width: 15px; height: 15px; }

/* CRM + WC panel cards: internal padding on all four sides */
.crm-panel { padding: 16px 18px 18px; }
.crm-panel .crm-task-list, .crm-panel .crm-notes { margin-top: 6px; }
.wc-card { padding: 16px 18px 18px; }

/* Advanced product import panel */
.wc-import-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.wc-import-stat { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.wc-import-stat span { font-size: 11.5px; color: var(--text-3); }
.wc-import-stat strong { font-size: 20px; color: var(--text); font-variant-numeric: tabular-nums; }
.wc-import-stat strong.err { color: var(--danger); }
.wc-import-controls { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-bottom: 12px; }
.wc-import-controls label { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px; color: var(--text-3); font-weight: 600; }
.wc-import-controls .select, .wc-import-controls .input { min-width: 120px; }
.wc-import-check { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 500 !important; color: var(--text-2) !important; }
.wc-import-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.wc-import-errors { margin-top: 12px; font-size: 12px; color: var(--danger); display: flex; flex-direction: column; gap: 4px; }

/* URL import (external product page → name + image) */
.wc-import-url { margin-bottom: 16px; padding: 14px; border: 1px dashed var(--border); border-radius: 12px; background: var(--surface-2); }
.wc-url-label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; font-weight: 600; color: var(--text); }
.wc-url-label span { font-size: 11.5px; font-weight: 400; color: var(--text-3); }
.wc-url-row { display: flex; gap: 10px; margin-top: 10px; }
.wc-url-row .input { flex: 1; }
.wc-url-preview { margin-top: 12px; }
.wc-url-loading { font-size: 12.5px; color: var(--text-3); }
.wc-url-error { font-size: 12.5px; color: var(--danger); }
.wc-url-result { display: flex; align-items: center; gap: 12px; }
.wc-url-result img { width: 48px; height: 48px; object-fit: contain; border-radius: 8px; border: 1px solid var(--border); background: #fff; flex-shrink: 0; }
.wc-url-nophoto { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--border); background: #fff; flex-shrink: 0; }
/* Multi-product URL extract: header + tick list */
.wc-url-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.wc-url-head strong { font-size: 13px; color: var(--text); }
.wc-url-all { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-2); cursor: pointer; user-select: none; }
.wc-url-all input { width: 15px; height: 15px; cursor: pointer; accent-color: #d92027; }
.wc-url-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.wc-url-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); cursor: pointer; transition: border-color .12s, background .12s;
}
.wc-url-item:hover { border-color: var(--border-strong); background: var(--surface-2); }
.wc-url-item input { width: 16px; height: 16px; cursor: pointer; accent-color: #d92027; flex-shrink: 0; }
.wc-url-item img { width: 40px; height: 40px; object-fit: contain; border-radius: 7px; border: 1px solid var(--border); background: #fff; flex-shrink: 0; }
.wc-url-item .wc-url-nophoto { width: 40px; height: 40px; }
.wc-url-item-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.wc-url-item-meta strong { font-size: 12.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wc-url-item-meta span { font-size: 11px; color: var(--text-3); }

.wc-url-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.wc-url-meta strong { font-size: 13px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wc-url-meta span { font-size: 11.5px; color: var(--text-3); }
.wc-url-meta .wc-url-src { font-size: 10.5px; color: var(--text-3); opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }

/* Queued product listing (what will be imported) */
.wc-import-list { margin-top: 14px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.wc-import-list-head { display: flex; align-items: center; justify-content: space-between; padding: 9px 12px; font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.wc-import-list-head span { color: var(--primary); font-weight: 700; }
.wc-import-list-row { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.wc-import-list-row:last-child { border-bottom: 0; }
.wc-import-list-row img { width: 28px; height: 28px; object-fit: contain; border-radius: 5px; border: 1px solid var(--border); background: #fff; flex-shrink: 0; }
.wc-import-list-row .cell-strong { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wc-import-list-cat { color: var(--text-3); font-size: 11px; flex-shrink: 0; }
.wc-import-list-more { padding: 7px 12px; font-size: 11.5px; color: var(--text-3); background: var(--surface-2); }

/* a touch more breathing room inside CRM list items */
.crm-task { padding: 11px 12px; }
.crm-note { padding: 12px; }
.crm-task-list, .crm-notes { gap: 10px; }

/* ================= CRM v2 (tabs, rows, activity, profile, stats, bars) ================= */
.crm-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.crm-tab { border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 999px; padding: 7px 14px; font-size: 13px; font-weight: 650; cursor: pointer; }
.crm-tab:hover { color: var(--text); border-color: var(--border-strong); }
.crm-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.crm-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); }
.crm-tag.muted { color: var(--text-3); }

.crm-prob { display: block; position: relative; height: 5px; background: var(--surface-3); border-radius: 999px; margin: 8px 0 8px; }
.crm-prob-bar { display: block; height: 100%; border-radius: 999px; }
.crm-prob-bar.hot { background: var(--success); }
.crm-prob-bar.warm { background: var(--warning); }
.crm-prob-bar.cold { background: var(--info); }
.crm-prob-txt { position: absolute; right: 0; top: -17px; font-size: 10.5px; font-weight: 700; color: var(--text-3); }
.crm-deal-close { font-size: 11px; color: var(--text-3); margin-bottom: 6px; }

.crm-list { display: flex; flex-direction: column; gap: 10px; }
.crm-row { display: flex; align-items: center; gap: 10px; padding: 11px 12px; background: var(--surface-2); border-radius: 10px; }
.crm-row-body { flex: 1; min-width: 0; }
.crm-row-title { font-size: 13px; font-weight: 700; color: var(--text); }
.crm-row-meta { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.crm-row-note { font-size: 11.5px; color: var(--text-2); margin-top: 4px; }

.crm-act { display: flex; align-items: flex-start; gap: 10px; padding: 11px 12px; background: var(--surface-2); border-radius: 10px; }
.crm-act-ic { width: 30px; height: 30px; flex-shrink: 0; border-radius: 8px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.crm-act-ic svg { width: 16px; height: 16px; }
.crm-act-body { flex: 1; min-width: 0; }
.crm-act-head { font-size: 11.5px; color: var(--text-3); margin-bottom: 2px; display: flex; gap: 4px; flex-wrap: wrap; }
.crm-act-type { font-weight: 700; color: var(--text-2); }
.crm-act-contact { font-weight: 650; color: var(--text-2); }
.crm-act-t { margin-left: auto; color: var(--text-3); }
.crm-act-text { font-size: 12.5px; color: var(--text-2); }

.crm-profile-head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.crm-profile-name { font-size: 16px; font-weight: 800; color: var(--text); }
.crm-profile-meta { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.crm-profile h3 { margin: 16px 0 8px; font-size: 13px; }

.crm-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.crm-stat { background: var(--surface-2); border-radius: 10px; padding: 12px; }
.crm-stat-v { display: block; font-size: 16px; font-weight: 800; color: var(--text); }
.crm-stat-l { font-size: 11px; color: var(--text-3); }
@media (max-width: 640px) { .crm-stats { grid-template-columns: repeat(2, 1fr); } }

.crm-bars { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.crm-bar-row { display: grid; grid-template-columns: 130px 1fr auto; gap: 10px; align-items: center; font-size: 12px; color: var(--text-2); }
.crm-bar { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.crm-bar span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.crm-bar-row b { font-size: 12px; color: var(--text); }

.crm-link { font-size: 12px; font-weight: 650; color: var(--primary); cursor: pointer; }
.crm-link:hover { text-decoration: underline; }

.crm-task.overdue { border: 1px solid var(--danger); }
.crm-task.overdue .crm-task-meta { color: var(--danger); }

/* ================= WhatsApp ================= */
.wa-top { color: #25D366 !important; }
.wa-top:hover { color: #128C7E !important; }
.icon-btn.wa-ic { color: #25D366; }
.icon-btn.wa-ic:hover { color: #128C7E; background: rgba(37, 211, 102, .12); }
.btn.wa-btn { background: #25D366; border-color: #25D366; color: #fff; display: inline-flex; align-items: center; gap: 7px; }
.btn.wa-btn:hover { background: #128C7E; border-color: #128C7E; color: #fff; }
.btn.wa-btn svg { width: 16px; height: 16px; }
.cell-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.send-log { display: flex; flex-direction: column; }
.send-log-row { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-top: 1px solid var(--border); font-size: 13px; }
.send-log-row:first-child { border-top: 0; }
.sl-ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: 0 0 auto; }
.sl-ic svg { width: 15px; height: 15px; }
.sl-ic.sl-auto { background: var(--warning-soft); color: var(--warning); }
.sl-main { display: flex; flex-direction: column; min-width: 0; }
.sl-muted { color: var(--text-3); font-size: 12px; }
.sl-tag { font-size: 11px; font-weight: 650; color: var(--text-2); background: var(--surface-3); border-radius: 6px; padding: 2px 7px; white-space: nowrap; }
.sl-time { margin-left: auto; color: var(--text-3); font-size: 12px; white-space: nowrap; }
.wa-float {
  position: fixed; right: 22px; bottom: 22px; z-index: 60;
  width: 56px; height: 56px; border-radius: 50%;
  background: #25D366; color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 6px 20px rgba(37, 211, 102, .45);
  transition: transform .18s ease, box-shadow .18s ease;
}
.wa-float:hover { transform: scale(1.08); box-shadow: 0 8px 26px rgba(37, 211, 102, .55); color: #fff; }
.wa-float svg { width: 28px; height: 28px; }

/* ================= WhatsApp module ================= */
.wa-layout { display: grid; grid-template-columns: 280px 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .wa-layout { grid-template-columns: 1fr; } }
.wa-list { padding: 0; overflow: hidden; }
.wa-list-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.wa-list-head h3 { margin: 0; font-size: 15px; }
.wa-convos { max-height: 560px; overflow-y: auto; }
.wa-convo { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 12px 16px; border: none; background: transparent; border-bottom: 1px solid var(--border); cursor: pointer; }
.wa-convo:hover { background: var(--surface-2); }
.wa-convo.active { background: var(--primary-soft); }
.wa-convo-avatar { width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.wa-convo-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.wa-convo-name { font-size: 13.5px; font-weight: 700; color: var(--text); }
.wa-convo-preview { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-unread { flex-shrink: 0; background: var(--success); color: #fff; border-radius: 999px; min-width: 18px; height: 18px; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; padding: 0 5px; }
.wa-list-empty { padding: 20px; text-align: center; color: var(--text-3); font-size: 13px; }

.wa-chat { display: flex; flex-direction: column; height: 620px; max-height: 620px; padding: 0; overflow: hidden; }
.wa-chat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.wa-chat-name { font-size: 15px; font-weight: 800; color: var(--text); }
.wa-chat-sub { font-size: 12px; color: var(--text-3); }
.wa-chat-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wa-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); }
.wa-msg { display: flex; flex-direction: column; max-width: 78%; }
.wa-msg.in { align-self: flex-start; }
.wa-msg.out { align-self: flex-end; align-items: flex-end; }
.wa-msg.sys { align-self: center; max-width: 90%; }
.wa-bubble { padding: 9px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.45; color: var(--text); background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.06); white-space: pre-wrap; word-break: break-word; }
.wa-msg.in .wa-bubble { background: var(--surface); border-bottom-left-radius: 4px; }
.wa-msg.out .wa-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.wa-msg.sys .wa-bubble { background: var(--surface-3); color: var(--text-2); font-size: 12px; text-align: center; }
.wa-time { font-size: 10.5px; color: var(--text-3); margin-top: 3px; padding: 0 4px; }
.wa-thread-empty, .wa-empty { flex: 1; display: grid; place-items: center; color: var(--text-3); font-size: 13px; }
.wa-input-row { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); align-items: center; }
.wa-input-row textarea { flex: 1; resize: none; min-height: 40px; }
.em-folders { display: flex; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.em-folder { border: 1px solid var(--border); background: transparent; color: var(--text-2); border-radius: 999px; padding: 5px 12px; font-size: 12px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.em-folder:hover { background: var(--surface-2); }
.em-folder.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.em-folder-count { background: var(--success); color: #fff; border-radius: 999px; min-width: 16px; height: 16px; font-size: 10px; display: grid; place-items: center; padding: 0 4px; }
.em-meta { font-size: 10.5px; opacity: .85; margin-bottom: 3px; }
.em-list .wa-convos { max-height: none; }
.em-section-title { font-size: 12px; font-weight: 800; color: var(--text); margin: 18px 0 10px; text-transform: uppercase; letter-spacing: .03em; }
.smtp-actions { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.em-status { font-size: 12px; color: var(--text-3); }
.em-attach-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.em-attach-row .btn svg { width: 14px; height: 14px; }
.em-attach-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.em-attach-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-3); color: var(--text-2); border-radius: 8px; padding: 5px 9px; font-size: 12px; }
.em-attach-chip svg { width: 13px; height: 13px; }
.em-attach-chip .icon-btn.sm { width: 20px; height: 20px; border-radius: 6px; margin-left: 2px; }
.em-attach-chip .icon-btn.sm svg { width: 12px; height: 12px; }
.em-attach-size { color: var(--text-3); font-size: 11px; }
.em-atts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.wa-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); cursor: pointer; }

.wa-rules { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 14px; max-height: 340px; overflow-y: auto; }
.wa-rule { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface-2); border-radius: 10px; }
.wa-rule-body { flex: 1; min-width: 0; }
.wa-rule-keys { font-size: 12px; font-weight: 700; color: var(--primary); margin-bottom: 2px; }
.wa-rule-reply { font-size: 12.5px; color: var(--text-2); }
.wa-rule-add { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 8px; align-items: center; }
@media (max-width: 640px) { .wa-rule-add { grid-template-columns: 1fr; } }

.wa-sale-picker { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 12px; }
.wa-sale-picker .field { flex: 1; margin: 0; }
.wa-sale-items { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; max-height: 260px; overflow-y: auto; }
.wa-sale-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--surface-2); border-radius: 8px; font-size: 13px; }
.wa-sale-item span:first-child { flex: 1; }
.wa-sale-item span:nth-child(2) { font-weight: 700; color: var(--text); }
.wa-sale-total { text-align: right; font-size: 14px; }
.wa-sale-empty { color: var(--text-3); font-size: 13px; padding: 10px 0; }

/* WhatsApp API settings */
.wa-webhook { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.wa-webhook code { flex: 1; font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-api-note { font-size: 12px; color: var(--text-3); margin: 10px 0 0; }

/* Purchasing + barcode scan */
.pos-scan {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  width: min(220px, 100%);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.pos-scan:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.pos-scan svg { width: 16px; height: 16px; color: var(--text-3); flex-shrink: 0; }
.pos-scan input { border: none; background: transparent; outline: none; width: 100%; font-size: 13px; color: var(--text); }
.pos-scan input::placeholder { color: var(--text-3); }
.chip.draft, .chip.ordered { color: var(--info); background: var(--info-soft); }
.chip.received { color: var(--success); background: var(--success-soft); }
.chip.partial { color: var(--warning); background: var(--warning-soft); }

/* Sortable table headers */
.th-sort {
  display: inline-flex; align-items: center; gap: 5px;
  width: 100%;
  background: none; border: 0; padding: 0; margin: 0;
  font: inherit; font-weight: inherit; color: inherit; cursor: pointer;
  white-space: nowrap; justify-content: flex-start;
}
.th-sort:hover { color: var(--primary); }
.th-sort:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
.th-sort-right { justify-content: flex-end; }
.sort-caret { font-size: 9px; color: var(--primary); line-height: 1; }

/* Serial / IMEI */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .3px; }

/* ============================================================
   Login screen
   ============================================================ */
.login-screen {
  position: fixed; inset: 0; z-index: 1000;
  display: grid; place-items: center;
  background: var(--bg);
  font-family: var(--font);
}
.login-screen[hidden] { display: none; }

.login-layout {
  display: grid;
  grid-template-columns: minmax(360px, 44%) 1fr;
  width: min(980px, 100vw);
  min-height: min(620px, 100vh);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .18);
}

/* Brand panel */
.login-brand {
  position: relative;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 44px 40px;
  color: #fff;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(213, 15, 15, .55), transparent 55%),
    radial-gradient(120% 100% at 0% 100%, rgba(0, 0, 0, .45), transparent 50%),
    linear-gradient(160deg, #3a0505 0%, #8a0a0a 45%, #0a0a0a 100%);
  overflow: hidden;
}
.login-brand::after {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(circle at 70% 30%, #000 0%, transparent 70%);
  pointer-events: none;
}
.login-brand-inner, .login-brand-foot { position: relative; z-index: 1; }

.login-logo {
  width: 64px; height: 64px; border-radius: 16px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  display: grid; place-items: center;
  overflow: hidden;
  backdrop-filter: blur(6px);
}
.login-logo img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.login-logo-fallback { font-size: 28px; font-weight: 800; color: #fff; }

.login-title {
  font-size: 40px; font-weight: 800; letter-spacing: -.5px;
  margin: 26px 0 8px; line-height: 1.05;
}
.login-tagline { font-size: 15px; color: rgba(255,255,255,.72); margin: 0 0 28px; line-height: 1.5; }

.login-features { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.login-features li { display: flex; align-items: center; gap: 12px; font-size: 14px; color: rgba(255,255,255,.88); }
.lf-ic {
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(213, 15, 15, .32);
  color: #ffd0d0;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}

.login-brand-foot { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: rgba(255,255,255,.55); }
.login-brand-foot strong { color: #fff; }
.login-brand-foot a { color: rgba(255,255,255,.7); text-decoration: none; }
.login-brand-foot a:hover { color: #fff; }

/* Form panel */
.login-form-panel {
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 48px 52px 24px;
  background: var(--surface);
}
.login-form-wrap { max-width: 360px; width: 100%; margin: 0 auto; }
.login-form-head { margin-bottom: 30px; }
.login-form-head h2 { font-size: 26px; font-weight: 800; letter-spacing: -.3px; margin: 0 0 6px; color: var(--text); }
.login-form-head p { font-size: 14px; color: var(--text-3); margin: 0; }

.login-field { margin-bottom: 18px; }
.login-field > label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 7px; }
.login-input {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  padding: 0 14px; height: 48px;
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.login-input:focus-within { border-color: #d50f0f; box-shadow: 0 0 0 3px rgba(213, 15, 15, .14); }
.login-input > svg { width: 19px; height: 19px; color: var(--text-3); flex-shrink: 0; }
.login-input input {
  flex: 1; border: none; background: transparent; outline: none;
  font-size: 15px; color: var(--text); font-family: inherit;
}
.login-input input::placeholder { color: var(--text-3); }

.login-eye {
  background: none; border: none; cursor: pointer; padding: 4px;
  color: var(--text-3); display: grid; place-items: center;
}
.login-eye svg { width: 19px; height: 19px; }
.login-eye:hover { color: var(--text-2); }

.login-error {
  background: var(--danger-soft); color: var(--danger);
  border: 1px solid #f5c6c6; border-radius: 9px;
  padding: 10px 14px; font-size: 13px; margin-bottom: 16px;
}

.login-submit {
  width: 100%; height: 50px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  background: linear-gradient(135deg, #d50f0f, #a30a0a);
  color: #fff; border: none; border-radius: 11px;
  font-size: 15px; font-weight: 700; font-family: inherit; cursor: pointer;
  transition: filter .15s, transform .05s;
  box-shadow: 0 8px 20px rgba(213, 15, 15, .32);
}
.login-submit:hover { filter: brightness(1.05); }
.login-submit:active { transform: translateY(1px); }
.login-submit:disabled { opacity: .7; cursor: default; }
.ls-spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
  animation: loginspin .7s linear infinite;
}
@keyframes loginspin { to { transform: rotate(360deg); } }

.login-alt { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 20px; }
.login-status { font-size: 12.5px; color: var(--text-3); display: inline-flex; align-items: center; gap: 7px; }
.login-status::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--warning);
  box-shadow: 0 0 0 3px var(--warning-soft);
}
.login-status.connected::before { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.login-status.demo::before { background: var(--text-3); box-shadow: 0 0 0 3px var(--border); }
.login-demo {
  background: none; border: none; cursor: pointer;
  font-size: 13px; font-weight: 600; color: #d50f0f; font-family: inherit;
}
.login-demo:hover { text-decoration: underline; }

.login-form-foot {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--text-3);
  margin-top: 30px; max-width: 360px; width: 100%; margin-left: auto; margin-right: auto;
}

@media (max-width: 820px) {
  .login-layout { grid-template-columns: 1fr; width: min(440px, 92vw); min-height: 0; }
  .login-brand { padding: 32px 28px; }
  .login-brand-foot { display: none; }
  .login-form-panel { padding: 32px 28px 20px; }
  .login-title { font-size: 30px; }
}

/* Email tracking status filter */
.em-track-filter{display:flex;align-items:center;gap:8px;padding:10px 12px;border-bottom:1px solid var(--border,#e5e7eb);font-size:12px;color:var(--muted,#64748b)}
.em-track-filter label{font-weight:600;white-space:nowrap}
.em-track-filter .select{min-height:32px;padding:5px 8px;font-size:12px;flex:1}

/* Email signature composer */
.em-signature-toggle{margin-top:8px;font-size:12px}
.em-signature-toggle input{accent-color:var(--primary)}
.em-signature-preview{margin-top:6px;padding:8px 10px;border-left:3px solid var(--primary);background:var(--surface-2);color:var(--text-3);font-size:11.5px;white-space:pre-line;max-height:90px;overflow:auto}

/* Email tracking status filter */
.em-track-filter{display:flex;align-items:center;gap:8px;padding:10px 12px;border-bottom:1px solid var(--border,#e5e7eb);font-size:12px;color:var(--muted,#64748b)}
.em-track-filter label{font-weight:600;white-space:nowrap}
.em-track-filter .select{min-height:32px;padding:5px 8px;font-size:12px;flex:1}

.em-signature-editor-preview{margin-top:8px;padding:12px;border:1px solid var(--border);border-radius:var(--radius-xs);background:var(--surface-2);color:var(--text-2);font-size:12px;line-height:1.45;min-height:54px;overflow:auto}
.em-signature-editor-preview a{color:var(--info);text-decoration:underline}
.em-signature-editor-preview img{max-width:180px;height:auto;display:block;margin-top:6px}
.em-signature-editor-preview table{border-collapse:collapse;max-width:100%}
.em-signature-editor-preview td{padding:3px 6px;border:1px solid var(--border)}
.em-signature-preview a{color:var(--info);text-decoration:underline}
.em-signature-preview img{max-width:160px;height:auto;display:block;margin-top:6px}

.notif-empty { padding: 18px 14px; color: var(--text-2); font-size: 13px; text-align: center; }
.notif-item.is-read { opacity: .62; }
.notif-item .notif-time { font-size: 11px; color: var(--text-3); margin-top: 3px; }
.grid-2 { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; }
.grid-3 { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:16px; }
@media (max-width:760px) { .grid-2,.grid-3 { grid-template-columns:1fr; } }


/* The mailbox reads like a mail client: a wide list of previews on the left, an
   icon toolbar, and the message laid out flat with its own pictures in place. */
.em-layout { grid-template-columns: minmax(300px, 34%) minmax(0, 1fr); gap: 0; align-items: stretch; }
.em-layout.is-reading { grid-template-columns: minmax(0, 1fr); }
.em-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.em-list .wa-list-head { align-items: flex-start; }
.em-list .wa-list-head h3 { font-size: 14.5px; letter-spacing: -.01em; }
.em-threads { flex: 1 1 auto; max-height: none; overflow-y: auto; }
.em-row { display: grid; gap: 2px; width: 100%; text-align: left; padding: 11px 14px; border: none; border-bottom: 1px solid var(--border); background: transparent; color: var(--text); font: inherit; cursor: pointer; }
.em-row:hover { background: var(--surface-2); }
.em-row.active { background: var(--primary); box-shadow: none; color: #fff; }
.em-row.active:hover { background: var(--primary); }
.em-row-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; min-width: 0; }
.em-row-who { display: flex; align-items: center; gap: 6px; min-width: 0; }
.em-row-from { min-width: 0; font-size: 13px; font-weight: 600; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.em-row.is-unread .em-row-from { font-weight: 800; color: var(--text); }
.em-row-date { flex: 0 0 auto; font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.em-row-subject { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.em-row.is-unread .em-row-subject { font-weight: 700; }
.em-row-snip { display: flex; align-items: center; gap: 6px; min-width: 0; }
.em-row-text { flex: 1 1 auto; min-width: 0; font-size: 11.8px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.em-row-clip { flex: 0 0 auto; color: var(--text-3); display: inline-flex; }
.em-row-clip svg { width: 12px; height: 12px; }
.em-row-count { flex: 0 0 auto; font-size: 10.5px; font-weight: 800; color: var(--text-2); background: var(--surface-3); border-radius: 999px; padding: 1px 5px; }
.em-row-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--primary) 35%, transparent); }
.em-row .em-star { opacity: 0; font-size: 14px; }
.em-row:hover .em-star, .em-row .em-star.active, .em-row:focus-visible .em-star { opacity: 1; }
/* The selected row is a solid block of the brand red, so every part of the
   preview has to switch to white with it — including the markers. */
.em-row.active .em-row-from, .em-row.active.is-unread .em-row-from, .em-row.active .em-row-subject,
.em-row.active .em-row-date, .em-row.active .em-row-text, .em-row.active .em-row-clip,
.em-row.active .em-star { color: #fff; }
.em-row.active .em-row-count { background: rgba(255,255,255,.24); color: #fff; }
.em-row.active .em-row-dot { background: #fff; box-shadow: 0 0 0 1.5px rgba(255,255,255,.4); }
.em-row.active:focus-visible { outline: 2px solid var(--primary); outline-offset: -3px; }

.em-chat { height: calc(100vh - 190px); min-height: 560px; max-height: none; }
.em-toolbar { display: flex; align-items: center; gap: 2px; padding: 7px 10px; border-bottom: 1px solid var(--border); background: var(--surface); flex-wrap: wrap; }
.em-tool-btn { width: 34px; height: 34px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--text-2); cursor: pointer; }
.em-tool-btn svg { width: 18px; height: 18px; }
.em-tool-btn:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.em-tool-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.em-tool-btn:disabled { opacity: .4; cursor: not-allowed; }
.em-tool-btn:disabled:hover { background: transparent; border-color: transparent; color: var(--text-2); }
.em-tool-btn.is-on { color: #a97400; background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 40%, transparent); }
.em-tool-btn.is-busy { opacity: .45; }
.em-doc { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 10px 26px 26px; background: var(--surface); }
.em-msgs { display: block; padding: 0; gap: 0; background: transparent; }
.em-message { max-width: none; padding: 15px 0 18px; border-bottom: 1px solid var(--border); }
.em-message:last-child { border-bottom: none; }
.em-msg-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 11px; }
.em-avatar { flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-2); font-size: 13px; font-weight: 800; }
.em-message.out .em-avatar { background: var(--primary-soft); color: var(--primary); }
.em-msg-who { flex: 1 1 auto; min-width: 0; display: grid; gap: 1px; }
.em-msg-who strong { font-size: 13.5px; font-weight: 700; color: var(--text); }
.em-msg-subject { font-size: 15px; font-weight: 650; letter-spacing: -.012em; color: var(--text); overflow-wrap: anywhere; }
.em-msg-line { font-size: 11.8px; color: var(--text-3); overflow-wrap: anywhere; }
.em-msg-meta { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }
.em-msg-when { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.em-send-status { border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.em-message-body { white-space: normal; word-break: break-word; line-height: 1.68; font-size: 13.5px; color: var(--text); }
.em-inline-img { display: block; max-width: min(100%, 640px); height: auto; margin: 12px 0; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); }
.em-inline-missing { display: inline-block; margin: 8px 0; padding: 6px 9px; border: 1px dashed var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text-3); font-size: 11.5px; }
.em-link { color:var(--primary); text-decoration:underline; text-underline-offset:2px; font-weight:650; overflow-wrap:anywhere; }
.em-link:hover { opacity:.78; }
.em-delivery-meta { margin-top:13px; font-size:11.5px; opacity:.8; }
.em-attachment-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(190px,1fr)); gap:10px; margin-top:16px; }
.em-attachment-card { min-width:0; display:flex; align-items:center; gap:10px; padding:9px; border:1px solid var(--border); border-radius:10px; background:var(--surface-2); color:var(--text); text-align:left; cursor:default; font:inherit; }
button.em-attachment-card { cursor:pointer; width:100%; }
button.em-attachment-card:hover { border-color:var(--primary); box-shadow:0 4px 12px rgba(217,32,39,.12); }
.em-attachment-thumb { width:44px; height:44px; object-fit:cover; border-radius:7px; flex:0 0 44px; background:var(--surface-3); }
.em-attachment-icon { width:44px; height:44px; display:grid; place-items:center; border-radius:7px; flex:0 0 44px; background:var(--primary-soft); color:var(--primary); font-size:10px; font-weight:850; letter-spacing:.03em; }
.em-attachment-copy { min-width:0; display:grid; gap:3px; flex:1; }
.em-attachment-copy strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:12px; }
.em-attachment-copy small { color:var(--text-3); font-size:10.5px; }
.em-attachment-open { font-size:10px; color:var(--primary); font-weight:800; }
.em-compose-attachment { position:relative; display:inline-flex; width:min(100%,360px); margin:4px 6px 4px 0; }
.em-compose-attachment .em-attachment-card { padding-right:38px; }
.em-compose-attachment > .icon-btn { position:absolute; top:5px; right:5px; z-index:1; background:var(--surface); }
.em-preview-modal { display:grid; gap:12px; }
.em-preview-modal img { width:100%; max-height:min(65vh,600px); object-fit:contain; border-radius:10px; background:var(--surface-2); border:1px solid var(--border); }
.em-preview-modal p { margin:0; color:var(--text-3); font-size:12px; }
.em-star { flex:0 0 auto; color:var(--text-3); font-size:18px; line-height:1; padding:2px 4px; cursor:pointer; border-radius:6px; }
.em-star:hover,.em-star.active { color:#d99a00; background:var(--warning-soft); }
.em-server-tracking { max-height:190px; overflow:auto; border-top:1px solid var(--border); }
.em-server-job { display:grid; gap:2px; padding:8px 12px; border-bottom:1px solid var(--border); font-size:11px; }
.em-server-job strong { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.em-server-job span,.em-server-job small { color:var(--text-3); font-size:10.5px; }
.em-recipient-detail { display:block; color:var(--text-3); font-size:10.5px; font-weight:500; margin-top:2px; }
@media (max-width:900px) {
  .em-layout, .em-layout.is-reading { grid-template-columns: 1fr; }
  .em-list { border-right: none; border-bottom: 1px solid var(--border); }
  .em-threads { max-height: 340px; }
  .em-chat { height: auto; min-height: 0; max-height: none; }
  .em-doc { overflow: visible; padding: 14px 16px 20px; }
}
@media (max-width:680px) { .em-attachment-grid { grid-template-columns: 1fr; } .em-msg-subject { font-size: 14px; } .em-msg-head { flex-wrap: wrap; } .em-msg-meta { width: 100%; justify-content: flex-end; } }
@media (prefers-reduced-motion: reduce) { .em-tool-btn, .em-row { transition: none; } }


/* Compose attachment drop target. */
.em-dropzone { margin-top:10px; min-height:112px; display:grid; place-items:center; align-content:center; gap:3px; padding:16px; border:1.5px dashed var(--border); border-radius:12px; background:var(--surface-2); color:var(--text-2); text-align:center; cursor:pointer; transition:.18s ease; outline:none; }
.em-dropzone:hover,.em-dropzone:focus-visible,.em-dropzone.is-dragging { border-color:var(--primary); background:var(--primary-soft); color:var(--primary); transform:translateY(-1px); }
.em-dropzone-icon { width:25px; height:25px; display:grid; place-items:center; border-radius:50%; background:var(--surface); border:1px solid var(--border); font-size:18px; line-height:1; }
.em-dropzone strong { font-size:13px; color:var(--text); }
.em-dropzone span:not(.em-dropzone-icon) { font-size:12px; }
.em-dropzone small { font-size:10.5px; color:var(--text-3); margin-top:3px; }

/* Dynamic template variables and richer template manager. */
.em-variable-controls { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.em-variable-controls .select { flex:1 1 240px; }
.em-template-editor-head > div:first-child { display:grid; gap:2px; }
.em-template-editor-head small { color:var(--text-3); font-size:10.5px; font-weight:500; }
.em-template-editor-head > div:last-child { display:flex; gap:8px; align-items:center; }
.em-template-toolbar { display:flex; justify-content:flex-end; margin:0 0 12px; }
.em-template-empty { padding:20px; border:1px dashed var(--border); border-radius:10px; text-align:center; color:var(--text-3); }

/* ============ POS FULL-SCREEN + MULTI-STORE CONTROL CENTRE ============ */
/* The navigation is removed only for an active POS full-screen session. */
html:fullscreen body.pos-fullscreen .sidebar,
body.app-maximized-fallback.pos-fullscreen .sidebar { display: none; }
html:fullscreen body.pos-fullscreen .sidebar-scrim,
body.app-maximized-fallback.pos-fullscreen .sidebar-scrim { display: none !important; }
html:fullscreen body.pos-fullscreen .main,
body.app-maximized-fallback.pos-fullscreen .main { width: 100%; min-width: 0; }
html:fullscreen body.pos-fullscreen .topbar,
body.app-maximized-fallback.pos-fullscreen .topbar { padding-left: 18px; padding-right: 18px; }

.store-hero { display: flex; justify-content: space-between; gap: 28px; padding: 25px 28px; margin-bottom: 18px; border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--border)); border-radius: var(--radius-lg); background: linear-gradient(120deg, color-mix(in srgb, var(--primary) 10%, var(--surface)), var(--surface)); }
.store-hero h2 { margin: 4px 0 8px; font-size: 25px; letter-spacing: -.5px; }
.store-hero p { max-width: 760px; color: var(--text-2); line-height: 1.55; }
.eyebrow { color: var(--primary); font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.store-hero-stats { min-width: 180px; display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-content: center; }
.store-hero-stats strong { font-size: 23px; color: var(--primary); text-align: right; }
.store-hero-stats span { color: var(--text-3); font-size: 12px; align-self: center; }
.store-toolbar { display: flex; justify-content: space-between; gap: 12px; margin: 0 0 18px; flex-wrap: wrap; }
.store-toolbar > div { display: flex; gap: 9px; flex-wrap: wrap; }
.store-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(355px, 1fr)); gap: 16px; margin-bottom: 18px; }
.store-card, .store-empty { padding: 20px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm); }
.store-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.store-card h3 { margin: 7px 0 4px; font-size: 17px; }
.store-card-head p { color: var(--text-3); font-size: 12px; overflow-wrap: anywhere; }
.store-provider { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 10.5px; font-weight: 800; letter-spacing: .04em; background: var(--surface-3); color: var(--text-2); }
.store-provider.woocommerce { background: #96588a22; color: #7d3f72; }
.store-provider.wix { background: #0c75df1c; color: #075aae; }
.store-status { display: inline-flex; align-items: center; white-space: nowrap; padding: 4px 8px; border-radius: 99px; font-size: 10.5px; font-weight: 800; }
.store-status.ok { color: #137333; background: #e6f4ea; }
.store-status.bad { color: #b3261e; background: #fce8e6; }
.store-status.warn { color: #9a6700; background: #fff4ce; }
.store-status.muted { color: var(--text-3); background: var(--surface-3); }
.store-stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px 0; margin-top: 12px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.store-stat-grid small { display: block; color: var(--text-3); font-size: 10.5px; margin-bottom: 3px; }
.store-stat-grid strong { display: block; font-size: 11.5px; color: var(--text-2); line-height: 1.35; }
.store-error { margin-top: 12px; color: var(--danger); font-size: 12px; line-height: 1.4; }
.store-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.store-actions .btn { font-size: 12px; padding: 7px 10px; }
.store-delete { margin-left: auto; color: var(--danger); }
.store-webhook { margin-top: 13px; font-size: 12px; color: var(--text-2); }
.store-webhook summary { cursor: pointer; color: var(--primary); font-weight: 700; }
.store-webhook p { margin: 8px 0; line-height: 1.45; }
.store-webhook code { display: block; overflow-wrap: anywhere; padding: 8px; background: var(--surface-2); border-radius: 6px; color: var(--text-2); font-size: 11px; }
.store-editor { margin: 0 0 18px; padding: 20px; border: 1px solid color-mix(in srgb, var(--primary) 45%, var(--border)); }
.store-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 15px; }
.store-form-grid .field-full { grid-column: 1 / -1; }
.store-toggle { align-self: end; padding-bottom: 11px; color: var(--text-2); }
.store-toggle label { font-size: 13px; font-weight: 600; }
.store-key-area { min-height: 94px; resize: vertical; }
.store-monitor-card { padding: 20px; margin: 18px 0; overflow: hidden; }
.store-table-wrap { overflow-x: auto; }
.store-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.store-table th { padding: 9px 10px; text-align: left; color: var(--text-3); border-bottom: 1px solid var(--border); font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; }
.store-table td { padding: 11px 10px; border-bottom: 1px solid var(--border); color: var(--text-2); vertical-align: middle; }
.store-table tr:last-child td { border-bottom: none; }
.store-guidance { padding: 20px; margin-top: 18px; }
.store-guidance h3 { margin-bottom: 14px; }
.store-guidance-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.store-guidance-grid strong { display: block; margin-bottom: 5px; font-size: 13px; }
.store-guidance-grid p { color: var(--text-2); font-size: 12px; line-height: 1.5; }
.store-guidance-grid code { font-size: 11px; }

@media (max-width: 760px) {
  .store-hero { display: block; padding: 20px; }
  .store-hero-stats { margin-top: 15px; max-width: 215px; }
  .store-form-grid, .store-guidance-grid { grid-template-columns: 1fr; }
  .store-form-grid .field-full { grid-column: auto; }
  .store-toolbar { display: block; }
  .store-toolbar > div + div { margin-top: 9px; }
}

/* ============ MOBILE PHONE ALIGNMENT PASS ============
   Keeps every RetailOS module inside the viewport while preserving readable
   controls and horizontal table access on small touch screens. */
html, body { max-width: 100%; overflow-x: hidden; }
img, picture, video, canvas { max-width: 100%; height: auto; }

@media (max-width: 768px) {
  .app, .main { min-width: 0; width: 100%; }
  .sidebar { width: min(86vw, 320px) !important; }
  .sidebar-brand { padding: 20px 18px 16px; }
  .sidebar-nav { padding: 6px 10px; }
  .nav-item { min-height: 44px; }

  .topbar { min-height: 58px; padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
  .topbar-title { flex: 1 1 120px; overflow: hidden; }
  .topbar-title h1 { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-actions { margin-left: 0; gap: 6px; flex: 0 0 auto; }
  .topbar-actions .icon-btn, .menu-btn { width: 40px; height: 40px; }
  .global-search { order: 3; flex: 1 0 100%; width: 100%; min-height: 40px; }
  .conn-badge { width: 40px; height: 40px; justify-content: center; padding: 0; font-size: 0; }
  .conn-badge .conn-dot { width: 10px; height: 10px; }
  .notif-panel { position: fixed; top: 62px; left: 12px; right: 12px; width: auto; max-height: min(72dvh, 520px); overflow-y: auto; }

  .content { padding: 12px; overflow-x: hidden; }
  .view-head { align-items: stretch; gap: 10px; margin-bottom: 14px; }
  .view-head > div, .view-head .seg-control { max-width: 100%; }
  .view-head .hint { line-height: 1.45; }
  .card { min-width: 0; }
  .card-head { align-items: flex-start; flex-wrap: wrap; padding: 14px 14px 0; }
  .card-head > div:last-child { width: 100%; justify-content: flex-start; }
  .card-body { padding: 14px; }
  .grid, .chart-grid, .chart-grid-2 { gap: 12px; }
  .kpi-grid, .stat-chips { gap: 10px; margin-bottom: 12px; }
  .kpi-card .card-body { padding: 13px; }

  .btn, .icon-btn, .input, .select, textarea.input { min-height: 40px; }
  .btn { padding: 9px 12px; }
  .btn-sm { min-height: 36px; padding: 7px 10px; }
  .icon-btn { width: 40px; height: 40px; }
  .seg-control { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .seg-control button { flex: 0 0 auto; }
  .form-grid-2, .grid-2, .grid-3 { grid-template-columns: 1fr; gap: 0; }
  .field { margin-bottom: 13px; }
  .switch-row { align-items: flex-start; }
  .switch-row .s-label { min-width: 0; }

  .table-wrap, .store-table-wrap { margin-left: -1px; margin-right: -1px; max-width: calc(100% + 2px); -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius-xs); }
  table.data-table { min-width: 560px; font-size: 12.5px; }
  .data-table th, .data-table td { padding: 10px 11px; }
  .data-table td { white-space: normal; }
  .cell-actions { justify-content: flex-start; min-width: 150px; gap: 6px; }
  .cell-actions .icon-btn { width: 36px; height: 36px; min-height: 36px; }

  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal, .modal.wide { width: 100%; max-height: min(92dvh, 760px); border-radius: 16px 16px 0 0; }
  .modal-head { padding: 14px 16px; }
  .modal-body { padding: 16px; }
  .modal-foot { padding: 12px 16px; flex-wrap: wrap; justify-content: stretch; }
  .modal-foot .btn { flex: 1 1 130px; }

  .pos-layout { gap: 12px; }
  .pos-toolbar { gap: 8px; margin-bottom: 12px; }
  .pos-toolbar .pos-search { flex: 1 0 100%; order: -1; }
  .pos-toolbar .btn { flex: 1 1 132px; }
  .cat-chips { flex-wrap: nowrap; overflow-x: auto; padding: 1px 0 5px; -webkit-overflow-scrolling: touch; }
  .cat-chip { flex: 0 0 auto; min-height: 36px; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
  .product-card { min-width: 0; }
  .cart-card { min-width: 0; }
  .cart-items { max-height: 300px; padding: 6px 12px; }
  .cart-actions { padding: 12px; grid-template-columns: 1fr; }

  .send-log-row { align-items: flex-start; gap: 8px; padding: 11px 12px; flex-wrap: wrap; }
  .send-log-row .sl-main { flex: 1 1 160px; }
  .send-log-row .sl-time { margin-left: 38px; }
  .sl-tag { margin-left: 38px; }

  .wa-layout { gap: 12px; }
  .wa-convos, .em-list .wa-convos { max-height: 280px; }
  .wa-chat { height: clamp(420px, 68dvh, 580px); max-height: none; }
  .wa-chat-head { padding: 12px; }
  .wa-chat-actions { width: 100%; justify-content: flex-start; }
  .wa-msgs { padding: 12px; }
  .wa-msg { max-width: 92%; }
  .wa-input-row { padding: 10px; align-items: flex-end; }
  .wa-input-row .btn { flex: 0 0 auto; }
  .wa-sale-picker { align-items: stretch; flex-wrap: wrap; }
  .wa-sale-picker .btn { flex: 1 1 140px; }
  .wa-webhook { align-items: flex-start; flex-wrap: wrap; }
  .wa-webhook code { flex: 1 1 210px; white-space: normal; overflow-wrap: anywhere; }

  .em-msgs { padding: 12px; }
  .em-message, .em-message-card { max-width: 100%; }
  .em-message-head { gap: 10px; flex-wrap: wrap; }
  .em-compose-attachment { width: 100%; margin-right: 0; }
  .em-template-editor-head, .em-template-editor-head > div:last-child { align-items: flex-start; flex-wrap: wrap; }

  .store-hero { padding: 18px; gap: 14px; }
  .store-hero h2 { font-size: 22px; }
  .store-hero-stats { min-width: 0; width: 100%; max-width: none; grid-template-columns: 54px 1fr; }
  .store-toolbar { gap: 10px; }
  .store-toolbar > div { width: 100%; }
  .store-toolbar .btn { flex: 1 1 145px; min-height: 42px; }
  .store-card-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .store-card, .store-empty, .store-editor, .store-monitor-card, .store-guidance { padding: 16px; }
  .store-card-head { flex-direction: column; }
  .store-status { align-self: flex-start; }
  .store-actions .btn { flex: 1 1 130px; min-height: 40px; }
  .store-delete { margin-left: 0; }
  .store-table { min-width: 560px; }
}

@media (max-width: 480px) {
  .content { padding: 10px; }
  .topbar { padding: 9px 10px; }
  .topbar-title h1 { font-size: 15px; }
  .conn-badge { display: none; }
  .kpi-grid, .stat-chips { grid-template-columns: 1fr; }
  .view-head .btn, .card-head > div:last-child .btn { flex: 1 1 100%; }
  .view-head .seg-control { width: 100%; }
  .view-head .seg-control button { flex: 1 0 auto; }
  .table-wrap, .store-table-wrap { border-left: 0; border-right: 0; border-radius: 0; }
  table.data-table { min-width: 520px; }
  .data-table th, .data-table td { padding: 9px 10px; }
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .product-card { padding: 10px; }
  .product-card h4 { font-size: 12.5px; }
  .cart-item { gap: 8px; }
  .cart-summary { padding-left: 12px; padding-right: 12px; }
  .wa-chat { height: clamp(390px, 66dvh, 520px); }
  .wa-input-row { flex-wrap: wrap; }
  .wa-input-row textarea { flex: 1 0 100%; }
  .wa-input-row .btn { width: 100%; }
  .store-stat-grid { grid-template-columns: 1fr; gap: 8px; }
  .store-card h3 { font-size: 16px; }
  .store-actions .btn, .store-toolbar .btn { flex-basis: 100%; }
  .store-webhook code { font-size: 10px; }
  .toast-stack { left: 10px; right: 10px; bottom: 12px; }
}

/* Compact phone landscape: reduce vertical chrome while keeping all controls reachable. */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 480px) {
  .topbar { min-height: 50px; padding: 7px 10px; }
  .btn, .icon-btn, .input, .select, textarea.input { min-height: 36px; }
  .btn-sm { min-height: 36px; padding: 7px 10px; }
  .icon-btn { width: 36px; height: 36px; }
  .global-search { min-height: 36px; }
  .content { padding: 10px 12px; }
  .view-head { margin-bottom: 10px; }
  .kpi-grid, .stat-chips { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wa-convos, .em-list .wa-convos { max-height: 130px; }
  .wa-chat { height: max(260px, calc(100dvh - 88px)); }
  .wa-chat-head { padding: 8px 10px; }
  .wa-msgs { padding: 9px 10px; }
  .wa-input-row { padding: 8px; }
  .modal, .modal.wide { max-height: 96dvh; }
  .store-hero { padding: 14px; }
  .store-card, .store-empty, .store-editor, .store-monitor-card, .store-guidance { padding: 14px; }
}

/* ---- Native Plugin Workflows ------------------------------------------------ */
.rwf-intro,.rwf-head{display:flex;align-items:flex-start;justify-content:space-between;gap:18px;margin-bottom:18px}
.rwf-intro h2,.rwf-head h2{font-size:22px;margin:3px 0 6px;color:var(--text)}
.rwf-intro p,.rwf-head p{max-width:760px;margin:0;color:var(--text-2);font-size:13.5px;line-height:1.55}
.rwf-eyebrow,.rwf-group{color:var(--primary);font-size:11px;font-weight:800;letter-spacing:.075em;text-transform:uppercase}
.rwf-kpis{margin-bottom:18px}
.rwf-filter-row{display:flex;gap:10px;margin:0 0 18px}.rwf-filter-row .input{min-width:0;flex:1}.rwf-filter-row .select{width:190px}
.rwf-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px}
.rwf-plugin-card{display:flex;min-height:224px;flex-direction:column;padding:17px}
.rwf-card-top,.rwf-card-meta,.rwf-inline-actions,.rwf-status-strip{display:flex;align-items:center;gap:8px}.rwf-card-top{justify-content:space-between;margin-bottom:13px}.rwf-card-top .chip,.rwf-status-strip .chip{white-space:nowrap}
.rwf-plugin-card h3{margin:0 0 7px;font-size:15px;line-height:1.3}.rwf-plugin-card p{margin:0;color:var(--text-2);font-size:12.5px;line-height:1.45;flex:1}.rwf-card-meta{justify-content:space-between;margin-top:14px;font-size:11.5px;color:var(--text-3)}.rwf-card-run{font-size:11.5px;color:var(--text-3);margin:9px 0}.rwf-card-run.muted,.rwf-last-run.muted{color:var(--text-3)}.rwf-plugin-card .btn{align-self:flex-start}
.rwf-head-copy{flex:1}.rwf-head-actions{display:flex;gap:8px;flex-wrap:wrap;justify-content:flex-end}.rwf-status-strip{flex-wrap:wrap;margin:-5px 0 15px}.rwf-notice{padding:13px 15px;margin-bottom:15px;background:var(--warning-soft);color:var(--text-2);font-size:13px;line-height:1.5;border:1px solid color-mix(in srgb,var(--warning) 24%,transparent)}
.rwf-workspace{display:grid;grid-template-columns:minmax(0,1fr) 272px;gap:18px}.rwf-main-card,.rwf-side-card{padding:18px}.rwf-main-card h3,.rwf-side-card h3{font-size:14px;margin:0 0 4px}.rwf-main-card .card-head{gap:12px;align-items:flex-start}.rwf-last-run{padding:10px 12px;margin:0 0 16px;background:var(--surface-2);font-size:12px;color:var(--text-2)}.rwf-section{margin:0 0 18px}.rwf-section .card-head{padding:0 0 10px;margin:0 0 10px;border-bottom:1px solid var(--border)}.rwf-report>h3{margin:0 0 10px}.rwf-cap-list{margin:0 0 22px;padding:0;list-style:none}.rwf-cap-list li{padding:8px 0;border-bottom:1px solid var(--border);font-size:12px;color:var(--text-2)}.rwf-cap-list li:before{content:"✓";color:var(--success);font-weight:800;margin-right:8px}.rwf-run-list{display:grid;gap:10px}.rwf-run-list div{padding-bottom:10px;border-bottom:1px solid var(--border)}.rwf-run-list strong,.rwf-run-list span{display:block}.rwf-run-list strong{font-size:12px}.rwf-run-list span{margin-top:3px;color:var(--text-3);font-size:11px}.rwf-list{display:grid;gap:8px}.rwf-list-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:11px 0;border-bottom:1px solid var(--border)}.rwf-list-row>div:first-child{min-width:0;flex:1}.rwf-list-row strong,.rwf-list-row span{display:block}.rwf-list-row strong{font-size:12.5px}.rwf-list-row span{margin-top:3px;color:var(--text-3);font-size:11.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.rwf-list-row>.chip{font-size:10px}.rwf-approval-detail{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;margin-bottom:14px}.rwf-approval-detail>div{padding:9px;background:var(--surface-2)}.rwf-approval-detail span,.rwf-approval-detail strong{display:block}.rwf-approval-detail span{font-size:10px;color:var(--text-3);text-transform:uppercase;font-weight:700}.rwf-approval-detail strong{font-size:12px;margin-top:3px}.rwf-approval-detail p{grid-column:1/-1;margin:4px 0 0;color:var(--text-2);font-size:13px;line-height:1.45}.rwf-settings-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px 14px}.rwf-settings-grid .field{margin:0}.rwf-settings-grid .toggle-row{padding:10px 0;border-bottom:1px solid var(--border)}.rwf-table td{max-width:220px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
@media(max-width:1180px){.rwf-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.rwf-workspace{grid-template-columns:1fr}.rwf-side-card{display:grid;grid-template-columns:1fr 1fr;gap:0 22px}.rwf-side-card h3:nth-of-type(2){grid-column:2;grid-row:1}.rwf-side-card .rwf-run-list{grid-column:2;grid-row:2}}
@media(max-width:700px){.rwf-intro,.rwf-head{display:block}.rwf-intro .btn,.rwf-head-actions{margin-top:12px}.rwf-head-actions{justify-content:flex-start}.rwf-grid{grid-template-columns:1fr}.rwf-filter-row{display:block}.rwf-filter-row .select{width:100%;margin-top:8px}.rwf-kpis{grid-template-columns:repeat(2,minmax(0,1fr))}.rwf-workspace{display:block}.rwf-side-card{display:block;margin-top:14px}.rwf-list-row{align-items:flex-start;flex-wrap:wrap}.rwf-inline-actions{flex-wrap:wrap}.rwf-approval-detail,.rwf-settings-grid{grid-template-columns:1fr}.rwf-approval-detail p{grid-column:auto}.rwf-table{font-size:11px}.rwf-table th,.rwf-table td{padding:8px 7px;max-width:150px}}
@media(max-width:420px){.rwf-kpis{grid-template-columns:1fr}.rwf-status-strip{gap:6px}.rwf-head-actions .btn{width:100%}.rwf-plugin-card{min-height:0}}

/* Multi-store event-driven sync progress and review queue */
.store-progress-card { margin: 0 0 18px; }
.store-progress-card .wc-card-head { align-items: center; }
.store-progress-card .wc-card-head > strong { font-size: 24px; color: var(--primary); font-variant-numeric: tabular-nums; }
.store-progress-track { height: 10px; width: 100%; background: var(--bg-3); border-radius: 999px; overflow: hidden; margin: 12px 0 8px; }
.store-progress-track > span { display: block; height: 10px; background: var(--primary); border-radius: 999px; }
.store-review-actions { display: flex; flex-wrap: wrap; gap: 6px; min-width: 190px; }
.store-monitor-card .store-table td { vertical-align: top; }
@media (max-width: 680px) {
  .store-progress-card .wc-card-head { align-items: flex-start; gap: 8px; }
  .store-progress-card .wc-card-head > strong { font-size: 20px; }
  .store-review-actions { min-width: 150px; }
  .store-review-actions .btn { flex: 1 1 auto; }
}


/* Strict multi-business context selector */
.business-context{display:flex;align-items:center;gap:7px;min-width:0;margin-right:4px}
.business-context-label{font-size:10px;letter-spacing:.08em;text-transform:uppercase;color:var(--muted);font-weight:700;white-space:nowrap}
.business-context-select{max-width:170px;min-height:36px;border:1px solid var(--border);border-radius:8px;background:var(--surface);color:var(--text);font:inherit;font-size:12px;font-weight:700;padding:0 28px 0 10px}
.business-context-select:disabled{opacity:.65;cursor:wait}
@media(max-width:1100px){.business-context-label{display:none}.business-context-select{max-width:150px}}
@media(max-width:760px){.business-context{order:-1;margin-right:auto}.business-context-select{max-width:138px;min-height:34px;font-size:11px}.topbar-actions .global-search{display:none}}
@media(max-width:480px){.business-context-select{max-width:122px}}


.business-admin-row{display:flex;align-items:center;justify-content:space-between;gap:14px;padding:14px 0;border-bottom:1px solid var(--border)}
.business-admin-row:last-child{border-bottom:0}
.business-admin-actions{display:flex;gap:8px;flex-wrap:wrap;justify-content:flex-end}
@media(max-width:640px){.business-admin-row{align-items:flex-start;flex-direction:column}.business-admin-actions{justify-content:flex-start;width:100%}}

/* v4.66 operations, email preview and mobile pass */
.dashboard-expense-card { margin: 0 0 18px; overflow: hidden; }
.dashboard-expense-summary { display: flex; align-items: baseline; gap: 12px; padding: 14px 18px; background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.dashboard-expense-summary strong { font-size: 24px; color: var(--primary); }
.dashboard-expense-summary span, .em-inbox-summary { color: var(--text-3); font-size: 11px; }
.dashboard-expense-table { min-width: 620px; }
.invoice-email-preview { display: grid; gap: 14px; }
.invoice-email-meta { display: grid; gap: 8px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.invoice-email-meta span { display: block; color: var(--text-3); font-size: 10px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.invoice-email-meta strong { display: block; margin-top: 3px; font-size: 12px; overflow-wrap: anywhere; }
.invoice-email-copy { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.invoice-email-copy h4 { margin: 0; padding: 10px 14px; background: var(--surface-2); font-size: 12px; }
.invoice-email-copy pre { margin: 0; padding: 14px; white-space: pre-wrap; font: 12px/1.55 inherit; color: var(--text-2); max-height: 190px; overflow: auto; }
.invoice-email-document { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.invoice-email-document summary { cursor: pointer; padding: 11px 14px; background: var(--surface-2); font-weight: 700; font-size: 12px; }
.invoice-email-document-body { max-height: 420px; overflow: auto; padding: 16px; background: #fff; color: #111; }
.em-thread-row { position: relative; align-items: flex-start; }
.em-thread-row .wa-convo-name small { display: block; margin-top: 2px; color: var(--text-3); font-size: 10px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.em-thread-row .wa-convo-preview { display: block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.em-thread-row .wa-convo-preview strong { color: var(--text); font-weight: 700; }
.em-thread-row.is-unread .wa-convo-name { font-weight: 800; }
.em-thread-date { flex: 0 0 auto; color: var(--text-3); font-size: 10px; white-space: nowrap; }
@media (max-width: 760px) {
  .dashboard-expense-summary { align-items: flex-start; flex-direction: column; gap: 3px; }
  .dashboard-expense-card .card-head { align-items: flex-start; flex-direction: column; }
  .dashboard-expense-card .card-head .btn { width: 100%; }
  .invoice-email-document-body { padding: 8px; }
  .invoice-email-meta { grid-template-columns: 1fr; }
  .em-thread-date { display: none; }
  .em-list .wa-list-head { align-items: flex-start; }
  .em-list .wa-list-head > div:last-child { flex-wrap: wrap; }
  .em-list .wa-list-head .btn { min-height: 36px; }
}
@media (max-width: 480px) {
  .topbar-actions { gap: 4px; }
  .topbar-actions .icon-btn, .topbar-actions .maximize-btn { width: 34px; height: 34px; }
  .sidebar { width: min(88vw, 300px); }
  .content { padding: 10px 8px; }
  .card-head { gap: 10px; align-items: flex-start; flex-wrap: wrap; }
  .card-head > div:first-child { min-width: 0; }
  .card-head h3 { font-size: 15px; }
  .view-head { gap: 8px; flex-wrap: wrap; }
  .view-head > div:last-child { width: 100%; }
  .view-head > div:last-child .btn { width: 100%; }
  .modal { width: calc(100vw - 16px); border-radius: 12px; }
  .modal-head { padding: 12px 14px; }
  .modal-body { padding: 14px; }
  .modal-foot { padding: 10px 14px; }
  .modal-foot .btn, .modal-foot a.btn { flex: 1 1 100%; justify-content: center; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .invoice-email-copy pre { max-height: 150px; }
  .em-message-head { align-items: flex-start; }
  .em-message-body { overflow-wrap: anywhere; }
  .em-threads .wa-convo { padding: 10px; }
  .em-threads .wa-convo-avatar { width: 30px; height: 30px; font-size: 10px; }
  .em-threads .wa-convo-body { min-width: 0; }
  .em-threads .em-star { padding: 2px; }
}

/* Mailbox paging, rich signature editor and the follow-up sequence builder. */
.em-pager { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--surface-2); }
.em-pager-label { flex: 1; text-align: center; font-size: 11px; color: var(--text-3); }
.em-pager .btn:disabled { opacity: .45; cursor: not-allowed; }

.em-rich-editor { display: grid; gap: 8px; }
.em-rich-toolbar { display: flex; flex-wrap: wrap; gap: 5px; padding: 6px; border: 1px solid var(--border-strong); border-radius: var(--radius-xs) var(--radius-xs) 0 0; background: var(--surface-3); }
.em-rich-btn { min-height: 30px; padding: 4px 10px; font: 12px var(--font); color: var(--text-2); background: var(--surface); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; }
.em-rich-btn:hover { border-color: var(--primary); color: var(--primary); }
.em-rich-area { min-height: 132px; max-height: 280px; overflow: auto; padding: 11px 12px; font-size: 13px; line-height: 1.5; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-top: 0; border-radius: 0 0 var(--radius-xs) var(--radius-xs); }
.em-rich-area:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
.em-rich-area:empty::before { content: attr(data-placeholder); color: var(--text-3); }
.em-rich-area img { max-width: 180px; height: auto; }
.em-rich-insert { display: grid; gap: 6px; }
.em-rich-insert-row { display: flex; gap: 6px; align-items: center; }
.em-rich-insert-row .input { flex: 1; min-width: 0; }
.em-rich-insert-row .btn { white-space: nowrap; }
.em-rich-tags { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.em-rich-tags .m-label { width: 100%; }
.em-rich-tag { padding: 3px 8px; font-size: 11px; color: var(--text-2); background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 999px; cursor: pointer; }
.em-rich-tag:hover { border-style: solid; border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.em-rich-error { padding: 7px 9px; color: var(--danger); background: var(--danger-soft); border: 1px solid rgba(220, 38, 38, .25); border-radius: var(--radius-xs); }
.em-rich-preview { display: grid; gap: 6px; margin-top: 2px; }

.em-seq-editor { display: grid; gap: 12px; }
.em-seq-card { display: grid; gap: 10px; padding: 13px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.em-seq-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.em-seq-name { flex: 1 1 210px; min-width: 0; margin: 0; }
.em-seq-actions { display: flex; gap: 9px; align-items: center; margin-left: auto; }
.em-seq-steps { display: grid; gap: 10px; }
.em-seq-step { display: grid; gap: 9px; padding: 11px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.em-seq-step-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.em-seq-step-head > .link-btn { margin-left: auto; }
.em-seq-delay, .em-seq-when { display: grid; grid-template-columns: auto 1fr; gap: 3px 6px; align-items: center; }
.em-seq-delay .m-label, .em-seq-when .m-label { grid-column: 1 / -1; }
.em-seq-delay input { width: 76px; }
.em-seq-when select { min-width: 174px; }
.em-var-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.em-var-chip { padding: 3px 7px; font: 10.5px ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--text-3); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; cursor: pointer; }
.em-var-chip:hover { border-color: var(--info); color: var(--info); background: var(--info-soft); }
.em-seq-invalid { display: grid; gap: 9px; justify-items: start; padding: 13px; background: var(--warning-soft); border: 1px dashed var(--warning); border-radius: var(--radius-sm); }
@media (max-width: 680px) {
  .em-seq-head, .em-seq-step-head { align-items: stretch; }
  .em-seq-actions, .em-seq-step-head > .link-btn { margin-left: 0; }
  .em-pager { flex-wrap: wrap; }
  .em-pager-label { order: -1; width: 100%; }
}

/* v4.75 — expense auto-categorisation (Settings → Expenses, Expenses screen) */
.field .hint { display: block; margin-top: 4px; font-size: 11.5px; color: var(--text-3); line-height: 1.45; }
.wa-toggle small { display: block; font-size: 11px; color: var(--text-3); font-weight: 400; }
.expense-rule { display: grid; gap: 8px; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.expense-rule-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.expense-rule-keys { display: flex; flex-wrap: wrap; gap: 6px; }
.expense-rule-keys .chip button { margin-left: 4px; }
.data-table tfoot td { font-weight: 700; border-top: 2px solid var(--border); color: var(--text); }

/* v4.75 — WhatsApp catalogue builder (RetailOS / WooCommerce -> Meta) */
.wa-catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(228px, 1fr)); gap: 12px; }
.wa-catalog-item { display: grid; grid-template-columns: 76px 1fr; gap: 12px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); }
.wa-catalog-item img { width: 76px; height: 76px; object-fit: cover; border-radius: var(--radius-xs); background: var(--surface-3); }
.wa-catalog-noimg { display: grid; place-items: center; width: 76px; height: 76px; border-radius: var(--radius-xs); background: var(--surface-3); color: var(--text-3); font-size: 11px; }
.wa-catalog-body { display: grid; gap: 4px; align-content: start; min-width: 0; }
.wa-catalog-body strong { font-size: 13px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; }
.wa-catalog-body .sub { font-size: 11.5px; color: var(--text-2); line-height: 1.4; }
.wa-catalog-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 2px; }
.wa-catalog-body .hint { font-size: 11px; color: var(--text-3); }
.data-table tr.row-selected td { background: var(--primary-soft); }
.data-table tr.row-selected td:first-child { border-radius: var(--radius-xs) 0 0 var(--radius-xs); }
@media (max-width: 680px) {
  .wa-catalog-item { grid-template-columns: 60px 1fr; }
  .wa-catalog-item img, .wa-catalog-noimg { width: 60px; height: 60px; }
}

/* v4.78 — workshop: technicians, jobs, parts by serial, camera shots, timesheets */
.m-of { font-size: 12px; font-weight: 600; color: var(--text-3); }
.select-sm { padding: 5px 26px 5px 9px; font-size: 12.5px; min-height: 30px; }
.check-row { display: flex; align-items: flex-start; gap: 9px; font-size: 12.5px; color: var(--text-2); padding: 5px 0; cursor: pointer; }
.check-row input { margin-top: 2px; accent-color: var(--primary); flex: none; }
.tech-dial { display: inline-flex; vertical-align: middle; margin-right: 6px; }
.tech-sect { margin: 18px 0 8px; font-size: 11.5px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--text-3); }
.tech-detail { display: block; }
.tech-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.tech-title { margin: 0 0 3px; font-size: 15px; font-weight: 700; color: var(--text); }
.tech-notes { margin: 8px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--text-2); }
.tech-people { display: flex; gap: 6px; flex-wrap: wrap; }
.tech-time-total { display: flex; align-items: baseline; gap: 9px; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-xs); margin-bottom: 10px; }
.tech-time-total strong { font-size: 19px; font-weight: 750; color: var(--text); font-variant-numeric: tabular-nums; }
.tech-time-total span { font-size: 11.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .4px; }
.tech-shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; }
.tech-shot { display: block; border: 1px solid var(--border); border-radius: var(--radius-xs); overflow: hidden; background: var(--surface-2); text-decoration: none; }
.tech-shot img { display: block; width: 100%; height: 104px; object-fit: cover; }
.tech-shot span { display: block; padding: 6px 8px; font-size: 11px; color: var(--text-2); border-top: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tech-cam { display: grid; gap: 12px; }
.tech-cam-stage { position: relative; background: var(--sidebar-bg); border-radius: var(--radius-sm); min-height: 210px; display: grid; place-items: center; overflow: hidden; }
.tech-cam-stage video { display: block; width: 100%; max-height: 320px; object-fit: cover; }
.tech-cam-msg { margin: 0; padding: 18px; font-size: 12.5px; color: #e2e8f0; text-align: center; }
.tech-cam-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.punch { display: inline-flex; align-items: center; margin: 2px 4px 2px 0; }
.punch-del { border: 0; background: none; color: var(--text-3); font-size: 15px; line-height: 1; padding: 0 4px; cursor: pointer; border-radius: var(--radius-xs); }
.punch-del:hover { color: var(--danger); background: var(--danger-soft); }
.punch.is-manual .chip { border: 1px dashed var(--border-strong); }

/* v4.80 — the technician's own workshop screen */
.btn-lg { padding: 11px 18px; font-size: 13.5px; border-radius: 10px; }
.btn-lg svg { width: 17px; height: 17px; }
.tech-cap-clock { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 14px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.tech-cap-name { display: flex; align-items: baseline; gap: 8px; font-size: 15px; font-weight: 700; color: var(--text); }
.tech-cap-name span { font-size: 11.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .4px; }
.tech-cap-job { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 9px; }
.tech-cap-job > label { font-size: 11.5px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .4px; }
.tech-cap-job .field-hint { flex-basis: 100%; }
.tech-cap-block { padding: 2px 16px 14px; }
.tech-cap-jobs { display: grid; grid-template-columns: repeat(auto-fill, minmax(292px, 1fr)); gap: 12px; }
.tech-job-card { display: grid; gap: 10px; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); }
.tech-job-card.is-late { border-color: var(--danger); }
.tech-job-card header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.tech-cap-meta { display: flex; flex-wrap: wrap; gap: 3px 14px; font-size: 11.5px; color: var(--text-3); }
.tech-cap-meta strong { color: var(--danger); font-weight: 700; }
.tech-cap-note { margin: 0; padding: 9px 11px; background: var(--surface-2); border-left: 2px solid var(--border-strong); border-radius: 0 var(--radius-xs) var(--radius-xs) 0; font-size: 12.5px; line-height: 1.45; color: var(--text-2); }
.tech-cap-note strong { margin-right: 4px; color: var(--text); font-weight: 700; }
.tech-cap-note span { display: block; margin-top: 3px; font-size: 11px; color: var(--text-3); }
.tech-cap-note.empty { background: none; border-left-color: var(--border); color: var(--text-3); }
.tech-cap-actions { display: flex; flex-wrap: wrap; gap: 7px; padding-top: 10px; border-top: 1px solid var(--border); }
.tech-cap-actions .btn svg { width: 14px; height: 14px; }
.tech-cap-actions .btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.tech-pick { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.tech-pick > div { min-width: 0; }
.tech-pick .cell-strong, .tech-pick .cell-sub { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tech-notes-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tech-notes-list li { padding: 9px 11px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-xs); }
.tech-notes-list .cell-strong { display: block; font-size: 12.5px; line-height: 1.45; }
.tech-notes-list .cell-sub { display: block; margin-top: 3px; font-size: 11px; }

/* The workshop dialler on the technician's own screen */
.tech-call-who { display: flex; align-items: center; gap: 9px; min-width: 0; }
.tech-call-face { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); box-shadow: 0 0 0 3px var(--surface-3); }
.tech-call-face.is-online { background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.tech-call-face.is-busy { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }
