/* ===================== Theme tokens ===================== */
:root {
  color-scheme: light;

  --bg-page:      #f9f9f7;
  --bg-sidebar:   #f0eee6;
  --bg-main:      #ffffff;
  --bg-card:      #ffffff;
  --bg-card-hover:#fbfaf7;
  --bg-input:     #ffffff;
  --bg-hover:     rgba(11, 11, 11, 0.05);
  --bg-active:    rgba(11, 11, 11, 0.08);

  --text-primary:   #1a1918;
  --text-secondary: #52514e;
  --text-muted:     #8b8981;

  --border:       rgba(11, 11, 11, 0.10);
  --border-strong: rgba(11, 11, 11, 0.16);

  --accent:        #c96442;
  --accent-hover:  #b5573a;
  --accent-tint:   rgba(201, 100, 66, 0.10);
  --accent-ink:    #ffffff;

  --good:      #0a7d2c;
  --good-tint: rgba(10, 125, 44, 0.10);
  --warn:      #b5750a;
  --warn-tint: rgba(181, 117, 10, 0.10);

  --chart-surface: #fcfcfb;
  --chart-grid:    #e1e0d9;
  --chart-axis:    #c3c2b7;
  --series-1:      #2a78d6;
  --series-1-tint: rgba(42, 120, 214, 0.14);

  --shadow-sm: 0 1px 2px rgba(11,11,11,0.06);
  --shadow-md: 0 4px 16px rgba(11,11,11,0.08);
  --shadow-lg: 0 12px 36px rgba(11,11,11,0.14);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg-page:      #0d0d0d;
    --bg-sidebar:   #191817;
    --bg-main:      #1c1b1a;
    --bg-card:      #232221;
    --bg-card-hover:#282726;
    --bg-input:     #232221;
    --bg-hover:     rgba(255, 255, 255, 0.06);
    --bg-active:    rgba(255, 255, 255, 0.10);

    --text-primary:   #f5f4f1;
    --text-secondary: #c3c2b7;
    --text-muted:     #8b8981;

    --border:        rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.18);

    --accent:        #d97757;
    --accent-hover:  #e28a6c;
    --accent-tint:   rgba(217, 119, 87, 0.16);
    --accent-ink:    #1a1110;

    --good:      #35c265;
    --good-tint: rgba(53, 194, 101, 0.14);
    --warn:      #e0a83c;
    --warn-tint: rgba(224, 168, 60, 0.14);

    --chart-surface: #201f1e;
    --chart-grid:    #34332f;
    --chart-axis:    #55534c;
    --series-1:      #3987e5;
    --series-1-tint: rgba(57, 135, 229, 0.18);

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg: 0 12px 36px rgba(0,0,0,0.5);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg-page:      #0d0d0d;
  --bg-sidebar:   #191817;
  --bg-main:      #1c1b1a;
  --bg-card:      #232221;
  --bg-card-hover:#282726;
  --bg-input:     #232221;
  --bg-hover:     rgba(255, 255, 255, 0.06);
  --bg-active:    rgba(255, 255, 255, 0.10);

  --text-primary:   #f5f4f1;
  --text-secondary: #c3c2b7;
  --text-muted:     #8b8981;

  --border:        rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);

  --accent:        #d97757;
  --accent-hover:  #e28a6c;
  --accent-tint:   rgba(217, 119, 87, 0.16);
  --accent-ink:    #1a1110;

  --good:      #35c265;
  --good-tint: rgba(53, 194, 101, 0.14);
  --warn:      #e0a83c;
  --warn-tint: rgba(224, 168, 60, 0.14);

  --chart-surface: #201f1e;
  --chart-grid:    #34332f;
  --chart-axis:    #55534c;
  --series-1:      #3987e5;
  --series-1-tint: rgba(57, 135, 229, 0.18);

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 12px 36px rgba(0,0,0,0.5);
}

/* ===================== Base ===================== */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-secondary:hover { background: var(--bg-hover); }

/* ===================== App shell ===================== */
.app {
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.mobile-logo { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--accent); }
.mobile-logo svg { width: 20px; height: 20px; }
.mobile-spacer { width: 34px; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 29;
}

/* ===================== Notification bell ===================== */
.notif-wrap { position: relative; }
.notif-btn { position: relative; }
.notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.notif-badge.hidden { display: none; }

