:root {
  color-scheme: light;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: #f5f7fb;
  color: #1f2933;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f5f7fb;
  height: 100vh;
  overflow: hidden;
}

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  height: 100vh;
}

.sidebar {
  background: #ffffff;
  border-right: 1px solid #e5eaf0;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
}

.pill {
  background: #e6eefc;
  color: #1d4ed8;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#visibleServiceButtons {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-divider {
  height: 1px;
  background: #e5eaf0;
  margin: 6px 0;
}

/* Daily Brief Button */
.daily-brief-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 16px;
  background: #f8fafc;
  color: #1f2933;
  border: 1px solid #e5eaf0;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
  margin-bottom: 8px;
  position: relative;
}

.daily-brief-button:hover {
  background: #ffffff;
  border-color: #cbd5e0;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(31, 41, 51, 0.08);
}

.daily-brief-button:active {
  transform: translateY(0);
  box-shadow: none;
}

.daily-brief-button.active {
  background: #e6eefc;
  border-color: #1d4ed8;
}

.daily-brief-button.active .daily-brief-title {
  color: #1d4ed8;
}

.daily-brief-button.active .daily-brief-date {
  color: #1d4ed8;
}

.daily-brief-content {
  flex: 1;
  text-align: left;
}

.daily-brief-title {
  font-size: 14px;
  font-weight: 600;
  color: #1f2933;
  margin-bottom: 2px;
}

.daily-brief-date {
  font-size: 12px;
  color: #6b7280;
  font-weight: 400;
}

.daily-brief-button .badge {
  background: #1d4ed8;
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
}

.sidebar-section details {
  background: #f8fafc;
  border-radius: 12px;
  padding: 10px 12px;
}

.sidebar-section summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #1f2933;
  list-style: none;
}

.sidebar-section summary::-webkit-details-marker {
  display: none;
}

.sidebar-list {
  margin: 10px 0;
  padding: 0 0 0 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: #475569;
}

.sidebar-link {
  background: transparent;
  border: none;
  padding: 0;
  text-align: left;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.sidebar-link:hover {
  text-decoration: underline;
}

.button.small {
  padding: 6px 10px;
  font-size: 12px;
  margin-right: 6px;
}

.nav-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
}

.nav-item {
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  color: #1f2933;
  background: #f3f6fb;
  border: none;
  text-align: left;
  cursor: pointer;
}

.nav-item.active {
  background: #1d4ed8;
  color: #ffffff;
}

.hidden {
  display: none;
}

.main {
  padding: 32px 36px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-height: 0;
  height: 100vh;
  overflow-y: auto;
  /* Reserve space so fixed chat panel doesn't cover content */
  padding-bottom: 620px;
}

/* Keep layout usable as window narrows before mobile breakpoints */
@media (max-width: 1280px) {
  .app {
    grid-template-columns: 220px 1fr;
  }

  .main {
    padding: 22px 20px 40px;
    padding-bottom: 560px;
  }

  .header {
    flex-wrap: wrap;
    gap: 10px;
    margin: 0;
    padding: 12px 14px;
  }

  .header-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: white;
  z-index: 100;
  padding: 16px 24px;
  border-bottom: 2px solid #e5e7eb;
  margin: 0 -24px;
  margin-bottom: 20px;
}
.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: #f3f6fb;
  border-radius: 999px;
}

.user-initials {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #1d4ed8;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
}

.header h1 {
  margin: 0 0 6px;
  font-size: 26px;
}

.header p {
  margin: 0;
  color: #6b7280;
}

