/* GermanBev Command & Control — design system ported from mockup-4b-2-3-split.
 * Dark theme, purple accent, Inter + JetBrains Mono, mobile-first breakpoints.
 *
 * Breakpoints:
 *   < 720px  → mobile:  sidebar collapses to bottom tab bar, cards stack, forms full-width
 *   ≥ 720px  → desktop: shell grid with sidebar + top/bottom split
 */

*,
*::before,
*::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Dark-render native controls (select popups, scrollbars, date pickers) —
   * without this the OS paints the dropdown LIST white while options
   * inherit the app's light text (illegible; Alexander, 31 Aug 2026). */
  color-scheme: dark;
  --bg:          #0B0B10;
  --surface:     #131319;
  --card:        #1C1C26;
  --border:      #252535;
  --subtle:      #3A3A50;
  --muted:       #6B6B8A;
  --text:        #E2E2EE;

  --accent:      #7B6FF0;
  --accent-glow: rgba(123, 111, 240, 0.18);
  --amber:       #F5A623;
  --amber-glow:  rgba(245, 166, 35, 0.15);
  --red:         #F0506E;
  --red-glow:    rgba(240, 80, 110, 0.12);
  --green:       #2DD4A0;
  --green-glow:  rgba(45, 212, 160, 0.12);

  --topbar-h:    48px;
  --sidebar-w:   60px;
  --mobile-tab-h: 58px;

  --font-sans:   'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:   'JetBrains Mono', 'SF Mono', Menlo, monospace;
}

html, body {
  height: 100%;
  /* Pastel background: anchor on the bg near-black, wash two very-soft
   * radial glows across it — purple from top-left, green from bottom-right.
   * Low enough opacity (~6%) that it reads as ambient warmth, not as
   * chrome. Same gradient pattern the login screen already uses, now
   * carried through to the main shell. */
  background:
    radial-gradient(1400px circle at 15% -10%, rgba(123, 111, 240, 0.07), transparent 55%),
    radial-gradient(1000px circle at 92% 110%, rgba(45, 212, 160, 0.05), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select {
  font-family: inherit;
  color: inherit;
}
select option {
  background: var(--card);
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono { font-family: var(--font-mono); }

#app { height: 100%; }

/* ═══════════════════════════════════════════════════════════════
   LOGIN SCREEN
═══════════════════════════════════════════════════════════════ */

.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px circle at 20% -10%, rgba(123, 111, 240, 0.12), transparent 60%),
    radial-gradient(800px circle at 90% 110%, rgba(45, 212, 160, 0.07), transparent 60%),
    var(--bg);
}

.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 28px 24px;
}

.login-logo {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 20px;
}
.login-logo .logo-mark {
  width: 36px; height: 36px;
  background: var(--accent);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: #fff;
}
.login-logo-text {
  font-size: 15px; font-weight: 500; color: var(--text);
  letter-spacing: -0.01em;
}
.login-logo-text small {
  display: block;
  font-size: 10.5px; font-weight: 500; color: var(--muted);
  letter-spacing: 0.08em; text-transform: uppercase;
  margin-top: 2px;
}

.login-form { display: flex; flex-direction: column; gap: 12px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 11px; font-weight: 600;
  color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase;
}
.field input {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 11px 13px;
  font-size: 14px;
  color: var(--text);
  transition: border-color 0.15s;
}
.field input:focus { outline: none; border-color: var(--accent); }
.field input:disabled { opacity: 0.6; cursor: not-allowed; }

.login-submit {
  margin-top: 4px;
  background: var(--accent); color: #fff;
  border: none; border-radius: 9px;
  padding: 12px 14px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.login-submit:hover:not(:disabled) { opacity: 0.9; }
.login-submit:active:not(:disabled) { transform: translateY(1px); }
.login-submit:disabled { opacity: 0.5; cursor: not-allowed; }

.login-error {
  font-size: 12.5px; color: var(--red);
  padding: 8px 11px; margin-top: 4px;
  background: var(--red-glow);
  border: 1px solid rgba(240, 80, 110, 0.25);
  border-radius: 7px;
}

.login-footer {
  margin-top: 20px;
  font-size: 11px; color: var(--muted);
  text-align: center;
  letter-spacing: 0.02em;
}

/* Google sign-in button (above the password form when enabled) */
.google-signin {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%;
  padding: 11px 14px;
  margin-bottom: 14px;
  background: #fff; color: #1f1f1f;
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 14px; font-weight: 500;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.google-signin:hover { background: #f5f5f5; text-decoration: none; border-color: var(--subtle); }
.google-signin:active { transform: translateY(1px); }
.google-signin svg { flex-shrink: 0; }

.login-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 8px 0 14px;
  font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted);
}
.login-divider::before,
.login-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}

.login-fallback {
  display: block;
  width: 100%;
  margin: -4px 0 6px;
  text-align: center;
  font-size: 11px;
}

/* ═══════════════════════════════════════════════════════════════
   SHELL — topbar + sidebar + main
═══════════════════════════════════════════════════════════════ */

.shell {
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  height: 100dvh;
}

/* Topbar --------------------------------------------------------- */

.topbar {
  grid-column: 1 / -1;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 20px 0 0;
  z-index: 10;
}

.topbar-logo {
  width: var(--sidebar-w); height: var(--topbar-h);
  display: flex; align-items: center; justify-content: center;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}

.logo-mark {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  letter-spacing: -0.5px;
}

.topbar-title {
  padding: 0 20px;
  font-size: 13px; font-weight: 500; color: var(--muted);
  letter-spacing: 0.04em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-title span { color: var(--text); }

.topbar-spacer { flex: 1; }

.status-dots { display: flex; align-items: center; gap: 16px; }
.status-dot { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  animation: pulse-dot 2.5s ease-in-out infinite;
}
.dot.live { background: var(--green); }
.dot.warn { background: var(--amber); animation: none; }
.dot.down { background: var(--red); animation: none; }
.dot.unknown { background: var(--muted); animation: none; }
@keyframes pulse-dot { 0%, 100% { opacity: 1 } 50% { opacity: 0.35 } }

.topbar-time {
  margin-left: 20px; padding-left: 20px;
  border-left: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px; color: var(--muted);
  white-space: nowrap;
}

.topbar-user {
  margin-left: 16px; padding-left: 16px;
  border-left: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.topbar-user .avatar-small {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--card); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: var(--muted);
}
.topbar-user button {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 11px;
  padding: 4px 8px; border-radius: 5px;
}
.topbar-user button:hover { color: var(--text); background: var(--card); }

/* Sidebar -------------------------------------------------------- */

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  align-items: center;
  padding: 16px 0; gap: 4px;
}
.nav-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 0.15s, color 0.15s;
  position: relative; color: var(--muted); font-size: 18px;
  background: transparent; border: none;
}
.nav-icon:hover { background: var(--card); color: var(--text); }
.nav-icon.active { background: var(--accent-glow); color: var(--accent); }
.nav-icon .badge {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--red); border-radius: 50%;
  border: 1.5px solid var(--surface);
}
.nav-sep { width: 24px; height: 1px; background: var(--border); margin: 6px 0; }
.nav-icon.bottom { margin-top: auto; }

/* Main area ------------------------------------------------------ */

.main {
  display: flex;
  flex-direction: row;            /* desktop: chat on the left, tiles on the right */
  overflow: hidden;
  background: transparent;        /* lets the body's pastel glow show through */
  min-width: 0;
}