.notif-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 320px;
  max-width: calc(100vw - 40px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
  z-index: 45;
}
.notif-dropdown.open { display: block; }
.notif-dropdown-header {
  font-size: 13px;
  font-weight: 600;
  padding: 8px 10px 6px;
  color: var(--text-primary);
}
.notif-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.notif-item {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-primary);
}
.notif-item:hover { background: var(--bg-hover); }
.notif-item-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-top: 5px; flex-shrink: 0; }
.notif-empty { padding: 16px 10px; text-align: center; font-size: 13px; color: var(--text-muted); }

/* ===================== Sidebar ===================== */
.sidebar {
  width: 272px;
  min-width: 272px;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  height: 100%;
  border-right: 1px solid var(--border);
  padding: 14px 12px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 14px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
}
.logo-mark { width: 22px; height: 22px; }
.logo-text {
  font-size: 17px;
  font-weight: 650;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.sidebar-search {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.18s ease, margin 0.18s ease;
  margin-bottom: 0;
}
.sidebar-search.open {
  max-height: 44px;
  margin-bottom: 8px;
}
.sidebar-search input {
  width: 100%;
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13.5px;
  outline: none;
}
.sidebar-search input:focus { border-color: var(--accent); }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 14px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--accent-tint); color: var(--accent); font-weight: 550; }

.recents {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.recents-heading {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 4px 10px 6px;
}
.recents-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.recent-item {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  color: var(--text-secondary);
  font-size: 13.5px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s ease, color 0.15s ease;
}
.recent-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.recent-item.active { background: var(--bg-active); color: var(--text-primary); font-weight: 500; }
.recents-empty {
  font-size: 13px;
  color: var(--text-muted);
  padding: 8px 10px;
}

.sidebar-footer {
  position: relative;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 6px;
}
.user-trigger {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  border: none;
  background: transparent;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease;
}
.user-trigger:hover { background: var(--bg-hover); }
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}
.user-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-chevron { width: 15px; height: 15px; color: var(--text-muted); flex-shrink: 0; }

.user-popover {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 6px;
  right: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 1px;
  z-index: 40;
}
.user-popover.open { display: flex; }
.popover-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 13.5px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
}
.popover-item svg { width: 16px; height: 16px; color: var(--text-secondary); flex-shrink: 0; }
.popover-item:hover { background: var(--bg-hover); }
.popover-divider { height: 1px; background: var(--border); margin: 4px 4px; }
.popover-toggle-row { cursor: default; justify-content: space-between; }
.popover-toggle-row:hover { background: transparent; }

.switch {
  width: 36px;
  height: 21px;
  border-radius: 12px;
  background: var(--border-strong);
  border: none;
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: background 0.15s ease;
}
.switch-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease;
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"] .switch-knob { transform: translateX(15px); }

/* ===================== Main ===================== */
.main {
  flex: 1;
  height: 100%;
  overflow: hidden;
  position: relative;
  background: var(--bg-page);
  display: flex;
  flex-direction: column;
}

.main-topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 52px;
  padding: 0 16px;
}

.view {
  display: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.view.active { display: flex; flex-direction: column; }

/* New chat / greeting view */
.new-chat-scroll {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 24px 48px;
  min-height: 100%;
}
.new-chat-hero {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 62vh;
}
.new-chat-hero-inner {
  width: 100%;
  margin: auto 0;
}
.new-chat-dashboard {
  width: 100%;
  max-width: 720px;
}
.greeting {
  text-align: center;
  font-size: 30px;
  font-weight: 550;
  color: var(--text-primary);
  margin: 0 0 24px;
  letter-spacing: -0.01em;
}

/* Composer */
.composer-slot { width: 100%; }
.composer {
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 12px 14px 10px;
  transition: border-color 0.15s ease;
}
.composer:focus-within { border-color: var(--accent); }

#promptInput {
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  min-height: 58px;
  max-height: 200px;
  overflow-y: auto;
  padding: 4px 4px 8px;
}
#promptInput::placeholder { color: var(--text-muted); }

.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.composer-toolbar-left {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.model-select { position: relative; margin-left: 4px; }
.model-select-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 9px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}
.model-select-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.model-select-btn svg { width: 13px; height: 13px; }
.model-select-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  min-width: 260px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 30;
}
.model-select-menu.open { display: flex; }
.model-select-menu button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
}
.model-select-menu button:hover { background: var(--bg-hover); }
.model-select-menu button.selected { background: var(--accent-tint); }
.model-name { font-size: 13.5px; font-weight: 550; color: var(--text-primary); }
.model-desc { font-size: 12px; color: var(--text-muted); }

