:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #475569;
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-soft: #e0f2fe;
  --navy: #0f172a;
  --navy-light: #1e293b;
  --success: #059669;
  --success-soft: #d1fae5;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --purple: #7c3aed;
  --purple-soft: #ede9fe;
  --radius: 14px;
  --shadow: 0 4px 18px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Top Header & Persona Bar */
.top-shell {
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

.top-bar {
  max-width: 1320px;
  margin: 0 auto;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

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

.brand img {
  width: 38px;
  height: 38px;
  border-radius: 10px;
}

.brand-title {
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 0.76rem;
  color: #94a3b8;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  background: rgba(16, 185, 129, 0.16);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.35);
  padding: 5px 10px;
  border-radius: 999px;
  font-weight: 600;
}

.live-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(1.25); }
}

.persona-strip {
  background: var(--navy-light);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.persona-nav {
  max-width: 1320px;
  margin: 0 auto;
  padding: 8px 18px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.persona-btn {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.15s ease;
}

.persona-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.persona-btn.active {
  background: var(--primary);
  border-color: #38bdf8;
  color: #fff;
  box-shadow: 0 2px 10px rgba(2, 132, 199, 0.45);
}

.badge-count {
  background: #ef4444;
  color: #fff;
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 700;
}

/* Main Container */
.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px 18px 64px;
}

.guest-container {
  max-width: 640px;
  margin: 0 auto;
  padding: 18px 14px 64px;
}

/* Cards & Grids */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.kpi-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 700;
}

.kpi-value {
  font-size: 1.85rem;
  font-weight: 800;
  margin-top: 4px;
  color: var(--text);
}

.kpi-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 3px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 18px;
}

.grid-equal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

@media (max-width: 920px) {
  .grid-2, .grid-equal {
    grid-template-columns: 1fr;
  }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 0.87rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover:not(:disabled) {
  background: #047857;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover:not(:disabled) {
  background: #b91c1c;
}

.btn-warning {
  background: var(--warning);
  color: #fff;
}

.btn-outline {
  background: #fff;
  border-color: #cbd5e1;
  color: var(--text);
}
.btn-outline:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #94a3b8;
}

.btn-dark-outline {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.22);
  color: #fff;
  padding: 6px 12px;
  font-size: 0.8rem;
}
.btn-dark-outline:hover {
  background: rgba(255, 255, 255, 0.18);
}

.btn-lg {
  padding: 13px 20px;
  font-size: 0.98rem;
  font-weight: 700;
  border-radius: 12px;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 0.78rem;
  border-radius: 8px;
}

/* Status Tags */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 700;
  white-space: nowrap;
}

.tag-ready { background: var(--success-soft); color: #065f46; }
.tag-waiting { background: var(--warning-soft); color: #92400e; }
.tag-inside { background: var(--primary-soft); color: #075985; }
.tag-done { background: #e2e8f0; color: #334155; }
.tag-critical { background: var(--danger-soft); color: #991b1b; }
.tag-cohost { background: var(--purple-soft); color: #5b21b6; }

/* Reservation Cards for Porteiro */
.porter-item {
  border: 1px solid var(--border);
  border-left: 5px solid var(--primary);
  border-radius: 12px;
  padding: 15px;
  margin-bottom: 12px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.porter-item.ready { border-left-color: var(--success); }
.porter-item.waiting { border-left-color: var(--warning); }
.porter-item.overstay { border-left-color: var(--danger); background: #fffafa; }

.porter-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

.apt-badge {
  background: var(--navy);
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  padding: 4px 11px;
  border-radius: 8px;
  display: inline-block;
}

.guest-chips {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface-alt);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.guest-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.86rem;
}

/* 100-Unit Building Matrix */
.building-legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  font-size: 0.8rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

.units-matrix {
  display: grid;
  grid-template-columns: repeat(10, minmax(54px, 1fr));
  gap: 6px;
  overflow-x: auto;
}

.unit-cell {
  border-radius: 8px;
  padding: 7px 4px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  position: relative;
  transition: transform 0.1s ease;
}

.unit-cell:hover {
  transform: translateY(-2px);
}

.unit-cell.RESIDENCIAL {
  background: #f1f5f9;
  color: #64748b;
  border-color: #cbd5e1;
}

.unit-cell.LIVRE_STR {
  background: #ecfdf5;
  color: #047857;
  border-color: #6ee7b7;
}

.unit-cell.CHECKIN_HOJE {
  background: #fef3c7;
  color: #b45309;
  border-color: #fcd34d;
}

.unit-cell.OCUPADO_STR {
  background: #0284c7;
  color: #ffffff;
  border-color: #0369a1;
}

.unit-alert-dot {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 12px;
  height: 12px;
  background: #dc2626;
  border: 2px solid #fff;
  border-radius: 50%;
}

/* Forms */
.form-group {
  margin-bottom: 13px;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 5px;
  color: #334155;
}

.form-control {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  font-size: 0.92rem;
  background: #fff;
  color: var(--text);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.form-control.ocr-filled {
  border-color: var(--success);
  background: #f0fdf4;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 560px) {
  .form-row {
    grid-template-columns: 1fr;
  }
  .units-matrix {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* OCR Capture Box */
.ocr-box {
  border: 2px dashed #38bdf8;
  background: linear-gradient(180deg, #f0f9ff 0%, #ffffff 100%);
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  margin-bottom: 16px;
}

.doc-preview-img {
  max-width: 100%;
  max-height: 200px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  margin-top: 10px;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--surface-alt);
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-panel {
  background: #fff;
  border-radius: 18px;
  max-width: 540px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

/* Toast Notification */
.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
  max-width: 360px;
}

.toast {
  background: var(--navy);
  color: #fff;
  padding: 13px 16px;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
  border-left: 4px solid #38bdf8;
  font-size: 0.86rem;
  animation: slideIn 0.25s ease;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Module Feature Toggle Cards (Admin System) */
.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(275px, 1fr));
  gap: 12px;
}

.module-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  transition: all 0.15s ease;
}

.module-card.enabled {
  border-color: #38bdf8;
  background: #f0f9ff;
}

.module-card.disabled {
  background: #f8fafc;
  opacity: 0.85;
}

.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #cbd5e1;
  transition: 0.2s;
  border-radius: 999px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.2s;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

input:checked + .slider {
  background-color: #059669;
}

input:checked + .slider:before {
  transform: translateX(22px);
}

.unit-cell.INQUILINO_LONGO {
  background: #ede9fe;
  border-color: #8b5cf6;
  color: #4c1d95;
}

.role-pills-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

/* Print Plaque / Assembly Report */
@media print {
  .top-shell, .no-print, .toast-stack {
    display: none !important;
  }
  body {
    background: #fff;
  }
  .card {
    box-shadow: none;
    border: 1px solid #cbd5e1;
  }
}
