:root {
  --primary: #da7756;
  --primary-light: #e8956e;
  --bg: #2f2b28;
  --bg-light: #3d3833;
  --bg-surface: #363230;
  --card-bg: rgba(54, 50, 48, 0.85);
  --text: #ece5d8;
  --text-secondary: #a39b8b;
  --border: rgba(255, 255, 255, 0.08);
  --chat-user: #da7756;
  --chat-ai-bg: rgba(54, 50, 48, 0.6);
  --accent: #da7756;
  --accent-light: #e8956e;
  --radius: 16px;
}

* { box-sizing: border-box; }

html { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  height: 100vh;
  height: 100dvh;
  height: var(--app-height, 100dvh);   /* JS sets --app-height = visible innerHeight on mobile */
  overflow: hidden;
  display: flex;
  -webkit-font-smoothing: antialiased;
}

/* ===== SIDEBAR (Desktop) =====
   Flex column that fills viewport. Logo and bottom section stay fixed,
   only the middle <nav> scrolls — keeps logo and Logout always visible. */
.sidebar {
  width: 260px;
  background: rgba(42, 38, 35, 0.95);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--border);
  height: 100vh;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  padding: 24px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;            /* sidebar itself does NOT scroll */
  z-index: 9999;
}
.sidebar > .sidebar-logo { flex-shrink: 0; }
.sidebar > nav {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.06) transparent;
  margin: 0 -4px;
  padding: 0 4px;
}
.sidebar > nav::-webkit-scrollbar { width: 4px; }
.sidebar > nav::-webkit-scrollbar-track { background: transparent; }
.sidebar > nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }
.sidebar > nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }
.sidebar > div:last-child { flex-shrink: 0; }

/* Apply same elegant scrollbar treatment everywhere inside the app */
.dashboard-view, .chat-session-list, .chat-messages, .ya-table-wrap {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.06) transparent;
}
.dashboard-view::-webkit-scrollbar,
.chat-session-list::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar { width: 8px; height: 8px; }
.dashboard-view::-webkit-scrollbar-track,
.chat-session-list::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.dashboard-view::-webkit-scrollbar-thumb,
.chat-session-list::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }
.dashboard-view::-webkit-scrollbar-thumb:hover,
.chat-session-list::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }

.sidebar-logo {
  font-size: 1.3rem;
  font-weight: 800;
  background: linear-gradient(135deg, #da7756, #e8a87c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 32px;
}

.nav-item {
  padding: 11px 14px;
  border-radius: 10px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.875rem;
  pointer-events: auto;
}
.nav-item:hover, .nav-item.active {
  background: rgba(218, 119, 86, 0.12);
  color: var(--text);
}

/* ===== NAV GROUPS (Collapsible) ===== */
.nav-group {
  margin-bottom: 4px;
}
.nav-group-header {
  padding: 11px 14px;
  border-radius: 10px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.15s;
  user-select: none;
}
.nav-group-header:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}
.nav-group-icon {
  flex-shrink: 0;
}
.nav-group-arrow {
  margin-left: auto;
  font-size: 0.65rem;
  transition: transform 0.25s ease;
  color: #64748b;
}
.nav-group-items {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.25s ease;
  opacity: 0;
}
.nav-group-items.open {
  max-height: 300px;
  opacity: 1;
}
.nav-sub-item {
  padding-left: 38px !important;
  font-size: 0.82rem !important;
  margin-bottom: 2px !important;
  position: relative;
}
.nav-sub-item::before {
  content: '';
  position: absolute;
  left: 22px;
  top: 50%;
  width: 6px;
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
}

/* Mobile nav groups */
.mobile-nav-group { margin-bottom: 2px; }
.mobile-nav-group-header {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
}
.mobile-nav-group-header:hover { color: var(--text); }
.mobile-nav-arrow {
  margin-left: auto;
  font-size: 0.65rem;
  transition: transform 0.25s ease;
  color: #64748b;
}
.mobile-nav-group-items {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.25s ease;
  opacity: 0;
}
.mobile-nav-group-items.open {
  max-height: 300px;
  opacity: 1;
}
.mobile-sub-item {
  padding-left: 44px !important;
  font-size: 0.88rem !important;
}

/* Voucher type filter buttons */
.voucher-type-btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.voucher-type-btn:hover {
  background: rgba(218, 119, 86, 0.08);
  color: var(--text);
  border-color: rgba(218, 119, 86, 0.2);
}
.voucher-type-btn.active {
  background: rgba(218, 119, 86, 0.15);
  color: var(--accent);
  border-color: var(--accent);
}

/* ===== CONNECTOR APP STORE ===== */
.connector-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.connector-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.connector-card:hover {
  border-color: rgba(218, 119, 86, 0.3);
  background: rgba(54, 50, 48, 0.95);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.connector-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.connector-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.connector-status {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.connector-status.connected {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}
.connector-status.available {
  background: rgba(56, 189, 248, 0.12);
  color: #38bdf8;
}
.connector-status.coming-soon {
  background: rgba(255, 255, 255, 0.05);
  color: #64748b;
}
.connector-name {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}
.connector-desc {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
  flex: 1;
}
.connector-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: #64748b;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

/* Connector Config Modal */
.connector-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.connector-modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

@media (max-width: 900px) {
  .connector-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .connector-grid { grid-template-columns: 1fr; }
}

/* ===== MAIN CONTENT — flex column that fills 100vh, NEVER scrolls itself.
   Demo banner (top, fixed) + view area (flex:1, owns scroll) ===== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  height: var(--app-height, 100dvh);
  overflow: hidden;
  min-width: 0;          /* allow flex children to shrink */
}
/* Each non-chat view scrolls internally and gets the page padding here */
.dashboard-view {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 32px;
  max-width: 100%;
}
.dashboard-view > .ya-section,
.dashboard-view > .card,
.dashboard-view > header { max-width: 1100px; margin-left: auto; margin-right: auto; }
/* Sprint 37 — compact page headers: reclaim top vertical space across all views */
.dashboard-view > header { margin-bottom: 14px; }
.dashboard-view h1 { font-size: 1.5rem; margin: 0 0 3px 0; line-height: 1.2; }
.dashboard-view > header p { font-size: 0.82rem; margin: 0; line-height: 1.4; }
.dashboard-view > .grid { max-width: 1100px; margin-left: auto; margin-right: auto; }
.grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 24px; }
/* Sprint 69 — launcher/grid pages span full width, so their header must left-align
   with the tiles (not the centered 1100px column used by card pages). */
