:root {
  --brand: #b0872d;
  --brand-soft: #f6efde;
  --brand-dark: #8e6b1f;

  --bg:        #ffffff;
  --bg-soft:   #f8f9fb;
  --bg-sidebar:#fbfbfa;
  --line:      #e6e7ea;
  --line-soft: #eef0f3;
  --ink:       #1f2328;
  --ink-2:     #3c4149;
  --muted:     #6b7280;
  --muted-2:   #9aa0a6;

  --green:    #137333;
  --green-bg: #e6f4ea;
  --red:      #b3261e;
  --red-bg:   #fce8e6;

  --radius:    14px;
  --radius-sm: 10px;
  --radius-pill: 999px;

  --shadow-1: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.04);
  --shadow-2: 0 4px 16px rgba(16,24,40,.06);

  --sidebar-w: 256px;
  --topbar-h:  64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
[hidden] { display: none !important; }
body {
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg-soft);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
h1 { font-size: 22px; }
h3 { font-size: 15px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------- Layout ---------- */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}
html, body { overflow-x: clip; }
#sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--line);
}
.main { display: flex; flex-direction: column; min-width: 0; }
.content > section { min-width: 0; }
.year-table-wrap { max-width: 100%; }
#topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--topbar-h);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.content {
  padding: 28px 36px 56px;
  max-width: 1480px;
  width: 100%;
}

/* ---------- Sidebar ---------- */
.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 18px 14px;
  gap: 14px;
}
.brand {
  display: flex;
  align-items: center;
  padding: 6px 8px 4px;
}
.brand img {
  height: 20px;
  width: auto;
  object-fit: contain;
  display: block;
}
.sidebar-cta {
  margin: 4px 0 8px;
  width: 100%;
  height: 38px;
  padding: 0 12px;
  font-size: 13.5px;
  justify-content: flex-start;
  gap: 12px;
}
.btn-block { width: 100%; }

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
  flex: 1;
}
.nav-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted-2);
  padding: 14px 12px 6px;
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-pill);
  color: var(--ink-2);
  font-weight: 500;
  font-size: 13.5px;
  transition: background .12s ease;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--muted); }
.nav-item:hover { background: #eef0f3; }
.nav-item.active {
  background: var(--brand-soft);
  color: var(--brand-dark);
}
.nav-item.active svg { color: var(--brand-dark); }
.nav-toggle {
  border: 0;
  width: 100%;
  text-align: left;
  font: inherit;
  cursor: pointer;
  background: transparent;
}
.nav-toggle .nav-chev {
  margin-left: auto;
  color: var(--muted);
  transition: transform .15s;
}
.nav-toggle.open .nav-chev { transform: rotate(180deg); }
.nav-sub {
  display: flex; flex-direction: column;
  padding: 2px 0 6px 36px;
  gap: 1px;
}
.nav-sub a {
  display: block;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-2);
}
.nav-sub a:hover { background: #eef0f3; }
.nav-sub a.active { color: var(--brand-dark); background: var(--brand-soft); }
.nav-sub a.danger { color: var(--red); }
.nav-sub a.danger:hover { background: var(--red-bg); }
.nav-item .badge {
  margin-left: auto;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 11px;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  color: var(--muted);
  font-weight: 600;
}
.sidebar-foot { padding: 8px 6px 4px; }
.storage { display: flex; flex-direction: column; gap: 6px; }
.storage-bar {
  height: 6px;
  background: var(--line-soft);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.storage-bar span {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: inherit;
}

/* ---------- Topbar ---------- */
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 100%;
  padding: 0 28px;
}
.search {
  flex: 1;
  max-width: 540px;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 14px;
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  transition: background .12s, border-color .12s;
}
.search:focus-within {
  background: #fff;
  border-color: var(--line);
  box-shadow: var(--shadow-1);
}
.search svg { color: var(--muted); }
.search input {
  flex: 1;
  border: 0;
  background: transparent;
  outline: none;
  font: inherit;
  color: var(--ink);
}
.search kbd {
  font-family: inherit;
  font-size: 11px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 6px;
  color: var(--muted);
}
.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.icon-btn {
  position: relative;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  display: grid;
  place-items: center;
}
.icon-btn:hover { background: var(--bg-soft); }
.notif-wrap { position: relative; }
.notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 360px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  z-index: 2000;
  display: none;
  overflow: hidden;
}
.notif-wrap.open .notif-panel { display: block; }
.notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.notif-head b { font-size: 13.5px; }
.notif-head a { font-size: 12px; color: var(--brand-dark); font-weight: 600; }
.notif-list {
  list-style: none; margin: 0; padding: 4px;
  max-height: 380px;
  overflow-y: auto;
  display: flex; flex-direction: column;
}
.notif-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  position: relative;
}
.notif-list li:hover { background: var(--bg-soft); }
.notif-list li.unread { background: rgba(176,135,45,0.06); }
.notif-list .n-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.notif-list .n-icon.green { background: var(--green-bg); color: var(--green); }
.notif-list .n-icon.red   { background: var(--red-bg);   color: var(--red); }
.notif-list .n-icon.amber { background: #fef3c7;        color: #a16207; }
.notif-list .n-icon.brand { background: var(--brand-soft); color: var(--brand-dark); }
.notif-list .n-icon.grey  { background: var(--bg-soft); color: var(--muted); }
.notif-list .n-text { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.notif-list .n-text b { font-size: 13px; }
.notif-list .n-text span { font-size: 12px; color: var(--ink-2); }
.notif-list .n-text .muted { color: var(--muted); margin-top: 2px; }
.notif-list .n-dot {
  width: 8px; height: 8px;
  background: var(--brand);
  border-radius: 50%;
  flex-shrink: 0;
}
.notif-foot {
  display: block;
  text-align: center;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  color: var(--brand-dark);
  font-size: 12.5px;
  font-weight: 600;
  background: var(--bg-soft);
}
.notif-foot:hover { background: #eef0f3; }

.icon-btn .dot {
  position: absolute;
  top: 9px; right: 10px;
  width: 7px; height: 7px;
  background: var(--brand);
  border-radius: 50%;
  border: 2px solid #fff;
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 12px 4px 4px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: #fff;
}
.user-chip { position: relative; cursor: pointer; }
.user-chip:hover { background: var(--bg-soft); }
.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: var(--shadow-2);
  z-index: 2000;
  display: none;
}
.user-chip.open .user-menu { display: block; }
.user-menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-pill);
  background: transparent;
  border: 0;
  font: 500 13px Inter, system-ui, sans-serif;
  color: var(--ink-2);
  cursor: pointer;
  text-align: left;
}
.user-menu-item svg { color: var(--muted); flex-shrink: 0; }
.user-menu-item:hover { background: var(--bg-soft); color: var(--ink); }
.user-menu-item.danger { color: var(--red); }
.user-menu-item.danger svg { color: var(--red); }
.user-menu-item.danger:hover { background: var(--red-bg); }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 600; font-size: 12px;
  letter-spacing: .04em;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-name { font-weight: 600; font-size: 13px; }