.panel {
  background: #ffffff;
  border-radius: 16px;
  padding: 20px 22px;
  box-shadow: 0 10px 28px rgba(31, 41, 51, 0.08);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.panel-header h2 {
  margin: 0;
  font-size: 18px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.stat-card {
  background: #f8fafc;
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-label {
  font-size: 12px;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
}

.badge {
  width: fit-content;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
}

.badge.success {
  background: #dcfce7;
  color: #166534;
}

.badge.neutral {
  background: #e2e8f0;
  color: #1f2933;
}

.outbound-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.outbound-card {
  background: #f8fafc;
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.outbound-details {
  display: flex;
  gap: 32px;
  margin-top: 12px;
}

.flag {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
}

.flag.warn {
  background: #fee2e2;
  color: #b91c1c;
}

.flag.neutral {
  background: #e2e8f0;
  color: #1f2933;
}

.advanced-section {
  margin-top: 12px;
  background: #f8fafc;
  border-radius: 12px;
  padding: 12px 14px;
}

.advanced-section summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #1f2933;
  list-style: none;
}

.advanced-section summary::-webkit-details-marker {
  display: none;
}

.status-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f8fafc;
}

.shortcuts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.shortcuts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.shortcut-item {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid #e5eaf0;
  background: #f8fafc;
  border-radius: 14px;
  padding: 14px 14px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  position: relative;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
}

.shortcut-item strong {
  font-size: 14px;
  font-weight: 700;
  color: #1f2933;
  padding-right: 22px; /* leave space for chevron */
}

.shortcut-item span {
  font-size: 12px;
  color: #6b7280;
  padding-right: 22px; /* leave space for chevron */
}

.shortcut-item::after {
  content: "›";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 22px;
  line-height: 1;
  color: #94a3b8;
}

.shortcut-item:hover {
  background: #ffffff;
  border-color: #cbd5e1;
  transform: translateY(-1px);
  box-shadow: 0 14px 26px rgba(31, 41, 51, 0.12);
}

.shortcut-item:active {
  transform: translateY(0);
}

.shortcut-item:focus-visible {
  outline: 3px solid rgba(29, 78, 216, 0.35);
  outline-offset: 2px;
}

.quick-actions-hint {
  margin: 4px 0 0;
  font-size: 12px;
}

.shortcut-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

.inline-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.shortcut-card {
  border: none;
  border-radius: 12px;
  padding: 12px;
  background: #ffffff;
  box-shadow: 0 10px 22px rgba(31, 41, 51, 0.12);
  font-size: 14px;
  color: #1f2933;
  transition: transform 160ms ease, box-shadow 160ms ease;
  cursor: pointer;
}

.shortcut-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 26px rgba(31, 41, 51, 0.18);
}

.chat-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: auto; /* Start collapsed */
}

/* When expanded, fill available space */
.chat-panel.expanded .chat-box {
  height: calc(100vh - 140px); /* Full height minus header and padding */
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-right: 8px;
  display: none; /* Hidden initially */
}

/* Show messages when expanded */
.chat-panel.expanded .chat-messages {
  display: flex;
}

.chat-panel .panel-header h2 {
  color: #1d4ed8;
}

.chat-message {
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  animation: fadeIn 0.3s ease-in;
  line-height: 1.6;
}

.chat-message.user {
  max-width: 66%;
  margin-left: auto;
  background: #e0e7ff;
  text-align: left;
}

.chat-message.assistant {
  max-width: 100%;
  background: #f3f6fb;
}

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

.chat-message .loading {
  color: #6b7280;
  font-style: italic;
}

.shortcut-card:focus-visible {
  outline: 2px solid #1d4ed8;
  outline-offset: 2px;
}

.loading-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #1f2933;
}

.loading-label {
  font-weight: 600;
}

.loading-dots {
  color: #6b7280;
}

.loading-meta {
  margin-top: 6px;
  font-size: 12px;
  color: #6b7280;
}

.loading-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid #cbd5e1;
  border-top-color: #1d4ed8;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.chat-input {
  display: flex;
  gap: 12px;
  align-items: center;
}

.chat-input input {
  flex: 1;
  border: 2px solid rgba(29, 78, 216, 0.55);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  box-shadow: 0 8px 18px rgba(29, 78, 216, 0.12);
}

.chat-panel {
  margin-top: auto;
  border: 1px solid rgba(29, 78, 216, 0.12);
  box-shadow: 0 16px 32px rgba(29, 78, 216, 0.12);
  position: fixed;
  left: calc(260px + 36px);
  right: 36px;
  bottom: 40px;
  z-index: 50;
  transition: all 0.3s ease;
  /* Start with just header + input visible (no messages) */
}

/* Expanded state after user sends first message */
.chat-panel.expanded {
  top: 100px; /* Below the sticky header */
  bottom: 40px;
  height: calc(100vh - 140px); /* Fill most of screen */
}

.chat-panel.expanded .chat-box {
  height: 100%;
}

