:root {
  --blue: #0b2b52;
  --blue-2: #123d73;
  --blue-3: #1d5fa8;
  --ink: #172033;
  --muted: #687385;
  --line: #e6eaf0;
  --bg: #f5f7fb;
  --success: #1f9d68;
  --danger: #c83b4b;
  --warning: #d39b2a;
  --info: #2f80ed;
  --gold: #c7a14a;
  --surface: #ffffff;
  --shadow: 0 18px 45px rgba(16, 38, 73, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, #f8fbff 0, var(--bg) 320px),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

a { text-decoration: none; }

.public-shell {
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 10%, rgba(29, 95, 168, .18), transparent 34%),
    linear-gradient(135deg, #f8fbff 0%, #edf3fb 48%, #ffffff 100%);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px 1fr;
}

.sidebar {
  background: linear-gradient(180deg, #09264a, #071b35 72%, #061327);
  color: #fff;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 28px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  background: var(--gold);
  color: #071b35;
}

.sidebar .nav-link {
  color: rgba(255,255,255,.78);
  border-radius: 8px;
  padding: 10px 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  min-height: 40px;
}

.sidebar .nav-link:hover {
  background: rgba(255,255,255,.09);
  color: #fff;
}

.nav-group {
  color: rgba(255,255,255,.45);
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  margin: 16px 8px 4px;
}

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

.topbar {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.content {
  padding: 28px;
}

.eyebrow {
  display: block;
  color: var(--muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 800;
}

.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}

.page-heading h1 {
  font-size: clamp(1.6rem, 2vw, 2.25rem);
  margin: 0;
  font-weight: 800;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
}

.stat-card, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 18px;
  border-left-width: 5px;
}

.panel-elevated {
  box-shadow: var(--shadow);
}

.dashboard-hero,
.resident-hero,
.product-landing {
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(11, 43, 82, .98), rgba(18, 61, 115, .94)),
    var(--blue);
  color: #fff;
  padding: clamp(24px, 4vw, 42px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 24px;
  overflow: hidden;
  position: relative;
}

.dashboard-hero::after,
.resident-hero::after,
.product-landing::after {
  content: "";
  position: absolute;
  right: -12%;
  top: -25%;
  width: 420px;
  height: 420px;
  border: 1px solid rgba(255,255,255,.16);
  transform: rotate(18deg);
}

.dashboard-hero > *,
.resident-hero > *,
.product-landing > * {
  position: relative;
  z-index: 1;
}

.dashboard-hero h1,
.resident-hero h1,
.product-landing h1 {
  font-weight: 900;
  font-size: clamp(2rem, 4vw, 4rem);
  margin: 0 0 8px;
}

.dashboard-hero p,
.resident-hero p,
.product-landing p {
  color: rgba(255,255,255,.78);
  max-width: 720px;
  margin: 0;
}

.dashboard-section {
  margin-bottom: 22px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.section-title span {
  width: 9px;
  height: 28px;
  border-radius: 999px;
  background: var(--gold);
}

.section-title h2 {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 900;
}

.section-title.compact {
  margin-bottom: 8px;
}

.section-title.compact span {
  height: 20px;
}

.stat-card-premium {
  border-left: 0;
  position: relative;
  overflow: hidden;
}

.stat-card-premium::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: var(--blue-2);
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #eef4ff;
  color: var(--blue-2);
  font-weight: 900;
  margin-bottom: 12px;
}

.tone-success::before,
.border-success.stat-card-premium::before {
  background: var(--success);
}

.tone-danger::before,
.border-danger.stat-card-premium::before {
  background: var(--danger);
}

.tone-warning::before,
.border-warning.stat-card-premium::before {
  background: var(--warning);
}

.tone-info::before,
.border-info.stat-card-premium::before {
  background: var(--info);
}

.metric-row,
.rich-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}

.metric-row span,
.rich-row small {
  display: block;
  color: var(--muted);
  font-size: .85rem;
}

.metric-row strong {
  font-size: 1.12rem;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-weight: 700;
  font-size: .88rem;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.55rem;
}

.panel {
  padding: 20px;
}

.panel h2 {
  font-size: 1.05rem;
  font-weight: 800;
  margin-bottom: 16px;
}

.list-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.empty-inline {
  color: var(--muted);
  background: #f8fafd;
  border: 1px dashed #cdd6e4;
  border-radius: 8px;
  padding: 18px;
  text-align: center;
}

.badge-soft {
  background: #eef4ff;
  color: var(--blue-2);
  border: 1px solid #d7e4ff;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: .78rem;
  font-weight: 800;
  line-height: 1;
  background: #eef4ff;
  color: var(--blue-2);
  border: 1px solid #d7e4ff;
  white-space: nowrap;
}

.status-pagado,
.status-aprobado,
.status-validado,
.status-activa,
.status-autorizado,
.status-resuelto,
.status-cerrado,
.status-usado,
.status-enviado,
.status-leida {
  background: #eaf8f1;
  color: #137a4d;
  border-color: #c8ecd9;
}

.status-pendiente,
.status-parcial,
.status-trial,
.status-en-revision,
.status-asignado,
.status-en-proceso {
  background: #fff7e6;
  color: #94630f;
  border-color: #f3dfaa;
}

.status-vencido,
.status-rechazado,
.status-anulado,
.status-suspendida,
.status-expirado,
.status-cancelado,
.status-fallido {
  background: #fff0f2;
  color: #a32435;
  border-color: #f2c7cf;
}

.status-nuevo,
.status-normal,
.status-neutral {
  background: #eef4ff;
  color: var(--blue-2);
  border-color: #d7e4ff;
}

.qr-box {
  width: 180px;
  height: 180px;
  display: grid;
  place-items: center;
  border: 8px solid var(--blue);
  background: repeating-linear-gradient(45deg, #fff, #fff 8px, #eef4ff 8px, #eef4ff 16px);
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--blue);
}

.access-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.search-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.security-card-list {
  display: grid;
  gap: 12px;
}

.security-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdff;
}

.security-card small {
  display: block;
  color: var(--muted);
  margin: 3px 0 8px;
}

.security-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.access-validation {
  min-height: calc(100vh - 180px);
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  max-width: 720px;
  margin: 0 auto;
}

.access-badge {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  font-size: 1.4rem;
  margin-bottom: 18px;
}

.access-badge.ok {
  background: var(--success);
}

.access-badge.blocked {
  background: var(--danger);
}

.form-stack {
  display: grid;
  gap: 12px;
}

.form-control,
.form-select {
  border-color: #d8e0ec;
  border-radius: 8px;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--blue-3);
  box-shadow: 0 0 0 .2rem rgba(29, 95, 168, .12);
}

