/* ⟁ XARVIS — HUD (r1). Estética fiel aos designs: fundo quase-preto azulado,
   orbe de plasma teal com anéis, tipografia monoespaçada, rótulos em caixa alta. */

:root {
  --bg:      #06090c;
  --bg2:     #0a1016;
  --panel:   rgba(20, 34, 38, 0.45);
  --line:    rgba(53, 224, 208, 0.14);
  --teal:    #35e0d0;
  --teal-soft: #7af0e4;
  --teal-dim: #1c6f68;
  --amber:   #f0a818;
  --red:     #ff5a6e;
  --violet:  #8b7bff;
  --muted:   #6b7a83;
  --text:    #cfe9e6;
  --mono:    'JetBrains Mono', 'Roboto Mono', Consolas, monospace;
  --hud:     'Share Tech Mono', var(--mono);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background:
    radial-gradient(120% 80% at 50% -10%, #0b1620 0%, var(--bg) 55%, #04060a 100%);
  color: var(--text);
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

#app {
  max-width: 720px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 18px 18px 28px;
}

/* ── Header ─────────────────────────────────────────────────────────── */
.hud-header {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--hud);
  letter-spacing: 2px;
  padding: 4px 2px 18px;
}
.hud-header .logo { color: var(--teal); font-size: 22px; text-shadow: 0 0 12px var(--teal-dim); }
.hud-header .wordmark { font-size: 22px; letter-spacing: 8px; color: #dfeeec; }
.hud-header .ver { color: var(--muted); font-size: 12px; letter-spacing: 1px; }
.hud-header .chip {
  margin-left: auto;
  font-size: 12px; color: var(--teal-soft);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 4px 10px; background: rgba(53,224,208,0.05);
}
.hud-header .link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; letter-spacing: 2px; color: var(--teal);
}
.hud-header .link .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--teal); box-shadow: 0 0 8px var(--teal);
}
.hud-header .link.off { color: var(--muted); }
.hud-header .link.off .dot { background: var(--muted); box-shadow: none; }

/* ── Stage / Orbe ───────────────────────────────────────────────────── */
.stage { flex: 1; display: flex; flex-direction: column; align-items: center; }

.orb {
  position: relative;
  width: 300px; height: 300px;
  margin: 18px 0 6px;
  display: grid; place-items: center;
  --c: var(--teal);
}
.orb .ring {
  position: absolute; border-radius: 50%;
  border: 1px solid transparent;
  animation: spin linear infinite;
}
.orb .ring1 { inset: 0;     border-top-color: var(--c); border-right-color: var(--c); opacity: .55; animation-duration: 14s; filter: drop-shadow(0 0 6px var(--c)); }
.orb .ring2 { inset: 34px;  border-bottom-color: var(--c); border-left-color: var(--c); opacity: .8; animation-duration: 9s; animation-direction: reverse; filter: drop-shadow(0 0 6px var(--c)); }
.orb .ring3 { inset: 64px;  border-top-color: var(--c); opacity: .35; animation-duration: 22s; }
@keyframes spin { to { transform: rotate(360deg); } }