/* ── Hamburger button (hidden on desktop) ── */
.hamburger-btn {
  display: none;
  background: none;
  border: 1px solid #d1d7e0;
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  color: #374151;
  flex-shrink: 0;
}

/* ── Sidebar overlay backdrop ── */
.sidebar-overlay {
  display: none;
}

/* ═══════════════════════════════════════════
   TABLET: Narrow sidebar
   ═══════════════════════════════════════════ */
@media (max-width: 980px) {
  .app {
    grid-template-columns: 220px 1fr;
  }
  .main {
    padding: 24px 20px 40px;
    padding-bottom: 560px;
  }
  .chat-panel {
    left: calc(220px + 20px);
    right: 20px;
  }
  #insightsChatPanel {
    left: calc(220px + 20px);
    right: 20px;
  }
}

/* ═══════════════════════════════════════════
   MOBILE: < 768px
   Full responsive layout for phone screens
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Bump base font size for readability on small screens */
  :root {
    font-size: 19px;
  }

  /* Grid becomes single column */
  .app {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  body {
    overflow: auto;
  }

  /* ── Hamburger visible ── */
  .hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* ── Sidebar: off-canvas slide-over ── */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.15);
  }

  /* Overlay backdrop */
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.4);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  .sidebar-overlay.visible {
    opacity: 1;
    pointer-events: auto;
  }

  /* ── Header: compact mobile bar ── */
  .header {
    padding: 10px 14px;
    margin: 0;
    gap: 8px;
    flex-wrap: nowrap;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 100;
    background: #fff;
  }
  .header h1 {
    font-size: 22px;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* Hide full name on narrow screens, show initials */
  .user-chip-name {
    display: none;
  }
  /* Compact user chip */
  .user-chip {
    gap: 6px;
    padding: 4px 6px;
  }
  .user-initials {
    width: 30px;
    height: 30px;
    font-size: 11px;
  }
  /* ── Main content: full-width, no excessive padding ── */
  .main {
    padding: 8px 12px 160px;
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
  }

  /* ── Shortcuts section ── */
  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    margin-bottom: 10px;
  }
  .panel-header h2 {
    font-size: 20px;
  }
  .shortcuts-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .shortcut-item {
    padding: 16px;
    min-height: 52px;
  }
  .shortcut-item strong {
    font-size: 17px;
  }
  .shortcut-item span {
    font-size: 15px;
  }
  .muted {
    font-size: 14px;
  }

  /* ── Chat panel: full-width, pinned to bottom ── */
  .chat-panel {
    position: fixed;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    border-radius: 16px 16px 0 0;
    margin: 0;
    z-index: 50;
    max-height: 60vh;
    transition: max-height 0.3s ease;
  }
  .chat-panel .panel-header {
    padding: 10px 14px;
  }
  .chat-panel.expanded {
    top: 56px !important;
    bottom: 0 !important;
    max-height: none;
    height: auto;
    border-radius: 0;
  }
  .chat-box {
    gap: 8px;
  }
  .chat-input {
    gap: 8px;
    padding: 0 4px 6px;
  }
  .chat-input input {
    font-size: 17px; /* >= 16px prevents iOS zoom */
    padding: 14px;
    border-radius: 12px;
    min-height: 48px;
  }
  .chat-input .button,
  #sendButton {
    min-height: 48px;
    min-width: 64px;
    font-size: 16px;
    padding: 12px 16px;
    border-radius: 12px;
  }
  .chat-message {
    font-size: 17px;
    line-height: 1.6;
    padding: 14px 16px;
    border-radius: 12px;
  }
  .chat-message.user {
    max-width: 85%;
  }

  /* ── Service buttons: bigger touch targets ── */
  .service-card {
    min-height: 52px;
    padding: 16px 18px;
    font-size: 17px;
  }

  /* ── Panels ── */
  .panel {
    padding: 14px;
    border-radius: 12px;
  }

  /* ── Training Insights panel (hide on mobile) ── */
  #trainingInsightsPanel,
  #insightsChatPanel,
  #trainingInsightsSection {
    display: none !important;
  }

  /* ── Insights chat (hide on mobile) ── */
  #insightsChatPanel {
    display: none !important;
  }

  /* ── Service dropdown on mobile ── */
  .service-dropdown-trigger {
    min-height: 52px;
    font-size: 17px;
  }

  /* ── Sidebar text sizes on mobile ── */
  .sidebar-section summary {
    font-size: 17px;
  }
  .sidebar-list {
    font-size: 16px;
    gap: 10px;
  }
  .sidebar-link {
    font-size: 16px;
  }
  .daily-brief-title {
    font-size: 17px;
  }
  .daily-brief-date {
    font-size: 14px;
  }
  .brand {
    font-size: 22px;
  }
  #configLink, #logoutButton {
    padding: 8px 12px !important;
    font-size: 14px !important;
  }
  .service-picker-row {
    font-size: 16px;
    padding: 10px 8px;
  }
  .badge {
    font-size: 13px;
    padding: 4px 10px;
  }
  .chat-panel .panel-header h2 {
    font-size: 18px;
  }

  /* ── Modal on mobile ── */
  .modal {
    width: calc(100vw - 16px);
    max-height: 90vh;
    padding: 14px;
    border-radius: 12px;
  }
  .modal-backdrop {
    padding: 8px;
  }

  /* ── Sources sidebar section (hide to simplify mobile) ── */

  /* ── Daily Brief button: bigger touch target ── */
  .daily-brief-button {
    min-height: 48px;
    padding: 12px 14px;
  }
}

