/* ============================================================
   Panel NORTE — Estilos. Theming vía CSS variables inyectadas
   por cliente desde app.js (applyTheme).
   ============================================================ */

:root {
  --base: #0D0B1E;
  --surface: #16122E;
  --surface2: #1E1840;
  --primary: #3D1B8E;
  --primary-soft: #5B3BB8;
  --accent: #C8FF00;
  --text: #FFFFFF;
  --text-muted: #B7AEDC;
  --border: rgba(232, 228, 255, 0.12);
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  background: var(--base);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background .4s ease, color .4s ease;
}

#app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: background .4s ease, border-color .4s ease;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--primary);
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 22px;
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.brand-title { font-family: var(--font-display); font-weight: 600; font-size: 16px; display: block; letter-spacing: -.01em; }
.brand-sub { font-size: 11px; color: var(--text-muted); letter-spacing: .04em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 14px; font-weight: 500;
  cursor: pointer; border: none; background: none; text-align: left; width: 100%;
  transition: all .18s ease;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--surface2); color: var(--text); }
.nav-item.active .nav-ico { color: var(--accent); }
.nav-ico { width: 18px; text-align: center; font-size: 15px; opacity: .9; }
.nav-badge {
  margin-left: auto; font-size: 11px; font-weight: 600;
  background: var(--primary); color: #fff; padding: 1px 7px; border-radius: 20px;
}

.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.agency { display: flex; align-items: center; gap: 10px; padding: 6px 8px; }
.agency-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.agency-name { font-size: 13px; font-weight: 600; }
.agency-role { font-size: 11px; color: var(--text-muted); }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--base) 80%, transparent);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 14px; }

.client-switch { display: flex; align-items: center; gap: 8px; }
.client-btn {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  padding: 8px 14px; border-radius: 12px; cursor: pointer;
  color: var(--text); font-family: var(--font-body); font-size: 14px; font-weight: 500;
  transition: all .18s ease;
}
.client-btn:hover { border-color: var(--primary-soft); }
.client-logo {
  width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
  display: grid; place-items: center; font-family: var(--font-display);
  font-weight: 700; font-size: 13px; color: #fff;
}
.client-meta { display: flex; flex-direction: column; line-height: 1.15; }
.client-name { font-weight: 600; font-size: 14px; }
.client-ind { font-size: 11px; color: var(--text-muted); }
.client-caret { color: var(--text-muted); font-size: 11px; margin-left: 4px; }

.client-menu {
  position: absolute; top: 60px; left: 28px; z-index: 40;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 8px; box-shadow: var(--shadow);
  min-width: 280px; display: none;
}
.client-menu.open { display: block; }
.client-menu-item {
  display: flex; align-items: center; gap: 12px; padding: 10px;
  border-radius: 10px; cursor: pointer; transition: background .15s ease;
}
.client-menu-item:hover { background: var(--surface2); }
.client-menu-item .client-logo { width: 32px; height: 32px; font-size: 14px; }
.cmi-phase { font-size: 11px; color: var(--text-muted); }
.cmi-badge { display: inline-block; font-size: 9px; font-weight: 700; letter-spacing: .5px; background: var(--accent); color: #000; border-radius: 4px; padding: 1px 5px; vertical-align: middle; margin-left: 5px; }
.client-menu-ingest { display: block; margin: 6px 2px 2px; padding: 9px 12px; font-size: 12px; font-weight: 600; color: var(--accent); text-decoration: none; border-radius: 8px; border: 1px dashed rgba(200,255,0,.3); text-align: center; transition: background .15s; }
.client-menu-ingest:hover { background: var(--surface2); }

.phase-pill {
  font-size: 12px; font-weight: 500; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  padding: 6px 12px; border-radius: 20px; display: flex; align-items: center; gap: 8px;
}
.phase-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

.user-chip {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 13px;
  font-family: var(--font-display);
}

.ghost-btn { background: none; border: none; color: var(--text); font-size: 20px; cursor: pointer; }
.only-mobile { display: none; }

/* ---------- View ---------- */
.view { padding: 28px; max-width: 1240px; width: 100%; margin: 0 auto; }
.view-head { margin-bottom: 24px; }
.view-title { font-family: var(--font-display); font-weight: 600; font-size: 28px; letter-spacing: -.02em; }
.view-sub { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

.section-label {
  font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 14px;
}

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  transition: background .4s ease, border-color .4s ease, transform .15s ease;
}
.card.hover:hover { transform: translateY(-2px); border-color: var(--primary-soft); }

.card-title { font-family: var(--font-display); font-weight: 600; font-size: 16px; margin-bottom: 4px; }
.card-sub { color: var(--text-muted); font-size: 13px; }

/* ---------- Roadmap NORTE (overview) ---------- */
.roadmap { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 8px; }
.norte-card {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; cursor: pointer;
  transition: all .2s ease; min-height: 168px;
  display: flex; flex-direction: column;
}
.norte-card:hover { transform: translateY(-3px); border-color: var(--primary-soft); }
.norte-ghost {
  position: absolute; right: -8px; bottom: -28px;
  font-family: var(--font-display); font-weight: 700; font-size: 120px;
  color: var(--primary); opacity: .14; line-height: 1; pointer-events: none;
}
.norte-letter {
  font-family: var(--font-display); font-weight: 700; font-size: 30px;
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  background: var(--primary); color: var(--accent); margin-bottom: 12px;
}
.norte-name { font-family: var(--font-display); font-weight: 600; font-size: 14px; line-height: 1.25; position: relative; z-index: 1; }
.norte-short { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.norte-progress { margin-top: auto; position: relative; z-index: 1; }
.progress-track { height: 6px; background: var(--surface2); border-radius: 10px; overflow: hidden; margin-top: 8px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 10px; transition: width .6s ease; }
.progress-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-muted); margin-top: 6px; }