/* ═══════════════════════════════════════════════════════════════
   COMMAND CENTRE — chat takes the left half along the sidebar,
   intel tiles fill the right half top-to-bottom
═══════════════════════════════════════════════════════════════ */

.chat-wrap {
  flex: 0 0 50%;                  /* ~half the screen, beside the sidebar */
  min-height: 0; min-width: 0;
  display: flex; flex-direction: column;
  padding: 22px 28px 16px;
  border-right: 1px solid var(--border);
  position: relative;
}

.chat-placeholder {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  color: var(--muted);
  gap: 14px;
  padding: 24px;
}

/* ─── Daily briefing panel (replaces the Phase-3 placeholder) ─── */

.briefing-card {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.briefing-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.briefing-head .avatar {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, #7B6FF0, #5B8EF0);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: #fff; flex-shrink: 0;
}
.briefing-title {
  font-size: 14px; font-weight: 500; color: var(--text);
  letter-spacing: -0.01em;
}
.briefing-meta {
  margin-left: auto;
  font-size: 10.5px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted);
}
.briefing-refresh {
  background: none; border: 1px solid var(--border);
  color: var(--muted); cursor: pointer;
  width: 28px; height: 28px; border-radius: 7px;
  font-size: 14px;
  transition: border-color 0.15s, color 0.15s;
}
.briefing-refresh:hover { border-color: var(--accent); color: var(--text); }
/* Shared scroll container wraps briefing-body AND chat-window so they
 * stack naturally — the old layout had briefing-body flex:1 competing
 * with the chat-window for vertical space, producing a 50/50 split as
 * soon as chat had content. Single scroller fixes it. */
.briefing-scroll {
  flex: 1; min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.briefing-body {
  padding: 18px 22px;
  font-size: 13.5px; line-height: 1.6;
  color: var(--text);
}
.briefing-body p { margin-bottom: 10px; }
.briefing-body p:last-child { margin-bottom: 0; }
.briefing-body strong { font-weight: 600; color: var(--text); }

@media (max-width: 719px) {
  .briefing-body { padding: 14px 16px; font-size: 13px; }
  .briefing-meta { font-size: 10px; }
}
/* "Your month" — the sales role's landing hero, shown in place of the
   admin-only AI briefing. Sized for the narrow briefing rail. */
.mymonth-hero {
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
}
.mymonth-hero.good   { border-left-color: var(--green); }
.mymonth-hero.warn   { border-left-color: var(--amber); }
.mymonth-hero.urgent { border-left-color: var(--red); }
.mymonth-hero-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted);
}
.mymonth-hero-value {
  font-size: 26px; font-weight: 600; color: var(--text);
  margin-top: 4px; line-height: 1.15;
}
.mymonth-hero-sub { margin-top: 8px; font-size: 12px; color: var(--muted); }
.mymonth-rows { margin-top: 14px; }
.mymonth-row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; padding: 8px 2px;
  border-bottom: 1px solid var(--border);
}
.mymonth-row:last-child { border-bottom: none; }
.mymonth-label { font-size: 12.5px; color: var(--muted); }
.mymonth-value { font-size: 14px; font-weight: 600; color: var(--text); }
.mymonth-row.warn .mymonth-value { color: var(--amber); }

.chat-placeholder .phase-tag {
  font-size: 10px; font-weight: 600; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--accent);
  padding: 4px 10px; border-radius: 20px;
  background: var(--accent-glow);
}
.chat-placeholder h2 {
  font-size: 18px; font-weight: 500; color: var(--text);
  max-width: 420px; line-height: 1.45;
}
.chat-placeholder p {
  font-size: 13px; line-height: 1.6; max-width: 420px;
}

.chat-input-area { flex-shrink: 0; margin-top: 12px; }
.chat-input-area.disabled { opacity: 0.55; pointer-events: none; }
.input-box {
  background: var(--card);
  border: 1px solid var(--border); border-radius: 13px;
  padding: 10px 14px;
  display: flex; align-items: flex-end; gap: 10px;
}
.input-box textarea {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: 14px;
  resize: none; line-height: 1.5; max-height: 100px; min-height: 22px;
}
.input-box textarea::placeholder { color: var(--muted); }
.input-send {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--accent); border: none; cursor: not-allowed;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.input-send:hover:not(:disabled) { opacity: 0.85; }
.input-send:disabled { opacity: 0.5; cursor: not-allowed; }
.input-send svg { fill: #fff; }

/* Quick-prompt chips under the input */
.quick-prompts {
  display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap;
}
.qp {
  padding: 5px 11px; border-radius: 20px;
  border: 1px solid var(--border); background: transparent;
  color: var(--muted); font-size: 11.5px; font-family: inherit;
  cursor: pointer; transition: all 0.15s;
}
.qp:hover { border-color: var(--accent); color: var(--text); background: var(--accent-glow); }

/* In-briefing chat conversation area — no own scroll; the .briefing-scroll
 * container scrolls for everything. Separator bar when chat has content
 * so users see where the briefing ends and the conversation begins. */
.chat-window {
  display: flex; flex-direction: column; gap: 12px;
  padding: 14px 22px 14px;
  font-size: 13px;
  border-top: 1px dashed var(--border);
  margin-top: 6px;
}
.chat-window:empty { display: none; }
.chat-row { display: flex; gap: 10px; align-items: flex-start; }
.chat-row.user-row { flex-direction: row-reverse; }
.chat-row .avatar {
  width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #7B6FF0, #5B8EF0);
  font-size: 12px; color: #fff; flex-shrink: 0;
}
.chat-row .avatar.user {
  background: var(--card);
  border: 1px solid var(--border);
  font-size: 10px; font-weight: 600; color: var(--muted);
}
.bubble {
  max-width: min(560px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px 12px 12px 12px;
  padding: 10px 13px;
  line-height: 1.55;
}
.bubble.user-bubble {
  background: var(--accent-glow);
  border-color: rgba(123, 111, 240, 0.25);
  border-radius: 12px 4px 12px 12px;
  margin-left: auto; max-width: 420px;
}
.bubble p { margin: 0 0 6px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul { margin: 6px 0 0 18px; }
.bubble li { margin-bottom: 2px; }
.bubble strong { font-weight: 600; color: var(--text); }

/* Typing indicator */
.typing { display: flex; align-items: center; gap: 4px; padding: 2px 0; }
.typing span {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--muted);
  animation: tbounce 1.2s ease-in-out infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes tbounce { 0%,80%,100%{transform:translateY(0);opacity:0.4}40%{transform:translateY(-4px);opacity:1} }

@media (max-width: 719px) {
  .chat-window { padding: 0 16px 12px; }
  .bubble { font-size: 13px; }
}

/* Intelligence area ---------------------------------------------- */

.intelligence {
  flex: 1 1 50%;
  min-height: 0; min-width: 0;
  overflow-y: auto;
  padding: 22px 28px 22px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.intelligence-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted);
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 10px;
}
.intelligence-label::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* Evidence lists in the weekly review — narrative rows, not tabular data, so
   they read the same on desktop and phone without a row-card twin. */
.plain-list { list-style: none; margin: 0 0 16px; padding: 0; }
.plain-list li {
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: 13px; line-height: 1.5;
}
.plain-list li:last-child { border-bottom: 0; }

/* Cards — auto-fit grid in the right pane (1-2 columns depending on width).
   Mobile collapses to single-column further down via the @media block. */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  overflow-x: visible;
  padding-bottom: 6px;
}

.intel-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  position: relative; overflow: hidden;
  min-height: 150px;
  display: flex; flex-direction: column;
  transition: border-color 0.2s;
}
.intel-card:hover { border-color: var(--subtle); }
.intel-card::before {
  content: ''; position: absolute;
  left: 0; top: 0; bottom: 0; width: 3px;
  border-radius: 12px 0 0 12px;
}
.intel-card.urgent::before  { background: var(--red); }
.intel-card.warn::before    { background: var(--amber); }
.intel-card.info::before    { background: var(--accent); }
.intel-card.good::before    { background: var(--green); }
.intel-card.neutral::before { background: var(--subtle); }