.table-premium,
.table {
  margin-bottom: 0;
}

.table-premium thead th,
.table thead th {
  background: #f8fafd;
  border-bottom: 1px solid var(--line);
}

.table-premium tbody tr:hover,
.table tbody tr:hover {
  background: #fbfdff;
}

.resident-hero {
  background: linear-gradient(135deg, #09264a, #144c82);
}

.resident-balance {
  min-width: min(320px, 100%);
  background: rgba(255,255,255,.11);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 8px;
  padding: 18px;
}

.resident-balance span,
.resident-balance small {
  display: block;
  color: rgba(255,255,255,.78);
}

.resident-balance strong {
  display: block;
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 900;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.quick-action {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
  color: var(--ink);
}

.quick-action strong,
.quick-action span {
  display: block;
}

.quick-action span {
  color: var(--muted);
  font-size: .86rem;
  margin-top: 3px;
}

.quick-action.primary {
  background: var(--blue-2);
  color: #fff;
}

.quick-action.primary span {
  color: rgba(255,255,255,.78);
}

.product-landing {
  min-height: 560px;
  border-radius: 0;
  margin-bottom: 0;
}

.landing-copy {
  max-width: 720px;
}

.landing-copy p {
  font-size: 1.35rem;
}

.landing-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 26px;
}

.landing-panel {
  width: min(420px, 100%);
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  padding: 18px;
}

.mini-dashboard {
  display: grid;
  gap: 12px;
}

.mini-dashboard div {
  background: rgba(255,255,255,.94);
  color: var(--ink);
  border-radius: 8px;
  padding: 16px;
}

.mini-dashboard span {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.mini-dashboard strong {
  display: block;
  font-size: 1.6rem;
  font-weight: 900;
}

.benefit-grid {
  max-width: 1180px;
  margin: 0 auto;
  padding: 34px 24px 54px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.benefit-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.benefit-card span {
  display: block;
  width: 38px;
  height: 5px;
  border-radius: 999px;
  background: var(--gold);
  margin-bottom: 14px;
}

.benefit-card h2 {
  font-size: 1.1rem;
  font-weight: 900;
}

.benefit-card p {
  color: var(--muted);
  margin: 0;
}

.notification-menu {
  min-width: 300px;
  max-width: 360px;
}

.auth-body {
  min-height: 100vh;
  background: radial-gradient(circle at top left, #194d88, #071b35 45%, #050b16);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 460px;
  gap: 40px;
  align-items: center;
  padding: 48px;
}

.auth-copy {
  color: #fff;
  max-width: 720px;
}

.auth-copy h1 {
  font-size: clamp(2.4rem, 5vw, 5rem);
  font-weight: 900;
  line-height: 1;
}

.auth-copy p {
  color: rgba(255,255,255,.78);
  font-size: 1.15rem;
}

.auth-card {
  background: #fff;
  border-radius: 12px;
  padding: 34px;
  box-shadow: 0 30px 80px rgba(0,0,0,.25);
}

.auth-brand {
  margin-bottom: 28px;
}

@media (max-width: 920px) {
  .auth-shell {
    grid-template-columns: 1fr;
    padding: 24px;
  }
}

@media (max-width: 720px) {
  .access-row {
    align-items: stretch;
    flex-direction: column;
  }
}

.table th {
  color: var(--muted);
  font-size: .8rem;
  text-transform: uppercase;
}

.btn-primary {
  --bs-btn-bg: var(--blue-2);
  --bs-btn-border-color: var(--blue-2);
}

.empty-state {
  min-height: 55vh;
  display: grid;
  place-content: center;
  text-align: center;
  max-width: 680px;
  margin: 0 auto;
}

.empty-state h1 {
  font-weight: 800;
}

.premium-empty {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(28px, 5vw, 56px);
  box-shadow: var(--shadow);
}

.premium-empty p {
  color: var(--muted);
}

.auth-form-panel {
  width: min(620px, 100%);
  margin-left: auto;
  margin-right: auto;
}

.print-body {
  background: #fff;
  color: #172033;
}

.printable-page {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px;
  background: #fff;
}

.print-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--blue);
  margin-bottom: 24px;
}

.print-brand {
  display: flex;
  gap: 16px;
  align-items: center;
}

.print-brand img,
.print-logo-fallback {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  object-fit: contain;
}

.print-logo-fallback {
  display: grid;
  place-items: center;
  background: var(--blue);
  color: #fff;
  font-weight: 900;
  font-size: 2rem;
}

.print-brand h1 {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 900;
}

.print-brand p,
.print-meta span,
.document-title p,
.document-note,
.print-footer p {
  color: var(--muted);
  margin: 0;
}

.print-brand p span + span::before {
  content: " | ";
}

.print-meta {
  text-align: right;
  min-width: 160px;
}

.document-title {
  margin-bottom: 20px;
}

.document-title h2 {
  margin: 4px 0 6px;
  font-size: 2rem;
  font-weight: 900;
}

.document-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.document-summary div {
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue-2);
  border-radius: 8px;
  padding: 12px;
}

.document-summary span {
  display: block;
  color: var(--muted);
  font-weight: 700;
  font-size: .82rem;
}

.document-summary strong {
  display: block;
  font-size: 1.2rem;
  margin-top: 4px;
}

.print-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 24px;
  page-break-inside: auto;
}

