:root {
  --brand-green: #68b022;
  --brand-green-dark: #528f18;
  --brand-green-light: #eef8e3;
  --header-dark: #1f2429;
  --panel-dark: #262c32;
  --bg-page: #f3f5f8;
  --card-bg: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --tenant-color: #2563eb;
  --tenant-bg: #eff6ff;
  --owner-color: #d97706;
  --owner-bg: #fffbeb;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  padding-bottom: 48px;
}

/* Topbar 3 zonas */
.topbar {
  background-color: var(--header-dark);
  color: #ffffff;
  min-height: 62px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 20px 0 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  height: 100%;
  gap: 14px;
}

.brand-box {
  background: linear-gradient(135deg, #68b022, #4d8a15);
  height: 62px;
  width: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.app-title-block .app-main-name {
  font-size: 16px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.2px;
}

.app-title-block .app-sub-name {
  font-size: 11.5px;
  color: #94a3b8;
}

/* Zona Central: Desarrollado por */
.topbar-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 6px 16px;
  border-radius: 99px;
}

.dev-label {
  font-size: 12px;
  color: #cbd5e1;
}

.dev-name {
  font-size: 13px;
  font-weight: 700;
  color: #a3e635;
}

.dev-logo-img {
  height: 26px;
  max-width: 90px;
  object-fit: contain;
  border-radius: 4px;
  background: #fff;
  padding: 2px;
}

/* Zona Derecha: Empresa Cliente + Usuario + Acciones */
.topbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.company-logo-img {
  height: 34px;
  max-width: 110px;
  object-fit: contain;
  border-radius: 4px;
  background: #fff;
  padding: 2px 4px;
}

.company-info {
  text-align: right;
  line-height: 1.25;
}

.company-info .company-short {
  font-size: 12.5px;
  font-weight: 700;
  color: #ffffff;
}

.company-info .user-session-badge {
  font-size: 11px;
  color: #a3e635;
}

/* Container a una sola columna amplia */
.container {
  max-width: 1280px;
  margin: 24px auto;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.card-header {
  background-color: var(--panel-dark);
  color: #ffffff;
  padding: 14px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.step-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 600;
}

.step-badge {
  background-color: var(--brand-green);
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.card-body {
  padding: 22px;
}

.search-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.dates-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

@media (max-width: 960px) {
  .dates-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .topbar {
    grid-template-columns: 1fr;
    padding: 10px 16px;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12.5px;
  font-weight: 600;
  color: #475569;
}

.form-control {
  height: 40px;
  padding: 6px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13.5px;
  color: var(--text-main);
  background-color: #fff;
}

.form-control:disabled,
.input-concepto:disabled,
.input-money:disabled,
.input-pct:disabled,
.select-rule:disabled {
  background-color: #f1f5f9 !important;
  color: #475569 !important;
  cursor: not-allowed;
  border-color: #e2e8f0 !important;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.btn-green { background-color: var(--brand-green); color: #ffffff; }
.btn-green:hover { background-color: var(--brand-green-dark); }
.btn-outline { background-color: #ffffff; border-color: #cbd5e1; color: #334155; }
.btn-outline:hover { background-color: #f1f5f9; }
.btn-dark { background-color: #334155; color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

/* Tabla Softinm */
.table-wrapper {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.softinm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.softinm-table thead th {
  background-color: var(--brand-green);
  color: #ffffff;
  text-align: left;
  padding: 11px 14px;
  font-weight: 600;
}

.softinm-table tbody tr {
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
}

.softinm-table tbody tr:hover { background-color: #f8fafc; }
.softinm-table tbody tr.selected-row { background-color: var(--brand-green-light); font-weight: 500; }
.softinm-table td { padding: 10px 14px; color: #334155; }

.badge-active {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
}
.badge-active.yes { background-color: #dcfce7; color: #15803d; }
.badge-active.no { background-color: #f1f5f9; color: #64748b; }

/* Dropzone PDF */
.pdf-dropzone {
  border: 2px dashed #94a3b8;
  background-color: #f8fafc;
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  margin-bottom: 18px;
}
.pdf-dropzone:hover { border-color: var(--brand-green); background-color: var(--brand-green-light); }
.pdf-status-box {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 18px;
  display: none;
}

/* Línea de Tiempo Visual */
.timeline-box {
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin-bottom: 20px;
}
.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}
.delay-pill {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 99px;
}
.timeline-bar-container {
  height: 38px;
  background: #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  margin: 14px 0 8px 0;
}
.timeline-segment-owner {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  transition: width 0.3s ease;
  overflow: hidden;
  white-space: nowrap;
}
.timeline-segment-tenant {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  transition: width 0.3s ease;
  overflow: hidden;
  white-space: nowrap;
}
.timeline-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* KPIs */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 24px;
}
.kpi-card { border-radius: 10px; padding: 18px 20px; border: 1px solid var(--border-color); }
.kpi-card.total-bill { background: #f8fafc; }
.kpi-card.tenant-share { background: var(--tenant-bg); border-color: #bfdbfe; }
.kpi-card.owner-share { background: var(--owner-bg); border-color: #fde68a; }
.kpi-label { font-size: 12px; font-weight: 700; text-transform: uppercase; margin-bottom: 6px; }
.kpi-card.tenant-share .kpi-label { color: #1e40af; }
.kpi-card.owner-share .kpi-label { color: #92400e; }
.kpi-amount { font-size: 28px; font-weight: 800; margin-bottom: 4px; }
.kpi-card.tenant-share .kpi-amount { color: #1d4ed8; }
.kpi-card.owner-share .kpi-amount { color: #b45309; }
.kpi-sub { font-size: 12.5px; color: var(--text-muted); }

/* Tablas de Servicios y Otros Conceptos */
.services-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  table-layout: fixed;
}
.services-table th {
  background: #f1f5f9;
  color: #334155;
  padding: 11px 14px;
  text-align: left;
  font-size: 12.5px;
  font-weight: 700;
  border-bottom: 1px solid #cbd5e1;
}
.services-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #e2e8f0;
  vertical-align: middle;
}
.input-concepto {
  width: 100%;
  height: 38px;
  padding: 6px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 500;
}
.input-money {
  width: 100%;
  height: 38px;
  padding: 6px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  text-align: right;
}
.input-pct {
  width: 82px;
  height: 38px;
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}
.select-rule {
  width: 100%;
  height: 38px;
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13px;
}

.whatsapp-box {
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 10px;
  padding: 16px 18px;
  margin-top: 20px;
}
.whatsapp-textarea {
  width: 100%;
  min-height: 170px;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 12px;
  font-family: inherit;
  font-size: 13.5px;
  margin-top: 10px;
}

/* Modales (Login y Panel Admin) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
}

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

.login-card {
  max-width: 420px;
}

.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 10px;
}

.perm-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 14px;
}

.perm-box h5 {
  font-size: 13px;
  color: #1e293b;
  margin-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 4px;
}

.perm-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  margin-bottom: 6px;
  cursor: pointer;
}

#activationPanel textarea, #recoveryPanel textarea, #recoveryPanel input[type="password"] {
  display: block;
  box-sizing: border-box;
  width: 100%;
  padding: 9px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  margin: 8px 0;
}
#activationPanel button, #recoveryPanel button { margin: 5px 0; }
#activationPanel input[type="file"], #recoveryPanel input[type="file"] { max-width: 100%; }
.print-field-value { display: none; }

@page { size: landscape; margin: 10mm; }

@media print {
  .topbar, .no-print, .modal-overlay {
    display: none !important;
  }
  body { background: #fff; padding: 0; }
  .container { max-width: 100%; margin: 0; padding: 0; }
  #mainAppContainer { gap: 12px; }
  .print-field-source { display: none !important; }
  .print-field-value {
    display: block;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: normal;
    min-width: 0;
    font-size: 11px;
    line-height: 1.4;
    color: #111827;
  }
  .table-wrapper { overflow: visible !important; }
  table { width: 100% !important; min-width: 0 !important; table-layout: fixed; }
  th, td { white-space: normal !important; overflow-wrap: anywhere; padding: 7px !important; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
  .card { box-shadow: none; overflow: visible; }
  .card-header, h4 { break-after: avoid; }
  .form-group { min-width: 0; break-inside: avoid; }
  .dates-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  #whatsappContainer .print-field-value { font-size: 11px; }
}

/* Demo web: panel de administración más amplio y tabla de usuarios legible */
#adminModal .modal-card { max-width: min(1320px, 96vw); }
#adminModal .table-wrapper { overflow-x: auto; }
#adminModal .services-table { min-width: 1180px; }
#adminModal .services-table td { vertical-align: top; }
#adminModal .services-table .input-concepto { width: 100%; min-width: 0; }
#adminModal .services-table .select-rule { width: 100%; min-width: 110px; }
