#appMain {
  padding-bottom: 20px;
}

html,
body {
  overflow-x: hidden;
}

input,
select,
textarea {
  font-size: 16px;
}

* {
  touch-action: manipulation;
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display',
    system-ui, Arial, sans-serif;
  background: #f4f6f8;
}

/* =========================
   HEADER CONTAINER
========================= */
.admin-header {
  display: flex;
  gap: 16px;
  padding: 16px;
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  margin: 12px;
}

/* =========================
   LEFT (60%)
========================= */
.admin-header-left {
  flex: 0 0 60%;
}

/* BACK */
.admin-back-btn {
  background: #f3f4f6;
  border: none;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  margin-bottom: 10px;
}

/* TITLE */
.admin-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-title-row h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: #111827;
}

/* BADGE */
.badge-completed {
  background: #d1fae5;
  color: #065f46;
  padding: 4px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
}

/* INFO */
.admin-info {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.info-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #4b5563;
}

.info-line i {
  font-size: 14px;
  color: #6b7280;
}

/* =========================
   RIGHT (40%)
========================= */
.admin-header-right {
  flex: 0 0 40%;
  padding-left: 16px;
  padding-right: 8px; /* 🔥 ESTE ES EL FIX */
  border-left: 1px solid #e5e7eb;
}

/* ROW */
.right-row {
  display: grid;
  grid-template-columns: 80px 1fr;
  font-size: 14px;
  align-items: center;
}

/* LABEL */
.right-row span {
  color: #6b7280;
}

/* VALUE */
.right-row strong {
  color: #111827;
  font-weight: 600;
}

/* STATUS COLOR */
#statusText {
  color: #16a34a;
}

/* =========================
   STATS ROW
========================= */
.admin-stats {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 16px 12px;
  padding: 14px;
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  overflow-x: hidden;
  flex-wrap: wrap;
}

/* ITEM */
.stat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

/* ICON */
.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
}

/* COLORS */
.stat-icon.blue {
  background: #3b82f6;
}
.stat-icon.green {
  background: #22c55e;
}
.stat-icon.purple {
  background: #8b5cf6;
}
.stat-icon.orange {
  background: #f97316;
}
.stat-icon.teal {
  background: #14b8a6;
}

/* TEXT */
.stat-text {
  display: flex;
  flex-direction: column;
  font-size: 12px;
}

.stat-text strong {
  font-size: 14px;
  color: #111;
}

.stat-text span {
  color: #6b7280;
}

.stat-item {
  min-width: auto;
  flex: 1 1 45%;
}

/* =========================
DOSAGES TABLE
========================= */

.admin-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 16px;
  margin: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* 🔥 SOLO ESTE BLOQUE NUEVO */
.admin-card:last-of-type {
  margin-bottom: 250px;
}

.admin-card-title {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 12px;
  color: #111827;
}

.admin-table-header,
.admin-table-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  align-items: center;
}

.admin-table-header {
  font-size: 13px;
  font-weight: 600;
  color: #6b7280;
  padding-bottom: 8px;
  border-bottom: 1px solid #e5e7eb;
}

.admin-table-row {
  font-size: 14px;
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
}

.admin-table-row:last-child {
  border-bottom: none;
}

/* ========================
READINGS
======================== */

/* GRID */
.readings-grid-4 {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 0.8fr 0.8fr;
  align-items: center;
}

/* TABLE */
.readings-table {
  width: 100%;
  overflow: hidden;
}

/* HEADER */
.readings-header {
  font-size: 13px;
  font-weight: 600;
  color: #6b7280;
  padding-bottom: 8px;
  border-bottom: 1px solid #e5e7eb;
}

/* ROW */
.readings-row {
  font-size: 14px;
  color: #111827;
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
}

/* LAST ROW */
.readings-row:last-child {
  border-bottom: none;
}

/* TEXT CONTROL */
.readings-header span,
.readings-row span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ALIGNMENT */
.readings-col-parameter {
  text-align: left;
}

.readings-col-ideal {
  text-align: left;
}

.readings-col-center {
  text-align: right; /* 🔥 este es el cambio importante */
}

/* CARD */
.readings-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 16px;
  margin: 12px 16px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

/* TITLE */
.readings-title {
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 12px;
}