#home-view > header,
#aiacc-home-view > header,
#store-view > header,
#uploads-view > header,
#dev-portal-view > header { max-width: none; margin-left: 0; margin-right: 0; }

/* ===== Sprint 60/61 — full-width app with a universal top bar (no left sidebar) ===== */
.sidebar { display: none !important; }                   /* chrome moved to #app-topbar */
#app-topbar {
  display: flex; align-items: center; gap: 12px; flex-shrink: 0;
  padding: 9px 18px; border-bottom: 1px solid var(--border);
  background: rgba(42,38,35,0.85); backdrop-filter: blur(8px);
}
#app-topbar .tb-left { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; overflow-x: auto; }
#app-topbar .tb-left::-webkit-scrollbar { height: 0; }
#app-topbar .tb-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.tb-logo { font-weight: 700; color: var(--primary); font-size: 1rem; white-space: nowrap; cursor: pointer; }
.tb-appname { font-weight: 600; color: #f4f4f5; font-size: 0.92rem; white-space: nowrap; }
.tb-divider { width: 1px; height: 22px; background: var(--border); flex-shrink: 0; }
.tb-tab {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px;
  color: #cbd5e1; cursor: pointer; white-space: nowrap; font-size: 0.85rem; border: 1px solid transparent;
}
.tb-tab:hover { background: var(--bg-light); color: #f4f4f5; }
.tb-tab.active { background: rgba(218,119,86,0.14); color: #f4f4f5; border-color: rgba(218,119,86,0.35); }
#app-topbar select, #app-topbar .ht-btn {
  background: var(--bg-light); color: #cbd5e1; border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; font-size: 0.82rem; cursor: pointer;
}
#app-topbar select { max-width: 200px; color: #f4f4f5; }
#app-topbar .ht-btn { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
#app-topbar .ht-btn:hover { border-color: var(--primary); color: #f4f4f5; }
#app-topbar .ht-wallet { color: #38bdf8; border-color: rgba(56,189,248,0.3); background: rgba(56,189,248,0.08); }
@media (max-width: 768px) { #app-topbar { display: none; } }   /* mobile keeps its own header/drawer */
.app-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px; margin-top: 18px;
}
.app-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 24px 14px; text-align: center; cursor: pointer;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 16px;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}
.app-tile:hover { transform: translateY(-2px); border-color: var(--primary); background: rgba(218,119,86,0.06); }
.app-tile .at-icon {
  width: 58px; height: 58px; border-radius: 16px; display: flex; align-items: center;
  justify-content: center; font-size: 1.8rem; background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
}
.app-tile .at-name { font-size: 0.9rem; font-weight: 600; color: #f4f4f5; }
.app-tile .at-sub { font-size: 0.72rem; color: #94a3b8; }

/* ===== Sprint 68 — AI Accountant feature launcher (compact app-drawer icons) ===== */
/* Desktop: icons sit in one line while there's room (flex-wrap), bigger icons. */
.feat-grid { display: flex; flex-wrap: wrap; gap: 22px 18px; }
.feat-tile {
  width: 104px; display: flex; flex-direction: column; align-items: center; gap: 9px;
  padding: 8px 4px; cursor: pointer; border-radius: 16px; transition: background .12s;
}
.feat-tile:hover { background: rgba(218,119,86,0.07); }
.feat-ic {
  width: 66px; height: 66px; border-radius: 18px; display: flex; align-items: center;
  justify-content: center; font-size: 2rem; background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
}
.feat-name { font-size: 0.8rem; color: #cbd5e1; text-align: center; line-height: 1.2; }

/* Sprint 71 — Upload anything: shared action buttons + list view */
.upl-btn { padding: 7px 10px; background: var(--bg-light); color: #cbd5e1; border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 0.85rem; line-height: 1; }
.upl-btn:hover { border-color: var(--primary); color: #f4f4f5; }
.upl-del { background: rgba(239,68,68,0.1); color: #f87171; border-color: rgba(239,68,68,0.25); }
.uploads-list { display: flex; flex-direction: column; gap: 8px; }
.upl-row { display: flex; align-items: center; gap: 12px; padding: 9px 12px; background: var(--card-bg);
  border: 1px solid var(--border); border-radius: 10px; }
.upl-ic { font-size: 1.3rem; cursor: pointer; flex-shrink: 0; }
.upl-name { flex: 1; min-width: 0; color: #e2e8f0; font-weight: 600; font-size: 0.88rem; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upl-meta { color: #94a3b8; font-size: 0.78rem; flex-shrink: 0; }
.upl-acts { display: flex; gap: 6px; flex-shrink: 0; }
@media (max-width: 768px) { .upl-when { display: none; } .upl-name { white-space: normal; } .upl-acts .upl-btn { padding: 7px 8px; } }

/* ===== CARD ===== */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

/* ===== TABLE ===== */
table { width: 100%; border-collapse: collapse; margin-top: 16px; }
th { text-align: left; color: var(--text-secondary); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px; padding: 12px; border-bottom: 1px solid var(--border); }
td { padding: 14px 12px; border-bottom: 1px solid var(--border); font-size: 0.85rem; }

/* ===== FORMS ===== */
.upload-zone {
  border: 2px dashed rgba(218,119,86,0.3);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  color: var(--text-secondary);
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--primary); background: rgba(218,119,86,0.05); }

.btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
  margin-top: 16px;
  font-size: 0.875rem;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.1); }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 6px; }
.form-group input {
  width: 100%;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  color: var(--text);
  box-sizing: border-box;
  font-size: 0.875rem;
}

.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 600;
  background: rgba(34, 197, 94, 0.1);
  color: #4ade80;
}

.loading-spinner {
  display: none;
  width: 24px; height: 24px;
  border: 3px solid rgba(255,255,255,0.1);
  border-radius: 50%;
  border-top-color: var(--primary);
  animation: spin 1s linear infinite;
  margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.status-matched { color: #4ade80; background: rgba(74,222,128,0.1); padding: 4px 8px; border-radius: 4px; }
.status-mismatch { color: #f87171; background: rgba(248,113,113,0.1); padding: 4px 8px; border-radius: 4px; }
.status-missing { color: #fbbf24; background: rgba(251,191,36,0.1); padding: 4px 8px; border-radius: 4px; }

/* =========================================
   CHAT — Claude-Inspired Interface
   ========================================= */

/* Chat view — fills its container, manages its own internal scroll
   No negative margins, no separate height. Padding is zero so chat-layout edges
   the panes precisely. */
#chat-view {
  padding: 0 !important;
  max-width: 100%;
  overflow: hidden;       /* internal panes scroll, not the view itself */
  display: flex;
  flex-direction: column;
}

.chat-layout {
  display: flex;
  flex: 1;
  min-height: 0;          /* allow children to shrink and scroll */
  height: 100%;
  gap: 0;
}

.chat-sidebar {
  width: 260px;
  background: rgba(42, 38, 35, 0.7);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px;
  flex-shrink: 0;
  min-height: 0;       /* allow inner list to scroll without growing the column */
  overflow: hidden;
}

.chat-new-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  margin-bottom: 16px;
  transition: all 0.2s;
}
.chat-new-btn:hover { filter: brightness(1.15); transform: translateY(-1px); }

.chat-session-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-session-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.chat-session-item:hover { background: rgba(218,119,86,0.08); color: var(--text); }
.chat-session-item.active { background: rgba(218,119,86,0.15); color: var(--text); }
.chat-session-icon { font-size: 0.85rem; }
.chat-session-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Sprint 82 — Create task: task-list tiles (reuse the chat-session look) */
.yt-session-item { border: 1px solid transparent; transition: all 0.15s; }
.yt-session-item:hover { background: rgba(218,119,86,0.08); }
.yt-session-item.active { background: rgba(218,119,86,0.15); border-color: rgba(218,119,86,0.35); }
@media (max-width: 768px) {
  #yt-tasks-toggle { display: inline-flex !important; }
  #yt-sidebar { display: none; }
  #yt-sidebar.yt-show { display: flex; position: absolute; z-index: 30; width: 240px; max-height: 60vh; box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
}

/* Chat Main Area — flex column where messages scroll but input is anchored */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;             /* critical: lets children compute heights for overflow */
  background: var(--bg);
  overflow: hidden;
}

/* Welcome Screen — fills available space, scrolls internally if needed */
.chat-welcome {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  overflow-y: auto;
  min-height: 0;
}

.chat-welcome-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 560px;
  width: 100%;
}

.chat-welcome-icon {
  font-size: 2rem;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 14px;
  color: white;
  margin-bottom: 8px;
}

.chat-welcome h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.chat-welcome p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin: 0 0 8px;
  text-align: center;
  line-height: 1.5;
}

.chat-starter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
  width: 100%;
}

.chat-starter-card {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.chat-starter-card:hover {
  border-color: rgba(218,119,86,0.35);
  background: rgba(218,119,86,0.07);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.chat-starter-card span {
  font-size: 1.25rem;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(218,119,86,0.1);
  border-radius: 8px;
}
.starter-text { flex: 1; }
.starter-text strong { font-size: 0.85rem; color: var(--text); display: block; margin-bottom: 2px; }
.starter-text p { margin: 0; font-size: 0.75rem; color: var(--text-secondary); line-height: 1.35; }

/* Messages Area — only this scrolls within the chat-main column */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
  min-height: 0;
}

.chat-msg { display: flex; gap: 12px; animation: fadeIn 0.25s ease; }
.chat-msg-user { justify-content: flex-end; }
.chat-msg-ai { align-items: flex-start; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.chat-msg-avatar {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(218,119,86,0.15);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.chat-msg-bubble {
  max-width: 720px;
  border-radius: 16px;
  padding: 12px 16px;
  font-size: 0.9rem;
  line-height: 1.65;
}

.chat-msg-bubble-user {
  background: var(--primary);
  color: white;
  border-radius: 16px 16px 4px 16px;
}

.chat-msg-bubble-ai {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 16px 16px 16px 4px;
  color: var(--text);
}

.chat-msg-text { margin-bottom: 8px; }
.chat-msg-text:last-child { margin-bottom: 0; }
.chat-msg-text strong, .chat-msg-text b { color: var(--primary-light); }
.chat-msg-text code { background: rgba(0,0,0,0.3); padding: 2px 6px; border-radius: 4px; font-size: 0.8rem; }

/* Thinking Animation */
.chat-thinking { display: flex; gap: 6px; padding: 4px 0; }
.thinking-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--primary);
  animation: bounce 1.4s infinite ease-in-out both;
}
.thinking-dot:nth-child(1) { animation-delay: -0.32s; }
.thinking-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Table UI */
.chat-ui-table { margin-top: 12px; overflow-x: auto; border-radius: 10px; border: 1px solid var(--border); background: rgba(0,0,0,0.15); }
.chat-ui-table table { margin: 0; }
.chat-ui-table th { background: rgba(218,119,86,0.1); font-size: 0.7rem; padding: 10px 12px; }
.chat-ui-table td { font-size: 0.8rem; padding: 10px 12px; }

/* Cards UI */
.chat-ui-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin-top: 12px; }
.chat-ui-card { background: rgba(0,0,0,0.15); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.chat-ui-card-title { font-size: 0.65rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.chat-ui-card-value { font-size: 1.15rem; font-weight: 700; margin-top: 4px; }
.chat-ui-card-change { font-size: 0.7rem; margin-top: 4px; color: var(--text-secondary); }

/* List UI */
.chat-ui-list { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.chat-ui-list-item {
  display: flex; align-items: flex-start; gap: 10px;
  background: rgba(0,0,0,0.1);
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.8rem;
}

/* Suggestions */
.chat-suggestions { display: flex; gap: 6px; padding: 0 40px 10px; flex-wrap: wrap; }
.chat-suggestion-btn {
  padding: 7px 12px;
  background: rgba(218,119,86,0.08);
  border: 1px solid rgba(218,119,86,0.2);
  border-radius: 20px;
  color: var(--primary-light);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.chat-suggestion-btn:hover { background: rgba(218,119,86,0.15); border-color: rgba(218,119,86,0.4); color: var(--text); }

/* Input Area — anchored at bottom of chat-main, never scrolls */
.chat-input-area {
  padding: 12px 40px 16px;
  border-top: 1px solid var(--border);
  background: rgba(42, 38, 35, 0.3);
  flex-shrink: 0;
}

/* Transaction Type Selector */
.txn-type-selector {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.txn-type-btn {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}
.txn-type-btn:hover { border-color: rgba(218,119,86,0.3); color: var(--text); }
.txn-type-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.chat-input-container { display: flex; flex-direction: column; gap: 6px; width: 100%; }

.chat-input-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 6px 8px 6px 6px;
  transition: border-color 0.2s;
}
.chat-input-wrapper:focus-within { border-color: rgba(218,119,86,0.4); }

.chat-input-wrapper textarea {
  flex: 1 1 auto;
  min-width: 0;                 /* allow the field to shrink within the flex row */
  border: none;
  background: transparent;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  resize: none;
  outline: none;
  line-height: 1.4;
  max-height: 120px;
  padding: 8px 4px;
  overflow-y: auto;
}
.chat-input-wrapper textarea::placeholder { color: #6b6359; }
/* hide the textarea scrollbar (the stray up/down arrows on mobile) */
.chat-input-wrapper textarea { scrollbar-width: none; }
.chat-input-wrapper textarea::-webkit-scrollbar { width: 0; height: 0; display: none; }

/* Action buttons in input — all the same circular size, vertically centered */
.attachment-btn, .camera-btn, .mic-btn {
  flex-shrink: 0;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.1rem;
  padding: 0;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
  border-radius: 50%;
}
.attachment-btn:hover, .camera-btn:hover, .mic-btn:hover {
  color: var(--primary);
  background: rgba(218,119,86,0.1);
}
.mic-btn.recording {
  color: #ef4444 !important;
  animation: pulse-red 1.2s infinite;
}
@keyframes pulse-red {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.75; }
  100% { transform: scale(1); opacity: 1; }
}

.send-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: white;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  font-size: 0.9rem;
}
.send-btn:hover { filter: brightness(1.15); }

.attachment-preview { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }

/* Sprint 40 — walkie-talkie live transcription pill */
.voice-pill {
  display: flex; align-items: center; gap: 8px;
  background: rgba(56,189,248,0.12);
  border: 1px solid rgba(56,189,248,0.35);
  color: #e2e8f0;
  padding: 8px 12px; border-radius: 12px;
  margin-bottom: 8px; font-size: 0.85rem;
}
.voice-pill.cancel-armed {
  background: rgba(239,68,68,0.14);
  border-color: rgba(239,68,68,0.5);
  color: #fca5a5;
}
.voice-pill .vp-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #ef4444; flex-shrink: 0;
  animation: pulse-red 1.2s infinite;
}
.voice-pill .vp-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-pill .vp-hint { color: #94a3b8; font-size: 0.72rem; flex-shrink: 0; }
.attachment-tag {
  background: rgba(218,119,86,0.1);
  border: 1px solid rgba(218,119,86,0.2);
  color: var(--primary-light);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.attachment-tag .close { cursor: pointer; font-size: 0.7rem; opacity: 0.6; }
.attachment-tag .close:hover { opacity: 1; }

/* Pull-to-refresh indicator */
#ptr-indicator {
  position: fixed; top: 0; left: 50%;
  transform: translateX(-50%) translateY(-46px);
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--bg-surface, #1e1b18); border: 1px solid var(--border);
  color: var(--primary); display: flex; align-items: center; justify-content: center;
  z-index: 9000; opacity: 0; box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  transition: opacity 0.15s ease;
}
#ptr-indicator i { transition: transform 0.15s ease; }

/* ===== "+" Add menu (Claude-style attachment menu) ===== */
.add-menu-popup {
  background: var(--bg-surface, #1e1b18);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 6px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
}
.add-menu-popup--sheet {
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -10px 30px rgba(0,0,0,0.45);
}
.add-menu-popup .ami-handle {
  width: 38px; height: 4px; border-radius: 2px;
  background: rgba(255,255,255,0.18);
  margin: 4px auto 10px;
}
.add-menu-popup .ami-section {
  padding: 8px 12px 4px; color: #8a8178;
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600;
}
.add-menu-popup .ami-divider { height: 1px; background: rgba(255,255,255,0.06); margin: 6px 8px; }
.add-menu-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 9px 10px;
  background: none; border: none; color: var(--text);
  text-align: left; cursor: pointer; border-radius: 12px;
  transition: background 0.15s;
}
.add-menu-item:hover, .add-menu-item:active { background: rgba(218,119,86,0.12); }
.add-menu-item .ami-ic {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; background: var(--bg-light); border: 1px solid var(--border);
}
.add-menu-item .ami-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.add-menu-item .ami-label { font-weight: 600; font-size: 0.92rem; }
.add-menu-item .ami-hint { font-size: 0.74rem; color: #94a3b8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 768px) {
  .add-menu-item { padding: 12px 12px; }
  .add-menu-item .ami-ic { width: 44px; height: 44px; }
  .add-menu-item .ami-label { font-size: 1rem; }
}

/* Sprint 41 — collapsible filter bar (mobile only).
   Desktop: toggle hidden, controls always shown as a flex row. */
.filter-toggle { display: none; }
.filter-body { display: flex; }

/* Interactive Table */
.chat-ui-table-container {
  background: rgba(0,0,0,0.1);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 12px;
  border: 1px solid var(--border);
}
.chat-ui-table-container table { width: 100%; border-collapse: collapse; }
.chat-ui-table-container th { background: rgba(218,119,86,0.1); color: var(--primary); text-align: left; padding: 10px; font-size: 0.75rem; }
.chat-ui-table-container td { padding: 10px; border-top: 1px solid rgba(255,255,255,0.04); font-size: 0.8rem; transition: background 0.2s; }
.chat-ui-table-container td[contenteditable="true"] { cursor: text; transition: all 0.2s; }
.chat-ui-table-container td[contenteditable="true"]:hover { background: rgba(255,255,255,0.04); box-shadow: inset 0 0 0 1px rgba(218,119,86,0.25); }
.chat-ui-table-container td[contenteditable="true"]:focus { outline: none; background: rgba(218,119,86,0.08) !important; box-shadow: inset 0 0 0 2px var(--primary); }

.table-action-btn { background: none; border: none; color: var(--text-secondary); cursor: pointer; padding: 4px 8px; border-radius: 4px; }
.table-action-btn.delete:hover { color: #f87171; background: rgba(248,113,113,0.1); }
.table-actions { display: flex; gap: 10px; padding: 10px; background: rgba(0,0,0,0.15); }
.confirm-btn { background: var(--primary); margin-left: auto; }
.btn-sm { padding: 8px 14px; border-radius: 8px; font-size: 0.8rem; margin-top: 0; width: auto; }

/* =========================================
   MOBILE HEADER, HAMBURGER & SLIDE-OUT DRAWER
   ========================================= */

/* --- Mobile Header Bar (hidden on desktop) --- */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: rgba(42, 38, 35, 0.97);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  z-index: 300;
  padding: 0 16px;
  align-items: center;
  gap: 12px;
}
.hamburger-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.2rem;
  padding: 8px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s;
}
.hamburger-btn:hover { background: rgba(255,255,255,0.06); }
.mobile-logo {
  font-size: 1rem;
  font-weight: 700;
  background: linear-gradient(135deg, #da7756, #e8a87c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.mobile-header-spacer { flex: 1; }

/* --- Overlay (dark backdrop when drawer is open) --- */
.mobile-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 400;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.mobile-overlay.open {
  display: block;
  opacity: 1;
}

/* --- Slide-Out Drawer --- */
.mobile-drawer {
  display: none;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 280px;
  background: rgba(42, 38, 35, 0.98);
  backdrop-filter: blur(24px);
  border-right: 1px solid var(--border);
  z-index: 500;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0;
  box-shadow: 4px 0 24px rgba(0,0,0,0.4);
}
.mobile-drawer.open {
  transform: translateX(0);
}

.mobile-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.mobile-drawer-logo {
  font-size: 1.1rem;
  font-weight: 800;
  background: linear-gradient(135deg, #da7756, #e8a87c);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.mobile-drawer-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.1rem;
  padding: 6px;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.15s;
}
.mobile-drawer-close:hover { color: var(--text); background: rgba(255,255,255,0.06); }

.mobile-drawer-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mobile-drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
}
.mobile-drawer-item:hover {
  background: rgba(218, 119, 86, 0.08);
  color: var(--text);
}
.mobile-drawer-item.active {
  background: rgba(218, 119, 86, 0.15);
  color: var(--text);
  font-weight: 600;
}
.mobile-drawer-item span {
  font-size: 1.15rem;
  width: 24px;
  text-align: center;
}

.mobile-drawer-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

/* ===== MOBILE BREAKPOINT ===== */
@media (max-width: 768px) {
  body { flex-direction: column; }

  .sidebar { display: none; }

  /* Sprint 41 — collapse filter controls behind a toggle; stats stay slim */
  .filter-toggle {
    display: flex; justify-content: space-between; align-items: center;
    width: 100%; padding: 9px 12px; cursor: pointer;
    background: var(--bg-light); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text); font-size: 0.85rem; font-weight: 600;
  }
  .filter-toggle .filter-count {
    background: var(--primary); color: #fff; border-radius: 10px;
    padding: 0 7px; font-size: 0.72rem; margin-left: 6px;
  }
  .filter-toggle .filter-count:empty { display: none; }
  .filter-toggle .fa-chevron-down { transition: transform 0.2s; }
  .card.filters-open .filter-toggle .fa-chevron-down { transform: rotate(180deg); }
  .filter-body { display: none !important; margin-top: 10px; width: 100%; }
  .card.filters-open .filter-body { display: flex !important; }
  /* slim, one-line scrollable stats strip */
  #bank-stats, #voucher-stats {
    flex-wrap: nowrap !important; overflow-x: auto; -webkit-overflow-scrolling: touch;
    white-space: nowrap; gap: 10px !important;
  }
  #bank-stats > span, #voucher-stats > span { flex-shrink: 0; }

  .mobile-header { display: flex; }
  /* Sprint 65 — on the Home launcher, drop the hamburger (its drawer just repeats
     the app grid). Agent views keep their hamburger. */
  body.home-active #hamburger-btn { display: none; }
  /* Sprint 68/69 — phone: fixed 4-column app grid, larger icons */
  .feat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px 6px; }
  .feat-tile { width: auto; }
  .feat-ic { width: 62px; height: 62px; font-size: 1.85rem; }
  .feat-name { font-size: 0.72rem; }
  /* iPhone-style swipeable app pages (Home, mobile) */
  /* Sprint 66 — Home fills the screen: greeting on top, app pager takes the rest,
     dots pinned at the bottom; page rows stretch so tiles fill (no empty band). */
  body.home-active #home-view { display: flex; flex-direction: column; overflow: hidden; }
  body.home-active #home-app-grid { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  .app-pager { display: flex; flex: 1; min-height: 0; width: 100%; overflow-x: auto;
    scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .app-pager::-webkit-scrollbar { display: none; }
  /* Each page = exactly the viewport width (no bleed), 2 columns; tiles are a FIXED
     size and top-aligned, so a full page (6) and a partial page (3) show identical
     tiles (no stretching that made the last page look different). */
  .app-page { flex: 0 0 100%; width: 100%; height: 100%; box-sizing: border-box;
    scroll-snap-align: start; display: grid; grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 132px; align-content: start; gap: 14px; padding: 6px 4px; }
  .app-page .app-tile { height: 132px; padding: 12px 10px; }
  .app-dots { display: flex; flex: 0 0 auto; justify-content: center; gap: 8px; margin-top: 12px; }
  .app-dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,0.2);
    border: none; padding: 0; cursor: pointer; }
  .app-dot.active { background: var(--primary); }
  .mobile-drawer { display: flex; }

  .main-content {
    padding: 0;
    padding-top: 52px;       /* height of mobile header */
    height: 100vh;
    height: 100dvh;
    height: var(--app-height, 100dvh);
  }

  .dashboard-view { max-width: 100%; padding: 16px !important; }
  .grid { grid-template-columns: 1fr; gap: 16px; }

  /* Demo banner — tighter on mobile, still above scroll area */
  .demo-banner {
    margin: 8px 12px 0 12px;
    padding: 10px 14px;
    font-size: 0.82rem;
  }

  /* Chat layout fills space below header — chat-sidebar slides in over chat-main */
  #chat-view {
    padding: 0 !important;
  }
  .chat-layout {
    flex-direction: row;
    height: 100%;
    margin: 0;
  }

  /* Chat sidebar slides in from right on mobile */
  .chat-sidebar {
    position: fixed;
    top: 52px; right: 0; bottom: 0;
    width: 280px;
    z-index: 450;
    transform: translateX(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(42, 38, 35, 0.98);
    backdrop-filter: blur(24px);
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 24px rgba(0,0,0,0.4);
  }
  .chat-sidebar.mobile-open {
    transform: translateX(0);
  }

  /* Hide chat sessions button when not on chat view */
  .mobile-chats-btn { display: none; }

  .chat-main { height: 100%; }

  .chat-messages {
    padding: 16px;
    padding-bottom: 8px;
  }

  .chat-msg-bubble { max-width: 85%; font-size: 0.88rem; }

  .chat-suggestions { padding: 0 16px 8px; gap: 6px; }
  .chat-suggestion-btn { font-size: 0.72rem; padding: 6px 10px; }

  .chat-input-area {
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border);
  }

  .chat-input-wrapper { border-radius: 24px; padding: 5px 6px; }
  .chat-input-wrapper textarea { font-size: 16px; /* prevent iOS zoom */ }

  .chat-welcome { padding: 24px 16px; }
  .chat-welcome h2 { font-size: 1.4rem; }
  .chat-starter-grid { grid-template-columns: 1fr; gap: 8px; }

  .txn-type-selector { flex-wrap: wrap; }

  /* Table scroll on mobile */
  .chat-ui-table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Dashboard on mobile */
  #dashboard-view { padding: 16px; }
  .card { padding: 20px; border-radius: 14px; }
  .upload-zone { padding: 24px; }

  /* History on mobile */
  #history-view { padding: 16px; }
  #history-view .card { overflow-x: auto; }
}

