/* ── Reset & base ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Wise Athena design tokens ───────────────────── */
:root {
  --wa-teal:       #008ba8;
  --wa-teal-dark:  #006d85;
  --wa-teal-light: #e6f6f9;
  --wa-coral:      #f95f5b;
  --wa-coral-dark: #e0443f;
  --wa-navy:       #14213d;
  --wa-navy-mid:   #1e3250;
  --wa-ink:        #18181b;
  --wa-muted:      #aebcb9;
  --wa-bg:         #ffffff;
  --wa-surface:    #f7fbfc;
  --wa-border:     #e0edf0;
  --wa-radius-pill: 999px;
  --wa-radius-card: 12px;
  --wa-radius-btn:  999px;
  --wa-shadow-card: 0 2px 12px rgba(0,139,168,0.07), 0 1px 3px rgba(0,0,0,0.05);
  --wa-shadow-hover: 0 6px 24px rgba(0,139,168,0.13), 0 2px 6px rgba(0,0,0,0.07);
}

body {
  display: flex;
  min-height: 100vh;
  font-family: 'Raleway', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: var(--wa-ink);
  background: var(--wa-bg);
}

/* ── Sidebar ──────────────────────────────────────── */
.sidebar {
  width: 210px;
  min-height: 100vh;
  background: var(--wa-navy);
  color: #c8d8e4;
  flex-shrink: 0;
  padding: 1.5rem 0;
  border-right: 1px solid rgba(0,139,168,0.18);
}

