/* MaissGraph — BASE (tokens + componentes compartilhados). GE-0001 / TASK-0001.10
   Layout mora em desktop.css (>=768px) e mobile.css (<768px). */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #4F46E5;
  --primary-dark: #4338CA;
  --ai: #5747E8;
  --bg: #F4F6FA;
  --surface: #FFFFFF;
  --text: #101828;
  --text-2: #344054;
  --muted: #667085;
  --border: #EAECF0;
  --border-2: #E4E7EC;
  --success: #22C55E;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #1D4ED8;
  --primary-050: #EEF0FE;
  /* degradê dos gráficos: vermelho -> laranja -> amarelo -> azul */
  --grad-red: #EF4444;
  --grad-orange: #F97316;
  --grad-yellow: #FACC15;
  --grad-blue: #3B82F6;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .10);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .07);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .10);
  --sidebar-w: 250px;
  --chat-w: 384px;
  --mtop-h: 58px;
  --mnav-h: 62px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
svg { display: block; }
button { font-family: inherit; cursor: pointer; }

.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 34px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--ai) 100%);
  color: #fff; font-weight: 800; font-size: 18px; display: grid; place-items: center;
  box-shadow: 0 4px 10px rgba(79, 70, 229, .35);
}

/* login */
.overlay { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 20% -10%, #E7E9FE 0%, var(--bg) 55%); padding: 1rem; }
.login-card { background: var(--surface); width: min(94vw, 400px); padding: 2.4rem 2.2rem;
  border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-lg); text-align: center; }
.login-card .brand-mark { width: 48px; height: 48px; flex: none; margin: 0 auto .9rem; font-size: 24px; border-radius: 12px; }
.login-card h1 { font-size: 1.7rem; font-weight: 800; letter-spacing: -.5px; }
.login-card h1 span, .side-brand b { color: var(--primary); }
.login-card p { color: var(--muted); margin: .35rem 0 1.6rem; }
.login-card label { display: block; text-align: left; font-weight: 600; font-size: .82rem; color: var(--text-2); margin-bottom: .35rem; }
.login-card input { width: 100%; padding: .75rem .85rem; border-radius: var(--radius-xs); border: 1px solid var(--border-2);
  background: #fff; color: var(--text); font-size: 1rem; margin-bottom: 1.1rem; transition: border-color .15s, box-shadow .15s; }
.login-card input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-050); }
.btn-primary { width: 100%; padding: .8rem; border: 0; border-radius: var(--radius-xs); background: var(--primary);
  color: #fff; font-weight: 700; font-size: 1rem; transition: background .15s, transform .05s; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: translateY(1px); }
.erro { color: var(--danger); font-size: .84rem; margin-top: .7rem; min-height: 1.2em; }

/* marca / nav (visual) */
.side-brand { display: flex; align-items: center; gap: .6rem; font-size: 1.15rem; font-weight: 800; letter-spacing: -.3px; }
.nav-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: .8rem .7rem .3rem; }
.nav-item { display: flex; align-items: center; gap: .7rem; padding: .68rem .7rem; border-radius: var(--radius-xs);
  color: var(--text-2); font-weight: 500; font-size: .92rem; text-decoration: none; border: 0; background: none;
  width: 100%; text-align: left; transition: background .12s, color .12s; }
.nav-item svg { width: 19px; height: 19px; stroke: currentColor; opacity: .85; }
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--primary-050); color: var(--primary); font-weight: 600; }
.nav-item.active svg { opacity: 1; }
.side-status { display: block; font-size: .76rem; color: var(--muted); padding: .1rem .6rem .6rem; line-height: 1.6; }
.side-status .on, .m-status .on { color: var(--success); font-weight: 600; }
.side-status .off, .m-status .off { color: var(--danger); font-weight: 600; }
.side-status .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.dot.on { background: var(--success); box-shadow: 0 0 0 3px rgba(34,197,94,.15); }
.dot.off { background: var(--danger); box-shadow: 0 0 0 3px rgba(239,68,68,.15); }
.btn-ghost { display: flex; align-items: center; gap: .55rem; width: 100%; padding: .6rem .7rem; border: 0; background: none;
  border-radius: var(--radius-xs); color: var(--text-2); font-size: .9rem; font-weight: 500; }
.btn-ghost svg { width: 18px; height: 18px; stroke: currentColor; }
.btn-ghost:hover { background: var(--bg); color: var(--danger); }

.topbar h2 { font-size: 1.25rem; font-weight: 700; letter-spacing: -.3px; }
.topbar p { color: var(--muted); font-size: .84rem; margin-top: 1px; }
.btn-soft { display: inline-flex; align-items: center; gap: .45rem; padding: .55rem .9rem; border: 1px solid var(--border-2);
  background: var(--surface); border-radius: var(--radius-xs); color: var(--text-2); font-weight: 600; font-size: .84rem;
  transition: background .12s, border-color .12s; }
.btn-soft svg { width: 16px; height: 16px; stroke: currentColor; }
.btn-soft:hover { background: var(--bg); border-color: var(--primary); color: var(--primary); }

