/* ===== Arquivamento SAP — tema dark neumórfico (Inove) ===== */
:root {
  --bg: #14172a;
  --surface: #1b1f38;
  --surface-2: #161a30;
  --ink: #e8ebf7;
  --ink-soft: #9aa2be;
  --ink-faint: #6b7295;
  --line: rgba(255,255,255,.07);
  --sidebar: #10121f;
  --sidebar-2: #1e2340;
  --brand: #22d3ee;    /* ciano */
  --brand-2: #ec4899;  /* magenta */
  --ok: #2dd4bf;
  --warn: #fbbf24;
  --bad: #fb7185;
  --radius: 20px;
  --shadow: 9px 9px 24px rgba(0,0,0,.55), -6px -6px 18px rgba(255,255,255,.022);
  --shadow-soft: 6px 6px 16px rgba(0,0,0,.42), -4px -4px 12px rgba(255,255,255,.018);
  --glow-c: 0 0 18px rgba(34,211,238,.45);
  --glow-m: 0 0 18px rgba(236,72,153,.45);
  --heading: #ffffff;
  --track: rgba(255,255,255,.08);
  --app-bg: radial-gradient(1200px 700px at 15% -15%, #1d2440, #14172a) fixed;
  --card-tint: var(--card-tint);
}
/* ---- Tema CLARO ---- */
:root[data-theme="light"] {
  --bg: #eef1f7;
  --surface: #ffffff;
  --surface-2: #f4f6fb;
  --ink: #0f172a;
  --ink-soft: #475569;
  --ink-faint: #8b93a7;
  --line: #e5e8f0;
  --brand: #0891b2;    /* ciano mais escuro p/ contraste no claro */
  --brand-2: #db2777;
  --shadow: 0 10px 30px -12px rgba(15,23,42,.18);
  --shadow-soft: 0 4px 16px -8px rgba(15,23,42,.14);
  --glow-c: 0 4px 14px -4px rgba(8,145,178,.45);
  --glow-m: 0 4px 14px -4px rgba(219,39,119,.4);
  --heading: #0f172a;
  --track: #eef0f7;
  --app-bg: #eef1f7;
  --card-tint: #f6f8fc;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--app-bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.app { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: linear-gradient(180deg, var(--sidebar) 0%, #0a0c16 100%);
  color: #c3cae0;
  padding: 22px 16px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 6px;
  border-right: 1px solid rgba(255,255,255,.05);
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 18px; }
.brand .logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid; place-items: center; color: #0b1020; font-weight: 800; font-size: 18px;
  box-shadow: var(--glow-c);
}
.brand .logo-img { height: 34px; width: auto; max-width: 120px; display: block; filter: drop-shadow(0 0 10px rgba(34,211,238,.25)); }
.brand h1 { font-size: 15px; margin: 0; color: #ffffff; line-height: 1.15; }
.brand small { color: var(--ink-faint); font-size: 11px; }

.nav-label { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: #5b6488; padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px; cursor: pointer;
  font-size: 13.5px; font-weight: 500; color: #aeb7d2;
  transition: background .15s, color .15s, box-shadow .15s; user-select: none;
}
.nav-item:hover { background: var(--sidebar-2); color: var(--heading); }
.nav-item.active { background: linear-gradient(135deg, rgba(34,211,238,.18), rgba(236,72,153,.15)); color: var(--heading); box-shadow: inset 0 0 0 1px rgba(34,211,238,.18); }
.nav-item .badge {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  font-size: 15px; flex: 0 0 auto;
}
.badge.b1 { background: rgba(34,211,238,.16); }
.badge.b2 { background: rgba(236,72,153,.16); }
.badge.b3 { background: rgba(251,191,36,.16); }
.badge.b4 { background: rgba(45,212,191,.16); }
.sidebar-foot { font-size: 11px; color: #5b6488; padding: 12px 10px 0; border-top: 1px solid rgba(255,255,255,.06); }

/* seletor de tema (fica no sidebar, sempre escuro) */
.theme-switch { margin-top: auto; display: flex; gap: 6px; padding: 8px 10px 4px; }
.theme-switch button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); color: #aeb7d2; border-radius: 9px; padding: 7px; font-size: 12.5px; font-weight: 600; cursor: pointer; transition: all .15s; font-family: inherit; }
.theme-switch button:hover { color: #fff; }
.theme-switch button.on { background: linear-gradient(135deg, rgba(34,211,238,.25), rgba(236,72,153,.2)); color: #fff; border-color: rgba(34,211,238,.35); }

/* ---------- Main ---------- */
.main { padding: 28px 34px 60px; max-width: 1500px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 24px; letter-spacing: -.02em; color: var(--heading); }
.page-head p { margin: 4px 0 0; color: var(--ink-soft); font-size: 13.5px; }
.pill { font-size: 12px; padding: 6px 12px; border-radius: 999px; background: var(--track); color: var(--ink-soft); font-weight: 600; border: 1px solid var(--line); }

/* KPI cards */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi { background: var(--surface); border-radius: var(--radius); padding: 18px 18px 16px; box-shadow: var(--shadow-soft); border: 1px solid var(--line); }
.kpi .ic { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; font-size: 20px; margin-bottom: 12px; }
.kpi .val { font-size: 26px; font-weight: 800; letter-spacing: -.02em; color: var(--heading); }
.kpi .lbl { color: var(--ink-soft); font-size: 12.5px; margin-top: 2px; }
.kpi .sub { font-size: 11.5px; margin-top: 8px; font-weight: 600; }

/* Resumo executivo — cartões grandes */
.hero-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.hero-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 20px 20px; box-shadow: var(--shadow); transition: transform .15s; }
.hero-card:hover { transform: translateY(-2px); }
.hero-ic { width: 48px; height: 48px; border-radius: 15px; display: grid; place-items: center; font-size: 23px; margin-bottom: 14px; }
.hero-val { font-size: 30px; font-weight: 800; letter-spacing: -.025em; line-height: 1.05; color: var(--heading); }
.hero-lbl { font-size: 14px; font-weight: 700; color: var(--ink); margin-top: 4px; }
.hero-sub { font-size: 12px; color: var(--ink-faint); margin-top: 4px; line-height: 1.35; }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-bottom: 20px; }
.card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow-soft); padding: 20px; }
.card h3 { margin: 0 0 4px; font-size: 15px; color: var(--heading); }
.card .hint { color: var(--ink-faint); font-size: 12px; margin: 0 0 16px; }

