/* Holding OS — Dashboard stijl v8 (Telegram/WhatsApp dark + light, geen CDN) */

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

/* ── Design tokens: Telegram-donker palet ───────────────────────────────── */
:root {
  /* Telegram-stijl kleuren */
  --bg-list:     #17212B;   /* chatlijst-achtergrond */
  --bg-chat:     #0E1621;   /* actieve chat-achtergrond */
  --header:      #232E3C;   /* topbar + bottom-nav */
  --surface:     #182533;   /* incoming bubble + kaartjes */
  --surface-2:   #1C2B3A;   /* hover / form-bg */
  --border:      #2A3A4D;
  --border-2:    #3A4F65;
  --text:        #F0F2F5;
  --text-muted:  #A0AEC0;
  --text-dim:    #6B7F96;
  --accent:      #5288C1;   /* Telegram blauw */
  --accent-h:    #3D6B9E;
  --bubble-out:  #2B5278;   /* uitgaande bubble */
  --bubble-in:   #182533;   /* inkomende bubble */
  --green:       #4DDA7A;
  --yellow:      #F5C240;
  --red:         #EF5350;
  --orange:      #F97316;
  --radius:      8px;
  --radius-lg:   14px;
  --radius-bubble: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bottom-nav-h: 60px;
}

/* ── Light mode tokens ───────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg-list:     #F0F2F5;
  --bg-chat:     #E8EBF0;
  --header:      #FFFFFF;
  --surface:     #FFFFFF;
  --surface-2:   #E8EBF0;
  --border:      #D9DEE5;
  --border-2:    #C8D0DA;
  --text:        #111B21;
  --text-muted:  #54656F;
  --text-dim:    #8696A0;
  --bubble-out:  #D9FDD3;
  --bubble-in:   #FFFFFF;
  color-scheme: light;
}

[data-theme="light"] .msg-shareholder .msg-from span:last-child {
  color: rgba(17,27,33,.45);
}

[data-theme="light"] .msg.msg-shareholder {
  background: #D9FDD3;
}

html {
  color-scheme: dark;
  background-color: var(--bg-list);
  transition: background-color 0.2s, color 0.2s;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  overflow: hidden;   /* app is full-screen; screens scrollen intern */
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  height: 100%;
  height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ── App shell ───────────────────────────────────────────────────────────── */

.app {
  display: flex;
  height: 100%;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
  position: relative;
}

/* ── Screens (mobiel: full-screen stack; desktop: side-by-side) ─────────── */

.screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  overflow: hidden;
  position: absolute;
  top: 0; left: 0;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

/* Chatlijst-screen is standaard zichtbaar */
.screen-list {
  background: var(--bg-list);
  z-index: 1;
  transform: translateX(0);
}

/* Chat-screen schuift in vanuit rechts */
.screen-chat {
  background: var(--bg-chat);
  z-index: 2;
  transform: translateX(100%);
}

/* Chat-screen actief: slide in */
.screen-chat.active {
  transform: translateX(0);
}

/* Lijst-screen: schuif weg naar links wanneer chat actief is (mobiel) */
.screen-list.pushed {
  transform: translateX(-30%);
}

/* ── Desktop (≥ 768px): naast elkaar ─────────────────────────────────────── */

@media (min-width: 768px) {
  .app {
    flex-direction: row;
  }

  .screen {
    position: relative;
    top: auto; left: auto;
    transform: none !important;
    transition: none;
    flex-shrink: 0;
  }

  .screen-list {
    width: 340px;
    border-right: 1px solid var(--border);
    z-index: 1;
  }

  .screen-chat {
    flex: 1;
    z-index: 1;
    transform: none;
  }

  /* Bottom-nav verbergen op desktop */
  .bottom-nav {
    display: none !important;
  }

  /* List-section-tabs tonen op desktop */
  .list-section-tabs {
    display: flex !important;
  }

  /* Chat-list heeft ruimte (geen bottom-nav) */
  .chat-list {
    padding-bottom: 0 !important;
  }

  /* Back-knop verbergen op desktop */
  .back-btn {
    display: none !important;
  }
}