/* KPIs */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; box-shadow: var(--shadow); display: flex; align-items: center; gap: .9rem; }
.stat .ico { width: 44px; height: 44px; border-radius: 12px; flex: none; display: grid; place-items: center; }
.stat .ico svg { width: 22px; height: 22px; }
.stat .ico.indigo { background: var(--primary-050); color: var(--primary); }
.stat .ico.green { background: #E9F9EF; color: var(--success); }
.stat .ico.amber { background: #FEF4E6; color: var(--warning); }
.stat .ico.blue { background: #E7EEFE; color: var(--info); }
.stat .val { font-size: 1.5rem; font-weight: 800; letter-spacing: -.5px; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: .8rem; font-weight: 500; margin-top: 2px; }

/* cards de gráfico */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.2rem 1.2rem; box-shadow: var(--shadow); transition: box-shadow .15s;
  display: flex; flex-direction: column; }
.card:hover { box-shadow: var(--shadow-md); }
.card h3 { display: flex; align-items: flex-start; justify-content: space-between; gap: .6rem;
  font-size: .95rem; font-weight: 600; color: var(--text); margin-bottom: 1rem; }
.card h3 > span:first-child { line-height: 1.35; }
.card h3 > span:last-child { display: inline-flex; align-items: center; gap: .5rem; flex: none; }
.card h3 small { color: var(--text-2); font-weight: 500; font-size: .68rem; background: var(--bg);
  border: 1px solid var(--border-2); padding: .18rem .5rem; border-radius: 999px; white-space: nowrap; }
.card .del { background: none; border: 0; color: var(--muted); font-size: .95rem; line-height: 1; padding: 2px 4px; border-radius: 6px; }
.card .del:hover { background: #FDECEC; color: var(--danger); }
.card .canvas-wrap { position: relative; flex: 1; min-height: 0; width: 100%; }
.card .canvas-wrap canvas { position: absolute; inset: 0; }
.card.err { border-color: #FBD5D5; background: #FEF3F2; color: var(--danger); font-size: .85rem; }
.vazio { text-align: center; color: var(--muted); padding: 3rem 1rem; border: 1px dashed var(--border-2);
  border-radius: var(--radius); background: var(--surface); }
.vazio em { color: var(--primary); font-style: normal; font-weight: 600; }

/* chat */
.chat-head { padding: 1.05rem 1.2rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .6rem; }
.chat-head .ai-mark { width: 32px; height: 32px; border-radius: 9px; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--ai), var(--primary)); color: #fff; }
.chat-head .ai-mark svg { width: 18px; height: 18px; stroke: #fff; }
.chat-head b { font-size: .95rem; font-weight: 700; display: block; }
.chat-head small { color: var(--muted); font-size: .74rem; }
.chat-head .chat-close { margin-left: auto; background: none; border: 0; color: var(--muted); width: 34px; height: 34px;
  border-radius: 8px; display: grid; place-items: center; }
.chat-head .chat-close svg { width: 20px; height: 20px; stroke: currentColor; }
.chat-head .chat-close:hover { background: var(--bg); color: var(--text); }
#messages { flex: 1; overflow-y: auto; padding: 1.1rem; display: flex; flex-direction: column; gap: .6rem; }
.chat-hint { color: var(--muted); font-size: .84rem; text-align: center; margin: auto 1rem; line-height: 1.6; }
.chat-hint span { color: var(--primary); font-weight: 600; }
.msg { max-width: 90%; padding: .6rem .85rem; border-radius: 14px; white-space: pre-wrap; font-size: .9rem; line-height: 1.5; }
.msg.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 5px; }
.msg.bot { align-self: flex-start; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.msg.pensando { color: var(--muted); font-style: italic; background: none; border: 0; }
#chat-form { display: flex; gap: .45rem; padding: .8rem; border-top: 1px solid var(--border); align-items: center; }
#chat-form input { flex: 1; min-width: 0; padding: .7rem .9rem; border-radius: 999px; border: 1px solid var(--border-2);
  background: var(--bg); color: var(--text); font-size: .95rem; transition: border-color .15s, box-shadow .15s; }
#chat-form input:focus { outline: none; background: #fff; border-color: var(--ai); box-shadow: 0 0 0 4px rgba(87,71,232,.12); }
#chat-form button { border: 0; border-radius: 50%; width: 44px; height: 44px; flex: none; display: grid; place-items: center; }
#chat-form button svg { width: 19px; height: 19px; }
#mic { background: var(--bg); border: 1px solid var(--border-2) !important; color: var(--text-2); }
#mic svg { stroke: currentColor; }
#mic:hover { background: var(--primary-050); color: var(--primary); }
#mic.gravando { background: var(--danger); border-color: var(--danger) !important; color: #fff; animation: pulse 1s infinite; }
#mic.gravando svg { stroke: #fff; }
@keyframes pulse { 50% { opacity: .55; } }
#send { background: var(--primary); color: #fff; }
#send svg { stroke: #fff; fill: none; }
#send:hover { background: var(--primary-dark); }
.tts { font-size: .78rem; color: var(--muted); padding: 0 1.1rem .85rem; display: flex; align-items: center; gap: .4rem; }
.tts input { accent-color: var(--primary); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #D0D5DD; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

.backdrop { position: fixed; inset: 0; background: rgba(16,24,40,.45); z-index: 44; opacity: 0; pointer-events: none; transition: opacity .2s; }
.backdrop.show { opacity: 1; pointer-events: auto; }
