/* ============================================================
   App layouts (Mel design system). Unlayered: the app's own rules,
   only layout, with the DS tokens.
   ============================================================ */

/* the hidden attribute wins over the display of classes like .btn */
[hidden] { display: none !important; }

/* ---------- Auth layout (base_auth.html): centered card ---------- */
.auth-brand { display: flex; justify-content: center; margin-bottom: var(--spacing-md); }
.auth-brand .mel-wordmark { height: 34px; }
.auth-title { margin: 0 0 var(--spacing-lg); text-align: center; font-size: var(--text-2xl); font-weight: 800; }
.auth-label { display: flex; justify-content: space-between; align-items: baseline; gap: var(--spacing-sm); }
.auth-label a { font-size: var(--text-sm); font-weight: 700; }
.auth-links { margin-top: var(--spacing-lg); padding-top: var(--spacing-md); border-top: 1px solid var(--border-subtle); text-align: center; font-size: var(--text-sm); color: var(--text-muted); }
.auth-links p { margin: 0; }
.auth-links a { font-weight: 700; }
.auth-links .lucide { vertical-align: -0.15em; }

/* ---------- Footer (site + auth) ---------- */
.site-foot { padding: var(--spacing-md); text-align: center; font-size: var(--text-xs); color: var(--text-muted); }
.site-foot p { margin: 0; }

/* ---------- Site header (base.html) ---------- */
.site-nav { display: flex; align-items: center; gap: var(--spacing-xs); }
.site-nav a[aria-current] { color: var(--text-main); background: color-mix(in srgb, var(--color-primary) 13%, transparent); }
@media (max-width: 480px) {
  .site-nav .btn { padding-inline: var(--spacing-sm); }
  .site-nav .btn .lucide { display: none; }
}

/* ---------- Theme toggle (v-theme-toggle): the icon of the other theme ---------- */
.theme-toggle .theme-toggle-light,
[data-theme="dark"] .theme-toggle .theme-toggle-dark { display: none; }
[data-theme="dark"] .theme-toggle .theme-toggle-light { display: contents; }
.theme-toggle .theme-toggle-dark { display: contents; }
@media (hover: none) {
  .theme-toggle[data-tooltip]::before, .theme-toggle[data-tooltip]::after { display: none; }
}

/* ---------- Settings menu (v-settings-menu): wraps instead of scrolling ---------- */
@media (max-width: 860px) { .mel-side-nav { flex-wrap: wrap; overflow: visible; } }

/* ---------- Admin shell (base_admin.html) ---------- */
.app-topbar .id-cell { text-decoration: none; }
.pg-user { display: flex; flex-direction: column; line-height: 1.25; }
.pg-user .id-name { font-size: var(--text-sm); }
.pg-user .id-sub { font-size: var(--text-xs); }
@media (max-width: 820px) { .app-topbar .mel-logo { margin-right: auto; } .app-topbar > .mel-spacer { display: none; } }
/* full-height variant (the page fills the "layout" block with "full"): it takes the
   window's height and each column scrolls by itself */
.app-shell.is-full-height { height: 100vh; height: 100dvh; overflow: hidden; }
.app-shell.is-full-height .app-content { height: 100%; }

/* ---------- CRUD list (crud/list.html) ---------- */
.data-card th a { display: inline-flex; align-items: center; gap: var(--spacing-xs); color: inherit; text-decoration: none; }
.data-card th a:hover { color: var(--text-main); }
.data-card .row-actions { flex-wrap: nowrap; }
.data-card td:first-child { font-weight: 700; color: var(--text-main); }

/* ---------- CRUD forms ---------- */
fieldset.form-section { margin: 0; border: 0; min-width: 0; }
.form-section + fieldset.form-section { border-top: 1px solid var(--border-subtle); }
form .grid-2 { row-gap: 0; }
.form-section > legend { float: left; width: 100%; padding: 0; margin-bottom: var(--spacing-md); font-weight: 800; }
.form-section > legend + * { clear: both; }