.orb .core {
  position: relative;
  width: 150px; height: 150px; border-radius: 50%;
  background:
    radial-gradient(38% 34% at 42% 34%, #d8fff8 0%, var(--c) 26%, #0e8d83 64%, #073f3b 100%);
  box-shadow:
    0 0 50px 8px color-mix(in srgb, var(--c) 55%, transparent),
    inset -10px -14px 30px rgba(0,0,0,0.45),
    inset 8px 10px 26px rgba(255,255,255,0.25);
  animation: breathe 4.5s ease-in-out infinite;
}
@keyframes breathe {
  0%,100% { transform: scale(1);    filter: brightness(1); }
  50%     { transform: scale(1.04); filter: brightness(1.12); }
}
.orb .core-label {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 12px; letter-spacing: 1px; color: #eafffb; text-shadow: 0 0 6px #000;
  padding: 0 8px; text-align: center; word-break: break-all;
}

/* Estados → cor do orbe */
.orb.idle      { --c: var(--teal); }
.orb.listening { --c: #46f3df; }
.orb.thinking  { --c: #8fb6c6; }   /* aço */
.orb.speaking  { --c: var(--amber); }
.orb.error     { --c: var(--red); animation: glitch .35s steps(2) 2; }
@keyframes glitch {
  0% { transform: translate(0,0); }
  25% { transform: translate(-3px,1px); filter: hue-rotate(20deg); }
  50% { transform: translate(3px,-1px); }
  75% { transform: translate(-2px,-1px); filter: hue-rotate(-20deg); }
}

/* ── Texto de estado / transcrição / resposta ──────────────────────── */
.state {
  font-family: var(--hud); letter-spacing: 7px; font-size: 17px;
  color: var(--teal); margin: 6px 0 4px; text-shadow: 0 0 10px var(--teal-dim);
}
.transcript { color: var(--teal-soft); opacity: .9; min-height: 22px; text-align: center; font-size: 15px; }
.transcript:not(:empty)::before { content: "› "; color: var(--teal); }
.reply {
  color: var(--text); margin: 12px 0; max-width: 640px; width: 100%; min-width: 0;
  line-height: 1.55; text-align: center; white-space: pre-wrap; min-height: 12px;
}
/* Tabelas rolam na horizontal quando largas — nunca cortam no mobile. */
.reply .md-wrap { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 10px auto; }
.reply table.md {
  border-collapse: collapse; margin: 0; font-size: 13px;
  white-space: nowrap; text-align: left;
}
.reply table.md th, .reply table.md td { border: 1px solid var(--line); padding: 5px 11px; }
.reply table.md th { color: var(--teal); background: rgba(53, 224, 208, 0.07); letter-spacing: .5px; }
.reply table.md tr:nth-child(even) td { background: rgba(255, 255, 255, 0.02); }
.reply table.md strong { color: var(--teal); font-weight: 600; }
@media (max-width: 560px) {
  .reply table.md { font-size: 11.5px; }
  .reply table.md th, .reply table.md td { padding: 4px 7px; }
}
.reply table.md td.num { text-align: right; font-variant-numeric: tabular-nums; }
.reply table.md tr.total td { background: rgba(53, 224, 208, .08); font-weight: 600; }

/* Card de aniversariantes — lista (dia · nome/empresa · idade) no tema do HUD */
.aniv-card { padding: 14px 14px 6px; }
.aniv-head { color: var(--teal); font-weight: 600; letter-spacing: .5px; margin-bottom: 6px; font-size: 14px; }
.aniv-row { display: flex; align-items: center; gap: 12px; padding: 9px 2px; border-top: 1px solid var(--line); }
.aniv-row:first-of-type { border-top: none; }
.aniv-day { flex: 0 0 38px; height: 38px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; background: rgba(53, 224, 208, .1); color: var(--teal); font-weight: 700; font-size: 14px; }
.aniv-info { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; text-align: left; }
.aniv-info b { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aniv-info small { color: var(--teal-soft); opacity: .7; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aniv-age { flex: 0 0 auto; color: var(--teal-soft); opacity: .85; font-size: 12.5px; white-space: nowrap; }
.aniv-age b { color: var(--teal); font-weight: 700; }

/* Guardião do aparelho — barra de status do celular (bateria/rede/armazenamento/local) */
.device-bar { position: fixed; top: 3px; left: 50%; transform: translateX(-50%); z-index: 40;
  display: flex; gap: 6px; pointer-events: none; max-width: 100vw; flex-wrap: wrap; justify-content: center; }
.device-bar span { background: rgba(8, 14, 18, 0.72); border: 1px solid var(--line);
  border-radius: 10px; padding: 2px 7px; color: var(--teal-soft); opacity: .88;
  font: 600 10.5px/1.4 ui-monospace, monospace; white-space: nowrap; }

/* Card do Painel de Sementes — KPIs visuais (estilo dashboard, tema escuro) */
.sem-card { padding: 14px; }
.sem-head { color: var(--teal); font-weight: 600; letter-spacing: .5px; margin-bottom: 10px; font-size: 13.5px; }
.sem-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sem-kpi { background: rgba(8, 14, 18, 0.5); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sem-kpi.wide { grid-column: 1 / -1; }
.sem-lbl { font: 600 9.5px/1.2 ui-monospace, monospace; letter-spacing: .6px; text-transform: uppercase;
  color: var(--teal-soft); opacity: .7; }
.sem-big { font: 700 23px/1.1 var(--mono); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sem-big.blue { color: #5b8cff; } .sem-big.green { color: #3ce07a; } .sem-big.red { color: #ff5a6e; }
.sem-big.teal { color: var(--teal); font-size: 18px; }
.sem-sub { font: 500 10.5px/1.3 ui-monospace, monospace; color: var(--teal-soft); opacity: .65;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sem-bar { height: 6px; background: rgba(255, 255, 255, .08); border-radius: 4px; overflow: hidden; margin: 3px 0; }
.sem-bar i { display: block; height: 100%; background: linear-gradient(90deg, #2e9e5b, #3ce07a); border-radius: 4px; }

/* Card Top Fabricantes — barras agrupadas (Meta/Liberado/Vendido/Comprado) */
.forn-card { padding: 14px 12px; }
.forn-head { color: var(--teal); font-weight: 600; font-size: 12.5px; margin-bottom: 10px;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.forn-tabs { display: flex; gap: 4px; }
.forn-tab { background: rgba(8, 14, 18, .6); border: 1px solid var(--line); color: var(--teal-soft);
  border-radius: 8px; padding: 3px 10px; font: 600 11px ui-monospace, monospace; cursor: pointer; }
.forn-tab.on { background: var(--teal); color: #05221f; border-color: var(--teal); }
.forn-chart { display: flex; gap: 10px; align-items: flex-end; height: 170px; overflow-x: auto;
  padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
.forn-group { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; height: 100%; width: 48px; }
.forn-bars { flex: 1; display: flex; align-items: flex-end; gap: 2px; width: 100%; }
.forn-bar { flex: 1; min-height: 2px; border-radius: 2px 2px 0 0; transition: height .25s ease; }
.forn-fab { margin-top: 5px; font: 600 8.5px/1.1 ui-monospace, monospace; color: var(--teal-soft);
  opacity: .8; text-align: center; white-space: nowrap; }
.forn-legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 9px; justify-content: center; }
.forn-leg { display: flex; align-items: center; gap: 5px; font: 500 10px ui-monospace, monospace;
  color: var(--teal-soft); opacity: .82; }
.forn-leg i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* Sinalização de mudança BRUSCA (Guardião) — banner no topo + pulso vermelho na tela */
.alert-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: linear-gradient(90deg, #6e0f1e, #c0223a, #6e0f1e); color: #fff;
  text-align: center; font: 700 12.5px/1.3 ui-monospace, monospace; letter-spacing: .4px;
  padding: 11px 12px; transform: translateY(-110%); transition: transform .32s ease;
  box-shadow: 0 4px 22px rgba(192, 34, 58, .55); }
.alert-banner.show { transform: translateY(0); }
body.alert-flash::after { content: ""; position: fixed; inset: 0; z-index: 90; pointer-events: none;
  animation: alertPulse .7s ease-in-out 4; }
@keyframes alertPulse { 0%, 100% { box-shadow: inset 0 0 0 rgba(255, 60, 90, 0); }
  50% { box-shadow: inset 0 0 150px rgba(255, 60, 90, .42); } }
/* "Achar meu celular" tocando → pulso teal */
body.ringing::after { content: ""; position: fixed; inset: 0; z-index: 88; pointer-events: none;
  animation: ringPulse .65s ease-in-out infinite; }
@keyframes ringPulse { 0%, 100% { box-shadow: inset 0 0 0 rgba(53, 224, 208, 0); }
  50% { box-shadow: inset 0 0 120px rgba(53, 224, 208, .3); } }
.cards { width: 100%; min-width: 0; display: flex; flex-direction: column; gap: 12px; margin-top: 6px; }

/* ── Cards de dados ─────────────────────────────────────────────────── */
.card {
  border: 1px solid var(--line); border-radius: 10px;
  background: linear-gradient(180deg, var(--panel), rgba(8,14,18,0.5));
  padding: 14px 16px; backdrop-filter: blur(3px);
}
.card .card-title { font-family: var(--hud); letter-spacing: 1px; color: #dff; margin-bottom: 10px; font-size: 15px; }
.card .kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; }
.card .kpi .k-label { font-size: 11px; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }
.card .kpi .k-value { font-size: 26px; color: var(--teal); }
.card .kpi.alert .k-value { color: var(--red); }
.card .kpi .k-sub { font-size: 11px; color: var(--muted); }

/* ── Controles ──────────────────────────────────────────────────────── */
.controls { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 14px; }
.mic {
  width: 66px; height: 66px; border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, rgba(53,224,208,0.16), rgba(10,20,24,0.6));
  border: 1px solid var(--line); color: var(--teal);
  display: grid; place-items: center; cursor: pointer;
  transition: transform .15s, box-shadow .2s;
}
.mic:hover { box-shadow: 0 0 22px var(--teal-dim); }
.mic.live { transform: scale(1.12); box-shadow: 0 0 30px var(--teal); border-color: var(--teal); }
.mic-hint { font-size: 12px; letter-spacing: 3px; color: var(--muted); text-transform: uppercase; }

.input-row { display: flex; align-items: center; gap: 8px; width: 100%; max-width: 620px; margin-top: 6px; }
.input-row input {
  flex: 1; background: rgba(8,14,18,0.6); border: 1px solid var(--line);
  border-radius: 10px; color: var(--text); font-family: var(--mono);
  font-size: 16px; padding: 13px 14px; outline: none;
}
.input-row input::placeholder { color: #44525a; }
.input-row input:focus { border-color: var(--teal-dim); box-shadow: 0 0 0 1px var(--teal-dim); }
.icon-btn {
  background: rgba(8,14,18,0.6); border: 1px solid var(--line); border-radius: 10px;
  color: var(--muted); width: 46px; height: 46px; font-size: 16px; cursor: pointer;
}
.icon-btn.send { color: var(--teal); }
.icon-btn:hover { border-color: var(--teal-dim); }

.attach-preview {
  display: flex; align-items: center; gap: 10px; width: 100%; max-width: 620px;
  margin: 8px 0 2px; padding: 6px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: rgba(8, 14, 18, 0.6);
}
.attach-preview img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; }
.attach-preview span { flex: 1; color: var(--teal-soft); font-size: 13px; }
.attach-preview button { background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 15px; }
.attach-preview button:hover { color: var(--red); }

.stop {
  margin-top: 6px; background: transparent; border: 1px solid var(--amber);
  color: var(--amber); border-radius: 8px; padding: 8px 18px; cursor: pointer;
  font-family: var(--mono); letter-spacing: 1px; opacity: .55; transition: opacity .2s;
}
.stop.active { opacity: 1; box-shadow: 0 0 16px rgba(240,168,24,0.3); }

.footer { display: flex; flex-wrap: wrap; gap: 18px; justify-content: center; margin-top: 14px; }
.footer .flink { color: var(--muted); font-size: 13px; letter-spacing: 1px; cursor: pointer; }
.footer .flink:hover { color: var(--teal); }
.footer .flink.muted { cursor: default; opacity: .6; }

/* ── Toast de atividade MCP (canto inferior esquerdo, violeta) ──────── */
.mcp-toast {
  position: fixed; left: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 6px;
  pointer-events: none; z-index: 50;
}
.mcp-toast .t {
  border-left: 2px solid var(--violet);
  background: rgba(18,16,34,0.8); color: #cfc8ff;
  font-size: 12px; letter-spacing: .5px; padding: 6px 10px; border-radius: 4px;
  animation: toastin .2s ease;
}
.mcp-toast .t .ok { color: var(--teal); float: right; margin-left: 14px; }
.mcp-toast .t .err { color: var(--red); float: right; margin-left: 14px; }
@keyframes toastin { from { opacity: 0; transform: translateY(6px); } }

/* ── Navegação embutida (rota + mapa Leaflet) ─────────────────────────── */
.rota-card { padding: 10px; }
.rota-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  margin-bottom: 8px; flex-wrap: wrap;
}
.rota-dest { color: var(--teal); font-weight: 600; letter-spacing: .3px; }
.rota-meta { color: #9fb0ba; font-size: 12px; white-space: nowrap; }
.rota-map {
  width: 100%; height: 260px; border-radius: 8px; overflow: hidden;
  border: 1px solid rgba(60,224,122,0.25); background: #0a1014;
}
.rota-map .leaflet-container { background: #0a1014; }
.rota-nomap { display: flex; align-items: center; justify-content: center; height: 100%; color: #7f8f99; font-size: 13px; }
.rota-btns { display: flex; gap: 8px; margin-top: 9px; flex-wrap: wrap; }
.rota-btn {
  flex: 1 1 30%; min-width: 96px; text-align: center; cursor: pointer;
  padding: 9px 8px; border-radius: 7px; font-size: 13px; font-weight: 600;
  text-decoration: none; border: 1px solid transparent; letter-spacing: .3px;
  font-family: inherit;
}
.rota-btn.waze { background: #33ccff; color: #04121a; }
.rota-btn.maps { background: rgba(60,224,122,0.16); color: var(--teal); border-color: rgba(60,224,122,0.4); }
.rota-btn.gps  { background: rgba(240,168,24,0.14); color: #f0a818; border-color: rgba(240,168,24,0.4); }
.rota-btn:active { transform: translateY(1px); }

/* ── Marcha da Colheita (medidor + KPIs + tabela por talhão · estilo GNS) ── */
.marcha-card { padding: 12px; }
.marcha-grupo + .marcha-grupo { margin-top: 16px; border-top: 1px solid rgba(60,224,122,0.15); padding-top: 14px; }
.marcha-head { color: var(--teal); font-weight: 600; letter-spacing: .3px; margin-bottom: 8px; }
.marcha-top { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.marcha-gauge { width: 132px; height: 76px; flex: 0 0 auto; }
.marcha-gauge .g-bg { fill: none; stroke: rgba(120,140,150,0.25); stroke-width: 9; stroke-linecap: round; }
.marcha-gauge .g-fg { fill: none; stroke: #3ce07a; stroke-width: 9; stroke-linecap: round; }
.marcha-gauge .g-txt { fill: #eaf6ef; font: 700 20px/1 "JetBrains Mono", monospace; }
.marcha-kpis { display: grid; grid-template-columns: repeat(2, minmax(84px, 1fr)); gap: 8px 18px; flex: 1 1 auto; }
.marcha-kpi { display: flex; flex-direction: column; }
.marcha-kpi .mk-v { color: #eaf6ef; font-weight: 600; font-size: 15px; }
.marcha-kpi .mk-l { color: #9fb0ba; font-size: 11px; letter-spacing: .4px; text-transform: uppercase; }
.marcha-tblwrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.marcha-tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; white-space: nowrap; }
.marcha-tbl th { text-align: left; color: #9fb0ba; font-weight: 600; padding: 6px 8px; border-bottom: 1px solid rgba(120,140,150,0.25); position: sticky; top: 0; }
.marcha-tbl td { padding: 5px 8px; border-bottom: 1px solid rgba(120,140,150,0.1); color: #dfe8ec; }
.marcha-tbl td.num { text-align: right; font-variant-numeric: tabular-nums; }
.marcha-sit { padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.marcha-sit.ok { background: rgba(60,224,122,0.16); color: #3ce07a; }
.marcha-sit.warn { background: rgba(240,168,24,0.16); color: #f0a818; }
.marcha-sit.idle { background: rgba(159,176,186,0.14); color: #9fb0ba; }

/* ── Card de download (.md pro Claude, etc.) ─────────────────────────── */
.dl-card { padding: 14px; text-align: center; }
.dl-title { color: var(--teal); font-weight: 600; letter-spacing: .3px; margin-bottom: 10px; }
.dl-btn {
  display: inline-block; padding: 11px 20px; border-radius: 8px; font-weight: 600;
  text-decoration: none; background: rgba(60,224,122,0.16); color: var(--teal);
  border: 1px solid rgba(60,224,122,0.45); font-size: 14px; cursor: pointer;
}
.dl-btn:active { transform: translateY(1px); }
.dl-path { margin-top: 8px; color: #7f8f99; font-size: 11px; font-family: "JetBrains Mono", monospace; }
