:root {
  --color-primary: #005E57; --color-primary-hover: #004E49; --color-primary-light: #E5EFEF;
  --bg-app: #F4F7F6; --bg-surface: #FFFFFF; --border: #E7E7E7;
  --text-primary: #2D1E2F; --text-secondary: #364656; --text-muted: #5E7389;
  --radius-sm: 6px; --radius-md: 8px; --radius-lg: 12px;
  --text-xs: 11px; --text-sm: 13px; --text-base: 14px;
}
[hidden] { display: none !important; }
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, system-ui, -apple-system, sans-serif; font-size: var(--text-base); color: var(--text-primary); background: var(--bg-app); }
a { color: var(--color-primary); }
button, input, select { font: inherit; }
.topbar { display: flex; align-items: center; gap: 24px; padding: 12px 24px; background: var(--bg-surface); border-bottom: 1px solid var(--border); }
.brand { font-weight: 700; color: var(--color-primary); text-decoration: none; }
.topnav { display: flex; gap: 16px; flex: 1; }
.topnav a { color: var(--text-secondary); text-decoration: none; font-weight: 600; padding: 6px 0; border-bottom: 2px solid transparent; }
.topnav a.is-active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.topbar-user { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: var(--text-sm); }
body.is-anon .topbar { display: none; }
#app { max-width: 1200px; margin: 0 auto; padding: 24px 16px; }
.login { display: flex; justify-content: center; padding: 80px 16px; }
.login[hidden] { display: none; }
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { margin: 0 0 8px; font-size: 20px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary); }
.card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; }
.btn { padding: 9px 14px; border-radius: var(--radius-md); border: 1px solid var(--color-primary); background: var(--color-primary); color: #fff; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--color-primary-hover); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.is-secondary { background: var(--bg-surface); color: var(--color-primary); }
.btn.is-ghost { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn.is-small { padding: 5px 10px; font-size: var(--text-sm); }
input[type=text], input[type=search], input[type=email], input[type=password], select { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-surface); }
input:focus, select:focus { outline: none; border-color: var(--color-primary); }
.error { color: #C62828; font-size: var(--text-sm); }
.muted { color: var(--text-muted); font-size: var(--text-sm); }
.stk-badge { display: inline-flex; align-items: center; padding: 4px 10px; font-size: var(--text-xs); font-weight: 600; border-radius: var(--radius-sm); line-height: 1; letter-spacing: .02em; white-space: nowrap; }
.stk-badge.is-default { background: var(--bg-app); color: var(--text-secondary); }
.stk-badge.is-success { background: #E8F5E9; color: #2E7D32; }
.stk-badge.is-warning { background: #FFF3E0; color: #E65100; }
.stk-badge.is-error { background: #FFEBEE; color: #C62828; }
.stk-badge.is-info { background: #E3F2FD; color: #1565C0; }
.stk-badge.is-waiting { background: #EDE7F6; color: #5E35B1; }
.stk-badge.is-primary { background: var(--color-primary-light); color: var(--color-primary); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab { padding: 8px 14px; border: 0; background: transparent; color: var(--text-muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; }
.tab.is-active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.list-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.list-head .btn { margin-bottom: 8px; text-decoration: none; }
.list-head .tabs { border-bottom: 0; margin-bottom: 0; flex: 1; }
.view-toggle { display: flex; gap: 4px; margin-bottom: -1px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters input[type=search] { flex: 1; min-width: 200px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); cursor: pointer; user-select: none; }
th.is-sorted::after { content: ' ↓'; } th.is-sorted.is-asc::after { content: ' ↑'; }
td.subject { white-space: normal; min-width: 240px; }
tbody tr { cursor: pointer; } tbody tr:hover { background: var(--bg-app); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; color: var(--text-muted); font-size: var(--text-sm); }
.kanban { display: grid; grid-template-columns: repeat(var(--kanban-cols, 5), minmax(0, 1fr)); gap: 12px; align-items: start; }
@media (max-width: 1240px) { .kanban { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1000px) { .kanban { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .kanban { grid-template-columns: 1fr; } }
.kanban-col { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 0 10px 10px; overflow: hidden; display: flex; flex-direction: column; gap: 8px; min-height: 120px; }
.kanban-col.is-drop { border-color: var(--color-primary); background: var(--color-primary-light); }
/* a faixa é uma .stk-badge: `currentColor` é o tom saturado do próprio status (a cor do texto
   da badge), então a cor sai de `.stk-badge.is-*` e nenhuma cor nova nasce aqui */
.stk-badge.kanban-stripe { height: 5px; padding: 0; margin: 0 -10px; border-radius: 0; flex: none; background: currentColor; }
.kanban-col-head { display: flex; align-items: center; gap: 8px; }
.kanban-col-head h2 { margin: 0; flex: 1; font-size: var(--text-xs); }
.kanban-count { font-size: var(--text-xs); font-weight: 700; color: var(--text-secondary); background: var(--bg-app); border-radius: var(--radius-sm); padding: 2px 8px; }
.kanban-cards { display: flex; flex-direction: column; gap: 8px; max-height: 68vh; overflow-y: auto; }
.kanban-empty { margin: 0; }
.kanban-more { align-self: flex-start; }
.kanban-card { background: var(--bg-app); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; cursor: pointer; }
.kanban-card:hover { border-color: var(--color-primary); }
.kanban-card:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 1px; }
.kanban-card.is-dragging { opacity: .4; }
.kanban-card.is-saving { opacity: .6; pointer-events: none; }
.kanban-card-top { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); color: var(--text-muted); }
.kanban-card .stk-type-icon { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.kanban-number { font-weight: 700; color: var(--text-secondary); }
.kanban-priority { padding: 2px 6px; font-size: 10px; }
.kanban-time { margin-left: auto; }
.kanban-subject { margin: 0; font-size: var(--text-sm); font-weight: 600; overflow-wrap: anywhere; }
.kanban-waiting { align-self: flex-start; }
.kanban-card-foot { display: flex; align-items: center; gap: 6px; }
.kanban-requester { flex: 1; min-width: 0; font-size: var(--text-xs); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kanban-move { max-width: 112px; padding: 2px 4px; font-size: var(--text-xs); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-surface); cursor: pointer; }
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; }
@media (max-width: 900px) { .detail { grid-template-columns: 1fr; } }
.detail-back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 12px; font-size: var(--text-sm); font-weight: 600; text-decoration: none; }
.detail-back:hover { text-decoration: underline; }
.detail-back svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.detail-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 16px; }
.detail-head h1 { margin: 0; font-size: 20px; flex: 1 1 100%; }
.detail-head select { min-width: 140px; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
/* Detalhe com comportamento de chat: a conversa rola dentro da coluna principal e o editor fica
   ancorado no pé dela, em vez de a página inteira rolar. `min-height: 0` é obrigatório — sem ele o
   item flex não encolhe abaixo do conteúdo e o scroll nasce na página de novo. A sidebar fica no
   topo (`align-self: start`) para não esticar até a altura da conversa. */
.detail > .info { align-self: start; }
.detail-main { display: flex; flex-direction: column; min-width: 0; height: calc(100vh - 230px); min-height: 380px; }
.detail-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.detail-compose { flex: 0 0 auto; display: flex; flex-direction: column; gap: 8px; }
.detail-compose .stk-editor-area { min-height: 80px; max-height: 30vh; }
.detail-send-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.detail-waiting { display: inline-flex; align-items: center; gap: 7px; font-size: var(--text-sm); color: var(--text-secondary); cursor: pointer; user-select: none; }
.detail-waiting input { width: 16px; height: 16px; margin: 0; accent-color: var(--color-primary); cursor: pointer; }
.info dl { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; margin: 0; font-size: var(--text-sm); }
.info dt { color: var(--text-muted); } .info dd { margin: 0; overflow-wrap: anywhere; }
.info ul { padding-left: 18px; margin: 4px 0; }
.stk-thread { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.stk-msg { max-width: 88%; padding: 10px 12px; border-radius: var(--radius-lg); background: var(--bg-surface); border: 1px solid var(--border); align-self: flex-start; }
.stk-msg.is-mine { align-self: flex-end; background: var(--color-primary-light); border-color: var(--color-primary-light); }
.stk-msg-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; display: flex; gap: 6px; align-items: center; }
.stk-rich p, .stk-rich div { margin: 0 0 8px; } .stk-rich img { max-width: 100%; border-radius: var(--radius-sm); display: block; margin: 8px 0; cursor: zoom-in; }
.stk-rich ul, .stk-rich ol, .stk-editor-area ul, .stk-editor-area ol { padding-left: 22px; margin: 4px 0; }
.stk-editor { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md); margin-top: 12px; }
.stk-editor:focus-within { border-color: var(--color-primary); }
.stk-editor.is-dragover { border-color: var(--color-primary); background: var(--color-primary-light); }
.stk-editor-toolbar { display: flex; gap: 2px; padding: 6px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.stk-editor-area { min-height: 120px; max-height: 50vh; overflow-y: auto; padding: 12px; outline: none; }
.stk-editor-area:empty::before { content: attr(data-placeholder); color: var(--text-muted); }
.stk-editor-area img { max-width: 100%; border-radius: var(--radius-sm); display: block; margin: 8px 0; }
.stk-upload-pending { color: var(--text-muted); font-style: italic; } .stk-upload-failed { color: #C62828; cursor: pointer; }
.stk-tool { width: 30px; height: 30px; border: 0; background: transparent; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; color: var(--text-secondary); cursor: pointer; }
.stk-tool:hover { background: var(--bg-app); } .stk-tool:disabled { opacity: .4; cursor: not-allowed; }
.stk-tool svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.stk-tool-sep { width: 1px; background: var(--border); margin: 4px; }
.stk-toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.stk-toast { padding: 10px 16px; border-radius: var(--radius-md); background: var(--text-primary); color: #fff; font-size: var(--text-sm); box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.stk-toast.is-error { background: #C62828; } .stk-toast.is-success { background: #2E7D32; }
.stk-annotate { position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,.85); display: flex; flex-direction: column; }
.stk-annotate-bar { display: flex; gap: 6px; align-items: center; padding: 10px 16px; background: var(--text-primary); color: #fff; flex-wrap: wrap; }
.stk-annotate-bar .stk-tool { color: #fff; } .stk-annotate-bar .stk-tool.is-active { background: rgba(255,255,255,.2); }
.stk-annotate-bar .stk-tool.is-color { border-radius: 50%; width: 22px; height: 22px; margin: 0 2px; border: 2px solid transparent; }
.stk-annotate-bar .stk-tool.is-color.is-active { border-color: #fff; }
.stk-annotate-bar .stk-tool.is-width span { display: block; background: currentColor; border-radius: 3px; width: 16px; }
.stk-annotate-bar .stk-grow { flex: 1; }
.stk-annotate-stage { flex: 1; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.stk-annotate-stage img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; user-select: none; }
.stk-annotate-stage canvas { position: absolute; touch-action: none; cursor: crosshair; }
.stk-annotate-help { color: #fff; opacity: .8; font-size: var(--text-sm); text-align: center; padding: 8px; }
.stk-lightbox { position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,.85); display: flex; flex-direction: column; }
.stk-lightbox-bar { display: flex; gap: 12px; align-items: center; padding: 10px 16px; background: var(--text-primary); color: #fff; }
.stk-lightbox-name { flex: 1; font-size: var(--text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stk-lightbox-close { width: 32px; height: 32px; flex: none; border: 0; background: rgba(255,255,255,.12); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; color: #fff; cursor: pointer; }
.stk-lightbox-close:hover { background: rgba(255,255,255,.28); }
.stk-lightbox-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.stk-lightbox-stage { flex: 1; display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 16px; }
.stk-lightbox-stage img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.stk-btn { padding: 9px 14px; border-radius: var(--radius-md); border: 1px solid var(--color-primary); background: var(--color-primary); color: #fff; font-weight: 600; cursor: pointer; }
.stk-btn.is-ghost { background: transparent; border-color: transparent; }
.config-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.config-list { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 6px; }
.config-list li { display: flex; gap: 8px; align-items: center; }
.config-list li span { flex: 1; }
.config-add { display: flex; gap: 8px; margin-top: 8px; }
.config-add input { flex: 1; }
.notice { padding: 10px 12px; border-radius: var(--radius-md); background: #E3F2FD; color: #1565C0; font-size: var(--text-sm); margin-top: 8px; }
.page-title { margin: 0 0 16px; font-size: 20px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; font-size: var(--text-sm); font-weight: 600; color: var(--text-secondary); }
.field > input { font-weight: 400; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-surface); font-weight: 400; }
.chips input { border: 0; padding: 3px; flex: 1; min-width: 120px; outline: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; border: 0; background: var(--color-primary-light); color: var(--color-primary); border-radius: var(--radius-sm); padding: 3px 8px; font-size: var(--text-sm); font-weight: 600; }
.chip.is-selectable { cursor: pointer; background: var(--bg-app); color: var(--text-secondary); }
.chip.is-selectable[aria-pressed="true"] { background: var(--color-primary); color: #fff; }
.chip-x { border: 0; background: transparent; color: inherit; cursor: pointer; padding: 0 2px; }
.picker { position: relative; }
.search-results { position: absolute; left: 0; right: 0; top: 100%; z-index: 5; list-style: none; margin: 2px 0 0; padding: 4px; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: 0 4px 12px rgba(0, 0, 0, .1); max-height: 260px; overflow-y: auto; }
.search-results button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 6px 8px; border-radius: var(--radius-sm); cursor: pointer; }
.search-results button:hover, .search-results button:focus { background: var(--color-primary-light); outline: none; }
.search-empty { padding: 6px 8px; }