.readings-header span:nth-child(1),
.readings-header span:nth-child(2) {
  text-align: left;
}

.readings-header span:nth-child(3),
.readings-header span:nth-child(4) {
  text-align: right;
}

/* =========================
NOTES
========================= */
.notes-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 16px;
  margin: 12px 16px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.notes-title {
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 12px;
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.notes-item {
  font-size: 14px;
  color: #111827;
  line-height: 1.4;
}

.notes-date {
  font-weight: 600;
  color: #6b7280;
  margin-right: 6px;
}

.notes-empty {
  font-size: 14px;
  color: #6b7280;
}

/* =========================
PHOTOS
========================= */
.photos-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 16px;
  margin: 12px 16px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

/* HEADER */
.photos-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.photos-title {
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
}

.photos-view-all {
  font-size: 13px;
  color: #2563eb;
  cursor: pointer;
}

/* LIST */
.photos-list {
  display: flex;
  gap: 10px;
  overflow-x: auto;
}

/* ITEM */
.photos-item {
  min-width: 90px;
  max-width: 90px;
  flex: 0 0 auto;
}

/* IMAGE */
.photos-img {
  width: 90px;
  height: 90px;
  object-fit: cover;
  border-radius: 10px;
  cursor: pointer;
}

/* LABEL */
.photos-label {
  font-size: 12px;
  color: #374151;
  margin-top: 4px;
  text-align: center;
}

/* TIME */
.photos-time {
  font-size: 11px;
  color: #9ca3af;
  text-align: center;
}

/* FULLSCREEN VIEWER */
.photo-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.photo-full {
  max-width: 90%;
  max-height: 90%;
  border-radius: 8px;
}

/* =========================
HISTORY
========================= */
.history-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 16px;
  margin: 12px 16px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.history-title {
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 12px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.history-left {
  display: flex;
  flex-direction: column;
}

.history-date {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
}

.history-time {
  font-size: 12px;
  color: #6b7280;
}

.history-status {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.status-completed {
  background: #dcfce7;
  color: #166534;
}

.status-in_progress {
  background: #dbeafe;
  color: #1e3a8a;
}

.status-scheduled {
  background: #fef3c7;
  color: #92400e;
}

.status-cancelled {
  background: #fee2e2;
  color: #991b1b;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.history-view-all {
  font-size: 13px;
  color: #2563eb;
  cursor: pointer;
}

.history-page-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
}

.back-btn {
  border: none;
  background: #f3f4f6;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}

.history-page-title {
  font-size: 16px;
  font-weight: 600;
}

/* =========================
NEXT VISIT
========================= */
.next-visit-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 16px;
  margin: 12px 16px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.next-visit-title {
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 12px;
}

/* =========================
NEXT VISIT GRID
========================= */
.next-visit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: stretch; /* 🔥 CLAVE */
}

/* LEFT */
.next-visit-left {
  display: flex;
  flex-direction: column;
}

/* RIGHT */
.next-visit-right {
  display: flex;
  justify-content: center;
  align-items: center;
  border-left: 2px solid #e5e7eb;
  padding-left: 16px;
  height: 100%; /* 🔥 CLAVE */
}

/* TEXT */
.next-visit-date {
  font-size: 18px;
  font-weight: 700;
  color: #111827;
}

.next-visit-time {
  font-size: 14px;
  color: #6b7280;
}

.next-visit-tech {
  font-size: 24px;
  font-weight: 600;
}

/* COLORS */
.tech-assigned {
  color: #16a34a;
}

.tech-unassigned {
  color: #dc2626;
}

.next-visit-empty {
  font-size: 14px;
  color: #6b7280;
}

/* =========================
VISIT ACTIONS
========================= */
.visit-actions {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  margin: 12px 16px;
}

.action-btn {
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* COLORS */
.btn-complete {
  background: #16a34a;
  color: #fff;
}

.btn-cancel {
  background: #dc2626;
  color: #fff;
}

.btn-reschedule {
  background: #2563eb;
  color: #fff;
}

@media (max-width: 768px) {
  .admin-header {
    flex-direction: column;
  }

  .admin-header-left,
  .admin-header-right {
    flex: 1 1 100%;
    border-left: none;
    padding-left: 0;
  }

  .admin-header-right {
    margin-top: 12px;
  }
}