/* ── Chat-header (gedeeld door beide screens) ───────────────────────────── */

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  min-height: 56px;
  background: var(--header);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  /* iOS safe-area */
  padding-top: env(safe-area-inset-top, 0px);
  z-index: 10;
}

.chat-header-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
  letter-spacing: -0.01em;
}

.chat-header-info {
  flex: 1;
  min-width: 0;
}

.chat-header-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-sub {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ── Icon-knoppen (transparant, cirkel-hover) ───────────────────────────── */

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
  touch-action: manipulation;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.icon-btn:active {
  background: var(--border);
}

/* ── Sectie-tabs IN de sidebar (alleen desktop) ─────────────────────────── */

.list-section-tabs {
  display: none;   /* mobiel verborgen: bottom-nav doet navigatie */
  border-bottom: 1px solid var(--border);
  background: var(--header);
  flex-shrink: 0;
}

.list-tab {
  flex: 1;
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
  touch-action: manipulation;
}

.list-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.list-tab-badge {
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  min-width: 18px;
  text-align: center;
  line-height: 16px;
}

.list-tab-badge.badge-yellow {
  background: var(--yellow);
  color: #000;
}

/* ── Zoekbalk ────────────────────────────────────────────────────────────── */

.search-bar-wrap {
  padding: 8px 12px;
  background: var(--bg-list);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 12px;
}

.search-icon {
  color: var(--text-dim);
  flex-shrink: 0;
}

.search-bar input[type="search"] {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
  min-width: 0;
}

.search-bar input[type="search"]::placeholder {
  color: var(--text-dim);
}

/* Hide browser default clear button (Safari/Chrome) */
.search-bar input[type="search"]::-webkit-search-cancel-button {
  display: none;
}

.search-clear {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 13px;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
}

.search-clear:hover {
  color: var(--text);
}

.search-result-count {
  padding: 5px 14px 4px;
  font-size: 11px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  background: var(--bg-list);
}

/* ── Chatlijst ───────────────────────────────────────────────────────────── */

.chat-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  /* Ruimte voor bottom-nav op mobiel */
  padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
}

/* ── Chatlijst-item (WhatsApp/Telegram-stijl) ───────────────────────────── */

.chat-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
  transition: background 0.12s;
  min-height: 72px;
  touch-action: manipulation;
  position: relative;
}

.chat-list-item:hover {
  background: var(--surface-2);
}

.chat-list-item:active {
  background: rgba(82,136,193,0.12);
}

.chat-list-item.selected {
  background: rgba(82,136,193,0.15);
}

/* Avatar-cirkel met initialen */
.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  user-select: none;
}