.card-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-icon {
  width: 30px; height: 30px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.urgent  .card-icon { background: var(--red-glow); }
.warn    .card-icon { background: var(--amber-glow); }
.info    .card-icon { background: var(--accent-glow); }
.good    .card-icon { background: var(--green-glow); }
.neutral .card-icon { background: var(--surface); }

.card-tag {
  font-size: 10px; font-weight: 600; letter-spacing: 0.07em;
  text-transform: uppercase;
}
.urgent .card-tag { color: var(--red); }
.warn   .card-tag { color: var(--amber); }
.info   .card-tag { color: var(--accent); }
.good   .card-tag { color: var(--green); }
.neutral .card-tag { color: var(--muted); }

.card-text {
  font-size: 12.5px; color: var(--text); line-height: 1.55;
  margin-bottom: 14px;
  flex: 1;
}
.card-text strong { font-weight: 600; }

.card-stat {
  font-family: var(--font-mono);
  font-size: 22px; font-weight: 500;
  color: var(--text); line-height: 1; margin-bottom: 4px;
}
.card-stat-sub {
  font-size: 11.5px; color: var(--muted); margin-bottom: 12px;
}

.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  padding: 6px 12px; border-radius: 6px; border: none;
  font-size: 11.5px; font-weight: 500; cursor: pointer;
  font-family: inherit; transition: opacity 0.15s, background 0.15s, border-color 0.15s;
}
.btn-primary        { background: var(--accent); color: #fff; }
.btn-primary:hover  { opacity: 0.9; }
.btn-primary.amber  { background: var(--amber); color: #0B0B10; }
.btn-primary.red    { background: var(--red);   color: #fff; }
.btn-primary.green  { background: var(--green); color: #0B0B10; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}
.btn-ghost:hover { border-color: var(--subtle); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 11px; }
.action-btns { display: flex; gap: 4px; flex-wrap: nowrap; }

/* Empty / loading / error states for cards */
.card-empty {
  grid-column: 1 / -1;
  padding: 22px;
  text-align: center;
  font-size: 12.5px; color: var(--muted);
  border: 1px dashed var(--border); border-radius: 12px;
}

.card-loading {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  min-height: 150px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 12px;
}
.card-loading::before {
  content: ''; width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin-right: 10px;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════════════════
   PAGE — generic header + body for CRUD screens
═══════════════════════════════════════════════════════════════ */

.page {
  height: 100%;
  display: flex; flex-direction: column;
  overflow: hidden;
  /* .main is a flex row — without flex:1 a sparse page (empty states) shrinks
     to content width and its header band stops mid-screen on desktop. */
  flex: 1;
  min-width: 0;
}

.page-header {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.page-title {
  font-size: 18px; font-weight: 500; color: var(--text);
  letter-spacing: -0.01em;
}
.page-subtitle {
  font-size: 12px; color: var(--muted);
  margin-left: auto;
  font-family: var(--font-mono);
}
.page-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
/* A button row inside a form section (no auto margin): pill + actions, wraps on phones. */
.inline-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.page-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 32px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ═══════════════════════════════════════════════════════════════
   TABLE — desktop view for list screens
═══════════════════════════════════════════════════════════════ */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead th {
  text-align: left;
  font-size: 10.5px; font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.data-table tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.data-table tbody tr { transition: background 0.1s; }
.data-table tbody tr:hover { background: var(--card); }
.data-table tbody tr.clickable { cursor: pointer; }
.data-table td.num { font-family: var(--font-mono); text-align: right; }
.data-table td.muted { color: var(--muted); }

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--surface); color: var(--muted);
  border: 1px solid var(--border);
}
.pill.good    { color: var(--green); border-color: var(--green-glow); background: var(--green-glow); }
.pill.warn    { color: var(--amber); border-color: var(--amber-glow); background: var(--amber-glow); }
.pill.urgent  { color: var(--red);   border-color: var(--red-glow);   background: var(--red-glow); }
.pill.info    { color: var(--accent); border-color: var(--accent-glow); background: var(--accent-glow); }

/* Mobile: swap table for stacked cards */
.row-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
  display: block;
  color: var(--text);
  cursor: pointer;
}
.row-card:hover { border-color: var(--subtle); }
.row-card-top {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 4px; gap: 10px;
}
.row-card-title {
  font-size: 14px; font-weight: 500;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.row-card-sub {
  font-size: 12px; color: var(--muted);
  display: flex; gap: 10px; flex-wrap: wrap;
}
.row-card-sub .mono { color: var(--text); }

/* Empty state */
.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  border: 1px dashed var(--border);
  border-radius: 12px;
}
.empty-state strong { color: var(--text); font-weight: 500; }
.empty-state p + p { margin-top: 10px; }

/* ═══════════════════════════════════════════════════════════════
   FORMS — full-page CRUD forms
═══════════════════════════════════════════════════════════════ */

.form-wrap {
  max-width: 640px;
}
.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
  margin-bottom: 14px;
}
.form-section-title {
  font-size: 11px; font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.08em; text-transform: uppercase;
  margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}
.form-section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
}
.form-grid .full { grid-column: 1 / -1; }

.field input,
.field select,
.field textarea {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 11px 13px;
  font-size: 14px;
  color: var(--text);
  transition: border-color 0.15s;
  width: 100%;
}
.field select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='%236B6B8A'%3E%3Cpath d='M2 4l4 4 4-4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.field textarea { min-height: 72px; resize: vertical; font-family: inherit; }
.field input:focus,
.field select:focus,
.field textarea:focus { outline: none; border-color: var(--accent); }
/* Inline-row controls (price-calculator lines, tier editor) sit outside
 * .field wrappers — without this they render native white with the app's
 * grey text (illegible; Alexander, 12 Aug 2026). Same skin, tighter padding.
 * calc rows have a --card background, so their controls step down to
 * --surface; tier rows sit on the form background and use --card like
 * every .field input. */
.calc-row select,
.calc-row input,
.quote-line select,
.quote-line input,
.tier-row input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13.5px;
  color: var(--text);
}
.tier-row input { background: var(--card); }
.calc-row select,
.quote-line select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='%236B6B8A'%3E%3Cpath d='M2 4l4 4 4-4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
.calc-row select:focus,
.calc-row input:focus,
.quote-line select:focus,
.quote-line input:focus,
.tier-row input:focus { outline: none; border-color: var(--accent); }
.field .hint {
  font-size: 11px; color: var(--muted); margin-top: 2px;
}

/* Date-confirmation line on visit forms: the echo turns amber for a suspiciously
   old date and red for a future one, so a day/month swap is visible at a glance
   rather than only after the server refuses. Also used inside the edit overlay,
   where .field is present, so the selector must not require it. */
.hint.warn { color: var(--amber); }
.hint.urgent { color: var(--red); }

/* The shared visit fields (visitfields.js) nested inside a timeline form:
   a full-width inner grid so photo / location / claim sit in their own row. */
.visit-extras { padding: 10px 12px; border: 1px dashed var(--border); border-radius: 10px; }
/* Draft restored after a reload (3 Nov 2026) — sits above the visit form. */
.visit-draft-banner { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; margin-bottom: 10px; }
.visit-draft-banner .btn { margin-left: auto; }
.visit-photo-preview { max-width: 100%; margin-top: 8px; border-radius: 8px; }
.modal-body .hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.field.error input,
.field.error select { border-color: var(--red); }
.field-error-msg {
  font-size: 12px; color: var(--red);
  margin-top: 4px;
}

.form-footer {
  display: flex; justify-content: flex-end;
  gap: 10px; padding-top: 6px;
}
.form-footer .left { margin-right: auto; }

.form-banner {
  font-size: 13px; padding: 10px 13px;
  border-radius: 8px; margin-bottom: 12px;
  border: 1px solid var(--border); background: var(--card);
}
.form-banner.error  { color: var(--red);   border-color: rgba(240, 80, 110, 0.3);  background: var(--red-glow); }
.form-banner.warn   { color: var(--amber); border-color: rgba(245, 166, 35, 0.3);  background: var(--amber-glow); }
.form-banner.info   { color: var(--text);  border-color: rgba(123, 111, 240, 0.3); background: var(--accent-glow); }

/* Item-list inputs (Receive lines, Sale lines) */
.item-line {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 2fr 90px 1fr 32px;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}
.item-line .field label { font-size: 10px; letter-spacing: 0.07em; }
/* Pricing hints (volume rung / agreement) sit on their own full-width row under
   the line, so a long hint never makes one cell taller than its neighbours. */
.item-line .line-hints { grid-column: 1 / -1; margin-top: -4px; display: grid; gap: 2px; }
.item-line .line-hints[hidden] { display: none; }
.item-line-remove {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 32px; height: 38px;
  border-radius: 7px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.15s, color 0.15s;
}
.item-line-remove:hover { border-color: var(--red); color: var(--red); }

.item-add {
  margin-top: 4px;
  width: 100%;
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--muted);
  border-radius: 10px;
  padding: 11px;
  cursor: pointer;
  font-size: 13px;
  transition: border-color 0.15s, color 0.15s;
}
.item-add:hover { border-color: var(--accent); color: var(--text); }