.user-role { font-size: 11.5px; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 13.5px;
  transition: background .12s, border-color .12s, transform .04s;
  background: transparent;
  color: var(--ink);
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--brand);
  color: #fff;
}
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--ink-2);
}
.btn-ghost:hover { background: var(--bg-soft); }
.btn-sm { height: 32px; padding: 0 14px; font-size: 12.5px; }

.chip-group { display: inline-flex; background: var(--bg-soft); padding: 4px; border-radius: var(--radius-pill); }
.chip {
  border: 0;
  background: transparent;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
}
.chip.active { background: #fff; color: var(--ink); box-shadow: var(--shadow-1); }

/* ---------- Selects ---------- */
.select-wrap {
  position: relative;
  display: inline-flex;
}
.select-wrap::after {
  content: '';
  position: absolute; right: 14px; top: 50%;
  width: 8px; height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.select-wrap select {
  appearance: none;
  -webkit-appearance: none;
  height: 38px;
  padding: 0 36px 0 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  min-width: 170px;
}
.select-wrap.subtle select {
  background: var(--bg-soft);
  border-color: transparent;
}
.select-wrap.subtle select:hover { background: #eef0f3; }
.select-wrap select:focus { outline: none; border-color: var(--brand); }

/* ---------- Cards ---------- */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}
.content > section { margin-bottom: 18px; }
.content > section:last-child { margin-bottom: 0; }
.card-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.card-actions { display: flex; gap: 8px; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.page-header p { margin-top: 4px; font-size: 13px; }
.page-actions { display: flex; gap: 10px; }

/* ---------- KPIs ---------- */
.kpis {
  display: grid;
  grid-template-columns: 1.7fr 1fr 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}
.kpi {
  display: flex; flex-direction: column; gap: 5px;
  padding: 14px 16px;
}
.kpi-label { color: var(--muted); font-size: 12px; font-weight: 500; }
.kpi-value {
  font-size: 22px; font-weight: 700; letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.15;
}

/* Wide KPI: split into left (value) + right (breakdown) */
.kpi-wide {
  flex-direction: row;
  align-items: stretch;
  gap: 16px;
  padding: 14px 18px;
}
.kpi-wide .kpi-left {
  display: flex; flex-direction: column; gap: 5px;
  flex: 1; min-width: 0;
}
.kpi-wide .kpi-breakdown {
  flex-shrink: 0;
  align-self: center;
  border-left: 1px solid var(--line);
  padding-left: 14px;
  max-width: 200px;
}
.kpi-unit { font-size: 16px; color: var(--muted); margin-left: 2px; font-weight: 600; }
.kpi-delta {
  font-size: 12px; font-weight: 600;
  width: max-content;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}
.kpi-delta.up   { color: var(--green); background: var(--green-bg); }
.kpi-delta.down { color: var(--red);   background: var(--red-bg); }
.kpi-conv {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: -2px;
  letter-spacing: .01em;
}
.kpi-rates {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-top: -1px;
}
.kpi-rates svg { color: var(--brand-dark); }
.kpi-rates small { color: var(--muted-2); }
.orig-amount {
  color: var(--muted);
  font-weight: 500;
  font-size: 11.5px;
  margin-left: 4px;
}

/* KPI breakdown by currency (Patrimonio total) */
.kpi-breakdown {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.kpi-breakdown li {
  font-size: 11.5px;
  line-height: 1.25;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-breakdown li small {
  color: var(--muted);
  font-weight: 500;
}

/* Profit ranked list (inline, top 5 by default, expand to all) */
.profit-rank-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column;
}
.profit-rank-foot { display: flex; justify-content: center; padding: 10px 0 0; }
.profit-rank-list li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1.4fr) minmax(0, 2fr) minmax(0, 100px);
  align-items: center;
  gap: 12px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--line-soft);
}
.profit-rank-list li:last-child { border-bottom: 0; }
.profit-rank-list .pl-rank {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--muted);
  display: grid; place-items: center;
  font-size: 10.5px; font-weight: 700;
}
.profit-rank-list .pl-name { font-weight: 600; font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.profit-rank-list .pl-name:hover { color: var(--brand-dark); }
.profit-rank-list .pl-bar { height: 8px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; }
.profit-rank-list .pl-bar span { display: block; height: 100%; background: rgba(46,158,87,0.7); border-radius: inherit; }
.profit-rank-list .pl-value { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 12.5px; }
.profit-empty { padding: 24px; text-align: center; }

/* FX info strip */
.fx-info {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 12.5px;
  color: var(--ink-2);
  flex-wrap: wrap;
}
.fx-info > svg { color: var(--brand-dark); flex-shrink: 0; }
.fx-info-label { font-weight: 600; }
.fx-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.fx-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
.fx-pill .arrow { color: var(--muted); }
.fx-pill b { color: var(--brand-dark); }
.fx-info-tag {
  margin-left: auto;
  color: var(--muted);
  font-size: 11.5px;
}

/* ---------- Grids ---------- */
.grid-2 {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}

/* ---------- Chart containers (fixed height = stop Chart.js infinite grow) ---------- */
.chart-box {
  position: relative;
  width: 100%;
  height: 320px;
}
.chart-box > canvas { width: 100% !important; height: 100% !important; }
.chart-box.compact { height: 220px; }

/* ---------- Treemap ---------- */
.treemap-box {
  position: relative;
  width: 100%;
  height: 320px;
}
.treemap-box > canvas { width: 100% !important; height: 100% !important; }
.legend.horiz {
  display: flex; flex-wrap: wrap; gap: 14px 22px;
  margin: 14px 0 0;
  padding: 0; list-style: none;
}
.legend.horiz li { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.legend.horiz .sw { width: 10px; height: 10px; border-radius: 3px; }
.legend.horiz .val { color: var(--muted); font-variant-numeric: tabular-nums; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.legend li { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; }
.legend .val { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Year table ---------- */
.year-table-wrap { overflow-x: auto; }
.year-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}
.year-table th, .year-table td {
  padding: 11px 10px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--line-soft);
}
.year-table thead th {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 600;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
}
.year-table th:first-child, .year-table td:first-child {
  text-align: left;
  position: sticky; left: 0;
  background: #fff;
  z-index: 1;
}
.year-table thead th:first-child { background: var(--bg-soft); }
.year-table tbody tr:hover td { background: #fafbfc; }
.year-table tbody tr:hover td:first-child { background: #fafbfc; }
.year-table .asset-cell {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600;
}
.asset-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  display: grid; place-items: center;
  flex-shrink: 0;
  font-weight: 700;
  font-size: 12px;
}
.year-table .pos { color: var(--ink); }
.year-table .neg { color: var(--red); }
.year-table .zero { color: var(--muted-2); }
.year-table tfoot td {
  border-top: 1px solid var(--line);
  font-weight: 700;
  background: #fafbfc;
}
.year-table tfoot td:first-child { background: #fafbfc; }

/* ---------- Lists ---------- */
.list-card { padding: 22px 22px 8px; }
.prop-list, .activity {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column;
}
.prop-list li, .activity li {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line-soft);
}
.prop-list li:last-child, .activity li:last-child { border-bottom: 0; }
.prop-thumb {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--brand-soft) center/cover;
  color: var(--brand-dark);
  display: grid; place-items: center;
  font-weight: 700;
  flex-shrink: 0;
}
.prop-thumb svg { width: 20px; height: 20px; }
.prop-main { display: flex; flex-direction: column; min-width: 0; }
.prop-name { font-weight: 600; }
.prop-meta { color: var(--muted); font-size: 12.5px; }
.prop-amount { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.prop-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--bg-soft);
  color: var(--muted);
  margin-left: 6px;
}

.activity .a-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg-soft);
  display: grid; place-items: center;
  flex-shrink: 0;
  color: var(--ink-2);
}
.activity .a-icon.green { background: var(--green-bg); color: var(--green); }
.activity .a-icon.red   { background: var(--red-bg);   color: var(--red); }
.activity .a-text { display: flex; flex-direction: column; }
.activity .a-text b { font-weight: 600; }
.activity .a-text span { color: var(--muted); font-size: 12.5px; }
.activity .a-amount { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.activity .a-amount.pos { color: var(--green); }
.activity .a-amount.neg { color: var(--red); }

/* ---------- Propiedades: filtros ---------- */
.kpis.kpis-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.filter-bar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.filter-search {
  flex: 1; min-width: 260px;
  display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 14px;
  border-radius: var(--radius-pill);
  background: var(--bg-soft);
  border: 1px solid transparent;
}
.filter-search:focus-within { background: #fff; border-color: var(--line); box-shadow: var(--shadow-1); }
.filter-search svg { color: var(--muted); }
.filter-search input { flex:1; border:0; background:transparent; outline:none; font:inherit; color: var(--ink); }
.filter-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.view-toggle .chip { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Propiedades: tabla ---------- */
.prop-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.prop-table th, .prop-table td {
  padding: 12px 12px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--line-soft);
}
.prop-table th.num, .prop-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.prop-table thead th {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 600;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
}
.prop-table tbody tr:hover td { background: #fafbfc; }
.prop-table .flag { margin-right: 4px; }
.icon-btn.sm { width: 30px; height: 30px; color: var(--muted); }

.pill {
  display: inline-flex; align-items: center;
  font-size: 11.5px; font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}
.pill.green { color: var(--green); background: var(--green-bg); }
.pill.amber { color: #a16207; background: #fef3c7; }
.pill.grey  { color: var(--muted); background: var(--bg-soft); }

/* ---------- Propiedades: tarjetas ---------- */
.prop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.prop-card { display: flex; flex-direction: column; gap: 8px; padding: 20px; }
.prop-card-head { display: flex; align-items: center; justify-content: space-between; }
.prop-thumb.lg { width: 48px; height: 48px; border-radius: 12px; font-size: 14px; }
.prop-card-name { font-size: 15px; margin-top: 6px; }
.prop-card-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  margin: 14px 0 8px;
  padding: 0;
}
.prop-card-grid > div { margin: 0; }
.prop-card-grid dt { font-size: 11.5px; color: var(--muted); margin-bottom: 2px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.prop-card-grid dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.prop-card-foot { margin-top: auto; border-top: 1px solid var(--line-soft); padding-top: 12px; }

/* ---------- Search suggestions panel ---------- */
.search.has-suggest,
.filter-search.has-suggest { position: relative; }
.search-suggest {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: 6px;
  display: none;
  max-height: 380px;
  overflow-y: auto;
  z-index: 1500;
}
.search-suggest.open { display: block; }
.search-suggest .ss-group { padding: 4px 0; }
.search-suggest .ss-group + .ss-group { border-top: 1px solid var(--line-soft); margin-top: 4px; padding-top: 8px; }
.search-suggest .ss-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  padding: 4px 10px 6px;
}
.search-suggest .ss-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink);
}
.search-suggest .ss-item:hover,
.search-suggest .ss-item.active { background: var(--bg-soft); }
.search-suggest .ss-ico {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.search-suggest .ss-ico svg { width: 15px; height: 15px; }
.search-suggest .ss-text { display: flex; flex-direction: column; min-width: 0; }
.search-suggest .ss-title { font-weight: 600; font-size: 13px; }
.search-suggest .ss-sub { color: var(--muted); font-size: 11.5px; }

/* ---------- Custom dropdown menu (replaces native <select>) ---------- */
.menu { position: relative; display: inline-block; }
.menu-trigger {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px;
  padding: 0 12px 0 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: 500 13px Inter, system-ui, sans-serif;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.menu-trigger:hover { background: var(--bg-soft); }
.menu.subtle .menu-trigger { background: var(--bg-soft); border-color: transparent; }
.menu.subtle .menu-trigger:hover { background: #eef0f3; }
.menu-trigger .chev {
  width: 14px; height: 14px;
  color: var(--muted);
  transition: transform .15s;
}
.menu.open .menu-trigger .chev { transform: rotate(180deg); }
.menu.open .menu-trigger { background: #fff; border-color: var(--line); box-shadow: var(--shadow-1); }

.menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: var(--shadow-2);
  z-index: 2000; /* above Leaflet map and topbar */
  display: none;
  max-height: 320px;
  overflow-y: auto;
}
.menu.open { z-index: 2000; }
.prop-filters { z-index: 2; } /* keep above sibling map for popovers */
.menu.right .menu-panel { left: auto; right: 0; }
.menu.open .menu-panel { display: block; }
.menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  background: transparent;
  border-radius: var(--radius-pill);
  color: var(--ink-2);
  font: 500 13.5px Inter, system-ui, sans-serif;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}
.menu-item:hover { background: #eef0f3; }
.menu-item.active { background: var(--brand-soft); color: var(--brand-dark); }
.menu-item .check { margin-left: auto; opacity: 0; color: var(--brand-dark); }
.menu-item.active .check { opacity: 1; }

/* Hide enhanced native selects */
select.enhanced { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.select-wrap.enhanced::after { display: none; }

/* ---------- Country flags ---------- */
.flag {
  display: inline-block;
  width: 18px; height: 12px;
  background-size: cover;
  background-position: center;
  border-radius: 2px;
  margin-right: 6px;
  vertical-align: -1px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.06);
}

/* ---------- Property type icons ---------- */
.type-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 6px;
  background: var(--bg-soft);
  border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 500;
  color: var(--ink-2);
}
.type-pill svg { width: 14px; height: 14px; color: var(--brand-dark); }

/* ---------- Propiedades: filtros ---------- */
.kpis.kpis-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.filter-bar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 16px;
  flex-wrap: wrap;
}
.filter-search {
  flex: 1; min-width: 260px;
  display: flex; align-items: center; gap: 10px;
  height: 40px; padding: 0 14px;
  border-radius: var(--radius-pill);
  background: var(--bg-soft);
  border: 1px solid transparent;
}
.filter-search:focus-within { background: #fff; border-color: var(--line); box-shadow: var(--shadow-1); }
.filter-search svg { color: var(--muted); }
.filter-search input { flex:1; border:0; background:transparent; outline:none; font:inherit; color: var(--ink); }
.filter-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.view-toggle { margin-left: auto; }
.view-toggle .chip { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Propiedades: layout filtros+mapa | grid ---------- */
.prop-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.prop-side {
  position: sticky;
  top: calc(var(--topbar-h) + 14px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.prop-main { min-width: 0; display: flex; flex-direction: column; gap: 14px; }

.prop-filters { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.prop-filters .filter-search { min-width: 0; flex: none; }
.filter-group { display: flex; flex-direction: column; gap: 6px; }
.filter-group > label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
  color: var(--muted);
  padding-left: 4px;
}
.prop-filters .menu { width: 100%; }
.prop-filters .menu-trigger { width: 100%; justify-content: space-between; height: 38px; }
.prop-filters .menu-panel { width: 100%; }

.prop-main-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 4px;
  margin-bottom: -4px;
}
.prop-main-head .count { color: var(--muted); font-size: 13px; }

.map-side {
  padding: 0;
  overflow: hidden;
  height: 340px;
  display: flex;
  flex-direction: column;
}
.map-side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.map-side-head h3 { font-size: 14px; }
.map-side-head .muted { font-size: 12px; }
.map-side-head .reset-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  font: 600 12px Inter, system-ui, sans-serif;
  color: var(--ink-2);
  cursor: pointer;
}
.map-side-head .reset-btn:hover { background: var(--bg-soft); }
.map-actions { display: flex; gap: 6px; }
.map-full,
.map-preview {
  position: relative;
  z-index: 0;
  isolation: isolate; /* contain Leaflet's high z-index inside this box */
}
.map-full { height: 70vh; min-height: 480px; width: 100%; }
.map-preview { flex: 1; width: 100%; }
.map-preview .leaflet-container,
.map-full .leaflet-container { background: #f3f4f6; }

/* Cap Leaflet's internal stacking so it never beats our chrome */
.leaflet-pane,
.leaflet-top,
.leaflet-bottom { z-index: 1 !important; }
.leaflet-popup-pane { z-index: 3 !important; }
@media (max-width: 1100px) {
  .prop-layout { grid-template-columns: 1fr; }
  .prop-side { position: static; }
}

/* Leaflet pin */
.ah-pin {
  width: 34px; height: 34px;
  background: #fff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: grid; place-items: center;
  border: 2px solid var(--brand);
  box-shadow: 0 4px 10px rgba(0,0,0,.18);
  transition: transform .15s ease, box-shadow .15s;
}
.ah-pin svg {
  width: 18px; height: 18px;
  transform: rotate(45deg);
  color: var(--brand-dark);
  stroke-width: 2;
}
.ah-pin.active {
  background: var(--brand);
  border-color: var(--brand-dark);
  transform: rotate(-45deg) scale(1.12);
}
.ah-pin.active svg { color: #fff; }

.leaflet-popup-content-wrapper {
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.12);
  border: 1px solid var(--line);
}
.leaflet-popup-content {
  margin: 12px 14px;
  font-family: Inter, system-ui, sans-serif;
  font-size: 13px;
}
.leaflet-popup-content b { display: block; margin-bottom: 2px; }
.leaflet-popup-content .pop-meta { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.leaflet-popup-content a {
  color: var(--brand-dark);
  font-weight: 600;
  font-size: 12.5px;
}
.leaflet-popup-tip { box-shadow: none; }

/* ---------- Propiedades: tabla ---------- */
.prop-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.prop-table th, .prop-table td {
  padding: 12px 12px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--line-soft);
  width: 1%; /* shrink to content */
}
.prop-table th:first-child, .prop-table td:first-child {
  width: auto; /* main column takes remainder */
}
.prop-table th.num, .prop-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.prop-table thead th {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 600;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
}
.prop-table tbody tr { cursor: pointer; }
.prop-table tbody tr:hover td { background: #fafbfc; }
.icon-btn.sm { width: 30px; height: 30px; color: var(--muted); }

.pill {
  display: inline-flex; align-items: center;
  font-size: 11.5px; font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}
.pill.green { color: var(--green); background: var(--green-bg); }
.pill.amber { color: #a16207; background: #fef3c7; }
.pill.grey  { color: var(--muted); background: var(--bg-soft); }

/* ---------- Propiedades: tarjetas compactas ---------- */
.prop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}
.prop-card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 14px 14px 12px;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
  min-width: 0;
}
.prop-card:hover { border-color: #d8dadf; box-shadow: var(--shadow-2); }
.prop-card-head { display: flex; align-items: center; justify-content: space-between; }
.prop-thumb.lg {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  display: grid; place-items: center;
}
.prop-thumb.lg svg { width: 18px; height: 18px; }
.prop-card-name {
  font-size: 14px;
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.prop-card-sub {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.prop-card-stats {
  display: flex; gap: 14px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}
.prop-card-stats > div { display: flex; flex-direction: column; }
.prop-card-stats dt {
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
  margin: 0 0 2px;
}
.prop-card-stats dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--ink);
}

/* ---------- Property detail page ---------- */
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 12px;
  font-size: 12.5px;
  color: var(--muted);
}
.breadcrumb a {
  color: var(--muted);
  border-radius: 6px;
  padding: 2px 4px;
}
.breadcrumb a:hover { color: var(--ink); background: var(--bg-soft); }
.breadcrumb svg { color: var(--muted-2); }
.breadcrumb span { color: var(--ink); font-weight: 500; }

.prop-detail-title {
  display: flex; align-items: center; gap: 14px;
}
.prop-detail-title .prop-thumb.lg {
  width: 52px; height: 52px;
  border-radius: 14px;
}
.prop-detail-title .prop-thumb.lg svg { width: 26px; height: 26px; }
.title-row { display: flex; align-items: center; gap: 10px; }
.title-row h1 { margin: 0; }

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 14px;
}
@media (max-width: 1000px) { .detail-grid { grid-template-columns: 1fr; } }

.info-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 24px;
  margin: 0;
  padding: 0;
}
.info-list > div { display: flex; flex-direction: column; gap: 2px; }
.info-list dt {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
}
.info-list dd { margin: 0; font-weight: 600; color: var(--ink); font-size: 13.5px; }

/* tenant list inside detail */
.tenant-list, .contract-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column;
}
.tenant-list li, .contract-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.tenant-list li:last-child, .contract-list li:last-child { border-bottom: 0; }
.tenant-list .avatar { width: 38px; height: 38px; font-size: 13px; flex-shrink: 0; }
.t-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.t-name { font-weight: 600; font-size: 13.5px; }
.t-side {
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
  flex-shrink: 0;
}
.t-rent {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
}
.t-rent small { color: var(--muted); font-size: 11px; font-weight: 500; }

.contract-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.contract-icon svg { width: 18px; height: 18px; }
.c-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.c-name { font-weight: 600; font-size: 13px; }
.c-side { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.empty { padding: 18px; text-align: center; }

.prop-link {
  color: var(--ink);
  font-weight: 500;
  border-bottom: 1px dashed transparent;
  transition: color .12s, border-color .12s;
}
.prop-link:hover { color: var(--brand-dark); border-bottom-color: var(--brand); }

td.desc {
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
  font-size: 12.5px;
}
td.desc.clickable { cursor: pointer; }
td.desc.clickable:hover { color: var(--ink); }
.desc-full {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink-2);
  margin: 0;
  white-space: pre-wrap;
}

/* ---------- Ajustes page ---------- */
.settings-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.settings-layout.single-col { grid-template-columns: minmax(0, 1fr); }
.settings-nav {
  position: sticky;
  top: calc(var(--topbar-h) + 14px);
  display: flex; flex-direction: column;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
}
.settings-nav a {
  display: block;
  padding: 9px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
}
.settings-nav a:hover { background: var(--bg-soft); }
.settings-nav a.active { background: var(--brand-soft); color: var(--brand-dark); }
.settings-nav a.danger { color: var(--red); }
.settings-nav a.danger.active { background: var(--red-bg); }

.settings-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.settings-main .card { scroll-margin-top: calc(var(--topbar-h) + 14px); }

.settings-row {
  padding: 14px 0;
  border-top: 1px solid var(--line-soft);
  display: flex; flex-direction: column; gap: 6px;
}
.settings-row:first-of-type { border-top: 0; padding-top: 6px; }
.settings-row > b { font-weight: 600; font-size: 13.5px; color: var(--ink); }
.settings-row > p { margin: 0 0 6px; }

.radio-group { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.radio-card {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.radio-card:hover { background: var(--bg-soft); }
.radio-card input { margin-top: 3px; accent-color: var(--brand); }
.radio-card div { display: flex; flex-direction: column; gap: 2px; }
.radio-card input:checked + div { color: var(--brand-dark); }
.radio-card:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }

.settings-profile {
  display: flex; gap: 22px; align-items: flex-start;
}
.profile-meta { flex: 1; }
.settings-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 14px;
}

.plan-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.plan-current h4 { font-size: 18px; margin: 8px 0 4px; }
.plan-actions { display: flex; gap: 10px; }

.toggle-list, .bank-list, .team-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column;
}
.toggle-list li {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.toggle-list li:last-child { border-bottom: 0; }
.toggle-list li > div { display: flex; flex-direction: column; gap: 2px; }
.toggle-list li b { font-weight: 600; font-size: 13.5px; }

.switch { position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0;
  background: #d8dadf;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s;
}
.switch span::before {
  content: '';
  position: absolute;
  left: 3px; top: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform .15s;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::before { transform: translateX(18px); }

.bank-list li { padding: 14px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }

.team-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.team-list li:last-child { border-bottom: 0; }
.team-list .t-meta { flex: 1; display: flex; flex-direction: column; gap: 2px; }

.api-row { display: flex; flex-direction: column; gap: 12px; }

.danger-zone { border-color: rgba(179, 38, 30, .2); }
.danger-zone h3 { color: var(--red); }
.danger-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line-soft);
}
.danger-row:last-child { border-bottom: 0; }
.danger-row > div { flex: 1; }
.danger-row b { font-weight: 600; font-size: 13.5px; }
.danger-row p { margin-top: 4px; }

.btn-danger {
  background: var(--red);
  color: #fff;
}
.btn-danger:hover { background: #8c1a14; }

@media (max-width: 1000px) {
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { position: static; flex-direction: row; overflow-x: auto; }
}

/* ---------- Empresas page ---------- */
.company-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 14px;
}
.company-card {
  display: flex; flex-direction: column;
  padding: 20px 22px;
  gap: 12px;
}
.company-head {
  display: flex; align-items: center; gap: 14px;
}
.company-logo {
  width: 46px; height: 46px;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}
.company-meta { flex: 1; min-width: 0; }
.company-meta h3 { font-size: 15px; }
.company-desc { margin: 4px 0 6px; }

.company-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 4px 0 0;
  padding: 14px 0 4px;
  border-top: 1px solid var(--line-soft);
}
.company-stats > div { display: flex; flex-direction: column; }
.company-stats dt {
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
  margin-bottom: 2px;
}
.company-stats dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-size: 13.5px;
}
.company-flags {
  display: flex; flex-wrap: wrap; gap: 8px 12px;
  font-size: 12px;
  color: var(--muted);
}
.flag-line { display: inline-flex; align-items: center; gap: 4px; }
.company-foot {
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
  margin-top: auto;
}
.company-expand {
  margin-top: 6px;
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
  display: flex; flex-direction: column; gap: 10px;
}
.company-search { width: 100%; }
.company-props {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex; flex-direction: column;
}
.company-props li { border-bottom: 1px solid var(--line-soft); }
.company-props li:last-child { border-bottom: 0; }
.company-prop-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 4px;
  color: inherit;
  border-radius: 8px;
}
.company-prop-link:hover { background: var(--bg-soft); }
.cpl-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.cpl-name { font-weight: 600; font-size: 13px; }
.cpl-rent {
  font-weight: 600; font-variant-numeric: tabular-nums; font-size: 13px;
}
.cpl-rent small { color: var(--muted); font-size: 11px; font-weight: 500; }

