:root {
  --brand: #0176d3;
  --brand-dark: #014486;
  --brand-tint: #f0f8ff;
  --page-bg: #f3f3f3;
  --panel: #ffffff;
  --border: #e5e5e5;
  --border-strong: #dddbda;
  --text: #181818;
  --text-muted: #706e6b;
  --text-faint: #a8a8a8;
  --success: #04844b;
  --success-bg: #e6f6ec;
  --warning: #a35200;
  --warning-bg: #fff2e0;
  --error: #ba0517;
  --error-bg: #fdecee;
  --neutral: #514f4d;
  --neutral-bg: #f3f2f2;
  --follow: #b8860b;
  --follow-bg: #fdf4e0;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --panel-w: 340px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--page-bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 14px;
}

.icon { width: 18px; height: 18px; vertical-align: middle; }

/* ---------- Global header ---------- */
.ghdr {
  height: 52px;
  background: var(--panel);
  border-bottom: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.applogo { display: flex; align-items: center; gap: 10px; }
.applogo-icon {
  width: 32px; height: 32px;
  background: var(--brand);
  color: #fff;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
}
.applogo-name { font-weight: 700; font-size: 16px; color: var(--text); }

.ghdr-search {
  flex: 1;
  max-width: 560px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--neutral-bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0 10px;
  height: 32px;
  color: var(--text-muted);
}
.ghdr-search input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 13px;
  color: var(--text);
}

.ghdr-right { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.org-chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--brand-tint);
  border: 1px solid #cfe6fb;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}
.org-label { color: var(--brand-dark); font-weight: 600; }
.org-value { color: var(--brand-dark); font-weight: 700; }

.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: #5f4b8b;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: calc(100vh - 52px); }

.navrail {
  width: 56px;
  background: var(--panel);
  border-right: 1px solid var(--border-strong);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-top: 12px;
}
.navrail-item {
  width: 40px; height: 40px;
  border: none;
  background: transparent;
  border-radius: var(--radius);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.navrail-item svg { width: 20px; height: 20px; }
.navrail-item:hover { background: var(--neutral-bg); }
.navrail-item.is-active { background: var(--brand-tint); color: var(--brand); }

.content { flex: 1; padding: 20px 28px 48px; max-width: 1400px; }

.crumb { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.crumb span { color: var(--text); font-weight: 600; }

/* ---------- Page header ---------- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}
.page-header-titles h1 { margin: 0 0 4px; font-size: 22px; font-weight: 700; }
.page-header-sub { margin: 0; color: var(--text-muted); font-size: 12.5px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: var(--radius);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
}
.btn:hover { background: var(--neutral-bg); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover { background: var(--brand-dark); }

.btn-star { color: #7c3aed; border-color: #ddd0f8; }
.btn-star:hover { background: #f6f1fe; }
.btn-star.is-active { background: #7c3aed; border-color: #7c3aed; color: #fff; }

.btn-tema { color: var(--brand-dark); border-color: #cfe6fb; font-size: 12.5px; padding: 7px 14px; }
.btn-tema:hover { background: var(--brand-tint); }
.btn-tema.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- Highlights panel ---------- */
.highlights {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.tile {
  background: var(--panel);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tile-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; }
.tile-value { font-size: 22px; font-weight: 700; color: var(--text); }
.tile-value.tile-accent { color: var(--brand); }
.tile-value.tile-follow { color: var(--follow); }
.tile-value.tile-star { color: #7c3aed; }
.tile-value.tile-small { font-size: 14px; font-weight: 600; }

/* ---------- Rubros bar ---------- */
.rubros-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.rubro-chip {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--text-muted);
}
.rubro-chip strong { color: var(--text); }

/* ---------- List view toolbar ---------- */
.listview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 10px;
}
.toolbar-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.listview-count { color: var(--text-muted); font-size: 12.5px; }

.filters-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
}

.active-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.active-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--brand-tint);
  border: 1px solid #cfe6fb;
  color: var(--brand-dark);
  border-radius: 999px;
  padding: 4px 6px 4px 10px;
  font-size: 12px;
}
.active-chip button {
  border: none;
  background: transparent;
  color: var(--brand-dark);
  cursor: pointer;
  display: flex;
  padding: 0;
}
.active-chip svg { width: 12px; height: 12px; }

/* ---------- Filter panel (slide-out) ---------- */
.panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.25);
  z-index: 29;
}

.filter-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: var(--panel-w);
  max-width: 90vw;
  background: var(--panel);
  border-left: 1px solid var(--border-strong);
  box-shadow: -4px 0 16px rgba(0,0,0,0.12);
  z-index: 30;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .2s ease;
}
.filter-panel.is-open { transform: translateX(0); }

.filter-panel-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-strong);
}
.filter-panel-hdr h2 { margin: 0; font-size: 16px; }

.icon-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  width: 28px; height: 28px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.icon-btn:hover { background: var(--neutral-bg); }
.icon-btn svg { width: 16px; height: 16px; }

.filter-panel-body { flex: 1; overflow-y: auto; padding: 4px 20px 20px; }