/* ---------- Developer quick start (welcome pages) ---------- */
.accordion-content > :last-child { margin-bottom: 0; }
.accordion-content pre { max-width: 100%; }
.qs-intro { margin: 0 0 var(--spacing-md); color: var(--text-muted); font-size: var(--text-sm); overflow-wrap: anywhere; }

/* ---------- Ferramentas (pages/admin/ferramentas/index.html) ---------- */
.pg-gap { margin-bottom: var(--spacing-md); }
.pg-alert { align-items: flex-start; gap: 12px; margin-bottom: var(--spacing-md); }
.pg-leads-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: var(--spacing-md); }
.pg-leads-bar .mel-segs { max-width: 100%; overflow-x: auto; }
.pg-leads-bar .mel-segs a { white-space: nowrap; }
.pg-lead-busca { flex: 1; min-width: 220px; max-width: 420px; margin-left: auto; }
/* Dashboard (/admin/painel): sections, cards, the series of bars and the horizontal bars */
.pg-dash { margin-bottom: var(--spacing-lg); }
.pg-dash .quartet { margin-bottom: var(--spacing-md); }
.pg-dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: var(--spacing-md); }
.pg-dash-grid.is-4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.pg-dash-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.pg-dash-grid > .mel-panel { margin: 0; }
.pg-dash-after { margin-top: var(--spacing-md); }
.pg-dash-card h3 { margin: 0; font-size: var(--text-base); }
.pg-dash-card > .btn { align-self: flex-start; margin-top: auto; }
.pg-dash-serie { display: flex; align-items: stretch; gap: 3px; height: 160px; }
.pg-dash-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; min-width: 0; }
.pg-dash-col span { display: block; min-height: 2px; border-radius: 4px 4px 0 0; background: var(--color-primary); }
.pg-dash-col small { height: 16px; margin-top: 4px; font-size: 10px; color: var(--text-muted); text-align: center; white-space: nowrap; overflow: visible; }
.pg-dash-dl { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 8px 12px; margin: 0; }
.pg-dash-dl dt { color: var(--text-muted); }
.pg-dash-dl dd { margin: 0; font-weight: 700; text-align: right; }
.pg-dash-bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.pg-dash-bar-h { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; font-size: var(--text-sm); }
.pg-dash-bar-h code { font-size: var(--text-xs); }
@media (max-width: 760px) { .pg-dash-grid { grid-template-columns: 1fr; } }
/* Knowledge base: the search test and the pieces of a document */
.pg-kb-busca { display: flex; gap: 8px; margin-bottom: var(--spacing-md); }
.pg-kb-busca .input { flex: 1; margin: 0; }
.pg-kb-achados { display: grid; gap: 10px; margin-bottom: var(--spacing-lg); }
.pg-kb-trecho { padding: 12px 16px; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: var(--bg-surface); }
.pg-kb-trecho-h { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: var(--text-sm); }
.pg-kb-trecho-h .mel-spacer { flex: 1; }
.pg-kb-texto { margin-top: 6px; font-size: var(--text-sm); color: var(--text-muted); }
.pg-kb-texto strong { display: block; margin-top: 4px; color: var(--text-main); }
.pg-kb-texto p { margin: 2px 0 0; font-size: inherit; }
@media (max-width: 760px) { .pg-kb-busca { flex-direction: column; } }
/* Tables that fit the page (leads, notices): text columns and names wrap; blocks on the phone */
.pg-fit .pg-desc { min-width: 160px; max-width: 220px; }
.pg-fit .id-cell > div { white-space: normal; min-width: 140px; }
.pg-fit-stack .row-actions { flex-direction: column; align-items: flex-end; gap: 4px; }
/* On the phone each row is a block: name first, short cells side by side, actions last */
@media (max-width: 760px) {
  .data-card .table-scroll > table.pg-fit { min-width: 0; white-space: normal; }
  .pg-fit thead { display: none; }
  .pg-fit tbody { display: block; }
  .data-card table.pg-fit tbody tr { display: flex; flex-wrap: wrap; align-items: center; column-gap: 8px; padding: 10px 16px; }
  .data-card table.pg-fit td { display: block; padding: 3px 0; border-bottom: 0; }
  .pg-fit td:first-child, .pg-fit td:last-child, .pg-fit td[colspan], .pg-fit-stack td { flex-basis: 100%; }
  .pg-fit .pg-desc { min-width: 0; max-width: none; }
  .pg-fit .row-actions { flex-direction: row; justify-content: flex-start; }
  .pg-fit td[data-label]::before { content: attr(data-label) ": "; color: var(--text-muted); font-size: var(--text-xs); }
}
.pg-section-title { font-size: var(--text-lg); margin: var(--spacing-lg) 0 var(--spacing-sm); }
.row-actions form { display: contents; }
/* The page that plays the signature provider (development) and the contract card */
.pc-contrato { width: min(520px, 100%); display: grid; gap: 12px; text-align: left; }
.pc-contrato h1 { margin: 0; font-size: var(--text-2xl); }
.pc-contrato p { margin: 0; }
.pc-contrato .mel-chip { justify-self: start; }
.pc-contrato-acoes { display: flex; justify-content: flex-end; gap: 8px; }
.pc-assinar { margin-top: 8px; }
.pc-sair { min-height: 100vh; justify-content: center; padding: 16px; text-align: center; }
.pg-alert p { margin: 2px 0 0; font-size: var(--text-sm); }
.pg-desc { white-space: normal; min-width: 200px; max-width: 260px; font-size: var(--text-sm); color: var(--text-muted); }
.pg-src { display: block; margin-top: 2px; font-size: var(--text-xs); font-weight: 700; color: var(--text-main); }
.pg-bots { display: flex; gap: 4px; flex-wrap: wrap; max-width: 150px; }
/* dialogs: the body scrolls when the form is taller than the window */
.pg-dialog .modal-body { max-height: min(70vh, 640px); overflow-y: auto; }
.pg-dialog .modal-body > p { margin-top: 0; }
.pg-dialog-meta { display: flex; align-items: center; flex-wrap: wrap; gap: var(--spacing-sm); font-size: var(--text-sm); }
.pg-dialog .form-section { padding: var(--spacing-md) 0 0; border-top: 1px solid var(--border-subtle); }
.pg-dialog .modal-body > .alert { margin-bottom: var(--spacing-md); font-size: var(--text-sm); }

