:root {
  /* paleta claude.ai */
  --bg-main: #faf9f5;
  --bg-side: #f0eee6;
  --bg-hover: #e8e6dc;
  --bg-active: #e3e0d3;
  --panel: #ffffff;
  --text: #3d3929;
  --text-soft: #53503f;
  --muted: #8a8778;
  --border: #e3e0d5;
  --border-soft: #eceade;
  --accent: #d97757;
  --accent-hover: #c15f3c;
  --user-bubble: #f0eee6;
  --code-bg: #f5f4ef;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --font-mono: 'SF Mono', ui-monospace, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font-ui); background: var(--bg-main); color: var(--text); -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
button { font-family: inherit; }

/* ---------- LOGIN ---------- */
.login-screen { height: 100%; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #f0e9dd 0%, var(--bg-main) 60%); }
.login-card { background: var(--panel); border: 1px solid var(--border); border-radius: 20px; padding: 42px 38px;
  width: 370px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 10px 44px rgba(61,57,41,.08); text-align: center; }
.login-logo { font-size: 36px; color: var(--accent); }
.login-card h1 { font-size: 22px; margin: 0; font-weight: 600; }
.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.login-card input { padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; font-size: 15px; font-family: inherit; outline: none; }
.login-card input:focus { border-color: var(--accent); }
.login-card button { margin-top: 6px; padding: 12px; background: var(--accent); color: #fff; border: none; border-radius: 10px; font-size: 15px; font-weight: 600; cursor: pointer; }
.login-card button:hover { background: var(--accent-hover); }
.login-error { color: #b3261e; font-size: 13px; min-height: 16px; }

/* ---------- LAYOUT ---------- */
.app { display: flex; height: 100%; }
.sidebar { width: 268px; background: var(--bg-side); display: flex; flex-direction: column; flex-shrink: 0; border-right: 1px solid var(--border-soft); }
.side-brand { display: flex; align-items: center; gap: 8px; padding: 18px 18px 10px; }
.side-logo { color: var(--accent); font-size: 20px; }
.side-name { font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.side-name em { font-style: normal; color: var(--muted); font-weight: 500; }
.new-chat { margin: 8px 12px 4px; display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  background: transparent; color: var(--accent-hover); border: none; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer; }
.new-chat:hover { background: var(--bg-hover); }
.side-label { padding: 14px 18px 4px; font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.conversations { flex: 1; overflow-y: auto; padding: 2px 8px; }
.conv { padding: 8px 10px; border-radius: 9px; font-size: 13.5px; color: var(--text-soft); cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.conv:hover { background: var(--bg-hover); }
.conv.active { background: var(--bg-active); color: var(--text); font-weight: 500; }
.conv .del { opacity: 0; color: var(--muted); font-size: 14px; border: none; background: none; cursor: pointer; padding: 0 2px; flex-shrink: 0; }
.conv:hover .del { opacity: 1; }
.conv .del:hover { color: #b3261e; }
.sidebar-foot { border-top: 1px solid var(--border-soft); padding: 10px; }
.user-row { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px; border: none; background: none; border-radius: 10px; cursor: pointer; text-align: left; }
.user-row:hover { background: var(--bg-hover); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; text-transform: uppercase; flex-shrink: 0; }
.user-meta { flex: 1; min-width: 0; }
.user-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-sub { font-size: 11.5px; color: var(--muted); }
.gear { color: var(--muted); font-size: 14px; }

/* ---------- MAIN ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; background: var(--bg-main); }
.topbar { display: flex; align-items: center; gap: 10px; padding: 10px 18px; min-height: 48px; }
.menu-toggle { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; width: 34px; height: 34px; font-size: 15px; cursor: pointer; color: var(--text-soft); }
.topbar-title { flex: 1; text-align: center; font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { width: 34px; }
.chat { flex: 1; overflow-y: auto; padding: 8px 0 24px; }
.chat-inner { max-width: 46rem; margin: 0 auto; padding: 0 24px; }

.empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.empty .big { font-size: 44px; color: var(--accent); }
.empty h2 { font-family: var(--font-serif); font-weight: 500; font-size: 30px; color: var(--text); margin: 0; letter-spacing: -.01em; }

/* mensagens */
.msg { padding: 10px 0; }
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble { background: var(--user-bubble); padding: 12px 16px; border-radius: 16px 16px 4px 16px;
  max-width: 85%; white-space: pre-wrap; word-wrap: break-word; line-height: 1.6; font-size: 15px; }
.msg.assistant { display: flex; gap: 12px; }
.msg.assistant .spark { color: var(--accent); font-size: 17px; line-height: 1.6; flex-shrink: 0; margin-top: 4px; }
.msg.assistant .bubble { font-family: var(--font-serif); font-size: 16.5px; line-height: 1.75; color: var(--text); min-width: 0; flex: 1; }
.msg.assistant .bubble p { margin: 0 0 14px; }
.msg.assistant .bubble p:last-child { margin-bottom: 0; }
.msg.assistant .bubble ul, .msg.assistant .bubble ol { margin: 0 0 14px; padding-left: 24px; }
.msg.assistant .bubble li { margin: 5px 0; }
.msg.assistant .bubble h1, .msg.assistant .bubble h2, .msg.assistant .bubble h3 { font-family: var(--font-ui); margin: 20px 0 10px; line-height: 1.3; letter-spacing: -.01em; }
.msg.assistant .bubble h1 { font-size: 20px; } .msg.assistant .bubble h2 { font-size: 18px; } .msg.assistant .bubble h3 { font-size: 16px; }
.msg.assistant .bubble strong { font-weight: 600; }
.msg.assistant .bubble a { color: var(--accent-hover); }
.msg.assistant .bubble code { background: var(--code-bg); border: 1px solid var(--border-soft); padding: 1px 6px; border-radius: 5px; font-size: 13px; font-family: var(--font-mono); }
.msg.assistant .bubble blockquote { border-left: 3px solid var(--border); margin: 0 0 14px; padding: 2px 0 2px 14px; color: var(--text-soft); }
.msg.assistant .bubble table { border-collapse: collapse; margin: 0 0 14px; font-family: var(--font-ui); font-size: 14px; display: block; overflow-x: auto; }
.msg.assistant .bubble th, .msg.assistant .bubble td { border: 1px solid var(--border); padding: 7px 11px; }
.msg.assistant .bubble th { background: var(--code-bg); }

/* blocos de codigo com header copiar */
.codewrap { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin: 0 0 14px; background: var(--code-bg); }
.codebar { display: flex; align-items: center; justify-content: space-between; padding: 6px 12px; font-family: var(--font-ui); font-size: 12px; color: var(--muted); background: #ecebe3; border-bottom: 1px solid var(--border-soft); }
.codebar button { background: none; border: none; color: var(--muted); font-size: 12px; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.codebar button:hover { color: var(--text); background: var(--bg-hover); }
.codewrap pre { margin: 0; padding: 13px 15px; overflow-x: auto; background: transparent; }
.codewrap pre code { background: none; border: none; padding: 0; font-size: 13px; font-family: var(--font-mono); }
.msg.assistant .bubble > pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 12px; padding: 13px 15px; overflow-x: auto; margin: 0 0 14px; }
.cursor::after { content: '▍'; color: var(--accent); animation: blink 1s steps(2) infinite; font-family: var(--font-ui); }
@keyframes blink { 0%,50% { opacity: 1; } 50.01%,100% { opacity: 0; } }

/* chips de anexo na mensagem */
.msg-atts { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; justify-content: flex-end; }
.att-chip { display: inline-flex; align-items: center; gap: 6px; background: #fff; border: 1px solid var(--border); border-radius: 9px; padding: 5px 10px; font-size: 12.5px; color: var(--text-soft); max-width: 240px; }
.att-chip .ico { color: var(--accent); }
.att-chip span.n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- COMPOSER ---------- */
.composer-wrap { padding: 0 24px 14px; }
.file-chips { max-width: 46rem; margin: 0 auto 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.file-chips .att-chip button { border: none; background: none; color: var(--muted); cursor: pointer; font-size: 13px; padding: 0; }
.file-chips .att-chip button:hover { color: #b3261e; }
.composer { max-width: 46rem; margin: 0 auto; background: var(--panel); border: 1px solid var(--border); border-radius: 22px;
  padding: 10px 10px 10px 8px; display: flex; align-items: flex-end; gap: 6px; box-shadow: 0 4px 22px rgba(61,57,41,.07); }
.composer:focus-within { border-color: #cfccbd; box-shadow: 0 4px 26px rgba(61,57,41,.1); }
.attach { width: 36px; height: 36px; border-radius: 10px; border: none; background: none; color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.attach:hover { background: var(--bg-hover); color: var(--text); }
.composer textarea { flex: 1; border: none; outline: none; resize: none; font-family: var(--font-ui); font-size: 15px; line-height: 1.5; background: none; max-height: 240px; padding: 8px 4px; color: var(--text); }
.send { width: 36px; height: 36px; border-radius: 50%; border: none; background: var(--accent); color: #fff; cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.send:hover { background: var(--accent-hover); }
.send:disabled { background: #d8d5ca; cursor: default; }
.composer-hint { max-width: 46rem; margin: 8px auto 0; text-align: center; font-size: 11.5px; color: var(--muted); }

/* ---------- MODAL / SETTINGS ---------- */
.modal { position: fixed; inset: 0; background: rgba(40,37,26,.4); display: flex; align-items: center; justify-content: center; z-index: 20; }
.modal-card { background: var(--bg-main); border-radius: 18px; width: 680px; max-width: 94vw; max-height: 88vh; overflow-y: auto; padding: 22px 26px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.x { background: none; border: none; font-size: 17px; cursor: pointer; color: var(--muted); }
.x:hover { color: var(--text); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tab { background: none; border: none; padding: 9px 14px; font-size: 13.5px; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent-hover); border-bottom-color: var(--accent); }
.pane { padding: 4px 2px 10px; }
.pane-desc { font-size: 13.5px; color: var(--text-soft); margin: 0 0 14px; line-height: 1.55; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-soft); margin-bottom: 5px; }
.field label .opt { color: var(--muted); font-weight: 400; }
.field input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; font-size: 14px; font-family: inherit; outline: none; background: #fff; }
.field input:focus { border-color: var(--accent); }
.field input:disabled { background: var(--bg-side); color: var(--muted); }
.btn-primary { background: var(--accent); color: #fff; border: none; border-radius: 9px; padding: 10px 16px; font-weight: 600; font-size: 13.5px; cursor: pointer; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { background: #d8d5ca; cursor: default; }
.form-msg { font-size: 13px; min-height: 18px; margin-top: 8px; }
.form-msg.ok { color: #1a7f37; }
.form-msg.err { color: #b3261e; }

/* conectores */
.conn-form { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; }
.conn-form input, .conn-form select { padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; font-size: 13.5px; font-family: inherit; outline: none; background: #fff; }
.conn-form input:focus { border-color: var(--accent); }
.mc-list { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.mc-item { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.mc-ico { width: 34px; height: 34px; border-radius: 9px; background: var(--code-bg); display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; }
.mc-info { flex: 1; min-width: 0; }
.mc-name { font-size: 14px; font-weight: 600; }
.mc-url { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-badge { font-size: 10.5px; padding: 2px 8px; border-radius: 20px; background: #e5f2e8; color: #1a7f37; font-weight: 600; }
.mc-badge.off { background: #eceadf; color: var(--muted); }
.mc-actions { display: flex; gap: 4px; }
.mc-actions button { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 12.5px; padding: 4px 8px; border-radius: 7px; }
.mc-actions button:hover { background: var(--bg-hover); color: var(--text); }
.mc-actions .rm:hover { color: #b3261e; }

/* funcionarios */
.user-form { display: grid; grid-template-columns: 1fr 1fr 1fr auto auto; gap: 8px; margin-bottom: 8px; }
.user-form input, .user-form select { padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; font-size: 13px; outline: none; background: #fff; }
.user-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 14px; }
.user-table th { text-align: left; color: var(--muted); font-weight: 500; padding: 8px 6px; border-bottom: 1px solid var(--border); font-size: 12px; }
.user-table td { padding: 9px 6px; border-bottom: 1px solid var(--border-soft); }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; background: #eceadf; color: #6b6862; }
.badge.admin { background: #f6e2d9; color: var(--accent-hover); }
.row-actions button { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 13px; margin-left: 8px; }
.row-actions button:hover { color: var(--accent); }
.row-actions .rm:hover { color: #b3261e; }

/* conta claude */
.claude-conn { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.conn-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.conn-title { font-size: 14px; font-weight: 600; }
.conn-status { font-size: 13px; margin-top: 2px; }
.conn-status.ok { color: #1a7f37; }
.conn-status.off { color: #b3261e; }
.conn-flow { margin-top: 14px; border-top: 1px dashed var(--border); padding-top: 12px; }
.conn-step { font-size: 13px; color: var(--text-soft); margin: 8px 0 6px; }
.conn-url { display: block; font-size: 12px; word-break: break-all; color: var(--accent-hover); background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.conn-code { display: flex; gap: 8px; margin-top: 6px; }
.conn-code input { flex: 1; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; font-size: 13px; outline: none; }

.modal-foot { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 14px; display: flex; justify-content: flex-end; }
.logout { background: none; border: 1px solid var(--border); border-radius: 9px; padding: 8px 14px; color: #b3261e; font-size: 13px; cursor: pointer; }
.logout:hover { background: #fbeae9; border-color: #edccc9; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 820px) {
  .sidebar { position: fixed; z-index: 10; height: 100%; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: 2px 0 24px rgba(0,0,0,.12); }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: block; }
  .user-form, .conn-form { grid-template-columns: 1fr 1fr; }
  .msg.assistant .bubble { font-size: 16px; }
}
