:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --text: #162033;
    --muted: #64748b;
    --line: #d9e2ef;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --accent: #2563eb;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; }
a { text-decoration: none; }
.app-shell { min-height: 100vh; display: flex; }
.sidebar { width: 260px; background: #102033; color: #fff; padding: 18px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: 0; min-width: 0; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; background: var(--primary); color: white; }
.brand-logo { display: block; height: auto; object-fit: contain; }
.brand-sidebar { flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 18px; }
.brand-sidebar .brand-logo { width: 190px; max-width: 100%; }
.brand-title { color: #dbeafe; font-size: .92rem; line-height: 1.2; white-space: nowrap; }
.auth-brand { flex-direction: column; align-items: flex-start; gap: 10px; }
.auth-logo { width: min(280px, 100%); }
.auth-brand .brand-title { color: var(--text); font-size: 1.02rem; }
.sidebar .nav-link { color: #cbd5e1; border-radius: 8px; padding: 11px 12px; display: flex; gap: 10px; align-items: center; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.main-shell { flex: 1; min-width: 0; }
.topbar { height: 68px; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px; padding: 0 22px; position: sticky; top: 0; z-index: 5; }
.icon-btn { border: 1px solid var(--line); background: #fff; width: 40px; height: 40px; border-radius: 8px; }
.global-search { flex: 1; position: relative; max-width: 720px; }
.global-search i { position: absolute; left: 13px; top: 10px; color: var(--muted); }
.global-search input { padding-left: 38px; }
.user-menu { display: flex; align-items: center; gap: 10px; }
.content { padding: 24px; }
.page-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
h1 { font-size: 1.6rem; margin: 0; font-weight: 800; }
h2 { font-size: 1rem; margin: 0 0 14px; font-weight: 700; }
.panel, .metric-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px; box-shadow: 0 10px 30px rgba(15, 23, 42, .04); }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric-card { color: var(--text); display: block; }
.metric-card span { color: var(--muted); font-size: .9rem; }
.metric-card strong { display: block; margin-top: 8px; font-size: 2rem; }
.auth-body { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #f7fbff 0%, #dfeaf7 100%); }
.auth-shell { width: min(440px, calc(100vw - 28px)); }
.auth-card { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 30px; box-shadow: 0 24px 80px rgba(15, 23, 42, .12); }
.auth-card h1 { margin-bottom: 8px; }
.priority { border-radius: 999px; padding: 4px 9px; font-size: .78rem; font-weight: 700; text-transform: uppercase; }
.priority-baixa { background: #e0f2fe; color: #075985; }
.priority-normal { background: #dcfce7; color: #166534; }
.priority-alta { background: #fef3c7; color: #92400e; }
.priority-urgente { background: #fee2e2; color: #991b1b; }
.priority-critica { background: #111827; color: #fff; }
.status-badge { background: #edf2f7; color: #334155; }
.ticket-layout, .chat-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.ticket-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.message { border-left: 4px solid var(--accent); background: #f8fafc; border-radius: 8px; padding: 14px; margin-bottom: 12px; }
.message.internal { border-left-color: #f59e0b; background: #fffbeb; }
.reply-box { display: grid; gap: 10px; margin-top: 16px; }
.side-panel dl { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; }
.side-panel dt { color: var(--muted); }
.timeline { display: grid; gap: 10px; border-left: 2px solid var(--line); padding-left: 14px; }
.timeline div { position: relative; }
.inbox { display: grid; grid-template-columns: 340px minmax(0,1fr); gap: 16px; }
.conversation-item { display: block; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 10px; }
.conversation-item span, .conversation-item small { display: block; color: var(--muted); }
.chat-stream { min-height: 460px; display: flex; flex-direction: column; gap: 10px; padding: 8px; overflow: auto; }
.chat-bubble { max-width: 75%; padding: 10px 12px; border-radius: 8px; background: #eef2ff; }
.chat-bubble.atendente { margin-left: auto; background: #d1fae5; }
.chat-bubble.interna { margin-inline: auto; background: #fef3c7; }
.chat-bubble.sistema { margin-inline: auto; background: #e5e7eb; }
.chat-bubble small { color: var(--muted); }
.empty-state { min-height: 220px; display: grid; place-items: center; color: var(--muted); text-align: center; }
.rich-editor { min-height: 240px; background: #fff; }
.rich-editor.compact { min-height: 150px; }
.ql-toolbar.ql-snow { border-color: var(--line); border-radius: 8px 8px 0 0; background: #fff; }
.ql-container.ql-snow { border-color: var(--line); border-radius: 0 0 8px 8px; font-size: 1rem; }
.rich-content img, .ql-editor img { max-width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); }
.rich-content p:last-child { margin-bottom: 0; }
.upload-zone { border: 1px dashed #94a3b8; border-radius: 8px; padding: 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: #f8fafc; }
.upload-zone.dragging { border-color: var(--primary); background: #ecfdf5; }
.upload-list { display: grid; gap: 8px; margin-top: 10px; }
.upload-item, .attachment-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; color: var(--text); background: #fff; }
.upload-item span, .attachment-item span { display: grid; }
.upload-item small, .attachment-item small { color: var(--muted); }
.upload-item em { color: var(--muted); font-style: normal; font-size: .85rem; }
.upload-item.done em { color: #166534; }
.upload-item.failed em { color: #991b1b; }
.upload-item button { border: 0; background: transparent; color: #991b1b; font-size: 1.2rem; }
.attachments { margin-top: 16px; display: grid; gap: 8px; }

@media (max-width: 980px) {
    .sidebar { position: fixed; left: -280px; transition: left .2s; z-index: 10; }
    .sidebar.open { left: 0; }
    .metric-grid, .ticket-layout, .chat-layout, .inbox { grid-template-columns: 1fr; }
    .topbar { padding: 0 12px; }
    .user-menu span, .global-search { display: none; }
    .content { padding: 14px; }
}
