/* Componentes. Dentro de las columnas laterales los bloques no llevan caja: solo título y contenido.
   Las cajas con borde se reservan para el lienzo, las tablas del centro y la tarjeta de propuesta. */

/* Bloques */
.panel { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.col-main > .panel.boxed, .boxed {
  background: var(--panel);
  border: 1px solid var(--line-strong);
}
.panel-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.panel-head > :first-child { flex-grow: 1; }
.card {
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.push-bottom { margin-top: auto; }

.row { display: flex; gap: 8px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.stack { display: flex; flex-direction: column; gap: 4px; }
.grow { flex-grow: 1; min-width: 0; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: 2px;
  background: var(--panel); color: var(--navy);
  font-size: 15px; font-weight: 700; text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--navy); color: var(--navy); }
.btn-primary { border-color: var(--action); background: var(--action); color: var(--panel); }
.btn-primary:hover { border-color: var(--action-hover); background: var(--action-hover); color: var(--panel); }
.btn-dark { border-color: var(--navy); background: var(--navy); color: var(--panel); }
.btn-dark:hover { color: var(--panel); }
.btn-icon { min-width: 44px; padding: 0; }
.btn-quiet { border-color: transparent; background: none; font-weight: 400; text-decoration: underline; padding: 0 8px; }
.btn-on-navy { min-height: 24px; padding: 0 10px; font-size: 13px; background: transparent; border-color: var(--on-navy-muted); color: var(--panel); }
.btn-on-navy:hover { border-color: #ffffff; color: #ffffff; }
.btn:disabled { background: var(--neutral-bg); border-color: var(--line); color: var(--muted); cursor: not-allowed; text-decoration: none; }
.btn-on-navy:disabled { background: transparent; border-color: var(--line-strong); color: var(--line-strong); }
.link-row { display: flex; align-items: center; min-height: 44px; font-size: 14px; }

/* Campos */
.field {
  flex-grow: 1; min-width: 0; width: 100%;
  height: 44px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 2px;
  background: var(--panel); color: var(--navy);
}
select.field { width: auto; padding: 0 10px; }
.field-group { display: flex; flex-direction: column; gap: 4px; }
.field-group label { font-size: 12px; line-height: 16px; color: var(--muted); }

/* Etiqueta de estado: píldora, siempre con texto */
.badge {
  display: inline-block; align-self: flex-start;
  padding: 2px 10px; border-radius: 999px;
  font-size: 12px; line-height: 18px; font-weight: 700; white-space: nowrap;
}
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-ok { background: var(--select-bg); color: var(--select); }
.badge-error { background: var(--error-bg); color: var(--error); }
.badge-navy { background: var(--navy-bg); color: var(--navy); }
.badge-navy-solid { background: var(--navy); color: var(--panel); }
.badge-neutral { background: var(--neutral-bg); color: var(--navy); }

/* Listas laterales: vistas, folios, revisiones */
.nav-list { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.nav-list a { padding: 11px 8px; border-radius: 4px; text-decoration: none; color: var(--navy); }
.nav-list a:hover { background: var(--paper); }
.nav-list a[aria-current="page"] { background: var(--select-bg); font-weight: 700; }

.tree { list-style: none; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.tree-item {
  width: 100%; min-height: 34px;
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border: 0; border-radius: 4px;
  background: none; text-align: left; cursor: pointer;
}
.tree-item:hover { background: var(--paper); }
.tree-item[aria-pressed="true"], .tree-item.is-current { background: var(--select-bg); font-weight: 700; }
li.tree-item { cursor: default; }
.tree-item .data { font-weight: 400; }
.tree-sub { padding: 6px 8px 6px 40px; }
.tree-sub.is-current { font-weight: 700; }

.item {
  list-style: none;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  font-size: 14px;
}
.item.is-selected { border-color: var(--select); background: var(--select-bg); }
.item-list { display: flex; flex-direction: column; gap: 4px; }

/* Filas dato/valor con origen debajo */
.rows-head {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 6px 0; border-bottom: 1px solid var(--line);
  font-size: 12px; line-height: 16px; color: var(--muted); font-weight: 700;
}
.kv, .source-row {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.kv:last-child, .source-row:last-child { border-bottom: 0; }
.kv > :last-child, .source-row > :last-child { text-align: right; overflow-wrap: anywhere; }
.source-row .origin { display: block; font-size: 12px; line-height: 16px; color: var(--muted); }

/* Tablas del centro */
.table-scroll { overflow-x: auto; }
.table { width: 100%; min-width: 560px; border-collapse: collapse; text-align: left; font-size: 14px; }
.table th { padding: 8px 16px; border-bottom: 1px solid var(--line-strong); font-size: 12px; color: var(--muted); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }

/* Avisos */
.notice {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  padding: 12px; border-radius: 2px;
  background: var(--neutral-bg); font-size: 14px;
}
.notice > .grow { flex: 1 1 240px; }
.notice-warn { background: var(--warn-bg); color: var(--warn); }
.notice-warn a { color: var(--warn); font-weight: 700; }
.notice-ok { background: var(--select-bg); color: var(--select); }
.notice-error { background: var(--error-bg); color: var(--error); }
.notice strong { font-weight: 700; }

.state-message { margin: 64px auto; max-width: 480px; padding: 24px; text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; }

/* Leyenda sobre el lienzo */
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; font-size: 13px; color: var(--muted); }
.legend-item { display: flex; align-items: center; gap: 8px; }
.legend-line { width: 28px; border-top: 2px solid var(--navy); }
.legend-line.proposed { border-top: 2px dashed var(--action); }
.legend-line.dotted { border-top: 2px dotted var(--navy); }
.legend-box { width: 14px; height: 14px; border: 2px solid var(--select); background: var(--select-bg); }
.legend-box.mod { border-color: var(--warn); background: var(--warn-bg); }
.legend-box.out { border: 2px dashed var(--line-strong); background: none; }
.zoom-value { min-width: 48px; text-align: center; color: var(--navy); }

/* Lienzo con retícula de puntos y cajetín */
.viewer {
  position: relative;
  flex: 1;
  min-height: 260px;
  background-color: var(--panel);
  background-image: radial-gradient(var(--line) 1px, transparent 1px);
  background-size: 20px 20px;
  border: 1px solid var(--line-strong);
  overflow: auto;
}
.viewer svg { display: block; height: auto; margin: 0 auto; }
.viewer-note { position: absolute; left: 24px; bottom: 12px; font-size: 12px; color: var(--muted); }
.title-block {
  position: absolute; right: 0; bottom: 0; width: 340px; max-width: 100%;
  display: grid; grid-template-columns: 90px 1fr;
  border-top: 1px solid var(--navy); border-left: 1px solid var(--navy);
  background: var(--panel); font-size: 12px; line-height: 18px;
}
.title-block > * { padding: 4px 8px; border-bottom: 1px solid var(--line); }
.title-block > :nth-last-child(-n+2) { border-bottom: 0; }
.title-block > :nth-child(odd) { color: var(--muted); }
.title-block .pending { font-weight: 700; color: var(--warn); }

.compare { display: flex; flex-wrap: wrap; gap: 12px; }
.compare > figure { position: relative; flex: 1 1 280px; min-height: 0; flex-grow: 1; }
.compare figcaption { position: absolute; left: 12px; top: 8px; font-family: var(--font-mono); font-size: 13px; font-weight: 700; }
.compare .viewer { min-height: 260px; }
.compare svg { width: 100%; }

/* Capas */
.layers { border: 0; margin: 0; padding: 0; min-width: 0; }
.layers legend { padding: 0; margin-bottom: 8px; font-size: 18px; line-height: 24px; font-weight: 700; }
.layer { display: flex; align-items: center; gap: 8px; min-height: 36px; cursor: pointer; }
.layer input { width: 18px; height: 18px; margin: 0; accent-color: var(--navy); }

/* Resultados normativos */
.result { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 14px; }
.result:last-child { border-bottom: 0; }
.result.is-selected { background: var(--select-bg); }
.result-title { font-weight: 700; font-size: 15px; }
.result > .stack { min-width: 0; }

/* Asistente */
.chat-log { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.chat-log p { overflow-wrap: anywhere; }
.chat-user { color: var(--muted); font-size: 13px; }

.list-plain { padding-left: 18px; display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); }

.zoom { display: flex; align-items: center; gap: 8px; flex: none; }
.compare figcaption { z-index: 1; }

/* Proyecto nuevo */
.field-group.big label { font-size: 18px; line-height: 24px; font-weight: 700; color: var(--navy); }
.type-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); gap: 8px; }
.type-card {
  min-height: 68px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 2px;
  border: 2px solid var(--line-strong); border-radius: 4px;
  background: var(--panel); text-align: left; cursor: pointer;
}
.type-card:hover { border-color: var(--navy); }
.type-card[aria-pressed="true"] { border-color: var(--select); background: var(--select-bg); }
.type-name { font-weight: 700; }
.type-detail { font-size: 12px; line-height: 16px; color: var(--muted); }
.dropzone {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px;
  padding: 16px; border: 2px dashed var(--line-strong); border-radius: 4px; background: var(--panel);
}
.dropzone.is-over { border-color: var(--select); background: var(--select-bg); }
.file-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 170px 90px 80px; gap: 16px; align-items: center;
  padding: 8px 16px; border-bottom: 1px solid var(--line); font-size: 14px;
}
.file-row .field { height: 36px; width: 100%; }
.file-row .btn-quiet { min-height: 36px; }
.file-head { border-bottom-color: var(--line-strong); font-size: 12px; font-weight: 700; color: var(--muted); }
@media (max-width: 700px) { .file-row { grid-template-columns: minmax(0, 1fr) 130px; } .file-head > :nth-child(n+3) { display: none; } }
.file-row .badge { justify-self: start; }

/* Leyenda de estados del unifilar */
.legend-line.new { border-top-color: var(--select); }
.legend-line.mod { border-top-color: var(--warn); }
.legend-line.out { border-top: 2px dashed var(--line-strong); }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--warn); background: var(--warn-bg); }
.legend-box { border-color: var(--navy); background: var(--navy-bg); border-width: 1.5px; border-radius: 3px; }
.legend { gap: 8px 18px; }