/* ═══════════════════════════════════════════
   VERY SMALL: < 380px (small phones)
   ═══════════════════════════════════════════ */
@media (max-width: 380px) {
  .header h1 {
    font-size: 15px;
  }
  .main {
    padding: 6px 8px 160px;
  }
  .sidebar {
    width: 260px;
  }
}

.button {
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  background: #1d4ed8;
  color: #ffffff;
  font-size: 13px;
  min-height: 36px;
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(29, 78, 216, 0.2);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.button.equal {
  min-width: 150px;
  text-align: center;
}

.button.secondary {
  background: #e2e8f0;
  color: #1f2933;
  box-shadow: 0 8px 16px rgba(148, 163, 184, 0.3);
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 22px rgba(29, 78, 216, 0.24);
}

.button.secondary:hover {
  box-shadow: 0 10px 18px rgba(148, 163, 184, 0.4);
}

.button:active {
  transform: translateY(0);
}

.tag-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tag {
  background: #eef2f7;
  color: #475569;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
}

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

.table th {
  text-align: left;
  color: #6b7280;
  padding-bottom: 8px;
}

.table td {
  padding: 10px 0;
  border-top: 1px solid #eef1f5;
}

/* ── Service buttons ── */
.service-card {
  display: block;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #e5eaf0;
  border-radius: 10px;
  padding: 12px 14px;
  background: #f8fafc;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
}

.service-card:hover {
  background: #eef2f9;
  border-color: #cbd5f5;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(31, 41, 51, 0.08);
}

.service-card:active {
  transform: translateY(0);
  box-shadow: none;
}

.service-card.active {
  border-color: #1d4ed8;
  background: #e6eefc;
  color: #1d4ed8;
  font-weight: 600;
}

/* Drag-and-drop reordering */
.service-card.dragging {
  opacity: 0.35;
  border: 2px dashed #1d4ed8;
}
.service-card.drag-over {
  border-top: 3px solid #1d4ed8;
}

/* ── Service dropdown ── */
.service-dropdown {
  position: relative;
}

.service-dropdown-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid #d1d7e0;
  border-radius: 10px;
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
  transition: border-color 120ms ease;
}
.service-dropdown-trigger:hover {
  border-color: #a5b4fc;
}
.service-dropdown-trigger svg {
  transition: transform 200ms ease;
}
.service-dropdown.open .service-dropdown-trigger svg {
  transform: rotate(180deg);
}

.service-dropdown-menu {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 50;
  background: #fff;
  border: 1px solid #d1d7e0;
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.10);
  max-height: 280px;
  overflow-y: auto;
}
.service-dropdown.open .service-dropdown-menu {
  display: block;
}

/* Checkbox rows inside the dropdown */
.service-picker-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: #374151;
}
.service-picker-row:hover {
  background: #f3f4f6;
}
.service-picker-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #1d4ed8;
  cursor: pointer;
  flex-shrink: 0;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

.field input,
.field select,
.field textarea {
  border: 1px solid #d5dbe1;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
}