.total-row {
  display: flex; justify-content: space-between;
  padding: 16px 4px 0;
  border-top: 1px solid var(--border);
  margin-top: 10px;
  font-size: 14px;
}
.total-row strong { font-family: var(--font-mono); font-size: 18px; color: var(--text); font-weight: 500; }

/* ═══════════════════════════════════════════════════════════════
   FINANCIALS — KPI grid + section blocks
═══════════════════════════════════════════════════════════════ */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--subtle);
  border-radius: 12px;
  padding: 16px 18px;
}
.kpi-card.good    { border-left-color: var(--green); }
.kpi-card.warn    { border-left-color: var(--amber); }
.kpi-card.info    { border-left-color: var(--accent); }
.kpi-card.urgent  { border-left-color: var(--red); }
.kpi-card.neutral { border-left-color: var(--subtle); }
.kpi-label {
  font-size: 10.5px; font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.08em; text-transform: uppercase;
  margin-bottom: 8px;
}
.kpi-value {
  font-size: 22px; font-weight: 500; color: var(--text);
  line-height: 1.1;
}
.kpi-sub {
  font-size: 11.5px; color: var(--muted);
  margin-top: 6px;
}
.kpi-line {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 13px;
}
.kpi-line .label {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em;
  color: var(--muted); text-transform: uppercase;
}

.section-block { margin-bottom: 22px; }

@media (max-width: 719px) {
  /* !important beats the inline `grid-template-columns:repeat(4,1fr)` the views
     set — without it the 4-col grid overflows the phone width (horizontal scroll,
     KPIs clipped off the right edge). */
  .kpi-grid { grid-template-columns: 1fr 1fr !important; gap: 10px; }
  .kpi-value { font-size: 18px; }
}

/* ═══════════════════════════════════════════════════════════════
   QUICK ACTIONS — top of the right pane
═══════════════════════════════════════════════════════════════ */

.quick-actions-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}
.qa-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 8px;
  cursor: pointer;
  font-size: 11.5px; font-weight: 500;
  color: var(--muted);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.qa-btn:hover { border-color: var(--accent); color: var(--text); background: var(--accent-glow); }
.qa-btn.green:hover { border-color: var(--green); background: var(--green-glow); }
.qa-icon { font-size: 20px; }

@media (max-width: 719px) {
  .quick-actions-row { grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
}

/* ═══════════════════════════════════════════════════════════════
   ACTIVITY TIMELINE — bottom of the right pane
═══════════════════════════════════════════════════════════════ */

.activity-timeline {
  display: flex; flex-direction: column; gap: 0;
}
.activity-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text);
}
.activity-row:last-child { border-bottom: none; }
.activity-icon {
  width: 26px; height: 26px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0;
  background: var(--surface);
}
.activity-body { flex: 1; min-width: 0; line-height: 1.45; }
.activity-body strong { font-weight: 600; }
.activity-date { flex-shrink: 0; font-size: 11px; font-family: var(--font-mono); }

/* ═══════════════════════════════════════════════════════════════
   MARKETING — campaign dashboard
═══════════════════════════════════════════════════════════════ */