/* ---------- Chatbots (pages/admin/chatbots/index.html) ---------- */
.pg-bar { display: flex; align-items: center; gap: var(--spacing-sm); flex-wrap: wrap; margin-bottom: var(--spacing-md); }
.pg-bar .input { max-width: 300px; margin: 0; }
.pg-bar .mel-spacer { flex: 1; }
.pg-tone { margin: 0; font-size: var(--text-sm); color: var(--text-muted); }
.pg-tone strong { display: block; color: var(--text-main); }
.pg-tone .mel-mono { font-size: var(--text-xs); }
.pg-kpis { display: flex; gap: var(--spacing-md); font-size: var(--text-sm); color: var(--text-muted); }
.pg-kpis b { display: block; color: var(--text-main); font-family: var(--font-mono); font-size: var(--text-base); }
.pg-new { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--spacing-sm); min-height: 260px; border: 2px dashed var(--border-base); border-radius: var(--radius-lg); color: var(--text-muted); text-decoration: none; text-align: center; padding: var(--spacing-md); transition: border-color var(--transition-fast), color var(--transition-fast); }
.pg-new:hover { border-color: var(--color-primary); color: var(--text-main); }
.pg-new strong { color: var(--text-main); }
.pg-new span { font-size: var(--text-sm); }
/* the one-button forms of the card footer (duplicate, delete) */
.pg-inline { display: contents; }
@media (max-width: 760px) { .pg-bar .input { max-width: none; flex: 1 1 100%; } }