.muted {
  color: #6b7280;
  font-size: 12px;
}

.footer-note {
  font-size: 12px;
  color: #6b7280;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 9999; /* Above everything including sticky header */
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}

.modal {
  background: #ffffff;
  border-radius: 16px;
  padding: 20px 22px;
  width: min(640px, calc(100vw - 24px));
  max-height: min(88vh, calc(100vh - 24px));
  box-shadow: 0 24px 40px rgba(15, 23, 42, 0.2);
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  z-index: 10000; /* Above backdrop */
  overflow-y: auto;
}

@media (max-width: 700px) {
  .modal-backdrop {
    padding: 12px;
  }

  .modal {
    width: calc(100vw - 24px);
    padding: 14px;
    border-radius: 12px;
  }
}

.modal-header {
  flex-shrink: 0;
}

.modal-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  flex: 1 1 auto;
  padding-right: 4px;
  min-height: 0;
}

.modal-actions {
  flex-shrink: 0;
  margin-top: auto;
}

.modal-content textarea {
  min-height: 80px;
}

.role-select {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #6b7280;
}

.role-select select {
  min-width: 160px;
}

.preview-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.summary-card {
  background: #f8fafc;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-stack {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: #1f2933;
  margin-bottom: 12px;
}

.table-scroll {
  max-height: 360px;
  overflow: auto;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

.table-scroll .table {
  margin: 0;
  border: none;
}

.table-scroll thead th {
  position: sticky;
  top: 0;
  background: #f9fafb;
  z-index: 1;
}

.warning-banner {
  background: #fef3c7;
  color: #7c2d12;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  margin: 10px 0;
}

.inline-alert {
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  margin-bottom: 12px;
}

.inline-alert.warn {
  background: #fef3c7;
  color: #7c2d12;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #1f2933;
}

.role-note.hidden {
  display: none;
}

.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.info-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  margin-left: 6px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #f1f5f9;
  color: #111827;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-appearance: none;
  appearance: none;
  box-shadow: none;
}

.info-tip:hover {
  background: #e2e8f0;
}

.info-tip:active {
  transform: translateY(0.5px);
}

.info-tip:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.35);
}

/* Setup Guide-only UI affordances (hidden unless Setup Guide is ON) */
.setup-only {
  display: none !important;
}

body.setup-mode .setup-only {
  display: inline-flex !important;
}

.blocked-banner {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: #fee2e2;
  border: 1px solid #fecaca;
  border-radius: 12px;
  margin-bottom: 16px;
}

.blocked-banner.hidden {
  display: none;
}

.blocked-text {
  font-weight: 600;
  color: #991b1b;
}

.state-banner {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  margin-bottom: 12px;
}

.state-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.blocked-focus {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 12px 0 16px;
}

.blocked-focus[data-state="ready"] .approval-status,
.blocked-focus[data-state="warnings"] .approval-status {
  display: none;
}

.blocked-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.approval-status {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.status-label {
  font-weight: 600;
  color: #1f2933;
}

.severity-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}

.severity-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  background: #f8fafc;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
}

.outbound-details.compact {
  margin-top: 12px;
}

.details-block {
  margin: 10px 0 0;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 12px;
}

.details-block summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #1f2933;
  list-style: none;
}

.details-block summary::-webkit-details-marker {
  display: none;
}

.zone {
  border-radius: 14px;
  padding: 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.zone.is-collapsed {
  opacity: 0.5;
  filter: grayscale(0.2);
}

.publish-zone {
  background: #fff7ed;
  border-color: #fed7aa;
}

.zone-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.filter-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0 12px;
}

.tab-button {
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  background: #f8fafc;
  padding: 6px 12px;
  font-size: 12px;
  color: #1f2933;
  cursor: pointer;
}

.tab-button.active {
  background: #e2e8f0;
  font-weight: 600;
}

.pill {
  margin-left: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
}

.advanced-section.locked summary {
  opacity: 0.6;
  cursor: not-allowed;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
}

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

.modal-backdrop.show {
  display: flex;
  align-items: center; /* Center the modal */
  justify-content: center;
}

/* ========================
   Training Insights Styles
   ======================== */

.insights-chart {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.insight-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #f8f9fb;
  border-radius: 6px;
  border: 1px solid #e5eaf0;
}