@media (max-width: 380px) {
  .chat-msg-bubble { max-width: 90%; padding: 10px 12px; font-size: 0.85rem; }
  .chat-msg-avatar { width: 24px; height: 24px; font-size: 0.75rem; }
}

/* ===== WEBCAM MODAL OVERLAY (DESKTOP/LAPTOP) ===== */
.webcam-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.webcam-container {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 500px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.webcam-container h3 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text);
  font-weight: 700;
}

#webcam-video {
  width: 100%;
  aspect-ratio: 4/3;
  border-radius: 12px;
  background: #000;
  object-fit: cover;
  transform: scaleX(-1); /* Mirror camera feed for native user view */
  border: 1px solid var(--border);
}

.webcam-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  justify-content: flex-end;
}
.webcam-actions .btn {
  margin-top: 0;
  width: auto;
  font-size: 0.8rem;
  padding: 8px 16px;
}

/* ═══════════════════════════════════════════════════════════════════
   DESIGN SYSTEM — UTILITY COMPONENTS
   Consistent radii, palette, and component vocabulary across all views.
   Use these classes instead of inline styles for new features.
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 999px;

  /* Semantic colors that still feel warm */
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.10);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.10);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.10);
  --info: var(--accent);
  --info-bg: rgba(218, 119, 86, 0.10);

  /* Spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
}

/* Inputs and selects — use across the app */
.ya-input,
.ya-select,
input[type="text"].ya, input[type="number"].ya, input[type="date"].ya, select.ya {
  background: var(--bg-light);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.ya-input:focus, .ya-select:focus,
input[type="text"].ya:focus, select.ya:focus {
  border-color: var(--primary);
  background: var(--bg-surface);
}

/* Buttons — standardize on three semantic variants */
.ya-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: none;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: transform 0.05s ease, filter 0.15s ease, background 0.15s;
  white-space: nowrap;
  font-family: inherit;
}
.ya-btn:hover { filter: brightness(1.1); }
.ya-btn:active { transform: translateY(1px); }