.campaign-phase-tracker {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 18px;
}
.phase-current {
  font-size: 13px; color: var(--muted);
  margin-bottom: 12px;
}
.phase-current strong { color: var(--text); }
.phase-bars {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.phase-bar {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color 0.2s;
}
.phase-bar.phase-active {
  border-color: var(--phase-color, var(--accent));
  background: color-mix(in srgb, var(--phase-color, var(--accent)) 10%, var(--surface));
}
.phase-bar.phase-past { opacity: 0.5; }
.phase-label {
  font-size: 13px; font-weight: 600; color: var(--text);
}
.phase-active .phase-label { color: var(--phase-color, var(--accent)); }
.phase-dates {
  font-size: 11px; color: var(--muted); margin-top: 2px;
  font-family: var(--font-mono);
}

@media (max-width: 719px) {
  .phase-bars { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════════
   INVENTORY — search/filter bar, stock bars, batch expansion
═══════════════════════════════════════════════════════════════ */

.inv-filter-bar {
  display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap;
}
.inv-search {
  flex: 1; min-width: 180px;
  background: var(--card); border: 1px solid var(--border); border-radius: 9px;
  padding: 9px 13px; font-size: 13px; color: var(--text);
}
.inv-search:focus { outline: none; border-color: var(--accent); }
.inv-search::placeholder { color: var(--muted); }
.inv-filter-select {
  background: var(--card); border: 1px solid var(--border); border-radius: 9px;
  padding: 9px 13px; font-size: 13px; color: var(--text); cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='%236B6B8A'%3E%3Cpath d='M2 4l4 4 4-4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px;
}

/* Mini stock-level bar inside table cells */
.stock-bar {
  width: 100%; height: 3px; border-radius: 2px;
  background: var(--border); margin-top: 4px;
}
.stock-bar-fill {
  height: 100%; border-radius: 2px;
  transition: width 0.3s ease;
}

/* Batch expansion row */
.batch-detail-row { background: var(--surface) !important; }
.batch-detail-row:hover { background: var(--surface) !important; }
.batch-detail-cell { padding: 12px 16px !important; }
.batch-header {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 8px;
}
.batch-row {
  display: grid; grid-template-columns: 60px 1fr 1fr 1fr;
  gap: 10px; padding: 6px 0; font-size: 12.5px;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.batch-row:last-child { border-bottom: none; }
.batch-row.depleted { opacity: 0.45; }

@media (max-width: 719px) {
  .inv-filter-bar { flex-direction: column; }
  .inv-search { min-width: unset; }
  .inv-kpi { grid-template-columns: 1fr 1fr !important; }
  .batch-row { grid-template-columns: 1fr 1fr; }
}

/* ═══════════════════════════════════════════════════════════════
   PENDING SHIPMENTS (top of Inventory page when PO in_transit)
═══════════════════════════════════════════════════════════════ */

.pending-shipments {
  margin-bottom: 18px;
}
.pending-shipment-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--green);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 10px;
}
.pending-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
}
.pending-title {
  font-size: 14px; font-weight: 600;
  font-family: var(--font-mono);
}
.pending-sub {
  font-size: 12.5px; color: var(--muted);
  margin-top: 3px; line-height: 1.5;
}
.pending-sub strong { color: var(--text); font-family: var(--font-mono); }

/* ═══════════════════════════════════════════════════════════════
   CONFIRM DELIVERY view
═══════════════════════════════════════════════════════════════ */

.po-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 18px;
  font-size: 13px;
}
.po-summary > div {
  display: flex; align-items: center; gap: 10px;
}
.po-summary .label {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted);
  min-width: 120px;
}

.confirm-line {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.confirm-line-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
  margin-bottom: 12px;
  font-size: 13.5px;
}
.confirm-line-top .muted { font-size: 12px; }
.confirm-line-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}

/* Receive flow: wider item-line (product / qty / exp / remove) */
.item-line-wide {
  grid-template-columns: 2fr 90px 150px 32px;
}
/* PO create: product / qty / cost / expiration / remove */
.po-line-wide {
  grid-template-columns: 2fr 90px 110px 140px 32px;
}

/* Mobile: stack confirm-line grid */
@media (max-width: 719px) {
  .po-summary { grid-template-columns: 1fr; }
  .confirm-line-grid { grid-template-columns: 1fr; }
  .pending-top { flex-direction: column; align-items: stretch; }
  .pending-top .btn { width: 100%; }
  .item-line-wide {
    grid-template-columns: 1fr 1fr;
  }
  .item-line-wide > .field:first-child { grid-column: 1 / -1; }
  .item-line-wide .item-line-remove { grid-column: 2; justify-self: end; }
}

/* ═══════════════════════════════════════════════════════════════
   SETTINGS — subtle inline links + status rows
═══════════════════════════════════════════════════════════════ */

.linkish {
  background: none; border: none;
  color: var(--muted);
  font-size: 11px; padding: 0 4px;
  cursor: pointer; text-decoration: underline;
  font-family: inherit;
}
.linkish:hover { color: var(--red); }

.status-row {
  display: flex; align-items: center; gap: 8px;
  padding-top: 10px;
}

/* ═══════════════════════════════════════════════════════════════
   MODAL / DIALOG
═══════════════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(7, 7, 12, 0.65);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 200;
  animation: modal-fade-in 0.12s ease-out;
}
@keyframes modal-fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%; max-width: 460px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  animation: modal-pop 0.15s ease-out;
}
@keyframes modal-pop {
  from { transform: translateY(8px) scale(0.97); opacity: 0; }
  to   { transform: translateY(0)     scale(1);    opacity: 1; }
}

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 {
  font-size: 15px; font-weight: 500;
  color: var(--text); margin: 0;
  letter-spacing: -0.01em;
}
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 22px; line-height: 1;
  width: 30px; height: 30px; border-radius: 6px;
}
.modal-close:hover { background: var(--card); color: var(--text); }

.modal-body { padding: 18px 20px; font-size: 13.5px; line-height: 1.55; }
.modal-body p { color: var(--text); }
.modal-body p + p { margin-top: 10px; }
.modal-body .field { margin-bottom: 12px; }
.modal-body .field:last-child { margin-bottom: 0; }
.modal-body strong { color: var(--text); }

.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
}

@media (max-width: 719px) {
  .modal-foot { flex-direction: column-reverse; gap: 8px; }
  .modal-foot .btn { width: 100%; }
}

/* ═══════════════════════════════════════════════════════════════
   FLOATING CHAT POPUP
═══════════════════════════════════════════════════════════════ */

.topbar-chat-toggle {
  width: 32px; height: 32px; border-radius: 8px;
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); font-size: 14px;
  cursor: pointer; margin-left: 12px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.topbar-chat-toggle:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }
.topbar-chat-toggle.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.chat-popup {
  position: fixed;
  right: -420px;
  top: var(--topbar-h);
  bottom: 0;
  width: 400px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 150;
  transition: right 0.25s ease;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.3);
}
.chat-popup.open { right: 0; }