.insight-label {
  flex: 1;
  font-size: 14px;
  color: #3d4852;
}

.insight-value {
  font-weight: 600;
  color: #1d4ed8;
  font-size: 14px;
}

.insight-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: #f8f9fb;
  border-radius: 8px;
  border: 1px solid #e5eaf0;
  margin-bottom: 12px;
}

.insight-stat-label {
  font-size: 14px;
  color: #636f7c;
}

.insight-stat-value {
  font-size: 24px;
  font-weight: 700;
  color: #1d4ed8;
}

.insights-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

.insights-table thead {
  background: #f8f9fb;
}

.insights-table th {
  text-align: left;
  padding: 12px;
  font-size: 13px;
  font-weight: 600;
  color: #636f7c;
  border-bottom: 2px solid #e5eaf0;
}

.insights-table td {
  padding: 12px;
  font-size: 14px;
  border-bottom: 1px solid #e5eaf0;
}

.insights-table tbody tr:hover {
  background: #f8f9fb;
}

.panel-section {
  margin-bottom: 32px;
}

.panel-section h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #1f2933;
}


/* Training Insights Chat Panel (anchored at bottom) */
#insightsChatPanel {
  position: fixed;
  left: calc(260px + 36px);
  right: 36px;
  bottom: 40px;
  z-index: 50;
  background: #ffffff;
  border: 1px solid rgba(29, 78, 216, 0.12);
  box-shadow: 0 16px 32px rgba(29, 78, 216, 0.12);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
  max-height: 120px;
  overflow: hidden;
}

#insightsChatPanel.expanded {
  max-height: calc(100vh - 120px);
  height: calc(100vh - 120px);
}

#insightsChatPanel .chat-messages {
  display: none;
}

#insightsChatPanel.expanded .chat-messages {
  display: flex;
}


/* Responsive: Training Insights Chat */
@media (max-width: 900px) {
  #insightsChatPanel {
    left: 24px;
    right: 24px;
    bottom: 18px;
  }
}


/* ========================
   Config Page Styles
   ======================== */

.config-pill {
  background: #fef3c7;
  color: #92400e;
}

.nav-button {
  display: block;
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-radius: 8px;
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  color: #636f7c;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 4px;
}

.nav-button:hover {
  background: #f3f6fb;
  color: #1d4ed8;
}

.nav-button.active {
  background: #e6eefc;
  color: #1d4ed8;
  font-weight: 600;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
  margin-bottom: 32px;
}

.stat-card {
  background: #ffffff;
  border: 1px solid #e5eaf0;
  border-radius: 12px;
  padding: 24px;
  text-align: center;
}

.stat-value {
  font-size: 36px;
  font-weight: 700;
  color: #1d4ed8;
  margin-bottom: 8px;
}

.stat-label {
  font-size: 13px;
  color: #636f7c;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  border-radius: 8px;
  overflow: hidden;
}

.data-table thead {
  background: #f8f9fb;
}

.data-table th {
  text-align: left;
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #636f7c;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid #e5eaf0;
}

.data-table td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid #e5eaf0;
}

.data-table tbody tr:hover {
  background: #f8f9fb;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.badge.success {
  background: #d1fae5;
  color: #065f46;
}


/* Role & Service Cards */
.role-card {
  background: #ffffff;
  border: 1px solid #e5eaf0;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

.role-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.role-card-header h3 {
  margin: 0 0 6px 0;
  font-size: 18px;
  font-weight: 600;
  color: #1f2933;
}

.role-card-header .muted {
  margin: 0;
  font-size: 14px;
}

/* Responsive: Stack buttons on small screens */
@media (max-width: 600px) {
  .data-table td {
    font-size: 13px;
  }
  
  .data-table td:last-child {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 120px;
  }
  
  .data-table td:last-child button {
    width: 100%;
  }
}

/* For larger screens, ensure buttons stay inline */
.data-table td:last-child {
  white-space: nowrap;
}

.data-table td:last-child button {
  margin-right: 4px;
}

.data-table td:last-child button:last-child {
  margin-right: 0;
}


/* Form textarea styling */
.field textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #d1d7e0;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  min-height: 80px;
}

.field textarea:focus {
  outline: none;
  border-color: #1d4ed8;
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}