.ya-btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
}
.ya-btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.ya-btn-secondary:hover { background: rgba(255, 255, 255, 0.04); border-color: var(--primary); color: var(--primary); }
.ya-btn-success { background: var(--success); color: white; }
.ya-btn-warning { background: var(--warning); color: white; }
.ya-btn-danger { background: var(--danger); color: white; }
.ya-btn-ghost { background: rgba(255, 255, 255, 0.03); color: var(--text-secondary); border: 1px solid var(--border); }
.ya-btn-ghost:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }
.ya-btn-sm { padding: 6px 12px; font-size: 0.78rem; }

/* Metric cards (used in dashboards) */
.ya-metric {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
  text-align: center;
}
.ya-metric .value {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}
.ya-metric .label {
  color: var(--text-secondary);
  font-size: 0.78rem;
  margin-top: var(--sp-1);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.ya-metric.success { background: var(--success-bg); border-color: rgba(16,185,129,0.25); }
.ya-metric.success .value { color: var(--success); }
.ya-metric.success .label { color: var(--success); }
.ya-metric.warning { background: var(--warning-bg); border-color: rgba(245,158,11,0.25); }
.ya-metric.warning .value { color: var(--warning); }
.ya-metric.warning .label { color: var(--warning); }
.ya-metric.danger { background: var(--danger-bg); border-color: rgba(239,68,68,0.25); }
.ya-metric.danger .value { color: var(--danger); }
.ya-metric.danger .label { color: var(--danger); }
.ya-metric.info { background: var(--info-bg); border-color: rgba(218,119,86,0.25); }
.ya-metric.info .value { color: var(--info); }
.ya-metric.info .label { color: var(--info); }

/* Status badges (table cells) */
.ya-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.ya-badge-success { background: var(--success-bg); color: var(--success); }
.ya-badge-warning { background: var(--warning-bg); color: var(--warning); }
.ya-badge-danger  { background: var(--danger-bg); color: var(--danger); }
.ya-badge-info    { background: var(--info-bg); color: var(--info); }
.ya-badge-neutral { background: rgba(255,255,255,0.06); color: var(--text-secondary); }

/* Filter pill row (Vouchers, Recon Studio, GST Filing) */
.ya-filter-row { display: flex; gap: 8px; flex-wrap: wrap; }
.ya-filter-pill {
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.ya-filter-pill:hover { color: var(--text); border-color: var(--primary); }
.ya-filter-pill.active { background: var(--info-bg); color: var(--primary); border-color: var(--primary); }

/* Section card (consistent block container) */
.ya-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
}
.ya-section + .ya-section { margin-top: var(--sp-5); }
.ya-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
  gap: var(--sp-3);
}
.ya-section-header h3, .ya-section-header h4 { margin: 0; }