/* ---------- Chatbot form (pages/admin/chatbots/form.html) ---------- */
.pg-split { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: var(--spacing-md); align-items: start; }
.pg-side { display: flex; flex-direction: column; gap: var(--spacing-md); position: sticky; top: var(--spacing-md); }
.pg-span2 { grid-column: span 2; }
.pg-count { display: flex; justify-content: space-between; gap: var(--spacing-sm); }
.pg-prompt { font-family: var(--font-mono); font-size: var(--text-sm); line-height: 1.6; min-height: 340px; }
.pg-vars { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: var(--spacing-sm); }
.pg-vars .text-sm { margin-right: 4px; }
.pg-vars button { cursor: pointer; }
.pg-group + .pg-group { margin-top: var(--spacing-md); }
.pg-group .mel-section-label { margin-bottom: var(--spacing-sm); }
.pg-check-id { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); }
.pg-check-id .badge-soft { font-family: var(--font-sans, inherit); vertical-align: 1px; }
.pg-tools-h { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--spacing-md); }
.form-foot .mel-spacer { flex: 1; }
.pg-test { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.pg-test-h { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border-subtle); }
.pg-test-h .id-name { font-size: var(--text-sm); }
.pg-test-h .id-sub { font-size: var(--text-xs); }
.pg-test-h .mel-spacer { flex: 1; }
.pg-test-body { padding: 16px; max-height: 360px; overflow-y: auto; background: var(--bg-base); }
.pg-test-compose { padding: 12px 16px 16px; border-top: 1px solid var(--border-subtle); }
.pg-test-compose .mel-composer textarea { min-height: 44px; }
.pg-ai-row { display: flex; gap: 10px; align-items: flex-start; }
.pg-ai-row > .mel-avatar-ai { flex: none; margin-top: 2px; }
.pg-tool-row { padding-left: 36px; }
.pg-link-row { display: flex; gap: var(--spacing-sm); }
.pg-link-row .input { margin: 0; font-family: var(--font-mono); font-size: var(--text-sm); }
@media (max-width: 1100px) { .pg-split { grid-template-columns: 1fr; } .pg-side { position: static; } }
@media (max-width: 760px) { .pg-span2 { grid-column: auto; } .pg-tools-h { flex-direction: column; } .form-foot { flex-wrap: wrap; } }
.pg-test .mel-thread { gap: 10px; }
.pg-sys { align-self: center; text-align: center; }
.pg-sys .mel-chip { white-space: normal; }
.pg-quick { display: flex; flex-wrap: wrap; gap: 6px; padding-left: 36px; }
.pg-quick .btn { background: var(--bg-surface); }
.pg-test-body .mel-typing { align-self: flex-start; }
/* "Montar com IA" dialog of the chatbot form: the chat and the proposal card */
.pg-ia { padding: 0; }
.pg-ia .modal-header { gap: 12px; }
.pg-ia .pg-test-h { padding: 0; border: 0; }
.pg-ia .mel-avatar-ai { flex: none; }
.pg-ia-body { min-height: 260px; max-height: min(56vh, 520px); }
.pg-ia .mel-thread { gap: 10px; }
.pg-ia .mel-typing { align-self: flex-start; }
.pg-proposta { display: grid; gap: 8px; margin-left: 36px; padding: 12px 14px; border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); background: var(--bg-surface); }
.pg-proposta p { margin: 0; }
.pg-proposta-h { display: flex; align-items: center; gap: 8px; }
.pg-proposta pre { max-height: 240px; overflow: auto; white-space: pre-wrap; font-size: var(--text-xs); }
.pg-proposta-tools { display: flex; flex-wrap: wrap; gap: 4px; }
.pg-proposta-foot { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
@media (max-width: 760px) { .pg-proposta { margin-left: 0; } }

/* ---------- Public chat (base_chat.html, pages/chat/) ---------- */
/* the page around the chat is darker than the thread, so the chat reads as one block */
.pc-body { margin: 0; background: color-mix(in srgb, var(--text-main) 9%, var(--bg-base)); }
.pc-app { height: 100vh; height: 100dvh; max-width: 1100px; margin: 0 auto; background: var(--bg-surface); border-inline: 1px solid var(--border-subtle); box-shadow: var(--shadow-lg); }
.pc-conv { display: flex; flex-direction: column; height: 100%; min-width: 0; }
.pc-conv-h { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border-subtle); background: var(--bg-surface); }
.pc-conv-h .pc-who { flex: 1; min-width: 0; }
.pc-conv-h strong { display: block; font-size: var(--text-base); line-height: 1.2; }
.pc-sub { display: block; font-size: var(--text-xs); color: var(--text-muted); }
.pc-status { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--text-muted); }
/* the status dot follows the conversation state */
.pc-app[data-estado="bot"] .pc-status .status-dot { background: var(--color-success); }
.pc-app[data-estado="fila"] .pc-status .status-dot { background: var(--color-warning); }
.pc-app[data-estado="atendimento"] .pc-status .status-dot { background: var(--color-info); }
.pc-app[data-estado="encerrada"] .pc-status .status-dot { background: var(--border-base); }
/* "?debug=true" box of the public chat: the test data of the stubs */
.pc-debug { position: fixed; top: 12px; right: 12px; z-index: 50; width: min(360px, calc(100vw - 24px)); background: var(--bg-surface); border: 1px dashed color-mix(in srgb, var(--color-warning) 60%, transparent); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); font-size: var(--text-sm); }
.pc-debug > summary { display: flex; align-items: center; justify-content: flex-start; gap: 6px; padding: 8px 12px; font-weight: 700; cursor: pointer; }
/* on wide screens the chat moves left so the box does not cover it */
@media (min-width: 761px) { .pc-body:has(.pc-debug) .pc-app { margin-right: 384px; } }
.pc-debug-body { max-height: calc(100dvh - 80px); overflow-y: auto; padding: 0 12px 12px; }
.pc-debug-body > p { margin: 0; font-size: var(--text-xs); color: var(--text-muted); }
.pc-debug h4 { margin: 12px 0 6px; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.pc-debug-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pc-debug-list ul { margin: 2px 0 0; padding-left: 18px; font-size: var(--text-xs); }
.pc-debug-meta { font-size: var(--text-xs); color: var(--text-muted); }
.pc-debug-fill { padding: 1px 6px; border: 1px solid var(--border-subtle); border-radius: 6px; background: var(--bg-base); font-family: var(--font-mono, monospace); font-size: var(--text-xs); color: var(--text-main); cursor: pointer; }
.pc-debug-fill:hover { border-color: var(--color-primary); }
@media (max-width: 760px) { .pc-debug { top: auto; bottom: 72px; } .pc-debug-body { max-height: calc(100dvh - 180px); } }
/* light gray (lighter than the page) with gray dots */
.pc-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 20px clamp(16px, 5vw, 64px); background-color: color-mix(in srgb, var(--text-main) 4%, var(--bg-base)); background-image: radial-gradient(color-mix(in srgb, var(--text-main) 16%, transparent) 1px, transparent 1px); background-size: 18px 18px; }
.pc-thread { max-width: 860px; margin: 0 auto; gap: 8px; }
.pc-day { align-self: center; padding: 4px 12px; border-radius: var(--radius-pill); background: var(--bg-surface); border: 1px solid var(--border-subtle); font-size: var(--text-xs); font-weight: 700; color: var(--text-muted); margin: 6px 0; }
.pc-notice { align-self: center; max-width: 520px; text-align: center; padding: 8px 14px; border-radius: var(--radius-md); background: var(--bg-base); border: 1px solid var(--border-subtle); font-size: var(--text-xs); color: var(--text-main); margin-bottom: 6px; }
.pc-sys { align-self: center; white-space: normal; text-align: center; }
.pc-thread .mel-msg { max-width: min(78%, 560px); }
.pc-thread .mel-msg:not(.is-user) { align-self: flex-start; }
.pc-thread .mel-msg:not(.is-user) .mel-bubble { background: var(--bg-surface); border: 1px solid var(--border-subtle); box-shadow: var(--shadow-xs); }
.pc-thread .mel-bubble { font-size: var(--text-sm); }
.pc-thread .mel-bubble > p:last-of-type { margin-bottom: 0; }
.pc-from { font-size: var(--text-xs); font-weight: 700; color: var(--text-muted); }
.pc-time { float: right; margin: 6px 0 -4px 12px; display: inline-flex; align-items: center; gap: 3px; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.pc-time .lucide { width: 15px; height: 15px; color: var(--color-info); }
.pc-file { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.pc-prods { display: grid; gap: 8px; margin: 8px 0; }
.pc-prod { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--bg-base); }
.pc-prod > div { flex: 1; min-width: 0; }
.pc-prod strong { display: block; font-size: var(--text-sm); }
.pc-prod small { color: var(--text-muted); font-size: var(--text-xs); }
.pc-price { font-family: var(--font-mono); font-weight: 700; font-size: var(--text-sm); }
.pc-price small { font-weight: 400; color: var(--text-muted); }
.pc-bill { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; margin: 8px 0; }
.pc-bill .pc-prod { margin-bottom: 2px; }
.pc-bill > small { color: var(--text-muted); font-size: var(--text-xs); }
.pc-code { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pc-code .btn { flex: none; }
.pc-code code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-xs); }
.pc-quick { display: flex; flex-wrap: wrap; gap: 6px; align-self: flex-start; max-width: 560px; margin-top: 2px; }
.pc-quick .btn { background: var(--bg-surface); }
.pc-typing { align-self: flex-start; background: var(--bg-surface); box-shadow: var(--shadow-xs); }
.pc-rate { align-self: center; text-align: center; padding: 12px 16px; border-radius: var(--radius-lg); background: var(--bg-surface); border: 1px solid var(--border-subtle); box-shadow: var(--shadow-xs); }
.pc-rate p { margin: 0 0 4px; font-size: var(--text-sm); font-weight: 700; }
.pc-stars { display: flex; gap: 2px; justify-content: center; }
.pc-stars .btn { color: var(--text-muted); }
/* hovering a star lights it and the ones before it */
.pc-stars:hover .btn { color: var(--color-warning); }
.pc-stars .btn:hover ~ .btn { color: var(--text-muted); }
.pc-compose { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--border-subtle); background: var(--bg-surface); }
.pc-compose .input { margin: 0; flex: 1; border-radius: var(--radius-pill); background: var(--bg-base); }
.pc-send { border-radius: 50%; flex: none; }
@media (max-width: 820px) {
  .pc-app { border: 0; }
  .pc-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pc-conv-h { padding: 8px 10px; gap: 8px; }
  .pc-scroll { padding: 14px 10px; }
  .pc-thread .mel-msg { max-width: 88%; }
  .pc-compose { padding: 8px 10px; }
}

