/*
=================================================================
  ARI Assist — Stylesheet
  Pas dit bestand aan om het uiterlijk te wijzigen.

  STRUCTUUR:
  - :root            → kleuren en variabelen (begin hier!)
  - body             → lettertype en achtergrond
  - LAYOUT           → header, sidebar, main
  - BUTTONS          → alle knoppen
  - SIDEBAR          → upload, PDF lijst, zoekbalk
  - CHAT             → berichten, welkomstscherm, input
  - MODALS           → popups (login, accounts, etc.)
  - MACHINE KEUZE    → keuzekaartjes bij meerdere machines
  - TOAST            → notificaties rechtsonder
  - RESPONSIVE       → tablet en mobiel aanpassingen
=================================================================
*/

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

    :root {
      --bg:      #ffffff;
      --sidebar: #f7f7f5;
      --border:  #e5e5e2;
      --text:    #1a1a1a;
      --muted:   #8a8a8a;
      --accent:  #2563eb;
      --danger:  #dc2626;
      --success: #16a34a;
      --warning: #ca8a04;
      --navbar: #0069B4;
      --sidebar-w: 268px;
      --header-h:  67px;
    }

    body {
      font-family: "Aptos", "Calibri", "Segoe UI", Arial, sans-serif;
      font-size: 16px;
      line-height: 1.5;
      background: var(--bg);
      color: var(--text);
      width: 100vw;
      height: 100vh;
      height: 100dvh;
      overflow: hidden;
      display: flex;
      flex-direction: column;
    }

    /* ════ HEADER ════ */
    header {
      height: var(--header-h);
      min-height: var(--header-h);
      flex-shrink: 0;
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 0 16px;
      background: var(--navbar);
      box-shadow: rgb(95, 95, 95) 0px 1px 3px 0px, rgba(90, 90, 90, 0.2) 0px 1px 2px 0px;
      position: relative;
      z-index: 10;
      color: white;
      overflow: visible;
    }

    #sidebar-toggle {
      display: flex;
      flex-direction: column;
      gap: 5px;
      align-items: center;
      justify-content: center;
      width: 32px;
      height: 32px;
      flex-shrink: 0;
      background: none;
      border: none;
      cursor: pointer;
      border-radius: 7px;
      transition: background .15s;
    }
    #sidebar-toggle:hover { background: rgb(255, 255, 255); }
    #sidebar-toggle:hover span { background: var(--navbar); }
    #sidebar-toggle span {
      display: block;
      width: 17px;
      height: 1.5px;
      background: white;
      border-radius: 99px;
    }

    .header-logo-link {
      display: flex;
      align-items: center;
      flex-shrink: 0;
      line-height: 0;
    }

    .header-logo {
      height: 56px;
      width: 56px;
      object-fit: contain;
      flex-shrink: 0;
    }

    .logo { font-weight: 1200; font-size: 20px; white-space: nowrap; }

    .user-badge {
      display: flex;
      align-items: center;
      gap: 6px;
      background: var(--sidebar);
      border: 1px solid var(--border);
      border-radius: 99px;
      padding: 3px 10px 3px 8px;
      font-size: 12px;
      color: var(--muted);
      white-space: nowrap;
    }
    .user-dot { width: 7px; height: 7px; border-radius: 50%; background: rgb(91, 148, 5); flex-shrink: 0; }
    .user-dot.eigenaar   { background: rgb(201, 148, 3); }
    .user-dot.beheerder  { background: #7c3aed; }
    .user-dot.superadmin { background: var(--accent); }
    .user-dot.admin      { background: var(--accent); }

    .header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

    /* Vaste breedte zodat taalswitch layout niet verschuift */
    #login-btn, #logout-btn {
      min-width: 90px;
      max-width: 90px;
      width: 90px;
      text-align: center;
      overflow: hidden;
      white-space: nowrap;
    }

    /* Lang toggle vaste breedte */
    .lang-toggle { display: flex; border: 1px solid var(--navbar); border-radius: 6px; overflow: hidden; flex-shrink: 0; }
    .lang-btn { min-width: 36px; text-align: center; }

    /* ════ BUTTONS ════ */
    .btn {
      border: 1px solid var(--border);
      border-radius: 6px;
      padding: 8px 16px;
      font-family: inherit;
      font-size: 13px;
      cursor: pointer;
      background: var(--bg);
      color: var(--text);
      transition: background .15s;
      white-space: nowrap;
    }
    .btn:hover    { background: var(--sidebar); }
    .btn:disabled { opacity: .5; cursor: not-allowed; }
    .btn.primary  { background: var(--text);    color: white; border-color: var(--text); }
    .btn.primary:hover { opacity: .85; background: var(--text); }
    .btn.danger   { color: var(--danger);  border-color: #fca5a5; }
    .btn.danger:hover  { background: #fef2f2; }
    .btn.accent   { background: var(--bg);  color: var(--navbar); border-color: var(--accent); }
    .btn.accent:hover  { opacity: .85; background: rgb(245, 243, 243); }
    .btn.purple   { background: #7c3aed; color: white; border-color: #7c3aed; }
    .btn.purple:hover  { opacity: .85; background: #7c3aed; }

    /* ════ LANG TOGGLE ════ */
    .lang-btn {
      background: var(--bg);
      border: none;
      padding: 9px 11px;
      font-family: inherit;
      font-size: 12px;
      font-weight: 500;
      cursor: pointer;
      color: var(--muted);
      transition: background .15s, color .15s;
    }
    .lang-btn.active { background: var(--text); color: white; }
    .lang-btn:hover:not(.active) { background: var(--sidebar); color: var(--text); }

    /* ════ BODY = SIDEBAR + MAIN ════ */
    .app-body {
      display: flex;
      flex: 1;
      min-height: 0;
      overflow: hidden;
    }

    /* ════ SIDEBAR ════ */
    aside {
      width: var(--sidebar-w);
      flex-shrink: 0;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      background: var(--sidebar);
      border-right: 1px solid var(--border);
      transition: width .25s cubic-bezier(.4,0,.2,1);
    }
    aside.collapsed {
      width: 0;
      border-right-color: transparent;
    }

    /* visitor */
    .visitor-sidebar {
      padding: 20px 16px;
      flex: 1;
      display: flex;
      flex-direction: column;
      gap: 12px;
    }
    .visitor-sidebar h3 { font-size: 13px; font-weight: 600; }
    .visitor-sidebar p  { font-size: 12px; color: var(--muted); line-height: 1.6; }
    .login-cta { margin-top: auto; padding: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; text-align: center; }
    .login-cta p { font-size: 12px; color: var(--muted); margin-bottom: 8px; }

    /* upload merk selector */
    .upload-brand-wrap {
      display: flex;
      align-items: center;
      gap: 8px;
      margin: 10px 12px 4px;
    }
    .upload-brand-label {
      font-size: 12px;
      color: var(--muted);
      white-space: nowrap;
    }
    .upload-brand-select {
      flex: 1;
      font-size: 12px;
      padding: 4px 8px;
      border: 1px solid var(--border);
      border-radius: 6px;
      background: var(--bg);
      color: var(--text);
      cursor: pointer;
    }

    /* admin upload */
    .drop-zone {
      margin: 12px;
      border: 1.5px dashed var(--border);
      border-radius: 8px;
      padding: 14px;
      text-align: center;
      cursor: pointer;
      position: relative;
      transition: border-color .15s, background .15s;
      flex-shrink: 0;
    }
    .drop-zone:hover, .drop-zone.over { border-color: var(--accent); background: #eff6ff; }
    .drop-zone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
    .dz-title { font-weight: 500; font-size: 13px; color: var(--accent); }
    .dz-sub   { font-size: 12px; color: var(--muted); margin-top: 2px; }

    #upload-progress { margin: 0 12px 8px; display: none; }
    .prog-bar  { background: var(--border); border-radius: 99px; height: 3px; overflow: hidden; }
    .prog-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 99px; transition: width .2s; }
    .prog-label { font-size: 11px; color: var(--muted); margin-top: 3px; }

    .search-wrap { padding: 0 12px 8px; flex-shrink: 0; }
    .search-input {
      width: 100%;
      border: 1px solid var(--border);
      border-radius: 6px;
      padding: 6px 10px;
      font-family: inherit;
      font-size: 13px;
      outline: none;
      background: var(--bg);
      color: var(--text);
    }
    .search-input:focus { border-color: var(--accent); }
    .search-input::placeholder { color: var(--muted); }

    .toolbar { display: flex; align-items: center; justify-content: space-between; padding: 0 12px 6px; flex-shrink: 0; }
    .toolbar-count { font-size: 12px; color: var(--muted); }
    .toolbar-actions { display: flex; gap: 4px; }

    #bulk-bar { display: none; align-items: center; gap: 8px; margin: 0 12px 6px; padding: 6px 10px; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 6px; font-size: 12px; }
    #bulk-bar.show { display: flex; }
    #bulk-bar span { color: var(--accent); flex: 1; }

    .pdf-list { flex: 1; overflow-y: auto; padding: 0 6px 6px; }
    .pdf-list::-webkit-scrollbar { width: 3px; }
    .pdf-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

    .pdf-group-header { font-size: 10px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); padding: 10px 8px 4px; margin-top: 4px; display:flex; align-items:center; gap:5px; }
    .pdf-group-header:first-child { margin-top: 0; }
    .pdf-group-header.collapsible { cursor: pointer; user-select: none; }
    .pdf-group-header.collapsible:hover { color: var(--text); }
    .grp-arrow { font-size: 11px; transition: transform .2s; display:inline-block; }
    .grp-arrow.grp-collapsed { transform: rotate(-90deg); }
    .grp-count { font-size: 9px; background: var(--border); border-radius: 99px; padding: 1px 5px; color: var(--muted); font-weight:500; margin-left:2px; }
    .pdf-item { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 6px; border: 1px solid transparent; transition: background .1s; }
    .pdf-item:hover { background: var(--bg); border-color: var(--border); }
    .pdf-item.selected { background: #eff6ff; border-color: #bfdbfe; }
    .pdf-checkbox { accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
    .pdf-thumb { width: 26px; height: 26px; background: #fee2e2; border-radius: 4px; display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 600; color: var(--danger); flex-shrink: 0; }
    .pdf-thumb-xl { background: #dcfce7; color: #16a34a; }
    .pdf-info { flex: 1; min-width: 0; }
    .pdf-name { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .pdf-meta { font-size: 11px; color: var(--muted); margin-top: 1px; }
    .pdf-open { color: var(--muted); padding: 2px 4px; border-radius: 4px; font-size: 13px; opacity: 0; transition: opacity .1s, color .1s; text-decoration: none; line-height: 1; flex-shrink: 0; }
    .pdf-item:hover .pdf-open { opacity: 1; }
    .pdf-open:hover { color: var(--accent); }
    .pdf-del { background: none; border: none; cursor: pointer; color: var(--muted); padding: 2px 4px; border-radius: 4px; font-size: 12px; opacity: 0; transition: opacity .1s, color .1s; }
    .pdf-item:hover .pdf-del { opacity: 1; }
    .pdf-del:hover { color: var(--danger); }
    .empty-state { padding: 32px 12px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.6; }

    .sidebar-footer { padding: 8px 12px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
    .storage-text { font-size: 11px; color: var(--muted); }

    /* ════ MAIN / CHAT ════ */
    main {
      flex: 1;
      min-width: 0;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      position: relative;
    }

    #bg-logo {
      position: absolute;
      top: 43%;
      left: 50%;
      width: clamp(200px, 38%, 500px);
      height: auto;
      transform: translate(-50%, -50%);
      opacity: 0.50;
      pointer-events: none;
      z-index: 0;
      transition: top 0.9s cubic-bezier(0.4,0,0.2,1),
                  left 0.9s cubic-bezier(0.4,0,0.2,1),
                  width 0.9s cubic-bezier(0.4,0,0.2,1),
                  height 0.9s cubic-bezier(0.4,0,0.2,1),
                  opacity 0.9s cubic-bezier(1,0,0.2,1);
    }

    #bg-logo.logo-moved {
      top: 43%;
      left: 70%;
      width: clamp(150px, 32%, 500px);
      height: auto;
      opacity: 1;
    }

    #bg-logo.logo-moved.logo-centered {
      left: 50%;
    }

    .chat-area {
      flex: 1;
      overflow-y: auto;
      padding: 32px 48px;
      display: flex;
      flex-direction: column;
      gap: 24px;
      background: rgba(255, 255, 255, 0.15);
      border-radius: 16px;
      position: relative;
      z-index: 1;
    }
    .chat-area::-webkit-scrollbar { width: 3px; }
    .chat-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

    .welcome { margin: auto; max-width: 400px; text-align: center; position: relative; z-index: 2; }
    .welcome h2 { font-size: 22px; font-weight: 600; margin-bottom: 8px; }
    .welcome p  { color: var(--text); font-size: 16px; line-height: 1.6; }

    @media (max-width: 1540px) {
      #bg-logo.logo-moved { left: 50%; }
    }

    @media (max-width: 1549px) {
      #bg-logo { width: clamp(150px, 35%, 400px); }
      #bg-logo.logo-moved { width: clamp(120px, 28%, 380px); height: auto; top: 43%; }
      #bg-logo.logo-moved.logo-centered { left: 50%; }
    }

    .msg { display: flex; gap: 10px; max-width: 780px; animation: up .2s ease; }
    .msg.user { align-self: flex-end; flex-direction: row-reverse; }
    @keyframes up { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }

    .msg-avatar { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; margin-top: 1px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 500; border: 1px solid var(--border); color: var(--muted); background: var(--sidebar); }
    .msg-body { padding: 10px 14px; border-radius: 10px; font-size: 14px; line-height: 1.65; max-width: 640px; }
    .msg.user      .msg-body { background: #1a1a1a; color: white; border-bottom-right-radius: 3px; }
    .msg.assistant .msg-body { background: var(--sidebar); border: 1px solid var(--border); border-bottom-left-radius: 3px; }

    .msg-body h1,.msg-body h2,.msg-body h3 { font-weight:600; margin:14px 0 6px; line-height:1.3; }
    .msg-body h1 { font-size:16px; } .msg-body h2 { font-size:15px; } .msg-body h3 { font-size:14px; }
    .msg-body h1:first-child,.msg-body h2:first-child,.msg-body h3:first-child { margin-top:0; }
    .msg-body p { margin-bottom:8px; } .msg-body p:last-child { margin-bottom:0; }
    .msg-body strong { font-weight:600; } .msg-body em { font-style:italic; }
    .msg-body ul,.msg-body ol { padding-left:18px; margin-bottom:8px; } .msg-body li { margin-bottom:3px; }
    .msg-body code { font-family:'Menlo','Monaco',monospace; font-size:12px; background:#e5e7eb; padding:1px 5px; border-radius:4px; }
    .msg.user .msg-body code { background:rgba(255,255,255,.15); }
    .msg-body pre { background:#1a1a1a; color:#e5e7eb; border-radius:6px; padding:12px; overflow-x:auto; margin:8px 0; }
    .msg-body pre code { background:none; padding:0; font-size:12px; color:inherit; }
    .msg-body blockquote { border-left:3px solid var(--border); padding-left:12px; color:var(--muted); margin:8px 0; }
    .msg-body hr { border:none; border-top:1px solid var(--border); margin:10px 0; }
    .msg-body .md-table { display:block; overflow-x:auto; width:100%; }
    .msg-body table { border-collapse:collapse; width:100%; margin:8px 0; font-size:13px; }
    .msg-body th,.msg-body td { border:1px solid var(--border); padding:6px 10px; text-align:left; white-space:nowrap; }
    .msg-body th { background:var(--sidebar); font-weight:600; }
    .msg-body tr:nth-child(even) td { background:#fafaf9; }
    .msg-body .md-img { max-width:100%; border-radius:6px; margin:12px 0; display:block; border:1px solid var(--border); cursor:zoom-in; }
    .doc-images { margin-top:10px; padding-top:8px; border-top:1px solid var(--border); display:flex; flex-direction:column; gap:6px; }
    .doc-diagram { max-width:100%; max-height:320px; object-fit:contain; border:1px solid var(--border); border-radius:6px; cursor:zoom-in; display:block; margin:12px 0; }

    /* Lightbox overlay */
    #lightbox { display:none; position:fixed; inset:0; background:rgba(0,0,0,.88); z-index:9999; align-items:center; justify-content:center; padding:24px; box-sizing:border-box; cursor:zoom-out; }
    #lightbox.active { display:flex; }
    #lightbox img { max-width:100%; max-height:100%; object-fit:contain; border-radius:8px; box-shadow:0 12px 48px rgba(0,0,0,.6); cursor:default; }
    #lightbox-close { position:fixed; top:16px; right:20px; background:none; border:none; color:#fff; font-size:28px; cursor:pointer; line-height:1; opacity:.8; }
    #lightbox-close:hover { opacity:1; }
    .msg-sources { margin-top:10px; padding-top:8px; border-top:1px solid var(--border); font-size:11px; color:var(--muted); }

    .brief-notice { display:flex; align-items:center; gap:7px; background:#f0f4ff; border:1px solid #c7d7f7; border-radius:7px; padding:7px 11px; margin-bottom:10px; font-size:12px; color:#3b5bdb; font-weight:500; }
    .brief-icon { font-size:14px; flex-shrink:0; }

    .sp-sources { margin-top:10px; padding-top:8px; border-top:1px solid var(--border); display:flex; flex-wrap:wrap; gap:6px; align-items:center; }
    .sp-sources-label { font-size:11px; color:var(--muted); font-weight:500; white-space:nowrap; }
    .sp-source-btn { display:inline-flex; align-items:center; gap:5px; padding:4px 10px; border-radius:99px; border:1px solid var(--border); background:var(--bg); color:var(--text); font-size:12px; text-decoration:none; white-space:nowrap; transition:background .15s, border-color .15s; }
    .sp-source-btn:hover { background:var(--accent); border-color:var(--accent); color:#fff; }
    .sp-source-btn .sp-icon { font-size:13px; }
    .sp-source-excel { border-color:#bbf7d0; color:#15803d; }
    .sp-source-excel:hover { background:#16a34a; border-color:#16a34a; color:#fff; }
    .excel-hint { font-size:13px; font-weight:600; color:#15803d; background:#f0fdf4; border:1px solid #bbf7d0; border-radius:6px; padding:7px 11px; margin-top:10px; margin-bottom:4px; }
    .xl-sources { flex-direction:column; align-items:flex-start; gap:4px; }
    .xl-toggle { background:none; border:none; cursor:pointer; font-size:12px; color:var(--muted); display:flex; align-items:center; gap:4px; padding:0; font-family:inherit; }
    .xl-toggle:hover { color:var(--text); }
    .xl-arrow { font-size:10px; transition:transform .2s; }
    .xl-list { display:none; flex-wrap:wrap; gap:6px; padding-top:4px; }
    .xl-list.open { display:flex; }
    .xl-arrow { display:inline-block; }

    .typing { display:flex; gap:4px; padding:4px 0; }
    .dot { width:5px; height:5px; background:var(--muted); border-radius:50%; animation:bounce 1.1s infinite; }
    .dot:nth-child(2){animation-delay:.15s;} .dot:nth-child(3){animation-delay:.3s;}
    @keyframes bounce { 0%,60%,100%{transform:translateY(0);opacity:.4;} 30%{transform:translateY(-5px);opacity:1;} }

    /* ════ INPUT ════ */
    .input-wrap { padding: 12px 48px 18px; padding-bottom: max(18px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); flex-shrink: 0; position: relative; }
    .input-row { display:flex; gap:8px; border:1px solid var(--border); border-radius:8px; padding:8px 10px; transition:border-color .15s; position:relative; }
    .input-row:focus-within { border-color:transparent; }
    .input-row::before { content:''; position:absolute; inset:-1px; border-radius:8px; padding:1px; background:linear-gradient(135deg,#5bc8f5,#d966cc); -webkit-mask:linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); -webkit-mask-composite:xor; mask-composite:exclude; opacity:0; transition:opacity .2s ease; pointer-events:none; }
    .input-row:focus-within::before { opacity:1; }
    #chat-input { flex:1; background:none; border:none; outline:none; font-family:inherit; font-size:14px; color:var(--text); resize:none; max-height:120px; line-height:1.5; }
    #chat-input::placeholder { color:var(--muted); }
    .send-btn { width:32px; height:32px; border-radius:6px; background:var(--text); color:white; border:none; cursor:pointer; display:flex; align-items:center; justify-content:center; font-size:14px; flex-shrink:0; align-self:flex-end; transition:opacity .15s; }
    .send-btn:hover { opacity:.8; } .send-btn:disabled { opacity:.3; cursor:not-allowed; }
    .input-hint { font-size:11px; color:var(--muted); margin-top:5px; text-align:right; }

    .folder-filter { display:flex; flex-wrap:wrap; gap:6px; margin-bottom:8px; min-height:0; align-items:center; }
    .folder-filter:empty { margin-bottom:0; }
    .folder-label { font-size:12px; font-weight:600; color:var(--text); white-space:nowrap; margin-right:2px; }
    .folder-btn { display:inline-flex; align-items:center; gap:6px; padding:0 14px; height:32px; border-radius:99px; border:1px solid var(--border); background:var(--bg); color:var(--muted); font-size:13px; font-weight:500; cursor:pointer; transition:background .15s, border-color .15s, color .15s; white-space:nowrap; position:relative; }
    .folder-btn:hover { border-color:transparent; color:var(--text); }
    .folder-btn:hover::before { opacity:1; }
    .folder-btn.active { background:var(--bg); border-color:transparent; color:var(--text); font-weight:600; }
    .folder-btn.active::before { opacity:1; }
    .folder-btn.active:hover::before { background:linear-gradient(135deg,#d00707d0,#d00707d0); }
    .folder-btn.active:hover { color:var(--muted); }
    .folder-btn .folder-icon { font-size:13px; }
    .folder-btn-img { height:18px; width:auto; max-width:48px; object-fit:contain; display:block; }
    .folder-btn::before { content:''; position:absolute; inset:-2px; border-radius:99px; padding:2px; background:linear-gradient(135deg,#5bc8f5,#d966cc); -webkit-mask:linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0); -webkit-mask-composite:xor; mask-composite:exclude; opacity:0; pointer-events:none; }
    @keyframes folder-pulse { 0%,100% { opacity:0; box-shadow:none; } 50% { opacity:1; box-shadow:0 0 10px rgba(91,200,245,.6), 0 0 20px rgba(217,102,204,.5); } }
    .folder-btn.pulse::before { animation:folder-pulse 1s ease-in-out 3; }
    @keyframes folder-pulse-glow { 0%,100% { box-shadow:none; } 50% { box-shadow:0 0 10px rgba(91,200,245,.6), 0 0 22px rgba(217,102,204,.45); } }
    .folder-btn.pulse { animation:folder-pulse-glow 1s ease-in-out 3; }
    .folder-btn.pulse-loop::before { animation:folder-pulse 1.2s ease-in-out infinite; }
    .folder-btn.pulse-loop { animation:folder-pulse-glow 1.2s ease-in-out infinite; }

    /* ════ MACHINE KEUZE ════ */
    .choice-msg { display:flex; gap:10px; max-width:780px; animation:up .2s ease; }
    .choice-body { max-width:640px; }
    .choice-body p { font-size:14px; color:var(--text); margin-bottom:12px; line-height:1.5; }
    .choice-grid { display:flex; flex-direction:column; gap:8px; }
    .choice-card { display:flex; align-items:center; gap:12px; padding:12px 16px; border:1px solid var(--border); border-radius:8px; cursor:pointer; background:var(--bg); transition:border-color .15s, background .15s; text-align:left; }
    .choice-card:hover { border-color:var(--accent); background:#eff6ff; }
    .choice-card.general { border-style:dashed; }
    .choice-card.general:hover { border-color:#7c3aed; background:#f5f3ff; }
    .choice-icon { font-size:20px; flex-shrink:0; }
    .choice-info { flex:1; }
    .choice-title { font-size:13px; font-weight:600; color:var(--text); }
    .choice-sub   { font-size:12px; color:var(--muted); margin-top:2px; }

    /* ════ MODALS ════ */
    .overlay { position:fixed; inset:0; background:rgba(0,0,0,0.25); display:flex; align-items:center; justify-content:center; z-index:200; }
    .overlay.hidden { display:none; }
    .modal { background:var(--bg); border:1px solid var(--border); border-radius:10px; padding:24px 28px; width:min(480px,95vw); max-height:90vh; overflow-y:auto; box-shadow:0 8px 32px rgba(0,0,0,0.12); }
    .modal h2 { font-size:16px; font-weight:600; margin-bottom:4px; }
    .modal .sub { font-size:12px; color:var(--muted); margin-bottom:20px; }
    .modal-close { float:right; background:none; border:none; font-size:18px; cursor:pointer; color:var(--muted); margin-top:-4px; line-height:1; }
    .modal-close:hover { color:var(--text); }
    .field { margin-bottom:12px; }
    .field label { display:block; font-size:12px; color:var(--muted); margin-bottom:4px; }
    .field input { width:100%; border:1px solid var(--border); border-radius:6px; padding:8px 10px; font-family:inherit; font-size:14px; outline:none; color:var(--text); background:var(--bg); transition:border-color .15s; }
    .field input:focus { border-color:var(--accent); }
    .login-error { font-size:12px; color:var(--danger); margin-top:8px; text-align:center; min-height:16px; }
    .acc-list { display:flex; flex-direction:column; gap:8px; margin-bottom:20px; }
    .acc-item { display:flex; align-items:center; gap:10px; padding:10px 12px; border:1px solid var(--border); border-radius:8px; }
    .acc-avatar { width:32px; height:32px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:13px; font-weight:600; color:white; flex-shrink:0; }
    .acc-avatar.eigenaar{background:var(--accent);} .acc-avatar.beheerder{background:var(--accent);} .acc-avatar.superadmin{background:var(--accent);} .acc-avatar.admin{background:var(--accent);}
    .acc-info{flex:1;} .acc-name{font-size:13px;font-weight:500;} .acc-role{font-size:11px;color:var(--muted);}
    .acc-actions{display:flex;gap:4px;}
    .icon-btn{background:none;border:1px solid var(--border);border-radius:5px;padding:4px 8px;font-size:11px;cursor:pointer;color:var(--muted);transition:all .15s;}
    .icon-btn:hover{border-color:var(--accent);color:var(--accent);}
    .icon-btn.del:hover{border-color:var(--danger);color:var(--danger);}
    .add-acc-form{border-top:1px solid var(--border);padding-top:16px;}
    .add-acc-form h3{font-size:13px;font-weight:600;margin-bottom:12px;}
    .form-row{display:flex;gap:8px;margin-bottom:10px;}
    .form-row input{flex:1;border:1px solid var(--border);border-radius:6px;padding:7px 10px;font-family:inherit;font-size:13px;outline:none;color:var(--text);background:var(--bg);}
    .form-row input:focus{border-color:var(--accent);}
    .form-row input::placeholder{color:var(--muted);}
    .apikey-status{display:flex;align-items:center;gap:8px;padding:10px 12px;border:1px solid var(--border);border-radius:8px;margin-bottom:16px;font-size:13px;}
    .apikey-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0;}
    .apikey-dot.set{background:var(--success);} .apikey-dot.unset{background:var(--danger);}

    /* ════ TOAST ════ */
    .input-area-wrap { position:relative; flex-shrink:0; }
    #toast { position:absolute; bottom:100%; left:50%; transform:translateX(-50%) translateY(8px); background:var(--text); color:white; border-radius:8px; padding:11px 20px; font-size:14px; font-weight:500; opacity:0; transition:opacity .2s, transform .2s; z-index:999; pointer-events:none; white-space:nowrap; box-shadow:0 4px 20px rgba(0,0,0,.18); margin-bottom:8px; }
    #toast.show { transform:translateX(-50%) translateY(0); opacity:1; }
    #toast.error   { background:var(--danger); }
    #toast.success { background:var(--success); }
    #toast.warning { background:var(--danger); }

    /* ════ SIDEBAR BACKDROP (mobiel) ════ */
    #sidebar-backdrop {
      display: none;
      position: fixed;
      inset: 0;
      top: var(--header-h);
      background: rgba(0,0,0,0.3);
      z-index: 99;
    }
    #sidebar-backdrop.show { display: block; }

    /* ════ TABLET ════ */
    @media (max-width: 1024px) and (min-width: 769px) {
      :root { --sidebar-w: 230px; }
      .chat-area { padding: 24px 28px; }
      .input-wrap { padding: 12px 28px 18px; }

      .header-logo { height: 48px; width: 48px; }

      /* Admin buttons iets compacter zodat ze passen */
      #apikey-btn, #sp-btn, #accounts-btn { padding: 6px 10px; font-size: 12px; }
      #login-btn, #logout-btn { min-width: 80px; max-width: 80px; width: 80px; }
    }

    /* ════ MOBIEL ════ */
    @media (max-width: 768px) {
      :root { --header-h: 50px; }

      header { padding: 0 10px; gap: 6px; }
      .header-logo { height: 36px; width: 36px; }
      .logo { font-size: 15px; }
      .key-input { display: none !important; }
      #save-key-btn { display: none !important; }

      /* User badge verbergen — te weinig ruimte */
      .user-badge { display: none; }

      .header-right { gap: 4px; }

      /* Alle buttons compacter */
      .btn { padding: 5px 8px; font-size: 12px; }

      /* Admin buttons: alleen emoji tonen, tekst verbergen */
      #apikey-btn, #sp-btn, #accounts-btn, #brands-btn {
        padding: 5px 7px;
        font-size: 0;       /* verberg tekst */
        line-height: 1;
      }
      #apikey-btn::before   { content: '🔑'; font-size: 15px; }
      #sp-btn::before       { content: '☁️'; font-size: 15px; }
      #accounts-btn::before { content: '👥'; font-size: 15px; }
      #brands-btn::before   { content: '🏷️'; font-size: 15px; }

      #login-btn, #logout-btn {
        min-width: 70px; max-width: 70px; width: 70px;
        font-size: 11px; padding: 5px 6px;
      }

      .lang-btn { min-width: 30px; padding: 6px 8px; font-size: 11px; }

      /* Sidebar als fixed overlay */
      aside {
        position: fixed !important;
        top: var(--header-h);
        left: 0;
        bottom: 0;
        height: calc(100dvh - var(--header-h));
        width: min(82vw, 290px) !important;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform .28s cubic-bezier(.4,0,.2,1) !important;
        border-right: 1px solid var(--border);
        box-shadow: 6px 0 24px rgba(0,0,0,0.1);
      }
      aside.open      { transform: translateX(0); }
      aside.collapsed { transform: translateX(-100%) !important; }

      /* Main volle breedte */
      main { width: 100% !important; }

      #bg-logo { width: clamp(100px, 45%, 260px); }
      #bg-logo.logo-moved { width: clamp(80px, 38%, 220px); height: auto; top: 43%; }
      #bg-logo.logo-moved.logo-centered { left: 50%; }

      .chat-area  { padding: 16px 14px; }
      .input-wrap { padding: 10px 14px max(16px, env(safe-area-inset-bottom)); }
      .msg        { max-width: 100%; }
      .msg-body   { max-width: calc(100vw - 60px); font-size: 13px; }
      .msg-avatar { width: 24px; height: 24px; font-size: 10px; }

      .welcome    { margin: auto; max-width: 300px; }
      .welcome h2 { font-size: 17px; }
      .welcome p  { font-size: 13px; }


      .modal      { width: 95vw; padding: 20px 18px; max-height: 85vh; }
      .acc-item   { flex-wrap: wrap; gap: 6px; }
      .acc-actions{ width: 100%; justify-content: flex-end; }
      .form-row   { flex-direction: column; gap: 6px; }

      .choice-msg  { flex-direction: column; gap: 6px; }
      .choice-body { max-width: 100%; }
      .choice-card { padding: 10px 12px; gap: 10px; }

      #toast .toast-inner { font-size: 13px; }
      .input-hint { font-size: 10px; }
    }

    /* ════ ≤ 490px — brands tekst verbergen ════ */
    @media (max-width: 490px) {
      #brands-btn { padding: 5px 7px; font-size: 0; line-height: 1; }
      #brands-btn::before { content: '🏷️'; font-size: 15px; }
    }

    /* ════ ≤ 456px — verberg merken en sharepoint ════ */
    @media (max-width: 456px) {
      #brands-btn { display: none !important; }
      #sp-btn { display: none !important; }
      #login-btn, #logout-btn { min-width: 52px; max-width: 52px; width: 52px; font-size: 10px; padding: 4px 5px; }
      header { gap: 4px; padding: 0 8px; }
    }

    /* ════ EXTRA KLEIN (≤ 400px, iPhone SE) ════ */
    @media (max-width: 400px) {
      :root { --header-h: 46px; }

      header { padding: 0 6px; gap: 4px; }
      .header-logo { height: 30px; width: 30px; }
      .logo { font-size: 13px; }

      #apikey-btn, #sp-btn, #accounts-btn, #brands-btn { padding: 4px 5px; }
      #login-btn, #logout-btn { min-width: 58px; max-width: 58px; width: 58px; font-size: 10px; }
      .lang-btn { min-width: 26px; padding: 5px 6px; font-size: 10px; }

      .chat-area { padding: 12px 10px; gap: 14px; }
      .input-wrap { padding: 8px 10px max(10px, env(safe-area-inset-bottom)); }
      .msg-body { max-width: calc(100vw - 48px); font-size: 12px; }

      #bg-logo { width: clamp(80px, 50%, 180px); }
      #bg-logo.logo-moved { width: clamp(60px, 40%, 150px); height: auto; top: 43%; left: 65%; }
      #bg-logo.logo-moved.logo-centered { left: 50%; }

      .welcome { margin: auto; }
      .welcome h2 { font-size: 15px; }
      .welcome p  { font-size: 12px; }
    }
