/* SofiLab CRM — rediseño visual VP-CRM-UI-20261002.
   Consola grafito + superficie clara + azul SofiLab. Estados con texto, icono y color.
   Assets self-hosted; sin estilos inline en markup; CSP intacta. */

:root {
  --blue: #004bff;
  --blue-dark: #16439a;
  --blue-soft: #e8effc;
  --graphite: #1b2130;
  --graphite-2: #232b3d;
  --graphite-line: #313b52;
  --bg: #f2f4f7;
  --card: #ffffff;
  --text: #1c2330;
  --muted: #5d6b82;
  --line: #dfe4ec;
  --warn-bg: #fff4e5;
  --warn-line: #f0b357;
  --err-bg: #fdecec;
  --err-line: #d9534f;
  --ok: #1f7a44;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .05), 0 8px 24px rgba(20, 30, 50, .05);
  --tone: var(--muted);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -.01em; }
img { max-width: 100%; }

.skip {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--blue); color: #fff; padding: 8px 12px; border-radius: 0 0 8px 0;
}
.skip:focus { left: 8px; top: 8px; }
:focus-visible { outline: 3px solid var(--blue-dark); outline-offset: 2px; }

/* ------------------------------------------------------------ topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 10px 18px; position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo { width: 132px; height: 44px; object-fit: contain; flex-shrink: 0; }
.brand-text { min-width: 0; }
.brand-text strong { display: block; font-size: 16px; }
.brand-text small { display: block; color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sync-indicator {
  background: var(--blue-soft); color: var(--blue-dark);
  border-radius: 999px; padding: 5px 12px; font-size: 12.5px; font-weight: 600;
  max-width: 100%; overflow-wrap: anywhere;
}

/* ------------------------------------------------------------ layout */
.layout { display: flex; align-items: flex-start; gap: 18px; padding: 18px; }
.sidebar {
  position: sticky; top: 78px;
  display: flex; flex-direction: column; gap: 6px;
  min-width: 176px; flex-shrink: 0;
  background: var(--graphite); border-radius: var(--radius);
  padding: 12px; box-shadow: var(--shadow);
}
.nav-item {
  text-align: left; border: 0; background: transparent; color: #cbd5e6;
  padding: 10px 12px; border-radius: var(--radius-sm); font-size: 15px; cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.nav-item:hover { background: var(--graphite-2); color: #fff; }
.nav-item.active { background: var(--blue); color: #fff; font-weight: 600; }

.content { flex: 1; min-width: 0; }
.content:focus { outline: none; }

.view-head { margin: 0 0 14px; }
.view-title { margin: 0 0 4px; font-size: 22px; }
.view-sub { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow); min-width: 0;
}
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.search {
  flex: 1 1 260px; max-width: 420px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 999px; font: inherit; background: #fff; color: var(--text);
}
.empty { padding: 26px; text-align: center; }
.empty h3 { margin: 0 0 6px; }
.empty-inline { color: var(--muted); padding: 8px; font-size: 13px; text-align: center; }

/* ------------------------------------------------------------ board */
.board { display: grid; grid-template-columns: repeat(5, minmax(min(200px, 100%), 1fr)); gap: 14px; align-items: start; }
.column { background: #eaedf3; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-width: 0; }
.column-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.column-head h3 { font-size: 12.5px; margin: 0; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.count { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; font-size: 12px; }
.column-body { display: flex; flex-direction: column; gap: 10px; }

.task-card {
  text-align: left; width: 100%; cursor: pointer; font: inherit; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--tone);
  border-radius: var(--radius-sm); padding: 10px 12px; box-shadow: 0 1px 2px rgba(20, 30, 50, .04);
  transition: box-shadow .15s ease, transform .15s ease;
}
.task-card:hover { box-shadow: 0 4px 14px rgba(20, 30, 50, .12); }
.task-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.task-id { font-size: 12px; color: var(--muted); font-weight: 700; letter-spacing: .02em; }
.task-objective { font-weight: 600; margin: 0 0 7px; overflow-wrap: anywhere; }
.task-card .task-objective {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4;
  overflow: hidden; max-height: 6em;
}
.task-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.task-updated { font-size: 12px; color: var(--muted); }
.pill {
  background: var(--blue-soft); color: var(--blue-dark); border-radius: 999px;
  padding: 2px 9px; font-size: 12px; white-space: nowrap;
}
.pill-alta { background: #fde8e8; color: #a11d1d; }
.pill-media { background: #fff2dd; color: #8a5307; }
.pill-baja { background: #e6f0ee; color: #1f6f60; }

.task-rows { display: flex; flex-direction: column; gap: 6px; }
.task-row {
  display: flex; align-items: center; gap: 8px; text-align: left; width: 100%; cursor: pointer;
  font: inherit; color: inherit; background: var(--card); border: 1px solid var(--line);
  border-left: 4px solid var(--tone); border-radius: var(--radius-sm); padding: 7px 10px; min-width: 0;
}
.task-row:hover { box-shadow: 0 2px 8px rgba(20, 30, 50, .1); }
.task-row-obj { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-row .badge { flex-shrink: 0; }

/* estados: color por kind, siempre acompañado de texto e icono */
.status-active       { --tone: var(--blue); }
.status-waiting      { --tone: #b45309; }
.status-delivered    { --tone: #7c3aed; }
.status-verified     { --tone: var(--ok); }
.status-blocked      { --tone: #c0392b; }
.status-cancelled    { --tone: #6b7280; }
.status-inconsistent { --tone: #b45309; }
.status-unknown      { --tone: #6b7280; }

.state-icon { vertical-align: -2px; margin-right: 4px; }
.badge {
  display: inline-flex; align-items: center; gap: 2px; border-radius: 999px;
  padding: 2px 9px 2px 7px; font-size: 12px; line-height: 1.5;
  background: #eef1f6; color: var(--muted); border: 1px solid transparent; max-width: 100%;
}
.badge-text { overflow-wrap: anywhere; }
.badge-active       { background: #e7eeff; color: var(--blue-dark); }
.badge-waiting      { background: #fdf1de; color: #8a5307; }
.badge-delivered    { background: #f1e9fe; color: #5b21b6; }
.badge-verified     { background: #e3f4e9; color: var(--ok); }
.badge-blocked      { background: var(--err-bg); color: #96201c; }
.badge-cancelled    { background: #eef1f6; color: #4b5563; }
.badge-inconsistent { background: #fdf1de; color: #8a5307; border-color: #e4b979; }
.badge-unknown      { background: #eef1f6; color: #4b5563; border-style: dashed; border-color: #b8c1d1; }
.badge-idle         { background: #eef1f6; color: var(--muted); }

/* ------------------------------------------------------------ equipo */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 14px; align-items: start; }
.team-card { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.team-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar { flex-shrink: 0; border-radius: 50%; background: #f4f7fc; }
.team-id { min-width: 0; }
.team-id h3 { margin: 0; font-size: 17px; overflow-wrap: anywhere; }
.team-id p { margin: 1px 0 0; }
.team-resp { color: var(--text); font-size: 13px; }
.team-status { display: flex; flex-wrap: wrap; gap: 6px; }
.team-counts { display: flex; flex-wrap: wrap; gap: 6px; }
.team-section { border-top: 1px solid var(--line); padding-top: 8px; min-width: 0; }
.team-section h4 { margin: 0 0 6px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.team-details { border-top: 1px solid var(--line); padding-top: 8px; min-width: 0; }
.team-summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); list-style: none; }
.team-summary::-webkit-details-marker { display: none; }
.team-summary::before { content: '▸'; margin-right: 6px; }
details[open] > .team-summary::before { content: '▾'; }
.team-details .task-rows { margin-top: 6px; }
.last-delivery { display: flex; flex-direction: column; gap: 6px; min-width: 0; align-items: flex-start; }
.last-delivery-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; width: 100%; min-width: 0; }
.last-delivery-obj {
  margin: 0; min-width: 0; width: 100%; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden;
}
.last-delivery .btn { align-self: flex-start; }

/* ------------------------------------------------------------ flujo */
.flow-block { margin-bottom: 22px; min-width: 0; }
.flow-block > h3 { margin: 0 0 10px; font-size: 16px; }
.flow-stages {
  list-style: none; display: flex; flex-wrap: wrap; align-items: stretch; gap: 6px;
  margin: 0; padding: 0;
}
.stage {
  flex: 1 1 130px; min-width: 0; display: flex; flex-direction: column; gap: 2px;
  background: var(--card); border: 1px solid var(--line); border-top: 3px solid var(--blue);
  border-radius: var(--radius-sm); padding: 8px 10px; box-shadow: var(--shadow);
}
.stage.pending { border-top-color: #b45309; }
.stage.exec { border-top-color: var(--blue); }
.stage.delivery { border-top-color: #7c3aed; }
.stage.qa { border-top-color: var(--ok); }
.stage.result { border-top-color: #0e7490; }
.stage-count { font-size: 24px; font-weight: 700; }
.stage-label { font-weight: 600; font-size: 13.5px; }
.stage-arrow { align-self: center; color: var(--muted); font-size: 18px; }

.meta-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 14px; }
.meta-card { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.meta-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.meta-head h3 { margin: 0; font-size: 16px; overflow-wrap: anywhere; }
.meta-note { margin: 0; font-size: 13px; color: var(--text); background: var(--blue-soft); border-radius: var(--radius-sm); padding: 7px 10px; overflow-wrap: anywhere; }
.warn-inline { margin: 0; font-size: 13px; color: #8a5307; background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: var(--radius-sm); padding: 7px 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; border-radius: 999px;
  padding: 3px 10px; font-size: 12px; background: #eef1f6; color: var(--muted);
  border: 1px solid transparent; border-left: 3px solid var(--tone); max-width: 100%; min-width: 0;
}
button.chip { cursor: pointer; font: inherit; }
.chip-task { background: var(--card); color: var(--text); }
.chip-muted { border-style: dashed; border-left-color: var(--muted); }
.chip-missing { background: var(--warn-bg); color: #8a5307; border-left-color: var(--warn-line); }
.chip-id { font-weight: 700; }
.chip-label { overflow-wrap: anywhere; }

.progress-wrap { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.progress { flex: 1 1 120px; min-width: 0; height: 8px; background: #e5e9f0; border-radius: 999px; overflow: hidden; }
.progress-fill { display: block; height: 100%; background: var(--blue); border-radius: 999px; transition: width .25s ease; }

.dep-list { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.dep-details { min-width: 0; }
.dep-details .dep-list { margin-top: 8px; }
.dep-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.dep-source { font-weight: 700; font-size: 12.5px; overflow-wrap: anywhere; }
.dep-arrow { color: var(--muted); font-weight: 700; }
.dep-targets { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-width: 0; }
.dep-target { border-radius: 999px; padding: 2px 9px; font-size: 12px; background: #eef1f6; color: var(--muted); max-width: 100%; overflow-wrap: anywhere; min-width: 0; }
.dep-target.is-missing { background: var(--warn-bg); color: #8a5307; }

.exec-box { margin-bottom: 12px; }
.activity-title { margin: 12px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.activity { display: flex; flex-direction: column; gap: 4px; }
.event {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line); padding: 6px 2px;
}
.event-time { color: var(--muted); font-size: 12.5px; min-width: 160px; }
.event-body { flex: 1; min-width: 0; overflow-wrap: anywhere; }

/* ------------------------------------------------------------ objetivos/formularios */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 14px; }
.objective-layout { display: grid; grid-template-columns: minmax(260px, 360px) 1fr; gap: 18px; align-items: start; }
.objective-form { display: flex; flex-direction: column; gap: 4px; }
.login { max-width: 420px; margin: 40px auto; display: flex; flex-direction: column; gap: 6px; }
label { font-weight: 600; font-size: 13.5px; margin-top: 6px; }
input, textarea, select {
  width: 100%; max-width: 100%; padding: 9px 10px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); font: inherit; background: #fff; color: var(--text);
}
textarea { resize: vertical; }
.btn {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: 9px 14px; border-radius: var(--radius-sm); cursor: pointer; font: inherit; margin-top: 8px;
}
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--blue-dark); }
.btn.ghost { background: transparent; }
.btn.tiny { padding: 3px 9px; font-size: 12px; margin-top: 0; }

.error-banner, .warn-banner { border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; border: 1px solid; }
.error-banner { background: var(--err-bg); border-color: var(--err-line); color: #8a1f1f; }
.warn-banner { background: var(--warn-bg); border-color: var(--warn-line); color: #7a4a06; }
.notice { max-width: 640px; margin: 24px auto; padding: 12px 16px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }

/* ------------------------------------------------------------ modal */
.modal-root {
  position: fixed; inset: 0; background: rgba(18, 24, 38, .58);
  display: grid; place-items: center; padding: 20px; z-index: 50; overflow: auto;
}
.modal { background: var(--card); border-radius: var(--radius); padding: 18px; width: min(680px, 100%); max-height: 90vh; overflow: auto; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.modal-head h2 { margin: 0; overflow-wrap: anywhere; }
.detail-list { display: grid; grid-template-columns: 180px 1fr; gap: 6px 12px; margin: 14px 0; }
.detail-list dt { font-weight: 600; color: var(--muted); }
.detail-list dd { margin: 0; overflow-wrap: anywhere; }
.comments { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.comment { background: var(--bg); border-radius: var(--radius-sm); padding: 9px 11px; }
.comment-meta { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.comment-text, .task-objective, .comment-meta { white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-form { display: flex; flex-direction: column; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .board { grid-template-columns: repeat(2, minmax(min(200px, 100%), 1fr)); }
  .objective-layout { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .layout { flex-direction: column; padding: 12px; }
  .content { width: 100%; max-width: 100%; align-self: stretch; }
  .sidebar { position: static; flex-direction: row; width: 100%; min-width: 0; overflow-x: auto; top: auto; }
  .nav-item { white-space: nowrap; }
}
@media (max-width: 560px) {
  .topbar { padding: 8px 12px; }
  .brand-logo { width: 104px; height: 36px; }
  .board { grid-template-columns: 1fr; }
  .detail-list { grid-template-columns: 1fr; }
  .detail-list dt { margin-top: 6px; }
  .event-time { min-width: 0; }
  .stage { flex: 1 1 100%; }
  .stage-arrow { transform: rotate(90deg); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
.files-panel { display:grid; gap:24px; max-width:1050px; }
.files-upload { display:grid; gap:14px; }
.files-upload input[type=file] { max-width:100%; padding:16px; border:1px dashed var(--border,#aab5ca); border-radius:10px; }
.files-upload .btn { justify-self:start; }
.files-list { display:grid; gap:12px; }
.file-row { display:flex; align-items:center; justify-content:space-between; gap:18px; }
.file-info { display:grid; gap:8px; min-width:0; }
.file-info strong { overflow-wrap:anywhere; }
.file-row .btn { flex-shrink:0; }
@media(max-width:600px) { .file-row { align-items:start; flex-direction:column; } }