/* Empty state */
.ya-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary);
}
.ya-empty-icon { font-size: 2.5rem; margin-bottom: var(--sp-3); opacity: 0.6; }
.ya-empty-title { color: var(--text); font-weight: 600; margin-bottom: var(--sp-1); }

/* Validation issue rows (used in GSTR + Recon) */
.ya-issue {
  padding: 12px 14px;
  margin-bottom: 8px;
  border-radius: var(--radius-md);
  border-left: 3px solid;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  font-size: 0.85rem;
}
.ya-issue-error   { background: var(--danger-bg);  border-left-color: var(--danger); }
.ya-issue-warning { background: var(--warning-bg); border-left-color: var(--warning); }
.ya-issue-info    { background: var(--info-bg);    border-left-color: var(--info); }
.ya-issue-meta { color: var(--text-secondary); font-size: 0.78rem; flex-shrink: 0; }

/* Tables — give every data table a consistent look */
.ya-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.ya-table thead { position: sticky; top: 0; background: var(--bg-surface); z-index: 1; }
.ya-table th {
  text-align: left;
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.ya-table td { padding: 12px; border-bottom: 1px solid var(--border); color: var(--text); }
.ya-table tbody tr:hover { background: rgba(255,255,255,0.025); }
.ya-table .numeric { text-align: right; font-variant-numeric: tabular-nums; }

/* Hover-clickable card */
.ya-card-clickable {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
  cursor: pointer;
  transition: all 0.15s;
}
.ya-card-clickable:hover { border-color: var(--primary); background: rgba(255,255,255,0.04); }

/* ═══════════════════════════════════════════════════════════════════
   DEMO COMPANY BANNER — high-contrast, prominent
   ═══════════════════════════════════════════════════════════════════ */
.demo-banner {
  display: none;        /* JS toggles to flex */
  align-items: center;
  gap: 14px;
  padding: 12px 22px;
  margin: 12px 24px 0 24px;     /* keeps banner away from edges; outside scrolling view */
  background: linear-gradient(135deg, rgba(218, 119, 86, 0.22), rgba(218, 119, 86, 0.12));
  border: 1px solid rgba(218, 119, 86, 0.55);
  border-left: 4px solid var(--primary);
  border-radius: 10px;
  font-size: 0.88rem;
  box-shadow: 0 2px 10px rgba(218, 119, 86, 0.08);
  flex-shrink: 0;       /* sits above scrolling view, never compresses */
  z-index: 5;
}
.demo-banner.demo-banner-flex { display: flex; }
.demo-banner-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  line-height: 1;
}
.demo-banner-text {
  flex: 1;
  line-height: 1.4;
}
.demo-banner-text strong {
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 0.2px;
}
.demo-banner-text span {
  color: var(--text);
  opacity: 0.92;
}