/* Zoom dentro del lienzo, arriba a la derecha */
.viewer-tools { position: sticky; top: 8px; float: right; margin: 8px 8px 0 0; z-index: 1; background: var(--panel); border: 1px solid var(--line); border-radius: 2px; padding: 4px; }
.viewer-tools .btn { min-height: 36px; }
.viewer-tools .btn-icon { min-width: 36px; }
.viewer svg { clear: both; }
.compare .viewer { min-height: 200px; }

/* Salidas */
.export-row {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) 60px 120px; gap: 12px; align-items: center;
  padding: 6px 16px; border-bottom: 1px solid var(--line); font-size: 14px;
}
.export-row input { width: 18px; height: 18px; margin: 0; accent-color: var(--navy); }
.export-row label { cursor: pointer; }
.export-row .origin { display: block; font-size: 12px; line-height: 16px; color: var(--muted); }
.export-row .badge { justify-self: start; }
.export-head { border-bottom-color: var(--line-strong); font-size: 12px; font-weight: 700; color: var(--muted); padding: 8px 16px; }
.export-group { padding: 7px 16px; background: var(--paper); border-bottom: 1px solid var(--line); font-weight: 700; }
@media (max-width: 700px) { .export-row { grid-template-columns: 28px minmax(0, 1fr) 60px; } .export-row .badge, .export-head > :nth-child(4) { display: none; } }