/* Toggle Switch for Setup Mode */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #d1d5db;
  transition: background-color 0.4s ease;
  border-radius: 24px;
  border: 1px solid #9ca3af;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: transform 0.4s ease;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

.toggle-switch input:focus + .toggle-slider {
  box-shadow: 0 0 1px var(--primary);
}

/* Setup Mode Hints */
.setup-hint {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border: 1px solid #93c5fd;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 24px;
}

.setup-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #e5e7eb;
}

.setup-step:last-child {
  border-bottom: none;
}

.setup-step-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.setup-step-icon.complete {
  background: #10b981;
  color: white;
}

.setup-step-icon.pending {
  background: #e5e7eb;
  color: #6b7280;
}

.setup-step-text {
  flex: 1;
}

.setup-step-title {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.setup-step-description {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Setup Action Cards */
.setup-action-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: white;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  width: 100%;
}

.setup-action-card:hover {
  border-color: #3b82f6;
  background: #f8fafc;
  transform: translateX(4px);
}

.setup-action-card.disabled,
.setup-action-card:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.setup-action-card.disabled:hover,
.setup-action-card:disabled:hover {
  border-color: #e5e7eb;
  background: white;
  transform: none;
}

.setup-action-card.disabled .setup-action-arrow,
.setup-action-card:disabled .setup-action-arrow {
  color: #cbd5e1;
}

.setup-action-card.priority {
  border-color: #fecaca;
  background: #fef2f2;
}

.setup-action-card.priority:hover {
  border-color: #ef4444;
  background: #fee2e2;
}

.setup-action-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 18px;
  flex-shrink: 0;
}

.setup-action-content {
  flex: 1;
}

.setup-action-title {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
  font-size: 15px;
}

.setup-action-description {
  font-size: 13px;
  color: var(--text-secondary);
}

.setup-action-arrow {
  font-size: 24px;
  color: #9ca3af;
  flex-shrink: 0;
}

.setup-action-card:hover .setup-action-arrow {
  color: #3b82f6;
}

/* Modal Info Boxes */
.modal-info-box {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.5;
}

.modal-info-box.info {
  background: #eff6ff;
  border: 1px solid #93c5fd;
  color: #1e40af;
}

.modal-info-box.warning {
  background: #fef3c7;
  border: 1px solid #fbbf24;
  color: #92400e;
}

.modal-info-box strong {
  display: block;
  margin-bottom: 4px;
}

/* CSV File Input Styling */
input[type="file"] {
  font-family: inherit;
  cursor: pointer;
}

input[type="file"]::file-selector-button {
  padding: 8px 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  margin-right: 12px;
}

input[type="file"]::file-selector-button:hover {
  background: #1e40af;
}

/* Shortcut Input Styling */
.shortcut-input-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.shortcut-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #d1d7e0;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
}

.shortcut-input:focus {
  outline: none;
  border-color: #1d4ed8;
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}

.remove-shortcut {
  width: 32px;
  height: 32px;
  border: none;
  background: #ef4444;
  color: white;
  border-radius: 6px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}

.remove-shortcut:hover {
  background: #dc2626;
}

/* ── Universal micro-animation for all clickable elements ── */
/* Header action buttons (Config, Logout, Send, etc.) */
#configLink,
#logoutButton,
#sendButton,
#insightsSendButton,
.service-dropdown-trigger,
.sidebar-list li,
#addShortcutSidebar,
[data-action="view-all-shortcuts"],
#addPromptSidebar,
.hamburger-btn,
#trainingInsightsButton {
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
}

#configLink:hover,
#logoutButton:hover,
#sendButton:hover,
#insightsSendButton:hover,
.sidebar-list li:hover,
#addShortcutSidebar:hover,
[data-action="view-all-shortcuts"]:hover,
#addPromptSidebar:hover,
#trainingInsightsButton:hover {
  transform: translateY(-1px);
}

#configLink:active,
#logoutButton:active,
#sendButton:active,
#insightsSendButton:active,
.service-dropdown-trigger:active,
.sidebar-list li:active,
#addShortcutSidebar:active,
[data-action="view-all-shortcuts"]:active,
#addPromptSidebar:active,
.hamburger-btn:active,
#trainingInsightsButton:active {
  transform: translateY(0.5px);
}