/* Avatar-kleurpalet (gebaseerd op hash van naam) */
.av-0 { background: #5288C1; }
.av-1 { background: #3BA55C; }
.av-2 { background: #CD6116; }
.av-3 { background: #8B44AC; }
.av-4 { background: #C0392B; }
.av-5 { background: #16A085; }
.av-6 { background: #D35400; }
.av-7 { background: #2980B9; }
.av-8 { background: #8E44AD; }
.av-9 { background: #27AE60; }

/* Rechter kolom van chatlijst-item */
.chat-list-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.chat-list-row1 {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-list-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-list-time {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}

.chat-list-row2 {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-list-preview {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* Ongelezen dot */
.unread-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.unread-badge {
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  min-width: 20px;
  text-align: center;
  flex-shrink: 0;
}

/* Urgency-kleur voor approvals */
.unread-badge.urgent {
  background: var(--red);
}

/* Section-header in lijst (voor approvals: In behandeling / Afgehandeld) */
.list-section-header {
  padding: 6px 14px 5px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  background: var(--bg-list);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
}

/* Todo-item in de lijst */
.todo-list-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.12s;
  min-height: 52px;
  touch-action: manipulation;
}

.todo-list-item:hover {
  background: var(--surface-2);
}

.todo-list-item.done .todo-text {
  text-decoration: line-through;
  color: var(--text-dim);
}

.todo-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border-2);
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, border-color 0.12s;
  touch-action: manipulation;
  min-width: 32px;
  min-height: 32px;
  margin-left: -5px;
}

.todo-check.checked {
  background: var(--green);
  border-color: var(--green);
}

.todo-check svg {
  width: 11px;
  height: 11px;
  stroke: #fff;
  stroke-width: 2.5;
  fill: none;
}

.todo-text {
  font-size: 14px;
  color: var(--text);
  flex: 1;
  line-height: 1.5;
  word-break: break-word;
}

.todo-meta {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Bottom navigation (mobiel) ──────────────────────────────────────────── */

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--bottom-nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--header);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 50;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 10px;
  font-weight: 500;
  transition: color 0.15s;
  touch-action: manipulation;
  position: relative;
  padding: 6px 0;
}

.bottom-nav-item.active {
  color: var(--accent);
}

.bottom-nav-item svg {
  stroke: currentColor;
  flex-shrink: 0;
}

/* Badge op bottom-nav-item */
.bnav-badge {
  position: absolute;
  top: 4px;
  right: calc(50% - 22px);
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  padding: 0 5px;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
}

.bnav-badge.bnav-badge-yellow {
  background: var(--yellow);
  color: #000;
}

/* ── Chat-screen: body (scrollbare chat + input onderaan) ─────────────────── */

.chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ── Berichten-container ─────────────────────────────────────────────────── */

.messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
}

/* ── Chat-bubbles (BEWAARD + verbeterd) ──────────────────────────────────── */

.msg {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 12px;
  border-radius: var(--radius-bubble);
  box-shadow: 0 1px 2px rgba(0,0,0,.4);
  min-width: 0;
  max-width: 78%;
  overflow: visible;
  word-break: break-word;
}

.msg.msg-shareholder {
  align-self: flex-end;
  background: var(--bubble-out);
  border-radius: var(--radius-bubble) var(--radius-bubble) 4px var(--radius-bubble);
  margin-left: 15%;
}

.msg.msg-agent {
  align-self: flex-start;
  background: var(--bubble-in);
  border-radius: var(--radius-bubble) var(--radius-bubble) var(--radius-bubble) 4px;
  margin-right: 15%;
}

/* Verberg naam/role bij shareholder, toon alleen timestamp */
.msg-shareholder .msg-from {
  font-size: 0;
  justify-content: flex-end;
  gap: 0;
}
.msg-shareholder .msg-from span {
  font-size: 0;
}
.msg-shareholder .msg-from span:last-child {
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: rgba(240,242,245,.45);
  margin-left: 0;
}

.msg-from {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #53BDEB;
  display: flex;
  align-items: center;
  gap: 6px;
}

.msg-agent .msg-from span:last-child {
  margin-left: auto;
  font-size: 11px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-dim);
}

.msg-body {
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
  word-break: break-word;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

/* Plain-tekst berichten (geen markdown-wrapper) tonen whitespace letterlijk */
.msg-body > :not(.md-prose) {
  white-space: pre-wrap;
}

/* ── Zoeken binnen thread ────────────────────────────────────────────────── */

.thread-search-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--header);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.thread-search-bar input {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 6px 12px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  min-width: 0;
}

.thread-search-bar input:focus {
  border-color: var(--accent);
}

mark.msg-highlight {
  background: rgba(255, 214, 0, 0.35);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.icon-btn.active {
  color: var(--accent);
  background: var(--surface-2);
}

/* ── Reply-area (onder chat) ─────────────────────────────────────────────── */

.reply-area {
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  padding-bottom: max(10px, var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  background: var(--header);
}

.reply-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.reply-input-row textarea {
  flex: 1;
  min-height: 42px;
  max-height: 120px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 22px;
  color: var(--text);
  font-size: 16px;   /* voorkomt auto-zoom op iOS/Android */
  padding: 10px 16px;
  resize: none;
  font-family: inherit;
  line-height: 1.4;
  transition: border-color 0.15s;
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

@media (min-width: 768px) {
  .reply-input-row textarea { font-size: 14px; }
}

.reply-input-row textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.reply-input-row textarea::placeholder {
  color: var(--text-dim);
}

.reply-row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

/* Prefix-pills */
.prefix-row {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.prefix-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-2);
  background: var(--surface-2);
  color: var(--text-muted);
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  user-select: none;
  touch-action: manipulation;
  white-space: nowrap;
}

.prefix-tag:hover  { background: var(--border); color: var(--text); }
.prefix-tag.active {
  background: rgba(82,136,193,.22);
  border-color: rgba(82,136,193,.5);
  color: #82b4e0;
}

/* ── Approval-detail in chat-body ────────────────────────────────────────── */

.approval-detail {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  -webkit-overflow-scrolling: touch;
}

.detail-section { display: flex; flex-direction: column; gap: 6px; }

.detail-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.detail-label-strong {
  font-size: 13px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
}

.detail-value {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.detail-value-prose {
  font-size: 14px;
  color: var(--text);
  line-height: 1.65;
  word-break: break-word;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

/* Markdown rendered content */
.md-prose .md-p       { margin: 0 0 6px; }
.md-prose .md-h1      { font-size: 18px; font-weight: 700; margin: 14px 0 6px; color: var(--text); border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.md-prose .md-h2      { font-size: 15px; font-weight: 700; margin: 12px 0 5px; color: var(--text); }
.md-prose .md-h3      { font-size: 13px; font-weight: 700; margin: 10px 0 4px; color: var(--text); }
.md-prose .md-h4      { font-size: 12px; font-weight: 600; margin: 8px 0 3px;  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.md-prose .md-list    { margin: 4px 0 8px; padding-left: 20px; }
.md-prose .md-olist   { list-style-type: decimal; }
.md-prose .md-list li { margin-bottom: 3px; }
.md-prose strong      { font-weight: 700; color: var(--text); }
.md-prose em          { font-style: italic; }
.md-prose code        { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; background: var(--border); border-radius: 3px; padding: 1px 4px; }
.md-prose .md-codeblock {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  background: var(--bg-chat);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin: 6px 0 10px;
  overflow-x: auto;
  white-space: pre;
  color: var(--text-muted);
}
.md-prose .md-codeblock code { background: none; padding: 0; border-radius: 0; font-size: inherit; }
.md-prose .md-bq {
  border-left: 3px solid var(--accent);
  margin: 6px 0 8px;
  padding: 4px 10px;
  color: var(--text-muted);
  font-style: italic;
}
.md-prose .md-hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

/* File viewer modal body */
.file-viewer-body {
  flex: 1;
  overflow: auto;
  padding: 1rem;
  font-size: 0.85rem;
  background: var(--bg-chat);
  border-radius: 0 0 12px 12px;
  margin: 0;
  line-height: 1.6;
}
.file-viewer-body.md-prose {
  padding: 1.25rem 1.5rem;
}

.detail-pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 360px;
  overflow: auto;
}

/* ── Action-bar (approve/reject onderaan detail) ─────────────────────────── */

.action-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  padding-bottom: max(12px, var(--safe-bottom));
  border-top: 1px solid var(--border);
  background: var(--header);
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* ── Knoppen ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity 0.15s, background 0.15s;
  min-height: 44px;
  touch-action: manipulation;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-approve {
  background: rgba(77,218,122,.15);
  color: var(--green);
  border-color: rgba(77,218,122,.28);
  flex: 1;
}
.btn-approve:hover:not(:disabled) { background: rgba(77,218,122,.25); }

.btn-reject {
  background: rgba(239,83,80,.13);
  color: var(--red);
  border-color: rgba(239,83,80,.22);
  flex: 1;
}
.btn-reject:hover:not(:disabled) { background: rgba(239,83,80,.22); }

.btn-ghost {
  background: var(--surface);
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-h); }

.btn-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
  touch-action: manipulation;
}
.btn-send:hover { background: var(--accent-h); }
.btn-send:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Mic-knop ────────────────────────────────────────────────────────────── */

.btn-mic {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
  min-width: 36px;
  min-height: 36px;
  flex-shrink: 0;
}
.btn-mic:hover { color: var(--text); background: var(--border); }
.btn-mic.recording { color: var(--red); animation: pulse-mic 1s ease-in-out infinite; }

@keyframes pulse-mic {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ── Badge (generiek) ────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-red    { background: rgba(239,83,80,.15);   color: var(--red); }
.badge-yellow { background: rgba(245,194,64,.15);  color: var(--yellow); }
.badge-green  { background: rgba(77,218,122,.15);  color: var(--green); }
.badge-blue   { background: rgba(82,136,193,.18);  color: #82b4e0; }
.badge-gray   { background: var(--surface);        color: var(--text-muted); }

/* ── Status-dots ─────────────────────────────────────────────────────────── */

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-red    { background: var(--red); }
.dot-yellow { background: var(--yellow); }
.dot-green  { background: var(--green); }
.dot-gray   { background: var(--text-dim); }
.dot-blue   { background: var(--accent); }

/* ── Lege staat ──────────────────────────────────────────────────────────── */

.empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
}

/* ── Loading ─────────────────────────────────────────────────────────────── */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 32px;
  color: var(--text-dim);
  font-size: 13px;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}

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

/* ── Toast ───────────────────────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 12px);
  right: 16px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}

@media (min-width: 768px) {
  .toast-container {
    bottom: 20px;
    right: 20px;
    left: auto;
    max-width: 320px;
  }
}

.toast {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  background: var(--header);
  border: 1px solid var(--border);
  color: var(--text);
  animation: slide-in 0.2s ease;
  pointer-events: all;
}

.toast.success { border-color: rgba(77,218,122,.4);  color: var(--green); }
.toast.error   { border-color: rgba(239,83,80,.4);   color: var(--red); }

@keyframes slide-in {
  from { transform: translateY(8px); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

/* ── Reject-dialog ───────────────────────────────────────────────────────── */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.dialog {
  background: var(--header);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 20px;
  width: min(440px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: dialog-in 0.2s cubic-bezier(.22,.68,0,1.2);
}

@keyframes dialog-in {
  from { transform: scale(0.93); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.dialog h3 { font-size: 15px; font-weight: 600; color: var(--text); }
.dialog p  { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

.textarea-mic-wrap {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.textarea-mic-wrap textarea {
  flex: 1;
  min-height: 80px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 16px;
  padding: 10px 12px;
  resize: vertical;
  font-family: inherit;
  transition: border-color 0.15s;
  max-width: 100%;
}
@media (min-width: 768px) {
  .textarea-mic-wrap textarea { font-size: 13px; }
}
.textarea-mic-wrap textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.dialog-actions .btn { min-width: 100px; }

/* ── New-thread overlay (simpele dialog) ─────────────────────────────────── */

.new-thread-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  padding: 0;
}

@media (min-width: 480px) {
  .new-thread-overlay {
    align-items: center;
    padding: 16px;
  }
}

.new-thread-sheet {
  background: var(--header);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 22px 20px;
  padding-bottom: max(22px, var(--safe-bottom));
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: sheet-up 0.25s cubic-bezier(.22,.68,0,1.2);
}

@media (min-width: 480px) {
  .new-thread-sheet {
    border-radius: var(--radius-lg);
    width: min(440px, 92vw);
    padding-bottom: 22px;
  }
}

@keyframes sheet-up {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.sheet-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.sheet-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sheet-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
}

.sheet-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 16px;
  padding: 10px 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
@media (min-width: 768px) { .sheet-input { font-size: 14px; } }
.sheet-input:focus { border-color: var(--accent); }

.sheet-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.sheet-actions .btn { min-width: 110px; }

/* ── Proposal-stijlen ────────────────────────────────────────────────────── */

.proposal-divider {
  border-top: 1px solid var(--border-2);
  margin: 6px 0;
}

.proposal-pre {
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
  line-height: 1.6;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-top: 4px;
}

.proposal-131 {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.p131-row {
  display: flex;
  gap: 8px;
  font-size: 12px;
  line-height: 1.5;
}

.p131-key {
  font-weight: 600;
  color: var(--text-dim);
  min-width: 72px;
  flex-shrink: 0;
}

.p131-val { color: var(--text-muted); flex: 1; min-width: 0; }

.p131-rec {
  background: rgba(82,136,193,.1);
  border: 1px solid rgba(82,136,193,.22);
  border-radius: 6px;
  padding: 6px 10px;
}
.p131-rec .p131-key { color: var(--accent); }
.p131-rec .p131-val { color: var(--text); font-weight: 500; }

.proposal-list {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.proposal-list li {
  font-size: 12px;
  color: var(--text-muted);
  padding: 3px 0 3px 12px;
  border-left: 2px solid var(--border-2);
  line-height: 1.5;
}

.proposal-options { gap: 8px; }

.proposal-option {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px !important;
  border-left-width: 3px !important;
}

.opt-head {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.opt-pro { font-size: 11px; color: var(--green); line-height: 1.4; }
.opt-con { font-size: 11px; color: var(--text-dim); line-height: 1.4; }
.proposal-rec { font-weight: 600; color: var(--accent); }

/* ── Raw-YAML details-block ──────────────────────────────────────────────── */
.raw-yaml-details summary {
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding: 6px 0;
  user-select: none;
}

/* ── New-todo inline form ────────────────────────────────────────────────── */
.new-todo-bar {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  gap: 8px;
  align-items: center;
}

.new-todo-input {
  flex: 1;
  background: var(--bg-list);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  padding: 8px 12px;
  outline: none;
  font-family: inherit;
  min-height: 38px;
  transition: border-color 0.15s;
}
.new-todo-input:focus { border-color: var(--accent); }

/* ── Scrollbar ───────────────────────────────────────────────────────────── */

::-webkit-scrollbar        { width: 5px; height: 5px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── Mobiel: kleinere chat-bubbles ──────────────────────────────────────── */
@media (max-width: 480px) {
  .msg { max-width: 85%; }
  .msg.msg-shareholder { margin-left: 10%; }
  .msg.msg-agent       { margin-right: 10%; }
}

/* ── Desktop: berichtencontainer heeft maximale hoogte ──────────────────── */
@media (min-width: 768px) {
  .messages {
    padding: 16px 20px 10px;
  }
  .reply-area {
    padding: 12px 20px;
    padding-bottom: 12px;
  }
  .approval-detail {
    padding: 20px;
  }
  .action-bar {
    padding: 14px 20px;
  }
}

/* ── Agenda-sectie ───────────────────────────────────────────────────────── */

.agenda-wrap {
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 16px);
}

.agenda-top-bar {
  display: flex;
  justify-content: flex-end;
  padding: 12px 16px 6px;
}

.agenda-add-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
}
.agenda-add-btn:hover { background: var(--accent-h); }

.agenda-date-header {
  padding: 10px 16px 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: capitalize;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border);
  margin-top: 4px;
}

.agenda-card {
  margin: 6px 12px;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}
.agenda-card:hover { background: var(--surface-2); }

.agenda-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
}

.agenda-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agenda-card-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}

.agenda-card-meta {
  display: flex;
  gap: 12px;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.agenda-card-notes {
  color: var(--text-dim);
}

/* ── Agenda dialog / modal ───────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.modal-header {
  padding: 16px 18px 12px;
  font-weight: 700;
  font-size: 16px;
  border-bottom: 1px solid var(--border);
}

.modal-body {
  padding: 14px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 2px;
  display: block;
}

.form-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
}
.form-input:focus {
  outline: none;
  border-color: var(--accent);
}
select.form-input option { background: var(--surface-2); }

textarea.form-input { resize: vertical; }

.btn {
  border: none;
  border-radius: var(--radius);
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-secondary { background: var(--surface-2); color: var(--text); }
.btn-secondary:hover { background: var(--border); }
.btn-red       { background: var(--red); color: #fff; }
.btn-red:hover { opacity: 0.85; }

/* ── Attach button (clickable file in messages) ─────────────────────────── */
.attach-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.25em 0.6em;
  background: rgba(79, 140, 255, 0.15);
  border: 1px solid rgba(79, 140, 255, 0.4);
  border-radius: 6px;
  color: #4F8CFF;
  cursor: pointer;
  font-size: 0.85em;
  font-family: inherit;
  transition: background 0.15s;
}
.attach-btn:hover { background: rgba(79, 140, 255, 0.3); }

/* ── File viewer modal ──────────────────────────────────────────────────── */
.modal-overlay.hidden { display: none !important; }

/* ── Login overlay (eigen SPA-login, geen browser-popup) ────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(4px);
}
.login-overlay.hidden { display: none !important; }
.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 360px;
  padding: 24px 22px 20px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.login-header { text-align: center; margin-bottom: 18px; }
.login-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.login-sub {
  font-size: 13px;
  color: var(--text-muted);
}
.login-form { display: flex; flex-direction: column; }
.login-btn { margin-top: 16px; padding: 10px 18px; font-size: 15px; }
.login-error {
  margin-top: 10px;
  padding: 8px 10px;
  background: rgba(220, 53, 69, 0.12);
  border: 1px solid rgba(220, 53, 69, 0.4);
  border-radius: var(--radius);
  color: var(--red, #dc3545);
  font-size: 13px;
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  overflow: hidden;
}

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

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }

/* ── Bulk-selectie ───────────────────────────────────────────────────────── */

/* Selectie-balk boven de lijst */
.select-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 10px;
}

.select-count {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.btn-delete-selected {
  background: rgba(239,83,80,.13);
  color: var(--red);
  border: 1px solid rgba(239,83,80,.28);
  border-radius: var(--radius);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  min-height: 36px;
  touch-action: manipulation;
}

.btn-delete-selected:hover:not(:disabled) {
  background: rgba(239,83,80,.24);
}

.btn-delete-selected.disabled,
.btn-delete-selected:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Checkbox in thread-lijstitem */
.thread-checkbox {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border-2);
  background: transparent;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, border-color 0.12s;
  color: #fff;
}

.thread-checkbox.checked {
  background: var(--accent);
  border-color: var(--accent);
}

/* Geselecteerd item in bulk-modus */
.chat-list-item.bulk-selected {
  background: rgba(82,136,193,0.13);
}

/* Context-menu (lang indrukken / rechtermuisklik) ────────────────────── */
.ctx-menu {
  position: fixed;
  z-index: 9999;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,.45);
  min-width: 160px;
  overflow: hidden;
  animation: ctx-menu-in 0.12s cubic-bezier(0.2, 0, 0.2, 1);
  transform-origin: top left;
}

@keyframes ctx-menu-in {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}

.ctx-menu button {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--text);
  padding: 12px 16px;
  text-align: left;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.ctx-menu button:hover { background: var(--surface-2); }
.ctx-menu button:active { background: var(--border); }