.send-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.send-btn svg { width: 16px; height: 16px; }
.send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.send-btn:disabled { opacity: 0.35; cursor: default; }

/* Suggestion chips */
.chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 18px;
}
.chip {
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.chip:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-strong); }
.chip-edit-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.chip-edit-btn svg { width: 14px; height: 14px; }
.chip-edit-btn:hover { color: var(--text-primary); border-color: var(--text-secondary); }

/* Widget dashboard */
.widget-grid-header {
  margin-top: 34px;
  margin-bottom: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.widget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  padding-bottom: 12px;
}
.widget-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 16px 14px;
  min-height: 128px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.15s ease, background 0.15s ease;
}
.widget-card:hover { box-shadow: var(--shadow-md); }
.widget-card--chart { grid-column: span 2; min-height: 210px; }
@media (max-width: 700px) {
  .widget-card--chart { grid-column: 1 / -1; }
}
.widget-card { cursor: grab; }
.widget-card.dragging { opacity: 0.4; cursor: grabbing; }

.widget-home-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-secondary);
}
.switch-sm { width: 30px; height: 18px; }
.switch-sm .switch-knob { width: 14px; height: 14px; }
.switch-sm[aria-checked="true"] .switch-knob { transform: translateX(12px); }

.dashboard-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin: -10px 0 18px;
}

.widget-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 10px;
}
.widget-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0;
  outline: none;
}
.widget-title[contenteditable="true"] {
  background: var(--accent-tint);
  border-radius: 4px;
  padding: 1px 4px;
  color: var(--text-primary);
}

.widget-menu-wrap { position: relative; flex-shrink: 0; }
.widget-menu-btn {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.widget-menu-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.widget-menu-btn svg { width: 16px; height: 16px; }
.widget-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 172px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 5px;
  display: none;
  flex-direction: column;
  z-index: 25;
}
.widget-menu.open { display: flex; }
.widget-menu button {
  border: none;
  background: transparent;
  text-align: left;
  padding: 7px 9px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
}
.widget-menu button:hover { background: var(--bg-hover); }
.widget-menu button.danger { color: #c94141; }

.widget-number-value {
  font-size: 26px;
  font-weight: 650;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  margin: auto 0 4px;
}
.widget-number-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0;
}
.widget-number-sub.good { color: var(--good); }
.widget-number-sub.warn { color: var(--warn); }

.widget-chart-body { flex: 1; display: flex; align-items: stretch; }
.widget-chart-body svg { width: 100%; height: 100%; overflow: visible; }

.add-widget-card {
  background: transparent;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  min-height: 128px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}
.add-widget-card:hover { border-color: var(--text-secondary); color: var(--text-primary); background: var(--bg-hover); }
.add-widget-card svg { width: 20px; height: 20px; }

/* ===================== Chat view ===================== */
#view-chat.view.active { display: flex; }
.chat-header {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 24px 8px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.msg-row { display: flex; width: 100%; }
.msg-row.user { justify-content: flex-end; }
.msg-row.assistant { justify-content: flex-start; }
.msg-bubble {
  max-width: 620px;
  padding: 11px 15px;
  border-radius: var(--radius-md);
  font-size: 14.5px;
  line-height: 1.55;
}
.msg-row.user .msg-bubble {
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius-md) var(--radius-md) 4px var(--radius-md);
}
.msg-row.assistant .msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius-md) var(--radius-md) var(--radius-md) 4px;
}
.msg-bubble p { margin: 0 0 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul { margin: 0 0 8px; padding-left: 20px; }
.msg-bubble ul:last-child { margin-bottom: 0; }
.msg-bubble strong { font-weight: 650; }

/* Inline chat action buttons (Yes/No, Attach/Skip) */
.msg-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.msg-action-btn {
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.msg-action-btn:hover:not(:disabled) { background: var(--bg-hover); }
.msg-action-btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.msg-action-btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.msg-action-btn:disabled { opacity: 0.45; cursor: default; }

/* Simulated bookkeeping evaluation steps */
.bk-steps { display: flex; flex-direction: column; gap: 9px; }
.bk-step { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--text-secondary); }
.bk-step.done { color: var(--text-primary); }
.bk-step-icon { width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.bk-step-icon svg { width: 15px; height: 15px; }
.bk-step.done .bk-step-icon { color: var(--good); }
.bk-spinner {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: bkSpin 0.7s linear infinite;
}
@keyframes bkSpin { to { transform: rotate(360deg); } }

/* Bookkeeping transaction summary card */
.bk-summary-intro { margin: 0 0 10px; }
.bk-summary {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 10px;
}
.bk-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-page);
}
.bk-summary-row:last-child { border-bottom: none; }
.bk-summary-label { color: var(--text-muted); }
.bk-summary-value { color: var(--text-primary); font-weight: 550; font-variant-numeric: tabular-nums; }
.bk-view-btn { margin-top: 2px; }