/* Table */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { text-align: left; color: var(--ink-faint); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
tbody td { padding: 11px 10px; border-bottom: 1px solid var(--line); }
tbody tr:hover { background: rgba(255,255,255,.03); }
tbody tr { cursor: pointer; }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 12px; color: var(--ink-soft); }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; color: #ffffff; }
.chip-mod { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; box-shadow: 0 0 8px currentColor; }
.st { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.st.ready { background: rgba(45,212,191,.16); color: #5eead4; }
.st.partial { background: rgba(251,191,36,.16); color: #fcd34d; }
.st.blocked { background: rgba(251,113,133,.16); color: #fda4af; }

.bar-wrap { background: var(--track); border-radius: 6px; height: 8px; overflow: hidden; min-width: 80px; }
.bar-fill { height: 100%; border-radius: 6px; }

/* legend */
.legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 14px; }
.legend .chip-mod { color: var(--ink-soft); }

/* Dependency map */
.map-shell { overflow-x: auto; border-radius: 14px; background: linear-gradient(180deg,#12152a,#0f1225); border: 1px solid var(--line); }
svg.depmap { display: block; min-width: 1180px; }
.node rect { rx: 11; transition: filter .15s; }
.node text { fill: #fff; font-size: 12px; font-weight: 600; pointer-events: none; }
.node .sub { fill: rgba(255,255,255,.82); font-size: 9.5px; font-weight: 500; }
.node { cursor: pointer; }
.node:hover rect { filter: brightness(1.18) drop-shadow(0 0 6px currentColor); }
.node.dim { opacity: .25; }
.node.rec rect { stroke: #fbbf24; stroke-width: 3; filter: drop-shadow(0 0 8px rgba(251,191,36,.7)); }

/* lista de recomendados */
.rec-list { display: flex; flex-direction: column; gap: 8px; }
.rec-item { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card-tint); }
.rec-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; cursor: pointer; font-size: 12.5px; transition: background .12s; }
.rec-row:hover { background: rgba(255,255,255,.04); }
.rec-why { padding: 0 12px 11px; font-size: 11.5px; color: var(--ink-soft); line-height: 1.5; }
.rec-why b { color: var(--ink); }

/* lista de tabelas do objeto (drawer da rede) */
.ao-tables { margin-top: 8px; max-height: 260px; overflow-y: auto; font-size: 11.5px; line-height: 1.5; }
.ao-trow { padding: 4px 0; border-bottom: 1px solid var(--line); }
.ao-trow b { color: var(--ink); }
.rec-n { width: 22px; height: 22px; flex: 0 0 auto; border-radius: 7px; background: linear-gradient(135deg,#fbbf24,#fb7185); color: #1a1300; display: grid; place-items: center; font-weight: 800; font-size: 12px; box-shadow: 0 0 12px rgba(251,191,36,.4); }
.edge { fill: none; stroke: rgba(255,255,255,.14); stroke-width: 1.6; }
.edge.hot { stroke: var(--brand); stroke-width: 2.6; filter: drop-shadow(0 0 4px var(--brand)); }

/* rede ADK real */
svg.anet .anode { cursor: pointer; transition: opacity .12s; }
svg.anet .anode:hover rect { filter: brightness(1.18) drop-shadow(0 0 5px currentColor); }
svg.anet .anode.dim { opacity: .1; }
svg.anet .aedge { fill: none; stroke: rgba(255,255,255,.1); stroke-width: 1.1; }
svg.anet .aedge.hot { stroke: var(--brand); stroke-width: 2.2; filter: drop-shadow(0 0 4px var(--brand)); }

/* Strategy waves */
.wave { border-left: 3px solid var(--brand); padding: 4px 0 4px 18px; margin-bottom: 20px; position: relative; box-shadow: -3px 0 12px -4px var(--brand); }
.wave-h { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.wave-h .n { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg,var(--brand),var(--brand-2)); color:#0b1020; display:grid; place-items:center; font-weight:800; font-size:14px; box-shadow: var(--glow-c); }
.wave-h h4 { margin: 0; font-size: 15px; color: var(--heading); }
.wave-h span { color: var(--ink-faint); font-size: 12px; }
.obj-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px,1fr)); gap: 12px; }
.obj-card { border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: var(--card-tint); }
.obj-card .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.obj-card .code { font-weight: 700; font-size: 13.5px; color: var(--heading); }
.obj-card .metrics { display: flex; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--ink-soft); }
.obj-card .metrics b { color: var(--ink); }

/* Simulator */
.sim-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; }
.sim-list { max-height: 560px; overflow-y: auto; padding-right: 6px; }
.sim-row { display: grid; grid-template-columns: 20px 1fr auto; gap: 12px; align-items: center; padding: 10px 6px; border-bottom: 1px solid var(--line); }
.sim-row .name { font-size: 13px; font-weight: 600; }
.sim-row .meta { font-size: 11px; color: var(--ink-faint); }
input[type=checkbox] { width: 17px; height: 17px; accent-color: var(--brand); cursor: pointer; }
.readout { position: sticky; top: 20px; }
.big-num { font-size: 40px; font-weight: 800; letter-spacing: -.03em; color: var(--heading); text-shadow: 0 0 22px rgba(45,212,191,.4); }
.gauge { height: 12px; border-radius: 8px; background: var(--track); overflow: hidden; margin: 10px 0 4px; }
.gauge > div { height: 100%; background: linear-gradient(90deg,var(--brand),var(--ok)); box-shadow: 0 0 12px rgba(34,211,238,.5); }
.slider-row { display: flex; align-items: center; gap: 12px; margin: 14px 0; font-size: 13px; }
.slider-row input[type=range] { flex: 1; accent-color: var(--brand); }
.btn { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #0b1020; border: none; padding: 9px 16px; border-radius: 11px; font-weight: 700; font-size: 13px; cursor: pointer; box-shadow: 0 4px 18px -4px rgba(34,211,238,.5); transition: filter .15s, transform .1s; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: var(--track); color: var(--ink); border: 1px solid var(--line); box-shadow: none; }

/* formulário de conexão */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid label { display: flex; flex-direction: column; font-size: 12px; font-weight: 600; color: var(--ink-soft); gap: 5px; }
.form-grid input { padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; font-size: 13.5px; font-weight: 400; color: var(--ink); font-family: inherit; background: rgba(255,255,255,.04); }
.form-grid input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(34,211,238,.15); }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

.hidden { display: none; }

/* carregando */
.loading-box { display: flex; align-items: center; gap: 12px; color: var(--ink-soft); font-size: 13.5px; padding: 22px 4px; }
.spinner { width: 18px; height: 18px; flex: 0 0 auto; border: 2.5px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; box-shadow: var(--glow-c); }
@keyframes spin { to { transform: rotate(360deg); } }

/* details drawer */
.drawer-back { position: fixed; inset: 0; background: rgba(5,7,15,.6); display: none; z-index: 40; backdrop-filter: blur(2px); }
.drawer-back.open { display: block; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: 420px; max-width: 92vw; background: var(--surface); z-index: 50; box-shadow: -20px 0 60px -20px rgba(0,0,0,.7); transform: translateX(100%); transition: transform .25s; padding: 26px; overflow-y: auto; border-left: 1px solid var(--line); }
.drawer.open { transform: translateX(0); }
.drawer h3 { margin: 0 0 2px; font-size: 20px; color: var(--heading); }
.drawer .kv { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; gap: 12px; }
.drawer .kv span:first-child { color: var(--ink-soft); }
.drawer .kv b { font-weight: 700; }
.close-x { float: right; cursor: pointer; color: var(--ink-faint); font-size: 22px; line-height: 1; }

@media (max-width: 1080px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .kpis, .hero-row { grid-template-columns: repeat(2,1fr); }
  .grid-2, .sim-grid { grid-template-columns: 1fr; }
  .main { padding: 20px; }
}

/* ===== login / setup (gate de autenticação) ===== */
.auth-gate { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px;
  background: var(--app-bg); }
.auth-card { width: 400px; max-width: 94vw; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px 30px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand .logo { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center;
  color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-2)); box-shadow: var(--glow-c); }
.auth-brand h1 { font-size: 17px; margin: 0; color: var(--heading); letter-spacing: -.01em; }
.auth-brand small { color: var(--ink-faint); font-size: 11.5px; }
.auth-card h2 { margin: 0 0 4px; font-size: 22px; color: var(--heading); }
.auth-sub { margin: 0 0 20px; color: var(--ink-soft); font-size: 13px; line-height: 1.5; }
.auth-form { display: flex; flex-direction: column; gap: 13px; }
.auth-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.auth-form input { padding: 11px 13px; border: 1px solid var(--line); border-radius: 11px; font-size: 14px;
  color: var(--ink); font-family: inherit; background: rgba(255,255,255,.04); }
.auth-form input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(34,211,238,.15); }
.auth-form .btn { margin-top: 6px; padding: 12px; font-size: 14px; }
.auth-msg { min-height: 18px; font-size: 12.5px; color: var(--ink-faint); text-align: center; }
.auth-msg.err { color: var(--bad); }
.auth-foot { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--ink-faint); text-align: center; }

/* ===== bloco de usuário no sidebar ===== */
.side-user { padding: 10px; }
.su-row { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.07); border-radius: 12px; padding: 8px 10px; }
.su-avatar { width: 32px; height: 32px; flex: 0 0 auto; border-radius: 9px; display: grid; place-items: center;
  font-size: 12px; font-weight: 800; color: #0b1020; background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
.su-info { min-width: 0; flex: 1; }
.su-name { font-size: 12.5px; font-weight: 700; color: #e8ebf7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.su-tenant { font-size: 11px; color: #7f88ab; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.su-logout { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 8px; cursor: pointer;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.1); color: #aeb7d2; font-size: 14px; }
.su-logout:hover { color: #fff; background: rgba(251,113,133,.2); border-color: rgba(251,113,133,.4); }