.print-table th,
.print-table td {
  border: 1px solid #d9dee8;
  padding: 8px 10px;
  vertical-align: top;
}

.print-table th {
  background: #f3f6fb;
  color: var(--ink);
  font-size: .78rem;
  text-transform: uppercase;
}

.print-table tr {
  page-break-inside: avoid;
}

.document-content {
  line-height: 1.65;
}

.document-note {
  border-left: 4px solid var(--gold);
  padding: 12px 14px;
  background: #fffaf0;
  margin: 22px 0;
}

.print-footer {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 32px;
  border-top: 1px solid var(--line);
  margin-top: 36px;
  padding-top: 24px;
}

.document-signature span {
  display: block;
  height: 54px;
  border-bottom: 1px solid #172033;
  margin-bottom: 8px;
}

.acta-template {
  display: grid;
  gap: 10px;
  margin-bottom: 24px;
}

.lined-block {
  min-height: 70px;
  border: 1px dashed #c7cfdd;
  background: linear-gradient(#fff 31px, #eef1f6 32px);
  background-size: 100% 32px;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .sidebar .nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  }

  .topbar, .content {
    padding: 18px;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 760px) {
  .dashboard-hero,
  .resident-hero,
  .product-landing {
    align-items: stretch;
    flex-direction: column;
  }

  .search-panel,
  .security-card {
    grid-template-columns: 1fr;
  }

  .security-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .security-actions .btn,
  .landing-actions .btn {
    width: 100%;
  }

  .product-landing {
    min-height: auto;
    padding-top: 54px;
    padding-bottom: 54px;
  }

  .print-footer {
    grid-template-columns: 1fr;
  }
}

@media print {
  .sidebar, .topbar, .page-heading .btn, .btn, .no-print, .dashboard-hero, .resident-hero, .quick-actions {
    display: none !important;
  }

  body, .print-body {
    background: #fff !important;
  }

  .app-shell {
    display: block;
  }

  .content {
    padding: 0;
  }

  .panel, .stat-card {
    box-shadow: none;
  }

  .printable-page {
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .print-header,
  .print-footer,
  .document-summary div,
  .print-table th,
  .print-table td {
    break-inside: avoid;
  }
}