.sidebar-logo {
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
  padding: 0 1.25rem 1.25rem;
  border-bottom: 1px solid rgba(0,139,168,0.25);
  margin-bottom: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar ul { list-style: none; }

.sidebar ul li a {
  display: block;
  padding: 0.55rem 1.25rem;
  color: #9bb4c1;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.sidebar ul li a:hover {
  background: rgba(0,139,168,0.12);
  color: #fff;
  border-left-color: var(--wa-teal);
}

/* ── Main content ─────────────────────────────────── */
.content {
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: 980px;
  background: var(--wa-bg);
}

/* ── Page header ──────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-header h1 { font-size: 1.6rem; font-weight: 800; color: var(--wa-ink); letter-spacing: -0.01em; }

.page-header .code-badge {
  font-family: monospace;
  font-size: 0.85rem;
  background: #e2e8f0;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  color: #475569;
}

/* ── Buttons ──────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 0.45rem 1.1rem;
  border-radius: var(--wa-radius-btn);
  border: none;
  cursor: pointer;
  font-family: 'Raleway', system-ui, sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
  transition: background 0.18s, box-shadow 0.18s, transform 0.12s;
}
.btn:active { transform: translateY(1px); }

.btn-primary   { background: var(--wa-coral); color: #fff; box-shadow: 0 2px 8px rgba(249,95,91,0.25); }
.btn-primary:hover { background: var(--wa-coral-dark); box-shadow: 0 4px 14px rgba(249,95,91,0.35); }
.btn-secondary { background: var(--wa-teal-light); color: var(--wa-teal-dark); border: 1px solid rgba(0,139,168,0.2); }
.btn-secondary:hover { background: #cceaf0; }
.btn-danger    { background: #fee2e2; color: #b91c1c; border-radius: var(--wa-radius-btn); }
.btn-danger:hover { background: #fecaca; }
.btn-ghost     { background: transparent; color: #64748b; padding: 0.2rem 0.5rem; border-radius: 6px; }
.btn-ghost:hover { color: var(--wa-navy); background: var(--wa-surface); }
.btn-sm        { padding: 0.22rem 0.7rem; font-size: 0.73rem; }

/* ── Cards / sections ─────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid var(--wa-border);
  border-radius: var(--wa-radius-card);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--wa-shadow-card);
  transition: box-shadow 0.2s;
}
.card:hover { box-shadow: var(--wa-shadow-hover); }

.section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  margin-bottom: 0.75rem;
}

/* ── Criteria list table ──────────────────────────── */
.criteria-table { width: 100%; border-collapse: collapse; }
.criteria-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  border-bottom: 2px solid #e2e8f0;
}
.criteria-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.criteria-table tr:last-child td { border-bottom: none; }
.criteria-table tr:hover td { background: #f8fafc; }
.criteria-table a { color: var(--wa-teal); text-decoration: none; font-weight: 500; }
.criteria-table a:hover { color: var(--wa-teal-dark); text-decoration: underline; }

/* ── Status badges ────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}
.badge-implemented { background: #dcfce7; color: #15803d; }
.badge-partial     { background: #fef9c3; color: #a16207; }
.badge-planned     { background: #f1f5f9; color: #475569; }
.badge-collected   { background: #dcfce7; color: #15803d; }
.badge-pending     { background: #fef9c3; color: #a16207; }
.badge-reviewed    { background: #dbeafe; color: #1d4ed8; }

/* ── Control & evidence items ─────────────────────── */
.control-item {
  border: 1px solid var(--wa-border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
  background: #fff;
  box-shadow: var(--wa-shadow-card);
}

.control-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}

.control-name { font-weight: 600; flex: 1; }
.control-owner { font-size: 0.75rem; color: #64748b; }

.evidence-list { margin-top: 0.5rem; padding-left: 1.2rem; }

.evidence-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0;
  border-bottom: 1px dashed #f1f5f9;
  font-size: 0.8rem;
}
.evidence-item:last-child { border-bottom: none; }
.evidence-item a { color: #2563eb; text-decoration: none; }
.evidence-item a:hover { text-decoration: underline; }

/* ── Policy chips ─────────────────────────────────── */
.policy-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.75rem; }
.policy-chip {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--wa-teal-light);
  border: 1px solid rgba(0,139,168,0.25);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  font-size: 0.78rem;
  color: var(--wa-teal-dark);
}
.policy-chip form { display: inline; }
.policy-chip button {
  background: none;
  border: none;
  cursor: pointer;
  color: #93c5fd;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0;
}
.policy-chip button:hover { color: #1d4ed8; }

/* ── Forms ────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.3rem;
}
.form-group input[type="text"],
.form-group input[type="url"],
.form-group input[type="date"],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  font-size: 0.85rem;
  background: #fff;
  color: #1a1a1a;
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--wa-teal);
  box-shadow: 0 0 0 3px rgba(0,139,168,0.15);
}
.form-group textarea { resize: vertical; min-height: 80px; }

.form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

/* ── Inline htmx forms ────────────────────────────── */
.htmx-form-container {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  padding: 1rem;
  margin-top: 0.5rem;
}

/* ── Policy select row ────────────────────────────── */
.add-policy-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.5rem;
}
.add-policy-row select { flex: 1; }

/* ── Utils ────────────────────────────────────────── */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.text-muted { color: #64748b; font-size: 0.8rem; }
.status-icon { font-size: 1rem; }

/* ── Reports index ────────────────────────────────── */
.subtitle { color: #64748b; margin-bottom: 1.5rem; }

.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.report-card {
  background: #fff;
  border: 1px solid var(--wa-border);
  border-radius: var(--wa-radius-card);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: var(--wa-shadow-card);
  transition: box-shadow 0.2s;
}
.report-card:hover { box-shadow: var(--wa-shadow-hover); }

.report-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.report-card-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
}

.report-icon { font-size: 1.25rem; }

.report-card p { font-size: 0.85rem; color: #475569; }

.report-audience {
  font-size: 0.75rem !important;
  color: #94a3b8 !important;
  font-style: italic;
}

.report-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.btn-secondary {
  background: var(--wa-teal-light);
  color: var(--wa-teal-dark);
  border: 1px solid rgba(0,139,168,0.2);
}

.btn-secondary:hover { background: #cceaf0; }

/* ── Auth: login page ─────────────────────────────── */
.content--fullwidth {
  max-width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 5vh;
  background: #f1f5f9;
  min-height: 100vh;
}

.auth-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 2rem 1rem;
}

.auth-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 4px 16px rgba(0,0,0,.06);
}

.auth-logo {
  font-size: 1.3rem;
  font-weight: 800;
  color: #1e293b;
  letter-spacing: .04em;
  margin-bottom: 1.75rem;
  text-align: center;
}

.auth-section { margin-bottom: 1rem; }

.auth-section-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #64748b;
  margin-bottom: .75rem;
}

