/* 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 {
  --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;
}

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; }
}
.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); }

/* 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;
}

.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; }
.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); }
.field .hint {
  font-size: 11px; color: var(--muted); margin-top: 2px;
}
.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; }
.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) {
  .kpi-grid { grid-template-columns: 1fr 1fr; 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);
    grid-template-columns: 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;
    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; }
  .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;
  }
}

/* Show stacked cards only on mobile; hide on desktop */
.row-card-list { display: none; }

/* Form grid button/input overrides on larger screens */
@media (min-width: 720px) {
  .page-actions .btn { padding: 8px 14px; font-size: 12.5px; }
}

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