/* ═══════════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — comprehensive coverage for all new views
   ═══════════════════════════════════════════════════════════════════ */

/* Touch-target safety for buttons */
@media (max-width: 768px) {
  button, .btn, .ya-btn { min-height: 40px; }
  .ya-btn-sm { min-height: 32px; }

  /* Main content padding — give edges some breathing room.
     Padding lives on the view, not main-content, so banner can stay edge-aware. */
  .main-content { padding: 0 !important; padding-top: 52px !important; }
  .dashboard-view { padding: 16px !important; }
  #chat-view { padding: 0 !important; }

  /* All ya-section blocks lose extra padding on mobile */
  .ya-section { padding: 16px; border-radius: 10px; }
  .ya-section-header { flex-direction: column; align-items: flex-start; }
  .ya-section-header > * { width: 100%; }

  /* Demo banner stays full-width and readable */
  .demo-banner {
    padding: 12px 14px;
    margin: 0 0 14px 0;
    font-size: 0.82rem;
    gap: 10px;
  }
  .demo-banner-icon { font-size: 1.2rem; }

  /* All dashboards — header h1 becomes smaller */
  .dashboard-view > header h1,
  .dashboard-view h1 { font-size: 1.4rem; }
  .dashboard-view > header p { font-size: 0.85rem; }

  /* Filter-pill rows wrap nicely with consistent spacing */
  .ya-filter-row { gap: 6px; }
  .ya-filter-pill { padding: 6px 12px; font-size: 0.78rem; }

  /* Table containers — horizontal scroll with momentum */
  .ya-table-wrap, .card .table-wrap, .card > table,
  div[style*="overflow-x: auto"] {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px;        /* break out of card padding */
    padding: 0 16px;
  }
  .ya-table { font-size: 0.8rem; min-width: 600px; /* keeps columns readable; user scrolls */ }
  .ya-table th, .ya-table td { padding: 8px 10px; }

  /* Metric card grids: 2 cols on small screens */
  .grid { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  .ya-metric { padding: 12px 8px; }
  .ya-metric .value { font-size: 1.15rem; }
  .ya-metric .label { font-size: 0.68rem; }

  /* Forms stack vertically */
  .form-row { flex-direction: column !important; align-items: stretch !important; }
  .form-row > * { width: 100% !important; }

  /* Inputs are 16px to prevent iOS zoom */
  input, select, textarea, .ya-input, .ya-select { font-size: 16px !important; }

  /* Cards / blocks lose excessive padding */
  .card { padding: 16px !important; }

  /* RECON STUDIO — multi-step wizard stacks */
  #recon-master-block, #recon-external-block { padding: 12px !important; }
  #recon-master-block > div, #recon-external-block > div { flex-direction: column !important; gap: 8px !important; align-items: stretch !important; }
  #recon-metrics-cards { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
  #recon-source-name { width: 100% !important; }

  /* GST FILING — period picker stacks, metric grid 2-col */
  #gstr-month, #gstr-year { width: 100% !important; }
  #gstr-due-cards { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  #gstr-due-cards > div { padding: 14px !important; }
  #gstr-due-cards > div > div:nth-child(2) { font-size: 1.2rem !important; }
  #gstr1-metrics, #gstr3b-metrics { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
  #gstr1-metrics > div, #gstr3b-metrics > div { padding: 10px !important; }
  #gstr1-metrics > div > div:first-child, #gstr3b-metrics > div > div:first-child { font-size: 1rem !important; }

  /* VOUCHERS — bulk action bar stacks */
  .voucher-actions, [id="vouchers-actions-bar"] { flex-direction: column !important; gap: 8px !important; align-items: stretch !important; }

  /* YANTRAI TASKS — task cards full width */
  .task-card { width: 100%; }

  /* Reconciliation results — column wrappers */
  .grid[style*="grid-template-columns: 1fr 1fr 1fr 1fr"] { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
  .grid[style*="grid-template-columns: repeat(auto-fit, minmax(160px"] { grid-template-columns: 1fr 1fr !important; gap: 8px !important; }
  .grid[style*="grid-template-columns: repeat(auto-fit, minmax(280px"] { grid-template-columns: 1fr !important; gap: 10px !important; }
  .grid[style*="grid-template-columns: repeat(auto-fill, minmax(280px"] { grid-template-columns: 1fr !important; gap: 10px !important; }

  /* Sticky action bars on mobile (Export / Sync to Tally / etc.) */
  .ya-mobile-sticky-actions {
    position: sticky;
    bottom: 0;
    background: var(--bg);
    padding: 12px;
    margin: 0 -16px -16px -16px;
    border-top: 1px solid var(--border);
    z-index: 100;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.3);
  }

  /* Issues / discrepancy rows */
  .ya-issue { flex-direction: column; align-items: flex-start; gap: 6px; }
  .ya-issue-meta { font-size: 0.72rem; }
}

@media (max-width: 480px) {
  /* Single column on very small screens */
  .grid { grid-template-columns: 1fr !important; }
  #recon-metrics-cards,
  #gstr-due-cards,
  #gstr1-metrics,
  #gstr3b-metrics { grid-template-columns: 1fr !important; }

  .dashboard-view > header h1,
  .dashboard-view h1 { font-size: 1.2rem; }

  /* Action button row in vouchers — full-width stacked */
  .ya-btn { width: 100%; justify-content: center; }
  .ya-btn-sm { width: auto; }

  /* Demo banner becomes condensed */
  .demo-banner-text span { display: block; margin-top: 4px; }
}