/* Status badges (shared: chat summary + transactions table) */
.status-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}
.status-badge.good { background: var(--good-tint); color: var(--good); }
.status-badge.warn { background: var(--warn-tint); color: var(--warn); }

.typing-dots {
  display: inline-flex;
  gap: 4px;
  padding: 4px 2px;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBlink 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBlink {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

.composer-slot-bottom {
  padding: 10px 24px 20px;
  flex-shrink: 0;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
}

/* ===================== Placeholder views (Transactions / Artifacts) ===================== */
.placeholder-view { padding: 28px 32px 40px; max-width: 1100px; width: 100%; margin: 0 auto; }
.placeholder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.placeholder-header h2 { font-size: 22px; font-weight: 600; margin: 0; }

.filter-tabs { display: flex; gap: 6px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.filter-tab {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.filter-tab:hover { color: var(--text-primary); }
.filter-tab.active { background: var(--accent); color: var(--accent-ink); font-weight: 500; }

.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: auto;
  box-shadow: var(--shadow-sm);
}
.txn-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 620px; }
.txn-table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.txn-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  white-space: nowrap;
}
.txn-table tbody tr:last-child td { border-bottom: none; }
.txn-table tbody tr:hover { background: var(--bg-hover); }
.txn-amount-col { text-align: right; }
.txn-table td.txn-amount { text-align: right; font-variant-numeric: tabular-nums; font-weight: 550; }
.txn-amount.credit { color: var(--good); }
.txn-category-tag {
  display: inline-block;
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-hover);
  color: var(--text-secondary);
}
.txn-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
}
.txn-type-badge.income { color: var(--good); }
.txn-type-badge.expense { color: var(--text-secondary); }
.txn-type-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.artifacts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.artifact-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.artifact-card:hover { box-shadow: var(--shadow-md); }
.artifact-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}
.artifact-icon svg { width: 18px; height: 18px; }
.artifact-icon.pdf { background: #c94141; }
.artifact-icon.xlsx { background: var(--good); }
.artifact-icon.doc { background: var(--series-1); }
.artifact-name { font-size: 14px; font-weight: 550; color: var(--text-primary); margin: 0; }
.artifact-meta { font-size: 12px; color: var(--text-muted); margin: 0; }

/* ===================== Modals ===================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  padding: 20px 22px 22px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.modal-header h3 { font-size: 17px; margin: 0; font-weight: 600; }
.modal-hint { font-size: 13px; color: var(--text-muted); margin: 0 0 14px; }

.chips-edit-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.chips-edit-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13.5px;
}
.chips-edit-list li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-remove-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chip-remove-btn:hover { background: var(--bg-hover); color: #c94141; }
.chip-remove-btn svg { width: 14px; height: 14px; }

.chips-add-row { display: flex; gap: 8px; margin-bottom: 16px; }
.chips-add-row input {
  flex: 1;
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13.5px;
  outline: none;
}
.chips-add-row input:focus { border-color: var(--accent); }

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

.form-row { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.form-row label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.form-row input, .form-row select {
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
}
.form-row input:focus, .form-row select:focus { border-color: var(--accent); }
.form-hint { font-size: 11.5px; color: var(--text-muted); margin: 0; }

/* ===================== Toasts ===================== */
.toast-container {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 90;
  align-items: center;
}
.toast {
  background: var(--text-primary);
  color: var(--bg-page);
  font-size: 13.5px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ===================== Responsive ===================== */
@media (max-width: 860px) {
  .mobile-topbar { display: flex; }
  .app { height: calc(100vh - 49px); }

  .sidebar {
    position: fixed;
    top: 49px;
    bottom: 0;
    left: 0;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }

  .greeting { font-size: 24px; }
  .widget-card--chart { grid-column: 1 / -1; }
  .placeholder-view { padding: 20px 16px 32px; }
  .main-topbar { height: 44px; }
  .new-chat-hero { min-height: 34vh; }
}

@media (max-width: 480px) {
  .widget-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .new-chat-scroll { padding: 0 14px 40px; }
}