.chat-popup-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-popup-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; font-weight: 500; color: var(--text);
}
.chat-popup-title .avatar {
  background: linear-gradient(135deg, #7B6FF0, #5B8EF0);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.chat-popup-close {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 20px; line-height: 1;
  width: 28px; height: 28px; border-radius: 6px;
}
.chat-popup-close:hover { background: var(--card); color: var(--text); }

.chat-popup-body {
  flex: 1; overflow-y: auto; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.chat-popup-empty {
  flex: 1; display: flex; align-items: center; justify-content: center;
  text-align: center; color: var(--muted); font-size: 13px;
  padding: 24px;
}

.chat-popup-msg {
  display: flex; gap: 8px; align-items: flex-start;
}
.chat-popup-msg.user { flex-direction: row-reverse; }

.chat-popup-avatar {
  width: 24px; height: 24px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; flex-shrink: 0;
}
.chat-popup-avatar.assistant {
  background: linear-gradient(135deg, #7B6FF0, #5B8EF0);
  color: #fff;
}
.chat-popup-avatar.user {
  background: var(--card); border: 1px solid var(--border);
  font-weight: 600; color: var(--muted);
}

.chat-popup-bubble {
  max-width: 85%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px 10px 10px 10px;
  padding: 8px 12px;
  font-size: 13px; line-height: 1.5;
  color: var(--text);
}
.chat-popup-bubble.user {
  background: var(--accent-glow);
  border-color: rgba(123, 111, 240, 0.25);
  border-radius: 10px 4px 10px 10px;
}
.chat-popup-bubble p { margin: 0 0 4px; }
.chat-popup-bubble p:last-child { margin-bottom: 0; }
.chat-popup-bubble li { margin-bottom: 2px; }
.chat-popup-bubble strong { font-weight: 600; }

.chat-popup-input {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-popup-input textarea {
  flex: 1; background: var(--card); border: 1px solid var(--border);
  border-radius: 9px; padding: 9px 12px;
  color: var(--text); font-size: 13px; font-family: inherit;
  resize: none; line-height: 1.5; max-height: 80px; min-height: 22px;
  outline: none;
}
.chat-popup-input textarea:focus { border-color: var(--accent); }
.chat-popup-input textarea::placeholder { color: var(--muted); }
.chat-popup-input .input-send {
  width: 30px; height: 30px; border-radius: 7px;
  flex-shrink: 0;
}

@media (max-width: 719px) {
  .chat-popup {
    width: 100%;
    right: -100%;
    top: var(--topbar-h);
  }
  .chat-popup.open { right: 0; }
}

/* ═══════════════════════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════════════════════ */

#toast-stack {
  position: fixed; top: 16px; right: 16px; z-index: 100;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  min-width: 240px; max-width: 360px;
  font-size: 13px; color: var(--text);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  animation: toast-in 0.25s ease-out;
}
.toast.error { border-left-color: var(--red); }
.toast.success { border-left-color: var(--green); }
@keyframes toast-in { from { transform: translateX(12px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ═══════════════════════════════════════════════════════════════
   MOBILE BREAKPOINT (< 720px)
   - Sidebar collapses to bottom tab bar
   - Topbar compressed (hide status dots, hide title suffix)
   - Chat/intel stack vertically (chat gets less headroom; cards stack 1-col)
   - Tap targets ≥ 44px
═══════════════════════════════════════════════════════════════ */

@media (max-width: 719px) {

  html, body { overflow: auto; }

  .shell {
    grid-template-rows: var(--topbar-h) 1fr var(--mobile-tab-h);
    /* minmax(0, …) — NOT plain `1fr`. A 1fr track's min is its content's
       min-content, so the bottom nav's row of fixed-width icons (~640px)
       stretched the whole shell past the viewport → sideways scroll + clipped
       content. minmax(0,1fr) lets the column shrink to the viewport. */
    grid-template-columns: minmax(0, 1fr);
    height: 100vh; height: 100dvh;
  }

  .topbar {
    grid-column: 1;
    padding: 0;
  }
  .topbar-logo { width: 52px; height: var(--topbar-h); border-right: 1px solid var(--border); }
  .topbar-title { padding: 0 14px; font-size: 12px; }
  .topbar-title span + span,
  .topbar-title span.sep { display: none; }
  .status-dots { display: none; }
  .topbar-time { display: none; }
  .topbar-user { margin-left: auto; padding-left: 12px; padding-right: 12px; }

  /* Sidebar becomes horizontal bottom tab bar */
  .sidebar {
    grid-row: 3;
    grid-column: 1;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    padding: 4px 8px;
    border-right: none;
    border-top: 1px solid var(--border);
    gap: 0;
    /* Many nav icons on a narrow phone: let the bar scroll horizontally rather
       than force the shell wider (paired with the shell's minmax(0,1fr)). */
    overflow-x: auto;
    position: sticky; bottom: 0; z-index: 5;
  }
  .nav-icon { width: 48px; height: 48px; font-size: 20px; }
  .nav-icon.bottom { margin-top: 0; }
  .nav-sep { display: none; }

  .main {
    grid-row: 2; grid-column: 1;
    flex-direction: column;        /* mobile: stack chat above tiles again */
  }

  .chat-wrap {
    flex: 0 0 auto;
    padding: 16px 16px 12px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .chat-placeholder { padding: 12px 0; }
  .chat-placeholder h2 { font-size: 15px; }
  .chat-placeholder p { font-size: 12.5px; }
  .chat-input-area { display: none; /* noise on mobile while Phase 3 is pending */ }

  .intelligence {
    flex: 1;
    padding: 14px 16px 20px;
  }

  /* Cards: single column stacked list, each full-width */
  .cards {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .intel-card { min-height: unset; }

  /* Login — full width with breathing room */
  .login-card { border-radius: 14px; padding: 24px 22px 22px; }

  /* Page layout on mobile */
  .page-header { padding: 14px 14px; flex-wrap: wrap; }
  /* The action bar itself must wrap too: with 3+ buttons (Leads, Financials)
     it overflows a portrait phone and .page{overflow:hidden} CLIPS the
     rightmost button — which is the primary "+ Add …". Landscape was the
     only way to reach it before this rule. */
  .page-actions { flex-wrap: wrap; justify-content: flex-end; row-gap: 8px; min-width: 0; }
  .page-title { font-size: 16px; }
  .page-body { padding: 14px 14px 20px; }
  .page-subtitle { display: none; }

  /* Tables → stacked cards on mobile */
  .data-table { display: none; }
  .row-card-list { display: block; }

  /* Form grid collapses to single column */
  .form-grid { grid-template-columns: 1fr; gap: 10px; }
  .form-section { padding: 16px 14px; border-radius: 10px; }
  .form-wrap { max-width: 100%; }

  /* Inputs — 44px min touch target */
  .field input, .field select, .field textarea { padding: 13px 14px; font-size: 15px; }

  /* Item lines — stack instead of grid */
  .item-line {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .item-line .field:first-child { grid-column: 1 / -1; }
  .item-line-remove { grid-column: 2; justify-self: end; }

  /* Buttons — bigger tap area */
  .btn { padding: 10px 14px; font-size: 13px; }

  /* Form footer sticky for easy save on long forms */
  .form-footer {
    position: sticky; bottom: 0;
    background: linear-gradient(to top, var(--bg) 60%, transparent);
    padding: 14px 0 6px;
    margin-top: 8px;
  }
}

/* Product thumbnails — small white tiles with the SKU's bottle shot
   (frontend/img/products/<SKU>.png, extracted from the B2B price list). */
.prod-thumb {
  width: 40px; height: 40px;
  border-radius: 8px;
  background: #fff;
  object-fit: contain;
  display: block;
  flex: 0 0 auto;
}
.thumb-cell { width: 48px; padding-right: 4px; }
.row-card-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row-card-title .prod-thumb { width: 34px; height: 34px; border-radius: 7px; }

/* Form grid button/input overrides on larger screens */
@media (min-width: 720px) {
  .page-actions .btn { padding: 8px 14px; font-size: 12.5px; }
  /* Stacked cards are mobile-only — hidden on desktop. This MUST live in the
     min-width query, not as a base rule: a base `.row-card-list{display:none}`
     placed after the max-width:719px block overrode its `display:block` by
     source order (equal specificity, later wins), blanking every mobile list. */
  .row-card-list { display: none; }
}

/* Very narrow phones */
@media (max-width: 360px) {
  .topbar-title { font-size: 11px; padding: 0 10px; }
  .nav-icon { width: 44px; }
}

/* ═══════════════════════════════════════════════════════════════
   Leads — activity timeline + onboarding documents
   ═══════════════════════════════════════════════════════════════ */

.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline-item {
  display: grid; grid-template-columns: 24px 1fr; gap: 12px;
  padding-bottom: 16px; position: relative;
}
.timeline-item:not(:last-child)::before {
  content: ''; position: absolute; left: 11px; top: 24px; bottom: 0;
  width: 1px; background: var(--border);
}
.timeline-dot {
  width: 23px; height: 23px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; font-size: 11px;
}
.timeline-body { font-size: 13px; min-width: 0; }
.timeline-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 3px; }
.timeline-when { color: var(--muted); font-size: 11px; }
.timeline-note { color: var(--text); white-space: pre-wrap; word-break: break-word; }

.doc-checklist { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.doc-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.doc-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; font-size: 13px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
}
.doc-row .doc-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-row .doc-meta { color: var(--muted); font-size: 11px; font-family: var(--font-mono); }
/* The AI reading under a PP20 / affidavit row (class-only — the production CSP strips inline styles). */
.doc-read { margin: -4px 0 6px 10px; padding: 8px 10px; border-left: 2px solid var(--border); display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.doc-read-facts { line-height: 1.5; overflow-wrap: anywhere; }
.doc-read-checks { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.doc-read-checks .pill { max-width: 100%; white-space: normal; text-align: left; line-height: 1.4; height: auto; }
.doc-read-remarks { color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.doc-read-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.check-label { display: flex; align-items: flex-start; gap: 8px; font-weight: normal; cursor: pointer; line-height: 1.4; }
.check-label input { margin-top: 3px; }
.doc-upload-msg { margin-top: 6px; padding: 8px 10px; border-radius: 6px; font-size: 12px; line-height: 1.45; background: var(--surface-2, rgba(255,255,255,.04)); border: 1px solid var(--border); overflow-wrap: anywhere; }
.doc-upload-msg.bad { border-color: var(--red); color: var(--red); }
.upload-hint { font-size: 11px; }
.doc-read-accepted { color: var(--green, #2e8b57); font-size: 12px; line-height: 1.4; }
.doc-fix { display: inline-flex; gap: 4px; align-items: center; }
.doc-fix-input { width: 150px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; padding: 3px 6px; }
.upload-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.upload-row select {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 10px; font-size: 12.5px; font-family: inherit; cursor: pointer;
}

/* ═══════════════════════════════════════════════════════════════
   TEAM — performance progress bars + target editor (Phase 4)
   No chart library: attainment is a width-percentage fill so it reads
   in both light and dark on the same --card / --border tokens.
   ═══════════════════════════════════════════════════════════════ */

.progress-track {
  width: 100%; height: 8px;
  background: var(--border); border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 4px;
  transition: width 0.3s ease;
  background: var(--subtle);
}
.progress-fill.good { background: var(--green); }
.progress-fill.warn { background: var(--amber); }
.progress-fill.low  { background: var(--red); }
.progress-fill.none { background: var(--subtle); }

/* Inline target input inside table cells / mobile cards */
.team-target-input {
  background: var(--card); border: 1px solid var(--border); border-radius: 7px;
  padding: 6px 9px; font-size: 12.5px; color: var(--text);
  font-family: var(--font-mono); width: 110px;
}
.team-target-input:focus { outline: none; border-color: var(--accent); }
.team-target-cell .btn-sm { white-space: nowrap; }


/* ─── Stock categories + samples (Aug 2026) ──────────────────── */
.inv-section-row td {
  padding: 16px 10px 6px;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted);
}
.inv-section-label {
  margin: 16px 2px 6px;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted);
}
.sample-chip { font-size: 11px; color: var(--amber); white-space: nowrap; }
.samples-section { margin-top: 10px; }
.samples-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap; margin: 10px 0;
}
.samples-toolbar .muted { font-size: 13px; }
.samples-toolbar-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.samples-empty { margin: 8px 0; }
.sample-pool-list { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.sample-pool-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
}
.sample-pool-row:last-child { border-bottom: none; }
.sample-pool-row .prod-thumb { width: 26px; height: 26px; object-fit: contain; flex: none; }
.sample-pool-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sample-pool-actions { display: flex; gap: 6px; flex: none; }
.samples-log { margin-top: 12px; }
.samples-log-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.sample-event-row { display: flex; gap: 10px; padding: 3px 0; font-size: 13px; }
.sample-event-row > .muted { flex: none; }
.samples-fromstock {
  display: flex; gap: 8px; align-items: flex-start;
  margin-top: 4px; font-size: 13px;
}
.samples-fromstock input { margin-top: 2px; }
@media (max-width: 719px) {
  .sample-pool-row .mono.muted { display: none; }
  .sample-event-row { flex-direction: column; gap: 0; }
}

/* ─── Quotations (Aug 2026) ──────────────────────────────────── */
.quotes-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap; margin: 10px 0;
}
.quote-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px;
  margin-bottom: 8px;
}
.quote-row-actions { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.quote-totals { font-size: 14px; }
@media (max-width: 719px) {
  .quote-row { gap: 8px; }
  .quote-row-actions { margin-left: 0; width: 100%; justify-content: flex-end; }
}


/* ─── Lead manager quick controls (Matt's format, Sep 2026) ──── */
.chip-row {
  display: flex; gap: 8px; flex-wrap: nowrap;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: 6px; margin-bottom: 10px;
}
.chip-row .chip {
  flex: none; display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 13px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card);
  color: var(--text); font-size: 12.5px; cursor: pointer;
  font-family: inherit;
}
.chip-row .chip:hover { border-color: var(--muted); }
.chip-row .chip.active {
  border-color: var(--accent); color: var(--accent); font-weight: 600;
  background: var(--accent-glow);
}
.chip-row .chip .chip-n { color: var(--muted); font-size: 11.5px; }
.chip-row .chip.active .chip-n { color: var(--accent); }

/* Collapsible heavy form sections (lead form) */
.form-section.collapsible > .form-section-title { cursor: pointer; user-select: none; }
.form-section.collapsible > .form-section-title::after {
  content: " ▾"; color: var(--muted); font-size: 11px;
}
.form-section.collapsible.collapsed > .form-section-title::after { content: " ▸"; }
.form-section.collapsible.collapsed > *:not(.form-section-title) { display: none; }

/* ─── Payment QR view (Sep 2026) ───────────────────────────── */
.payqr-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.payqr-hint { margin-top: 10px; }
.payqr-breakdown { margin-top: 10px; font-size: 13px; color: var(--muted); }
.payqr-card { text-align: center; }
.payqr-title { font-weight: 600; font-size: 13px; letter-spacing: .3px; }
.payqr-amount { font-size: 28px; font-weight: 700; margin: 6px 0 2px; }
.payqr-payee { font-size: 12px; color: var(--muted); letter-spacing: .3px; }
/* The QR sits on white regardless of theme — dark modules on the dark card
   would not scan. */
.payqr-qr { background: #fff; border-radius: 10px; padding: 10px; margin: 10px auto 8px; width: 260px; max-width: 100%; min-height: 120px; display: flex; align-items: center; justify-content: center; }
.payqr-qr svg { width: 100%; height: auto; display: block; }
.payqr-ref { font-size: 12.5px; min-height: 18px; }
@media (max-width: 719px) {
  .payqr-grid { grid-template-columns: 1fr; }
}

/* ─── Consignment card (customer detail, Sep 2026) ─────────────── */
.consign-pill { margin-left: 6px; font-size: 10px; }
.consign-intro { font-size: 13px; margin: 4px 0 8px; }
.consign-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 8px 0 10px; }
.consign-kpis > div { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.consign-kpis strong { font-size: 15px; }
.consign-list { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 10px; }
.consign-row {
  display: grid; grid-template-columns: 120px 1fr auto auto auto; gap: 12px; align-items: center;
  padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 13px;
}
.consign-row:last-child { border-bottom: none; }
.consign-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.consign-events { margin-top: 10px; }
.consign-sub { font-size: 12px; margin-bottom: 4px; }
.consign-event { display: grid; grid-template-columns: 90px 1fr auto; gap: 10px; align-items: center; font-size: 13px; padding: 3px 0; }
.consign-modal-p { font-size: 13px; margin: 0 0 10px; }
.consign-delivery { display: grid; grid-template-columns: 90px 90px 1fr auto; gap: 10px; align-items: center; font-size: 13px; padding: 3px 0; }
.consign-delivery-actions { display: flex; gap: 6px; }
.consign-lines { display: flex; flex-direction: column; gap: 10px; max-height: 50vh; overflow-y: auto; }
.consign-line { border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; }
.consign-line-name { font-size: 13px; margin-bottom: 6px; }
.consign-line-inputs { display: flex; gap: 10px; flex-wrap: wrap; }
.consign-line-inputs label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--muted); }
.consign-line-inputs input {
  width: 110px; background: var(--card); border: 1px solid var(--border); border-radius: 9px;
  padding: 9px 11px; font-size: 14px; color: var(--text);
}
.consign-line-inputs input:focus { outline: none; border-color: var(--accent); }
.consign-meta { margin-top: 12px; }
.consign-total { font-size: 13px; margin-top: 8px; min-height: 1em; }
.form-banner.consign-banner { display: none; margin-top: 10px; }
.form-banner.consign-banner.show { display: block; }
@media (max-width: 719px) {
  .consign-row { grid-template-columns: 1fr auto; }
  .consign-row .consign-name { grid-column: 1 / -1; order: -1; }
  .consign-event { grid-template-columns: 1fr auto; }
  .consign-event > .muted { grid-column: 1 / -1; }
  .consign-delivery { grid-template-columns: 1fr auto; }
  .consign-delivery-actions { grid-column: 1 / -1; }
  .consign-line-inputs input { width: 90px; }
}

/* ═══════════════════════════════════════════════════════════════
   BACK-OFFICE WORKSPACE (#/accounting, Oct 2026) — class-only layout;
   the production CSP strips inline style attributes.
   ═══════════════════════════════════════════════════════════════ */
.acc-th { font-family: 'Inter', 'Sarabun', 'Thonburi', 'Leelawadee UI', system-ui, -apple-system, sans-serif; }
.acc-note { font-size: 12px; color: var(--muted); margin-top: 4px; }
.acc-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 8px; }
.acc-kpi {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; cursor: pointer; transition: border-color .15s;
}
.acc-kpi:hover { border-color: var(--muted); }
.acc-kpi.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-glow); }
.acc-kpi .n { font-size: 22px; font-weight: 700; font-family: var(--font-mono); line-height: 1.1; }
.acc-kpi .l { font-size: 12px; color: var(--muted); margin-top: 4px; }
.acc-kpi.warn .n { color: var(--amber); }
.acc-kpi.good .n { color: var(--green); }
.acc-kpi.bad .n { color: var(--red); }
.acc-month { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 10px; }
.acc-month .acc-kpi { cursor: default; }
.acc-steps { display: flex; gap: 2px; align-items: flex-start; }
.acc-step { display: flex; flex-direction: column; align-items: center; min-width: 50px; font-size: 10px; color: var(--muted); text-align: center; }
.acc-step .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border); margin-bottom: 3px; }
.acc-step.done { color: var(--text); }
.acc-step.done .dot { background: var(--green); border-color: var(--green); }
.acc-step.partial .dot { background: var(--amber); border-color: var(--amber); }
.acc-step.next .dot { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.acc-step .d { font-size: 9.5px; color: var(--muted); min-height: 12px; }
.acc-row-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.acc-toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.acc-toolbar .field { margin: 0; min-width: 180px; }
.acc-table-wrap { overflow-x: auto; }
.acc-clickable { cursor: pointer; }
.warn-text { color: var(--amber); }
.acc-unbooked td:first-child { border-left: 3px solid var(--amber); }
@media (max-width: 719px) {
  .acc-steps { flex-wrap: wrap; gap: 6px; margin: 8px 0; }
  .acc-step { min-width: 44px; }
}


/* Petty-cash top-up list (17 Oct 2026): its own class — it used to be a
   .row-card-list kept visible on desktop by an inline style, which the
   production CSP strips (the list vanished at ≥720px). */
.pc-topup-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
/* `hidden` attribute wins over any class display rule. */
[hidden] { display: none !important; }
.mt6 { margin-top: 6px; }
.mt10 { margin-top: 10px; }

/* Other reps' accounts on a sales rep's customer list (19 Oct 2026): a
   directory, not a link target. */
.data-table tr.other-customer td, .row-card.other-customer { opacity: 0.85; cursor: default; }


/* Copy-for-LINE dialog + undelivered-messages outbox (28 Oct 2026) */
.linecopy-card { max-width: 560px; width: min(560px, 94vw); }
.linecopy-text { width: 100%; font-size: 13px; line-height: 1.45; font-family: inherit; resize: vertical;
  background: var(--surface-2, #1a1a1a); color: var(--text, #eee); border: 1px solid var(--border, #333);
  border-radius: 8px; padding: 10px; margin-top: 8px; box-sizing: border-box; }
.linecopy-offscreen { position: fixed; left: -9999px; top: 0; opacity: 0; }
.acc-outbox { display: flex; flex-direction: column; gap: 10px; }
.acc-outbox-row { border: 1px solid var(--border, #333); border-radius: 10px; padding: 10px 12px; background: var(--surface-1, #141414); }
.acc-outbox-meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 12px; margin-bottom: 6px; }
.acc-outbox-text { white-space: pre-wrap; font-family: inherit; font-size: 12.5px; line-height: 1.4; margin: 0 0 8px;
  max-height: 220px; overflow: auto; background: var(--surface-2, #1a1a1a); border-radius: 8px; padding: 8px 10px; }

/* Retail price list (Nov 2026): the ladder editor on the product form. */
.retail-tier-editor { margin-top: 18px; }
.retail-tier-editor > .hint { margin-bottom: 10px; }
.retail-tier-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.retail-tier-row .rt-label { flex: 1 1 110px; min-width: 100px; }
.retail-tier-row .rt-min { width: 84px; }
.retail-tier-row .rt-price { width: 130px; }
.retail-tier-row .rt-pack { flex: 1 1 150px; font-size: 12px; }
.retail-tier-editor .tier-actions { display: flex; gap: 8px; margin-top: 4px; }
.retail-note { margin-top: 6px; }
.price-list-hint { color: var(--amber); }

.data-table th.num { text-align: right; }

/* Customer list: sales-rep filter row */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; }
.filter-bar select { min-width: 180px; max-width: 100%; }
.filter-bar input[type=search] { flex: 1 1 240px; min-width: 0; }

/* Back-office LINE inbox: file previews */
.inbox-thumb { width: 64px; height: 64px; padding: 0; border: 1px solid var(--border, #444); border-radius: 6px; background: var(--surface-2, rgba(255,255,255,.04)); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; overflow: hidden; }
.inbox-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.inbox-thumb.has-img .inbox-thumb-icon { display: none; }
.inbox-thumb-icon { font-size: 26px; }
.inbox-viewer { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.88); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 56px 12px 12px; }
.inbox-viewer-bar { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: 10px 14px; color: #fff; }
.inbox-viewer-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-viewer-img { max-width: 100%; max-height: 100%; object-fit: contain; }