.fp-section { padding: 14px 0; border-bottom: 1px solid var(--border); }
.fp-section:last-child { border-bottom: none; }
.fp-section h3 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); font-weight: 700; }

.fp-checklist { display: flex; flex-direction: column; gap: 8px; max-height: 180px; overflow-y: auto; }
.fp-checklist label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.fp-checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 10px; cursor: pointer; }

.fp-input {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text);
}

.fp-range { display: flex; align-items: center; gap: 8px; }
.fp-range input {
  flex: 1;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 7px 8px;
  font-size: 12.5px;
  color: var(--text);
}
.fp-range span { color: var(--text-faint); }

.fp-quick-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip-btn {
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}
.chip-btn:hover { background: var(--neutral-bg); }
.chip-btn.is-active { background: var(--brand); border-color: var(--brand); color: #fff; }

.filter-panel-ftr {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-strong);
}
.filter-panel-ftr .btn { flex: 1; justify-content: center; }

/* ---------- List view table ---------- */
.listview-wrap {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}

table.listview { width: 100%; border-collapse: collapse; font-size: 13px; }

table.listview thead th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-muted);
  font-weight: 700;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-strong);
  background: #fafafa;
  white-space: nowrap;
}

table.listview tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

table.listview tbody tr:hover { background: var(--brand-tint); }
table.listview tbody tr:last-child td { border-bottom: none; }

.col-title { min-width: 260px; }
.col-num { text-align: right; }
.col-link { width: 36px; }
.col-track { width: 168px; }

.track-cell { display: flex; align-items: center; gap: 6px; }
.star-btn {
  border: none;
  background: transparent;
  color: var(--text-faint);
  width: 26px; height: 26px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.star-btn:hover { background: var(--follow-bg); color: var(--follow); }
.star-btn.is-active { color: var(--follow); }
.star-btn svg { width: 17px; height: 17px; }

.etapa-select {
  flex: 1;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 5px 6px;
  font-size: 12px;
  color: var(--text);
}
.etapa-select.has-etapa { border-color: var(--follow); color: var(--follow); background: var(--follow-bg); }

.row-title { font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; }
.row-code { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.row-match {
  font-size: 11.5px;
  color: var(--brand-dark);
  background: var(--brand-tint);
  border-radius: 4px;
  padding: 3px 7px;
  margin-top: 6px;
  display: inline-block;
}
.match-more {
  border: none;
  background: transparent;
  color: var(--brand-dark);
  text-decoration: underline;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  padding: 0 0 0 4px;
}
.row-match-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.row-match-list li {
  font-size: 11.5px;
  color: var(--brand-dark);
  background: var(--brand-tint);
  border-radius: 4px;
  padding: 3px 7px;
  width: fit-content;
}
.row-inst { color: var(--text-muted); }
.row-amount { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-date { white-space: nowrap; color: var(--text-muted); }

.pill {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .02em;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.pill-new { background: var(--brand-tint); color: var(--brand-dark); border: 1px solid #b9dcf7; }
.pill-star { background: #f6f1fe; color: #7c3aed; border: 1px solid #ddd0f8; }
.pill-service { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.pill-hardware { background: #f8fafc; color: #475569; border: 1px solid #cbd5e1; }

.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 4px;
  white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-error { background: var(--error-bg); color: var(--error); }
.badge-neutral { background: var(--neutral-bg); color: var(--neutral); }

.link-out {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 4px;
  color: var(--text-muted);
}
.link-out:hover { background: var(--neutral-bg); color: var(--brand); }
.link-out svg { width: 16px; height: 16px; }

.empty { text-align: center; color: var(--text-muted); padding: 60px 20px; font-size: 13px; }
.hidden { display: none; }

@media (max-width: 900px) {
  .highlights { grid-template-columns: repeat(2, 1fr); }
  .ghdr-search { display: none; }
}

/* ---------------- Auth / PIN Overlay ---------------- */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.25s ease-out;
}
.auth-overlay.hidden {
  display: none !important;
}
.hidden {
  display: none !important;
}

.auth-card {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  width: 100%;
  max-width: 380px;
  padding: 32px 28px;
  text-align: center;
  border: 1px solid #e2e8f0;
}

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}
.auth-logo h2 {
  font-size: 20px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}
.auth-subtitle {
  font-size: 13px;
  color: #64748b;
  margin: 0 0 24px;
}

.auth-field {
  text-align: left;
  margin-bottom: 18px;
}
.auth-field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}
.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.auth-input-wrap input {
  width: 100%;
  height: 42px;
  padding: 0 40px 0 14px;
  font-size: 14px;
  border: 1.5px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  color: #0f172a;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-input-wrap input:focus {
  border-color: var(--brand);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(1, 118, 211, 0.15);
}
.toggle-pin-btn {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}
.toggle-pin-btn:hover { color: #475569; }

.auth-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  font-size: 12.5px;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 16px;
  text-align: left;
}

.auth-btn {
  width: 100%;
  height: 42px;
  font-size: 14px;
  font-weight: 600;
  justify-content: center;
}

.logout-btn {
  background: none;
  border: 1px solid transparent;
  color: rgba(255, 255, 255, 0.75);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  margin-left: 4px;
}
.logout-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}

