 /* ─── RESET & BASE ─────────────────────────────────────────── */
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  
  :root {
    --bg:          #090d13;
    --sidebar:     #0e1520;
    --surface:     #131c2b;
    --surface2:    #1a2540;
    --border:      #1f2e45;
    --accent:      #1b6bec;
    --accent2:     #38bdf8;
    --accent-glow: rgba(27,107,236,0.25);
    --bot-bub:     #111927;
    --user-bub:    #1b6bec;
    --text:        #dde6f0;
    --muted:       #556070;
    --success:     #3fb950;
    --warn:        #f0a040;
    --danger:      #f85149;
    --radius:      14px;
    --font-ui:     'DM Sans', sans-serif;
    --font-head:   'Syne', sans-serif;
    --font-mono:   'IBM Plex Mono', monospace;
  }

  html, body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font-ui);
    background: var(--bg);
    color: var(--text);
  }

  /* ─── LAYOUT ─────────────────────────────────────────────────── */
  #app {
    display: flex;
    height: 100vh;
    overflow: hidden;
  }

  /* ─── SIDEBAR ────────────────────────────────────────────────── */
  #sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
  }

  #sidebar::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 1px; height: 100%;
    background: linear-gradient(180deg, transparent, var(--accent) 40%, var(--accent2) 60%, transparent);
    opacity: 0.3;
  }

  .sidebar-logo {
    padding: 22px 20px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 14px;
    cursor: default;
  }

  .logo-icon {
    width: 42px; height: 42px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-head);
    font-weight: 800;
    font-size: 15px;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 0 20px var(--accent-glow);
    cursor: pointer;
  }

  .logo-text h1 {
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 14px;
    color: var(--text);
    letter-spacing: 0.3px;
    line-height: 1.2;
  }

  .logo-text span {
    font-size: 11px;
    color: var(--muted);
    font-weight: 400;
    font-family: var(--font-mono);
  }

  .sidebar-section-label {
    padding: 18px 20px 8px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: var(--muted);
    text-transform: uppercase;
    font-family: var(--font-mono);
  }

  .quick-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .quick-list::-webkit-scrollbar { width: 3px; }
  .quick-list::-webkit-scrollbar-track { background: transparent; }
  .quick-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

  .quick-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 9px;
    background: transparent;
    border: none;
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 400;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, color 0.15s, transform 0.1s;
    width: 100%;
    line-height: 1.3;
  }

  .quick-btn:hover {
    background: var(--surface2);
    color: #fff;
    transform: translateX(2px);
  }

  .quick-btn:active { transform: translateX(1px) scale(0.99); }

  .quick-btn .q-icon {
    font-size: 15px;
    flex-shrink: 0;
    opacity: 0.8;
  }

  .quick-btn.special {
    background: linear-gradient(135deg, rgba(27,107,236,0.15), rgba(56,189,248,0.1));
    border: 1px solid rgba(27,107,236,0.35);
    color: var(--accent2);
    font-weight: 500;
    margin-top: 8px;
  }

  .quick-btn.special:hover {
    background: linear-gradient(135deg, rgba(27,107,236,0.25), rgba(56,189,248,0.15));
    border-color: var(--accent2);
    color: #fff;
  }

  .sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    font-size: 10.5px;
    color: var(--muted);
    font-family: var(--font-mono);
    line-height: 1.6;
  }

  .status-dot {
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--success);
    margin-right: 5px;
    animation: pulse-dot 2s ease-in-out infinite;
  }

  @keyframes pulse-dot {
    0%, 100% { opacity: 1; box-shadow: 0 0 4px var(--success); }
    50% { opacity: 0.5; box-shadow: none; }
  }

  /* ─── MAIN CHAT ────────────────────────────────────────────── */
  #main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
    position: relative;
  }

  /* noise grain overlay */
  #main::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
    opacity: 0.4;
  }

  /* ─── HEADER ─────────────────────────────────────────────────── */
  #header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 28px;
    background: var(--sidebar);
    border-bottom: 1px solid var(--border);
    z-index: 10;
    flex-shrink: 0;
  }

  .header-avatar {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-head);
    font-weight: 800;
    font-size: 14px;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 0 24px var(--accent-glow);
  }

  .header-info h2 {
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
    letter-spacing: 0.2px;
  }

  .header-info p {
    font-size: 12px;
    color: var(--success);
    font-family: var(--font-mono);
    display: flex;
    align-items: center;
    gap: 5px;
  }

  .header-info p::before {
    content: '●';
    font-size: 8px;
    animation: pulse-dot 2s ease-in-out infinite;
  }

  .header-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
  }

  .header-chip {
    padding: 5px 12px;
    border-radius: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--muted);
    cursor: default;
  }

  /* ─── MESSAGES AREA ─────────────────────────────────────────── */
  #messages {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 1;
    position: relative;
  }

  #messages::-webkit-scrollbar { width: 4px; }
  #messages::-webkit-scrollbar-track { background: transparent; }
  #messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

  /* ─── MESSAGE ROWS ───────────────────────────────────────────── */
  .msg-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    animation: msg-in 0.3s cubic-bezier(.22,.68,0,1.2) both;
  }

  @keyframes msg-in {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to   { opacity: 1; transform: none; }
  }

  .msg-row.user { flex-direction: row-reverse; }

  .msg-avatar {
    width: 32px; height: 32px;
    border-radius: 10px;
    background: var(--surface2);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    border: 1px solid var(--border);
  }

  .msg-row.user .msg-avatar {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    border-color: transparent;
    font-size: 12px;
    font-weight: 700;
    font-family: var(--font-head);
    color: #fff;
  }

  /* ─── BUBBLES ────────────────────────────────────────────────── */
  .bubble {
    max-width: 62%;
    padding: 13px 17px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.65;
    word-break: break-word;
    white-space: pre-wrap;
    position: relative;
    border: 1px solid transparent;
  }

  .bubble.bot {
    background: var(--bot-bub);
    border-color: var(--border);
    border-bottom-left-radius: 4px;
    color: var(--text);
  }

  .bubble.user {
    background: var(--user-bub);
    border-color: rgba(255,255,255,0.1);
    border-bottom-right-radius: 4px;
    color: #fff;
    box-shadow: 0 4px 24px rgba(27,107,236,0.35);
  }

  /* markdown-ish bold */
  .bubble b, .bubble strong {
    color: var(--accent2);
    font-weight: 600;
  }

  /* ─── SYSTEM MSG ─────────────────────────────────────────────── */
  .sys-msg {
    text-align: center;
    font-size: 11px;
    color: var(--muted);
    font-family: var(--font-mono);
    padding: 4px 0;
  }

  /* ─── TYPING INDICATOR ───────────────────────────────────────── */
  #typing-row {
    display: none;
    align-items: flex-end;
    gap: 10px;
    animation: msg-in 0.3s ease both;
  }

  #typing-row.visible { display: flex; }

  .typing-bubble {
    background: var(--bot-bub);
    border: 1px solid var(--border);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    padding: 14px 18px;
    display: flex; gap: 5px; align-items: center;
  }

  .typing-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--muted);
    animation: bounce 1.2s ease-in-out infinite;
  }

  .typing-dot:nth-child(2) { animation-delay: 0.2s; }
  .typing-dot:nth-child(3) { animation-delay: 0.4s; }

  @keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); background: var(--muted); }
    30% { transform: translateY(-6px); background: var(--accent2); }
  }

  /* ─── INPUT AREA ─────────────────────────────────────────────── */
  #input-area {
    padding: 16px 24px 20px;
    background: var(--sidebar);
    border-top: 1px solid var(--border);
    z-index: 10;
    flex-shrink: 0;
  }

  .input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px 10px 10px 18px;
    transition: border-color 0.2s, box-shadow 0.2s;
  }

  .input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
  }

  #txt-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    max-height: 130px;
    min-height: 24px;
    padding: 2px 0;
    overflow-y: auto;
  }

  #txt-input::-webkit-scrollbar { display: none; }
  #txt-input::placeholder { color: var(--muted); }

  #btn-send {
    width: 42px; height: 42px;
    border-radius: 10px;
    background: var(--accent);
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 0 16px var(--accent-glow);
  }

  #btn-send:hover { background: #2678ff; transform: scale(1.05); }
  #btn-send:active { transform: scale(0.96); }
  #btn-send:disabled { background: var(--surface2); cursor: not-allowed; box-shadow: none; transform: none; }

  #btn-send svg { width: 18px; height: 18px; fill: #fff; }

  .input-hint {
    text-align: right;
    font-size: 10.5px;
    color: var(--muted);
    font-family: var(--font-mono);
    margin-top: 7px;
    height: 14px;
  }

  /* ─── CHAMADO FORM STYLING (inside bubble) ───────────────────── */
  .form-step {
    background: linear-gradient(135deg, rgba(27,107,236,0.08), rgba(56,189,248,0.06));
    border: 1px solid rgba(27,107,236,0.3);
    border-radius: 12px;
    padding: 14px 16px;
    margin-top: 8px;
    font-size: 12.5px;
    color: var(--accent2);
    font-family: var(--font-mono);
  }

  /* ─── TICKET CARD ────────────────────────────────────────────── */
  .ticket-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--accent);
    border-radius: 12px;
    padding: 16px;
    font-size: 12.5px;
    line-height: 1.8;
    font-family: var(--font-mono);
    color: var(--text);
  }

  .ticket-card .ticket-id {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent2);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .ticket-card .ticket-id::before {
    content: '◆';
    color: var(--accent);
    font-size: 10px;
  }

  .ticket-row { display: flex; gap: 8px; }
  .ticket-key { color: var(--muted); min-width: 90px; }
  .ticket-val { color: var(--text); }

  .urgency-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .urgency-alta  { background: rgba(248,81,73,0.2);  color: var(--danger);  border: 1px solid rgba(248,81,73,0.4);  }
  .urgency-media { background: rgba(240,160,64,0.2); color: var(--warn);    border: 1px solid rgba(240,160,64,0.4); }
  .urgency-normal{ background: rgba(63,185,80,0.15); color: var(--success); border: 1px solid rgba(63,185,80,0.3);  }

  /* ─── RESPONSIVE ──────────────────────────────────────────────── */
  @media (max-width: 720px) {
    #sidebar { display: none; }
    #messages { padding: 16px 14px; }
    .bubble { max-width: 85%; }
    #input-area { padding: 12px 14px 16px; }
  }

  /* ─── SCROLL ANCHOR ───────────────────────────────────────────── */
  #anchor { height: 1px; }

  /* ── Botão de imagem ── */
  #btn-imagem {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
    color: var(--muted, #888);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
  }
  #btn-imagem:hover {
    background: var(--surface2, rgba(255,255,255,0.08));
    color: var(--text, #fff);
  }
  #btn-imagem svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
  }
  #btn-imagem.has-image {
    color: var(--accent, #4f8ef7);
  }

  /* ── Preview da imagem ── */
  .img-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--surface2, rgba(255,255,255,0.06));
    border: 1px solid var(--border, rgba(255,255,255,0.1));
    border-radius: 10px;
    margin-bottom: 8px;
    animation: slideDown 0.2s ease;
  }
  @keyframes slideDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  .img-preview img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
  }
  .img-preview-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
    min-width: 0;
  }
  .img-preview-info span {
    font-size: 12px;
    color: var(--muted, #888);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
  }
  .img-preview-info button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted, #888);
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
  }
  .img-preview-info button:hover {
    color: #e55;
    background: rgba(220,80,80,0.1);
  }