.auth-hint { font-size: 0.85rem; color: #475569; margin-bottom: .75rem; }

.auth-form .form-group { margin-bottom: .75rem; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 1.25rem 0;
  color: #94a3b8;
  font-size: 0.8rem;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid #e2e8f0;
}

.auth-alert {
  border-radius: 6px;
  padding: .75rem 1rem;
  font-size: .85rem;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}
.auth-alert--error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.auth-alert--success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }

/* Botón de Google */
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  width: 100%;
  padding: .6rem 1rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #1a1a1a;
  font-size: .875rem;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, border-color .15s;
}
.btn-google:hover { background: #f8fafc; border-color: #94a3b8; }

/* ── Auth: sidebar user info ──────────────────────── */
.sidebar-user {
  border-top: 1px solid #334155;
  margin-top: auto;
  padding: 1rem 1.25rem .5rem;
  position: absolute;
  bottom: 0;
  left: 0;
  width: 200px;
}

.sidebar { position: relative; padding-bottom: 5.5rem; }

.sidebar-user-name {
  font-size: .8rem;
  font-weight: 600;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-email {
  font-size: .72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: .1rem;
}

.sidebar-logout {
  display: block;
  margin-top: .5rem;
  font-size: .75rem;
  color: #94a3b8;
  text-decoration: none;
}
.sidebar-logout:hover { color: #f87171; }

/* ── Badges ───────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 600;
}
.badge-admin    { background: #dbeafe; color: #1d4ed8; }
.badge-readonly { background: #f1f5f9; color: #475569; }
.badge-active   { background: #dcfce7; color: #166534; }
.badge-inactive { background: #fee2e2; color: #991b1b; }

/* ── Data table ───────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.data-table th {
  text-align: left;
  padding: .5rem .75rem;
  background: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
  font-weight: 600;
  color: #475569;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.data-table td {
  padding: .6rem .75rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.data-table tr:hover td { background: #f8fafc; }
.row-inactive td { opacity: .55; }

/* ── Alert banners ────────────────────────────────── */
.alert {
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.alert-warning {
  background: #fef9c3;
  border: 1px solid #fde047;
  color: #854d0e;
}

/* ── Compliance calendar ──────────────────────────── */
.cal-table { min-width: 100%; }

.cal-header {
  font-size: 0.7rem;
  padding: 0.3rem 0.4rem;
  text-align: center;
  white-space: nowrap;
  min-width: 2.5rem;
}

.cal-cell {
  text-align: center;
  padding: 0.25rem 0.3rem;
  font-size: 0.8rem;
}

.cal-cell.ok      { background: #dcfce7; color: #15803d; }
.cal-cell.missing { background: #fee2e2; color: #b91c1c; }
.cal-cell.future  { background: #f8fafc; color: #94a3b8; }

/* ── Breadcrumb ───────────────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: #64748b;
  margin-bottom: 1rem;
}
.breadcrumb a { color: var(--wa-teal); text-decoration: none; font-weight: 500; }
.breadcrumb a:hover { color: var(--wa-teal-dark); text-decoration: underline; }
.bc-sep { color: #cbd5e1; }

/* ── Edit page layout ─────────────────────────────────────────────── */
.edit-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 900px) {
  .edit-layout { grid-template-columns: 1fr; }
  .edit-sidebar { order: -1; }
}

.edit-main { min-width: 0; }

.edit-sidebar .card { position: sticky; top: 1rem; }

/* ── Form section labels ──────────────────────────────────────────── */
.form-section-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: 0.6rem;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 0.3rem;
}

/* ── Form row (side by side) ──────────────────────────────────────── */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

/* ── Field hint text ──────────────────────────────────────────────── */
.field-hint {
  font-size: 0.72rem;
  color: #94a3b8;
  margin: 0.25rem 0 0;
}

/* ── Sidebar meta ─────────────────────────────────────────────────── */
.sidebar-meta-title {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: 0.3rem;
}

/* ── Home hero ────────────────────────────────────────────────────── */
.home-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.home-hero h1 { font-size: 1.75rem; font-weight: 800; color: var(--wa-ink); letter-spacing: -0.01em; }
.home-hero .subtitle { font-size: 0.85rem; color: #64748b; margin-top: 0.25rem; }

.readiness-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  flex-shrink: 0;
}
.readiness-badge .readiness-pct { font-size: 1.5rem; font-weight: 800; line-height: 1; }
.readiness-badge .readiness-label { font-size: 0.62rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.readiness-green  { background: #dcfce7; color: #15803d; border: 3px solid #86efac; }
.readiness-yellow { background: #fef9c3; color: #a16207; border: 3px solid #fde047; }
.readiness-red    { background: #fee2e2; color: #b91c1c; border: 3px solid #fca5a5; }

/* ── KPI Grid ─────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 900px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .kpi-grid { grid-template-columns: 1fr; } }

.kpi-card {
  background: #fff;
  border: 1px solid var(--wa-border);
  border-radius: var(--wa-radius-card);
  padding: 1rem 1.1rem;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  box-shadow: var(--wa-shadow-card);
  transition: box-shadow 0.2s;
}
.kpi-card:hover { box-shadow: var(--wa-shadow-hover); }
.kpi-card-alert {
  border-color: #fca5a5;
  background: #fff5f5;
}

.kpi-icon { font-size: 1.5rem; line-height: 1; flex-shrink: 0; padding-top: 0.15rem; }

.kpi-body { flex: 1; min-width: 0; }

.kpi-value {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1;
  color: #0f172a;
}
.kpi-value-red { color: #dc2626; }
.kpi-total { font-size: 1rem; font-weight: 400; color: #94a3b8; margin-left: 0.15rem; }

.kpi-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #374151;
  margin: 0.2rem 0 0.3rem;
}

.kpi-sub { font-size: 0.72rem; }
.kpi-ok   { color: #15803d; }
.kpi-warn { color: #b45309; }
.kpi-bad  { color: #b91c1c; }

/* ── Semáforo list ────────────────────────────────────────────────── */
.semaphore-list { display: flex; flex-direction: column; gap: 0; }

.semaphore-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.5rem;
  border-radius: 5px;
  text-decoration: none;
  color: inherit;
  transition: background 0.12s;
}
.semaphore-row:hover { background: #f8fafc; }

.semaphore-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-green  { background: #22c55e; }
.dot-yellow { background: #eab308; }
.dot-red    { background: #ef4444; }

.semaphore-code { font-size: 0.72rem; font-weight: 700; color: #1e293b; width: 4.5rem; flex-shrink: 0; }
.semaphore-name { font-size: 0.78rem; color: #475569; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.semaphore-meta { font-size: 0.68rem; color: #94a3b8; flex-shrink: 0; }

/* ── Distribution bar ─────────────────────────────────────────────── */
.dist-bar {
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  background: #f1f5f9;
  margin-bottom: 0.6rem;
}
.dist-seg { height: 100%; transition: width 0.3s; }
.dist-implemented { background: #22c55e; }
.dist-partial     { background: #eab308; }
.dist-planned     { background: #e2e8f0; }

.dist-legend { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.dist-legend-item { font-size: 0.7rem; color: #64748b; display: flex; align-items: center; gap: 0.3rem; }
.dist-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ── Quick links ──────────────────────────────────────────────────── */
.quick-links { display: flex; flex-direction: column; gap: 0.1rem; }

.quick-link {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--wa-navy);
  font-size: 0.8rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.quick-link:hover { background: var(--wa-teal-light); color: var(--wa-teal-dark); }
.quick-link-icon { font-size: 1rem; flex-shrink: 0; }

/* ── Tags: chips ──────────────────────────────────────────────────── */
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--wa-teal-light);
  border: 1px solid rgba(0,139,168,0.25);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--wa-teal-dark);
  white-space: nowrap;
  cursor: default;
}
.tag-chip-sm {
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
}
.tag-chip-active {
  background: var(--wa-teal);
  color: #fff;
  border-color: var(--wa-teal);
}
.tag-chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: #60a5fa;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
}
.tag-chip-remove:hover { color: #1e40af; }

/* ── Tags: input area ─────────────────────────────────────────────── */
.tag-input-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  background: #fff;
  cursor: text;
  min-height: 2.25rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.tag-input-wrap:focus-within {
  border-color: var(--wa-teal);
  box-shadow: 0 0 0 3px rgba(0,139,168,0.15);
}
.tag-chips { display: contents; }

.tag-text-input {
  border: none;
  outline: none;
  flex: 1;
  min-width: 120px;
  font-size: 0.85rem;
  background: transparent;
  padding: 0;
}

/* ── Tags: autocomplete dropdown ──────────────────────────────────── */
.tag-suggestions {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  margin-top: 0.25rem;
  overflow: hidden;
  position: relative;
  z-index: 100;
}
.tag-suggestion-item {
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  cursor: pointer;
  color: #1e293b;
  transition: background 0.1s;
}
.tag-suggestion-item:hover,
.tag-suggestion-item:focus { background: #eff6ff; color: #1e40af; }

/* ── Tags: search form ────────────────────────────────────────────── */
.tag-search-form { margin-bottom: 0; }
.tag-search-wrap {
  display: flex;
  align-items: center;
}
.tag-search-input {
  flex: 1;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.tag-search-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

/* ── Tags: top-tags sidebar ───────────────────────────────────────── */
.tag-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.5rem;
  border-radius: 5px;
  transition: background 0.12s;
  color: #1e293b;
}
.tag-top-row:hover { background: #f1f5f9; }
.tag-top-row-active { background: #eff6ff; }
.tag-top-name { font-size: 0.8rem; font-weight: 500; }
.tag-top-count {
  font-size: 0.7rem;
  background: #e2e8f0;
  color: #475569;
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  font-weight: 600;
}

/* ── Tags: selected row highlight ────────────────────────────────── */
.tag-row-selected td { background: #f0f7ff; }

/* ── kbd ──────────────────────────────────────────────────────────── */
kbd {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  font-size: 0.7rem;
  font-family: monospace;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  background: #f8fafc;
  color: #475569;
}

/* ── Policy card list ─────────────────────────────────────────────────────── */
.policy-card-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.policy-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  transition: box-shadow 0.15s;
}
.policy-card:hover {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.07);
}

.policy-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.policy-card-title-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-width: 0;
}

.policy-card-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--wa-teal);
  text-decoration: none;
}
.policy-card-name:hover {
  text-decoration: underline;
  color: var(--wa-teal-dark);
}

.policy-card-date {
  font-size: 0.75rem;
  color: #94a3b8;
}

.policy-card-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.policy-card-desc {
  font-size: 0.83rem;
  color: #475569;
  line-height: 1.55;
  margin: 0;
}

.policy-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-top: 0.4rem;
  border-top: 1px solid #f1f5f9;
}

.policy-card-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.policy-card-meta-label {
  font-size: 0.72rem;
  color: #94a3b8;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.policy-card-tags {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

/* ── Related policies: list card ──────────────────────────────────────────── */
.policy-card-related {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  padding-top: 0.35rem;
  border-top: 1px dashed #e2e8f0;
  font-size: 0.78rem;
}
.policy-related-link {
  color: #3b82f6;
  text-decoration: none;
  font-weight: 500;
}
.policy-related-link:hover {
  text-decoration: underline;
}

/* ── Related policies: form widget ───────────────────────────────────────── */
.related-policy-list {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.35rem 0.25rem;
  background: #fafafa;
}
.related-policy-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 0.6rem;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.1s;
  user-select: none;
}
.related-policy-item:hover {
  background: #f1f5f9;
}
.related-policy-item-checked {
  background: #eff6ff;
}
.related-policy-item input[type=checkbox] {
  accent-color: #3b82f6;
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
.related-policy-name {
  font-size: 0.83rem;
  color: #1e293b;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Trends: contenedor de tarjeta ───────────────────────────────────────── */
.trend-card {
  margin-bottom: 1.25rem;
}
.trend-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.trend-card-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #334155;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.trend-legend {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.tl-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: #64748b;
}
.tl-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Trends: gráfico SVG de líneas ───────────────────────────────────────── */
.trend-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

/* ── Trends: gráfico de semáforo (barras apiladas) ───────────────────────── */
.traffic-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 140px;
  padding-bottom: 20px; /* espacio etiquetas */
  position: relative;
}
.traffic-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  min-width: 0;
}
.traffic-bar {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column-reverse; /* rojo abajo, verde arriba */
  border-radius: 3px 3px 0 0;
  overflow: hidden;
  cursor: default;
}
.traffic-seg { width: 100%; transition: height 0.3s; }
.seg-green  { background: #22c55e; }
.seg-yellow { background: #eab308; }
.seg-red    { background: #ef4444; }
.traffic-label {
  font-size: 7px;
  color: #94a3b8;
  margin-top: 3px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  max-width: 100%;
}

/* ── Trends: gráfico de brechas (barras simples) ─────────────────────────── */
.gaps-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 120px;
  padding-bottom: 20px;
}
.gaps-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  min-width: 0;
}
.gaps-bar-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  cursor: default;
}
.gaps-bar {
  width: 100%;
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  transition: height 0.3s;
}
.gaps-bar-ok   { background: #22c55e; }
.gaps-bar-warn { background: #f59e0b; }
.gaps-bar-bad  { background: #ef4444; }
.gaps-label {
  font-size: 7px;
  color: #94a3b8;
  margin-top: 3px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  max-width: 100%;
}

/* ── Trends: tabla histórica ─────────────────────────────────────────────── */
.trends-table td,
.trends-table th {
  font-size: 0.8rem;
  padding: 0.45rem 0.6rem;
}
.trend-pct-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.78rem;
}
.tpb-green  { background: #dcfce7; color: #166534; }
.tpb-yellow { background: #fef9c3; color: #854d0e; }
.tpb-red    { background: #fee2e2; color: #991b1b; }

/* ══════════════════════════════════════════════════════════════════════════
   Versiones y comentarios de políticas
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Version badge (lista) ─────────────────────────────────────────────── */
.version-badge-sm {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.45rem;
  border-radius: var(--wa-radius-pill);
  background: var(--wa-teal-light);
  color: var(--wa-teal-dark);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* ── Badge comentarios abiertos (lista) ────────────────────────────────── */
.badge-comments-open {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.1rem 0.5rem;
  border-radius: var(--wa-radius-pill);
  background: #fff0f0;
  color: var(--wa-coral-dark);
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid #fccaca;
}

/* ── Version badge (detalle) ───────────────────────────────────────────── */
.version-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.7rem;
  border-radius: var(--wa-radius-pill);
  background: var(--wa-teal-light);
  color: var(--wa-teal-dark);
  font-size: 0.82rem;
  font-weight: 700;
  margin-left: 0.5rem;
  vertical-align: middle;
}

/* ── Detail card ───────────────────────────────────────────────────────── */
.detail-card { padding: 1.25rem 1.5rem; }
.detail-grid { display: flex; flex-direction: column; gap: 0.55rem; margin-bottom: 1rem; }
.detail-row  { display: flex; gap: 0.75rem; align-items: flex-start; flex-wrap: wrap; }
.detail-label {
  min-width: 130px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--wa-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-top: 0.1rem;
}
.detail-description {
  margin-top: 0.75rem;
  color: var(--wa-ink);
  font-size: 0.9rem;
  line-height: 1.6;
  border-top: 1px solid var(--wa-border);
  padding-top: 0.75rem;
}

/* ── Version card ──────────────────────────────────────────────────────── */
.version-card { padding: 1rem 1.5rem; }
.version-current { margin: 0.25rem 0 0.75rem; font-size: 0.9rem; color: var(--wa-ink); }
.version-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* ── Sección comentarios ───────────────────────────────────────────────── */
.comments-header { margin-bottom: 1rem; }
.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--wa-navy);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.badge-open-count {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: var(--wa-radius-pill);
  background: #fff0f0;
  color: var(--wa-coral-dark);
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid #fccaca;
}
.badge-resolved-count {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: var(--wa-radius-pill);
  background: #f0fdf4;
  color: #166534;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid #bbf7d0;
}

/* ── Add comment wrap ──────────────────────────────────────────────────── */
.add-comment-wrap {
  margin-bottom: 1.25rem;
}
.add-comment-wrap summary { list-style: none; }
.add-comment-wrap summary::-webkit-details-marker { display: none; }
.add-comment-wrap .comment-form {
  margin-top: 0.75rem;
  padding: 1rem;
  background: var(--wa-surface);
  border-radius: var(--wa-radius-card);
  border: 1px solid var(--wa-border);
}

/* ── Comment list ──────────────────────────────────────────────────────── */
.comment-list { display: flex; flex-direction: column; gap: 0.75rem; }
.comment-list-resolved { margin-top: 0.5rem; opacity: 0.75; }

.comment-thread {}

.comment-root {
  border-radius: var(--wa-radius-card);
  padding: 0.85rem 1rem;
  border: 1px solid var(--wa-border);
}
.comment-open     { border-left: 3px solid var(--wa-coral); background: #fffbfb; }
.comment-resolved { border-left: 3px solid #86efac;         background: var(--wa-surface); }

.comment-meta {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
  font-size: 0.78rem;
  color: var(--wa-muted);
}
.comment-author    { font-weight: 700; color: var(--wa-navy); }
.comment-dot       { color: var(--wa-border); }
.comment-version-at { font-style: italic; }
.comment-body      { font-size: 0.88rem; color: var(--wa-ink); line-height: 1.55; margin: 0; }

.comment-status {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.45rem;
  border-radius: var(--wa-radius-pill);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.comment-status-open     { background: #fff0f0; color: var(--wa-coral-dark); border: 1px solid #fccaca; }
.comment-status-resolved { background: #f0fdf4; color: #166534;              border: 1px solid #bbf7d0; }

.comment-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

/* ── Replies ───────────────────────────────────────────────────────────── */
.reply-list {
  margin-top: 0.65rem;
  margin-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border-left: 2px solid var(--wa-border);
  padding-left: 0.85rem;
}
.comment-reply {
  background: var(--wa-surface);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
}

/* ── Reply form ────────────────────────────────────────────────────────── */
.reply-form {
  margin-top: 0.65rem;
  margin-left: 1.25rem;
  padding: 0.75rem;
  background: var(--wa-surface);
  border-radius: 8px;
  border: 1px solid var(--wa-border);
}
.reply-form .form-group { margin-bottom: 0.4rem; }
.reply-form input, .reply-form textarea {
  width: 100%;
  font-size: 0.85rem;
  padding: 0.35rem 0.6rem;
}

/* ── Resolved section toggle ───────────────────────────────────────────── */
.resolved-section { margin-top: 1rem; }
.resolved-toggle {
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--wa-muted);
  user-select: none;
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.resolved-toggle::-webkit-details-marker { display: none; }

/* ── Extra btn sizes ───────────────────────────────────────────────────── */
.btn-xs {
  padding: 0.15rem 0.5rem;
  font-size: 0.73rem;
}