/* ---------- Service desk (pages/admin/atendimento/): the page fills the window ---------- */
.at-status { margin: 0; font-size: var(--text-sm); font-weight: 700; }
.at-desk { flex: 1; min-height: 0; display: grid; grid-template-columns: 340px minmax(0, 1fr) 300px; background: var(--bg-surface); position: relative; }
.at-list { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border-subtle); }
.at-list-h { padding: var(--spacing-md); display: grid; gap: var(--spacing-sm); border-bottom: 1px solid var(--border-subtle); }
.at-list-h h1 { font-size: var(--text-xl); margin: 0; display: flex; align-items: center; gap: var(--spacing-sm); }
.at-list-h form { margin: 0; }
.at-list-h .input { margin: 0; }
.at-list-h .mel-segs { display: flex; }
/* the tabs are links (?aba=…): same look as the .mel-segs buttons */
.mel-segs a { display: inline-flex; align-items: center; gap: 7px; color: var(--text-muted); font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: 8px; text-decoration: none; }
.mel-segs a:hover { color: var(--text-main); text-decoration: none; }
.mel-segs a.is-active { background: var(--bg-surface); color: var(--text-main); box-shadow: var(--shadow-xs), inset 0 0 0 1.5px color-mix(in srgb, var(--color-primary) 55%, transparent); }
.at-list-h .mel-segs a { flex: 1 1 auto; justify-content: center; padding: 6px 4px; gap: 5px; white-space: nowrap; }
.at-count { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); }
.mel-segs a.is-active .at-count { color: var(--text-main); }
.at-items { flex: 1; min-height: 0; overflow-y: auto; list-style: none; margin: 0; padding: 0; }
.at-item { display: flex; gap: 12px; width: 100%; padding: 12px var(--spacing-md); border-bottom: 1px solid var(--border-subtle); background: transparent; text-align: left; color: var(--text-main); text-decoration: none; }
.at-item:hover { background: var(--bg-base); text-decoration: none; }
.at-item.is-active { background: color-mix(in srgb, var(--color-primary) 10%, var(--bg-surface)); box-shadow: inset 3px 0 0 var(--color-primary); }
.at-item-main { flex: 1; min-width: 0; display: grid; gap: 3px; }
.at-item-top { display: flex; align-items: baseline; gap: var(--spacing-sm); }
.at-item-top strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-sm); }
.at-item-top time { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); }
.at-prev { font-size: var(--text-sm); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.at-item.is-unread .at-prev { color: var(--text-main); font-weight: 700; }
.at-item-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.at-item-meta .mel-chip { font-size: 11px; padding: 1px 8px; }
.at-item-top .badge { align-self: center; }
.at-none { padding: var(--spacing-lg) var(--spacing-md); text-align: center; color: var(--text-muted); font-size: var(--text-sm); }
.at-conv { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.at-conv-h { display: flex; align-items: center; gap: 12px; padding: 10px var(--spacing-md); border-bottom: 1px solid var(--border-subtle); }
.at-who { flex: 1; min-width: 0; }
.at-who > strong { display: block; line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.at-who > span { display: block; font-size: var(--text-xs); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.at-who .status-dot { margin-right: 6px; vertical-align: 1px; }
.at-conv-actions { display: flex; gap: var(--spacing-xs); align-items: center; }
.at-conv-actions .dropdown-menu { right: 0; left: auto; }
.at-conv-actions .dropdown-menu form { margin: 0; }
.at-conv-actions .dropdown-item { width: 100%; text-align: left; }
.at-back, .at-info-btn { display: none; }
.at-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 20px clamp(16px, 4vw, 48px); background-color: color-mix(in srgb, var(--color-primary) 6%, var(--bg-surface)); background-image: radial-gradient(color-mix(in srgb, var(--color-primary) 18%, transparent) 1px, transparent 1px); background-size: 18px 18px; }
.at-thread { max-width: 820px; margin: 0 auto; gap: 8px; }
.at-thread .mel-msg { max-width: min(78%, 560px); align-self: flex-start; }
.at-thread .mel-msg.is-user { align-self: flex-end; }
.at-thread .mel-bubble { font-size: var(--text-sm); }
.at-thread .mel-msg:not(.is-user) .mel-bubble { background: var(--bg-surface); box-shadow: var(--shadow-xs); }
.at-thread .mel-msg.is-bot .mel-bubble { background: color-mix(in srgb, var(--text-muted) 12%, var(--bg-surface)); border-color: var(--border-subtle); }
.at-thread .mel-msg.is-note .mel-bubble { background: color-mix(in srgb, var(--color-warning) 14%, var(--bg-surface)); border: 1px dashed color-mix(in srgb, var(--color-warning) 55%, transparent); }
.at-from { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 800; color: var(--text-muted); padding: 0 4px; }
.at-from .lucide { width: 12px; height: 12px; }
.at-time { float: right; margin: 6px 0 -4px 12px; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.at-day { align-self: center; padding: 4px 12px; border-radius: var(--radius-pill); background: var(--bg-surface); border: 1px solid var(--border-subtle); font-size: var(--text-xs); font-weight: 700; color: var(--text-muted); margin: 6px 0; }
.at-sys { align-self: center; white-space: normal; text-align: center; }
.at-file { display: flex; align-items: center; gap: 8px; padding: 6px 8px; margin: 4px 0; border-radius: var(--radius-md); background: var(--bg-base); border: 1px solid var(--border-subtle); font-size: var(--text-xs); }
.at-foot { border-top: 1px solid var(--border-subtle); padding: 12px var(--spacing-md); background: var(--bg-surface); }
.at-take { display: flex; align-items: center; gap: var(--spacing-md); flex-wrap: wrap; }
.at-take + .mel-composer { margin-top: var(--spacing-sm); }
.at-take p { flex: 1; min-width: 220px; margin: 0; font-size: var(--text-sm); color: var(--text-muted); }
.at-take p strong { color: var(--text-main); }
.at-take form { margin: 0; }
.at-quick { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; }
.at-quick .btn { flex: none; }
.at-foot .mel-composer textarea { min-height: 52px; max-height: 160px; }
.at-foot .mel-composer.is-note { background: color-mix(in srgb, var(--color-warning) 8%, var(--bg-surface)); }
.at-foot .mel-segs button { padding: 4px 10px; }
.at-info { min-height: 0; overflow-y: auto; border-left: 1px solid var(--border-subtle); padding: var(--spacing-md); display: grid; align-content: start; gap: var(--spacing-md); background: var(--bg-surface); }
.at-info-close { display: none; }
.at-person { display: flex; align-items: center; gap: 12px; }
.at-person strong { display: block; }
.at-person div span { font-size: var(--text-xs); color: var(--text-muted); }
.at-sec { display: grid; gap: var(--spacing-sm); }
.at-sec h2 { margin: 0; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .06em; font-weight: 800; color: var(--text-muted); }
.at-sec .mel-summary dl { font-size: var(--text-sm); }
.at-sec .mel-summary dd { font-weight: 600; }
.at-sec .alert { font-size: var(--text-sm); padding: 10px 12px; }
.at-sec .alert strong { display: block; }
.at-sum { margin: 0; padding-left: 1.1rem; font-size: var(--text-sm); display: grid; gap: 4px; }
.at-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.at-orders { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.at-orders li { display: flex; align-items: center; gap: 8px; font-size: var(--text-sm); padding: 8px 10px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); }
.at-orders li span { white-space: nowrap; }
.at-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.at-result { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin-top: 8px; }
.at-result-dl { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; gap: 4px 12px; margin: 0; font-size: var(--text-xs); line-height: 1.4; }
.at-result-dl > dt, .at-result-dl > dd { margin: 0; padding: 0; }
.at-result-dl > dt { color: var(--text-muted); font-weight: 400; }
.at-result-dl > dd { overflow-wrap: anywhere; }
.at-result-item + .at-result-item { border-top: 1px dashed var(--border-subtle); padding-top: 6px; }
.at-orders li span:first-child { flex: 1; }
@media (max-width: 1280px) {
  .at-desk { grid-template-columns: 320px minmax(0, 1fr); }
  .at-info-btn { display: inline-flex; }
  .at-info { position: absolute; top: 0; right: 0; bottom: 0; width: min(340px, 100%); z-index: 20; box-shadow: var(--shadow-lg); transform: translateX(105%); transition: transform var(--transition-base); }
  .at-desk.info-open .at-info { transform: none; }
  .at-info-close { display: inline-flex; justify-self: end; margin-bottom: calc(-1 * var(--spacing-sm)); }
}
@media (max-width: 820px) {
  .at-desk { grid-template-columns: minmax(0, 1fr); }
  .at-conv { display: none; }
  .at-desk.conv-open .at-list { display: none; }
  .at-desk.conv-open .at-conv { display: flex; }
  .at-back { display: inline-flex; }
  .at-conv-h { padding: 8px 10px; gap: 8px; }
  .at-conv-actions .at-label { display: none; }
  .at-scroll { padding: 14px 10px; }
  .at-thread .mel-msg { max-width: 88%; }
  .at-foot { padding: 10px; }
  .at-foot .mel-composer-hint { display: none; }
}
/* attachments */
.pc-file { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: inherit; }
.pc-thumb { display: block; margin-bottom: 6px; }
.pc-thumb img { display: block; max-width: 220px; max-height: 220px; border-radius: var(--radius-md); object-fit: cover; }
.pc-clip { flex: none; cursor: pointer; }
a.at-file { color: inherit; text-decoration: none; }
a.at-file:hover { text-decoration: underline; }
.mel-composer-bar label.btn { cursor: pointer; margin: 0; }