.status-tag {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 20px; border: 1px solid var(--border);
}
.status-tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); }
.st-cerrado::before, .st-completada::before { background: #4ade80; }
.st-en-curso::before, .st-en-validacion::before, .st-en-cierre::before, .st-iniciando::before { background: var(--accent); }
.st-bloqueada::before { background: #f87171; }
.st-no-iniciado::before, .st-pendiente::before { background: var(--text-muted); }
.st-abierta::before { background: var(--accent); }
.st-respondida::before { background: #4ade80; }

/* ---------- Health ring ---------- */
.health-row { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.ring { position: relative; width: 132px; height: 132px; flex-shrink: 0; }
.ring svg { transform: rotate(-90deg); }
.ring-label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring-num { font-family: var(--font-display); font-weight: 700; font-size: 30px; }
.ring-cap { font-size: 11px; color: var(--text-muted); }

/* ---------- Next action / summary ---------- */
.next-action {
  background: linear-gradient(135deg, var(--primary), var(--primary-soft));
  border: 1px solid var(--primary-soft); border-radius: var(--radius);
  padding: 20px 22px; position: relative; overflow: hidden;
}
.next-action .na-label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.next-action .na-text { font-family: var(--font-display); font-weight: 500; font-size: 17px; margin-top: 6px; line-height: 1.35; }

.summary-text { font-size: 14.5px; line-height: 1.65; color: var(--text); }

/* ---------- Tasks ---------- */
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kcol { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.kcol-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.kcol-title { font-family: var(--font-display); font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.kcol-count { font-size: 11px; color: var(--text-muted); background: var(--surface2); padding: 2px 8px; border-radius: 20px; }
.prio-dot { width: 9px; height: 9px; border-radius: 3px; }
.p-p0 { background: #f87171; } .p-p1 { background: var(--accent); } .p-p2 { background: var(--primary-soft); } .p-p3 { background: var(--text-muted); }

.task {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px; margin-bottom: 10px; transition: all .15s ease; cursor: default;
}
.task:hover { border-color: var(--primary-soft); }
.task-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.stage-chip {
  font-family: var(--font-display); font-weight: 700; font-size: 11px;
  width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center;
  background: var(--primary); color: var(--accent);
}
.task-area { font-size: 11px; color: var(--text-muted); }
.task-title { font-size: 13.5px; font-weight: 500; line-height: 1.35; margin-bottom: 10px; }
.task-foot { display: flex; align-items: center; justify-content: space-between; }
.task-owner { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--text-muted); }
.avatar { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 10px; font-weight: 600; color: #fff; }
.task-due { font-size: 11px; color: var(--text-muted); }
.task-due.overdue { color: #f87171; }

/* table view toggle */
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { background: none; border: none; color: var(--text-muted); font-family: var(--font-body); font-size: 13px; font-weight: 500; padding: 6px 14px; border-radius: 7px; cursor: pointer; }
.seg button.active { background: var(--surface2); color: var(--text); }

table.tasks-table { width: 100%; border-collapse: collapse; }
.tasks-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); padding: 10px 12px; border-bottom: 1px solid var(--border); }
.tasks-table td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.tasks-table tr:hover td { background: var(--surface); }

/* ---------- Metrics ---------- */
.metric-card { display: flex; flex-direction: column; gap: 8px; }
.metric-top { display: flex; align-items: flex-start; justify-content: space-between; }
.metric-name { font-size: 13px; color: var(--text-muted); }
.metric-source { font-size: 10px; color: var(--text-muted); border: 1px solid var(--border); padding: 2px 7px; border-radius: 20px; }
.metric-val { font-family: var(--font-display); font-weight: 700; font-size: 32px; letter-spacing: -.02em; }
.metric-val .unit { font-size: 14px; color: var(--text-muted); font-weight: 500; margin-left: 4px; }
.metric-delta { font-size: 12px; font-weight: 600; }
.delta-up { color: #4ade80; } .delta-down { color: #f87171; } .delta-flat { color: var(--text-muted); }
.metric-bar { height: 5px; background: var(--surface2); border-radius: 10px; overflow: hidden; }
.metric-bar span { display: block; height: 100%; background: var(--primary-soft); border-radius: 10px; }
.metric-target { font-size: 11px; color: var(--text-muted); }
.spark { width: 100%; height: 34px; }

/* ---------- Q&A ---------- */
.qa-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 12px; }
.qa-q { display: flex; gap: 12px; align-items: flex-start; }
.qa-icon { width: 30px; height: 30px; border-radius: 9px; background: var(--primary); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-family: var(--font-display); flex-shrink: 0; }
.qa-question { font-family: var(--font-display); font-weight: 600; font-size: 15px; line-height: 1.4; }
.qa-byline { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.qa-a { margin-top: 12px; padding: 12px 14px; background: var(--surface2); border-radius: 10px; border-left: 2px solid var(--accent); font-size: 14px; line-height: 1.6; }
.qa-a .qa-answerer { font-size: 11px; color: var(--text-muted); margin-top: 8px; }
.qa-open-note { margin-top: 10px; font-size: 13px; color: var(--accent); display: flex; align-items: center; gap: 8px; }
.qa-tags { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.tag { font-size: 11px; color: var(--text-muted); background: var(--surface2); padding: 3px 9px; border-radius: 20px; }
.tag.stage { color: var(--accent); }

.qa-form { display: flex; gap: 10px; margin-bottom: 22px; }
.qa-input { flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 13px 16px; color: var(--text); font-family: var(--font-body); font-size: 14px; }
.qa-input::placeholder { color: var(--text-muted); }
.qa-input:focus { outline: none; border-color: var(--primary-soft); }
.btn-primary { background: var(--accent); color: #0D0B1E; border: none; border-radius: 12px; padding: 0 20px; font-family: var(--font-body); font-weight: 600; font-size: 14px; cursor: pointer; transition: filter .15s ease; }
.btn-primary:hover { filter: brightness(1.05); }

/* ---------- Risks ---------- */
.risk { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border); }
.risk:last-child { border-bottom: none; }
.risk-level { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 3px 8px; border-radius: 6px; flex-shrink: 0; }
.rl-alto { background: rgba(248,113,113,.16); color: #f87171; }
.rl-medio { background: rgba(200,255,0,.14); color: var(--accent); }
.rl-bajo { background: var(--surface2); color: var(--text-muted); }
.risk-text { font-size: 13.5px; line-height: 1.5; }

/* ---------- NORTE detail ---------- */
.norte-detail-head { display: flex; align-items: center; gap: 18px; margin-bottom: 20px; }
.nd-letter { font-family: var(--font-display); font-weight: 700; font-size: 40px; width: 72px; height: 72px; border-radius: 18px; background: var(--primary); color: var(--accent); display: grid; place-items: center; }
.nd-stepper { display: flex; gap: 6px; margin-bottom: 24px; }
.nd-step { flex: 1; padding: 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); cursor: pointer; text-align: center; transition: all .15s ease; }
.nd-step:hover { border-color: var(--primary-soft); }
.nd-step.active { background: var(--primary); border-color: var(--primary-soft); }
.nd-step.active .nds-letter { color: var(--accent); }
.nds-letter { font-family: var(--font-display); font-weight: 700; font-size: 18px; }
.nds-name { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.nd-step.active .nds-name { color: #fff; }

.bullet-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.bullet-list li { display: flex; gap: 10px; font-size: 14px; line-height: 1.55; }
.bullet-list li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-top: 8px; flex-shrink: 0; }
.evidence-chip { display: inline-block; font-size: 12px; color: var(--text-muted); background: var(--surface2); padding: 5px 11px; border-radius: 20px; margin: 4px 6px 0 0; }

.banner {
  background: var(--surface2); border: 1px dashed var(--primary-soft); border-radius: 12px;
  padding: 14px 16px; font-size: 13px; color: var(--text-muted); display: flex; gap: 10px; align-items: flex-start;
}
.banner b { color: var(--text); }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .roadmap { grid-template-columns: repeat(2, 1fr); }
  .kanban { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(-100%); transition: transform .25s ease; }
  .sidebar.open { transform: translateX(0); }
  .only-mobile { display: block; }
  .grid-2, .grid-3, .grid-4, .roadmap, .kanban { grid-template-columns: 1fr; }
  .view { padding: 18px; }
  .client-ind { display: none; }
}