/* ---------- Drive-style contract cards ---------- */
.drive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.drive-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
  display: flex;
  flex-direction: column;
}
.drive-card:hover { border-color: #d8dadf; box-shadow: var(--shadow-2); }
.drive-thumb {
  height: 140px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line-soft);
  display: grid;
  place-items: center;
  position: relative;
}
.drive-doc-icon {
  position: relative;
  width: 64px; height: 80px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--brand-dark);
  box-shadow: 0 4px 14px rgba(16,24,40,.06);
}
.drive-doc-icon svg { width: 30px; height: 30px; }
.drive-ext {
  position: absolute;
  bottom: -8px;
  background: var(--brand);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .04em;
  padding: 2px 7px;
  border-radius: 4px;
}
.drive-meta {
  padding: 12px 14px 14px;
  display: flex; flex-direction: column; gap: 4px;
  min-width: 0;
}
.drive-title {
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.drive-sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.drive-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}
.drive-amount {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

/* ---------- Document preview (fake PDF) ---------- */
.doc-page {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 48px 56px;
  margin: 0 auto;
  max-width: 720px;
  box-shadow: 0 2px 10px rgba(0,0,0,.04);
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-2);
}
.doc-letterhead {
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
  margin-bottom: 22px;
}
.doc-letterhead img { height: 20px; }
.doc-ref {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 600;
}
.doc-h1 {
  font-size: 22px; font-weight: 700; color: var(--ink);
  letter-spacing: -0.01em;
  margin-bottom: 18px;
}
.doc-h2 {
  font-size: 13px; font-weight: 700; color: var(--ink);
  text-transform: uppercase; letter-spacing: .06em;
  margin: 24px 0 10px;
}
.doc-p { margin: 0 0 8px; }
.doc-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px 24px;
  margin-bottom: 10px;
}
.doc-grid > div { display: flex; flex-direction: column; }
.doc-k {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
}
.doc-v { font-weight: 600; color: var(--ink); }
.doc-signatures {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 36px;
  margin-top: 56px;
}
.doc-signatures > div { display: flex; flex-direction: column; gap: 4px; }
.doc-sig-line {
  height: 1px; background: var(--ink-2);
  margin-bottom: 8px;
}
.doc-foot { text-align: center; margin-top: 48px; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(15, 18, 22, .42);
  display: none;
  align-items: center; justify-content: center;
  z-index: 3000;
  padding: 24px;
  animation: fadeIn .15s ease;
}
.modal.open { display: flex; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.modal-card {
  background: #fff;
  border-radius: 18px;
  width: 100%; max-width: 640px;
  max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,.18);
}
.modal-card.lg { max-width: 980px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 17px; font-weight: 600; }
.tenant-head { display: flex; align-items: center; gap: 14px; }
.tenant-head .avatar { width: 44px; height: 44px; font-size: 14px; }
.modal-head p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.modal-close {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 0; background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: grid; place-items: center;
}
.modal-close:hover { background: var(--bg-soft); }
.modal-body { padding: 22px 24px; overflow-y: auto; }
.modal-body.flush { padding: 0; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
}

/* Add-asset modal type cards */
.type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.type-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: var(--ink);
  transition: border-color .12s, background .12s;
}
.type-tile:hover { background: var(--bg-soft); }
.type-tile.active { border-color: var(--brand); background: var(--brand-soft); }
.type-tile .ti-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--bg-soft);
  display: grid; place-items: center;
  color: var(--brand-dark);
}
.type-tile.active .ti-icon { background: #fff; }
.type-tile b { font-size: 13.5px; font-weight: 600; }
.type-tile span { font-size: 11.5px; color: var(--muted); }

/* Form */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.field input, .field textarea {
  height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
  color: var(--ink);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.field textarea { padding: 10px 14px; height: auto; min-height: 80px; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.field .menu-trigger { width: 100%; height: 40px; justify-content: space-between; }
.field .menu-panel { width: 100%; }

/* Year-table tweak: ingresos/gastos coloring */
.year-table tbody tr { cursor: pointer; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  #app { grid-template-columns: 1fr; }
  #sidebar { display: none; }
  .content { padding: 20px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .topbar-actions .select-wrap { display: none; }
}
