:root {
  --primary: #2A9D8F;
  --primary-dark: #1f7a6e;
  --primary-light: #e8f5f3;
  --accent: #E9C46A;
  --danger: #E76F51;
  --warning: #F4A261;
  --success: #2A9D8F;
  --text: #264653;
  --muted: #6c757d;
  --border: #dee2e6;
  --white: #ffffff;
  --bg: #f8fafb;
}

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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ── Navbar ── */
.navbar {
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.5rem;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.navbar-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: white;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.navbar-nav {
  display: flex;
  gap: 0.25rem;
  list-style: none;
  flex: 1;
}

.navbar-nav a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  padding: 0.4rem 0.85rem;
  border-radius: 6px;
  font-size: 0.875rem;
  transition: background 0.15s;
}

.navbar-nav a:hover,
.navbar-nav a.active {
  background: rgba(255,255,255,0.2);
  color: white;
}

.navbar-end {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.rol-badge {
  background: rgba(255,255,255,0.2);
  color: white;
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  font-weight: 600;
  text-transform: capitalize;
}

.navbar-end a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 0.875rem;
}

.navbar-end a:hover { color: white; }

/* ── Layout ── */
.page-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

/* ── Cards ── */
.card {
  background: white;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary-light);
}

/* ── Forms ── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.form-group input,
.form-group select,
.form-group textarea {
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  color: var(--text);
  background: white;
  transition: border-color 0.15s;
  width: 100%;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(42,157,143,0.15);
}

.form-group textarea { resize: vertical; min-height: 80px; }

.form-group.full-width { grid-column: 1 / -1; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  border-radius: 7px;
  border: none;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: white;
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover { background: var(--bg); }

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}

.btn-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

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

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

table th {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 700;
  padding: 0.6rem 0.75rem;
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table tr:last-child td { border-bottom: none; }
table tr:hover td { background: var(--primary-light); }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-al-dia    { background: #d1f0ec; color: #1a6b63; }
.badge-proximo   { background: #fff3cd; color: #856404; }
.badge-vencido   { background: #fde8e4; color: #9b2715; }
.badge-alerta    { background: #fde8e4; color: #9b2715; }
.badge-normal    { background: #d1f0ec; color: #1a6b63; }

/* ── Alerts ── */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffc107; }
.alert-danger  { background: #fde8e4; color: #9b2715; border: 1px solid var(--danger); }
.alert-success { background: #d1f0ec; color: #1a6b63; border: 1px solid var(--primary); }
.alert-info    { background: #e8f4fd; color: #0c5d8c; border: 1px solid #90cdf4; }

/* ── Search bar ── */
.search-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.search-bar input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
}

.search-bar input:focus {
  outline: none;
  border-color: var(--primary);
}

/* ── Login page ── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.login-card {
  background: white;
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-logo h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
}

.login-logo p {
  color: var(--muted);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* ── Stats pills ── */
.stats-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.stat-pill {
  background: white;
  border-radius: 8px;
  padding: 0.75rem 1.25rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.stat-pill .stat-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
}

.stat-pill.warning .stat-value { color: var(--warning); }
.stat-pill.danger  .stat-value { color: var(--danger); }

/* ── Two-column layout ── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 768px) {
  .two-col { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

/* ── Sidebar layout (replaces inline 2-panel grids) ── */
.sidebar-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 900px) {
  .sidebar-layout { grid-template-columns: 1fr; }
}
.sidebar-layout-reverse {
  grid-template-columns: 1fr 360px;
}
@media (max-width: 900px) {
  .sidebar-layout-reverse { grid-template-columns: 1fr; }
}

/* ── Tablet (≤ 900px) ── */
@media (max-width: 900px) {
  .row-4 { grid-template-columns: 1fr 1fr; }
  .row-3 { grid-template-columns: 1fr 1fr; }
}

/* ── Phone (≤ 640px) ── */
@media (max-width: 640px) {
  .page-container { padding: 0.875rem; }

  /* grids */
  .row-4 { grid-template-columns: 1fr 1fr; }
  .row-3 { grid-template-columns: 1fr 1fr; }
  .row-2 { grid-template-columns: 1fr; }

  /* stats */
  .stats-row { flex-wrap: wrap; }
  .stat-pill  { flex: 1 1 calc(50% - 0.5rem); }

  /* ficha footer */
  .ficha-footer { flex-direction: column; gap: 10px; align-items: stretch; }
  .ficha-footer .footer-note { text-align: center; }
  .ficha-footer .footer-btns { flex-direction: column; gap: 8px; }
  .ficha-footer .footer-btns .btn { justify-content: center; }

  /* treatment row: product full-width, dosis/freq stack */
  .treatment-row { grid-template-columns: 1fr auto; flex-wrap: wrap; }

  /* timeline */
  .tl-time { min-width: 44px; font-size: 10px; }
  .tl-card  { flex-wrap: wrap; gap: 8px; }
  .tl-card .btn { padding: 0.25rem 0.55rem; font-size: 0.75rem; }

  /* slots grid: 4 cols on phone */
  .slots-grid { grid-template-columns: repeat(4, 1fr); }

  /* mini calendar */
  .cal-day { width: 28px; height: 28px; font-size: 11px; }
  .cal-dow  { font-size: 9px; padding-bottom: 4px; }

  /* patient header: stack avatar + meta */
  .patient-hdr { flex-wrap: wrap; gap: 12px; }

  /* tabs: horizontal scroll */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .tab-item { white-space: nowrap; }

  /* appt list cards */
  .appt { flex-wrap: wrap; }

  /* autocomplete fixed on phone */
  .ac-dropdown { position: fixed; left: 0.75rem; right: 0.75rem; }

  /* card body padding tighter */
  .card-body { padding: 14px; }
  .f-section { padding: 14px; }
}

/* ── Responsive tables: card style on phone ── */
@media (max-width: 640px) {
  .table-responsive table thead { display: none; }
  .table-responsive table tr {
    display: block;
    border-bottom: 2px solid var(--border);
    padding: 8px 4px;
  }
  .table-responsive table tr:last-child { border-bottom: none; }
  .table-responsive table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 8px;
    font-size: 13px;
    border-bottom: none;
  }
  .table-responsive table td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--muted);
    margin-right: 8px;
    flex-shrink: 0;
  }
  .table-responsive table tr:hover td { background: transparent; }
}

/* ── Navbar hamburger ── */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px 8px;
  margin-left: auto;
  line-height: 1;
}
@media (max-width: 640px) {
  .navbar { flex-wrap: wrap; padding: 0 1rem; height: auto; min-height: 52px; gap: 0; }
  .navbar-brand { padding: 12px 0; }
  .nav-toggle { display: block; padding: 12px 0; }
  .navbar-nav {
    display: none;
    flex-direction: column;
    width: 100%;
    gap: 0;
    padding: 6px 0 10px;
    border-top: 1px solid rgba(255,255,255,0.15);
    order: 3;
  }
  .navbar-nav.open { display: flex; }
  .navbar-nav a { padding: 0.55rem 0.5rem; border-radius: 6px; }
  .navbar-end {
    order: 2;
    margin-left: auto;
    gap: 0.4rem;
  }
  .navbar-end > span:not(.rol-badge) { display: none; }
}

/* ── Misc ── */
.text-muted  { color: var(--muted); }
.text-danger { color: var(--danger); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }

.errorlist {
  list-style: none;
  color: var(--danger);
  font-size: 0.8rem;
  margin-top: 0.25rem;
}

.inline-formset-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)) 40px;
  gap: 0.5rem;
  align-items: end;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.inline-formset-row:last-of-type { border-bottom: none; }

.btn-remove-row {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.4rem;
}

.stock-bar-wrap {
  background: var(--border);
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
  margin-top: 0.25rem;
}

.stock-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.3s;
}

.stock-bar.low  { background: var(--warning); }
.stock-bar.empty { background: var(--danger); }

/* ── Card header (colored) ── */
.card-hdr {
  background: var(--primary);
  color: white;
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 10px 10px 0 0;
}
.card-hdr .hdr-icon {
  width: 30px; height: 30px;
  background: rgba(255,255,255,0.2);
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 15px;
}
.card-hdr .hdr-badge {
  margin-left: auto;
  background: rgba(255,255,255,0.25);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.card-body { padding: 20px; }
.card-hdr + .card-body { border-top: none; }
.card.no-pad { padding: 0; overflow: hidden; }

/* ── Client info box ── */
.client-box {
  background: #F0FAF8;
  border: 1px solid #BFE3DD;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 16px;
}
.client-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: grid; place-items: center;
  font-weight: 700; font-size: 16px;
  margin-bottom: 8px;
}
.client-box .client-name { font-weight: 700; font-size: 15px; }
.client-box .client-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ── Patient selection list ── */
.patient-list { display: flex; flex-direction: column; gap: 8px; }
.patient-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  background: #fff;
  transition: all 0.15s;
}
.patient-item:hover { border-color: var(--primary); }
.patient-item.selected {
  border-color: var(--primary);
  background: #E8F5F3;
  box-shadow: 0 0 0 2px rgba(42,157,143,0.15);
}
.patient-item .p-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: #F0FAF8;
  display: grid; place-items: center;
  font-size: 18px;
  flex-shrink: 0;
}
.patient-item.selected .p-icon { background: var(--primary); }
.patient-item .p-info { flex: 1; min-width: 0; }
.patient-item .p-name { font-weight: 600; font-size: 14px; }
.patient-item .p-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.patient-item .p-check {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 11px;
  font-weight: 700;
  color: transparent;
}
.patient-item.selected .p-check {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

/* ── Time slot grid ── */
.slots-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.slot {
  padding: 10px 4px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: #FAFBFC;
  transition: all 0.15s;
  user-select: none;
}
.slot:hover:not(.taken) { border-color: var(--primary); }
.slot.taken {
  background: #FDECE7;
  border-color: #F6C6B6;
  color: var(--danger);
  cursor: not-allowed;
  text-decoration: line-through;
  opacity: 0.7;
}
.slot.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(42,157,143,0.3);
}

/* ── Availability banner ── */
.avail-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  border-radius: 10px;
  background: #E8F5F3;
  border: 1px solid #BFE3DD;
  color: #1f7a6e;
  font-size: 13px; font-weight: 500;
  margin-bottom: 16px;
}
.avail-banner .avail-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(42,157,143,0.2);
  flex-shrink: 0;
}

/* ── Summary box ── */
.summary-box {
  background: #FAFBFC;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-top: 16px;
}
.summary-title {
  font-size: 11px; font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.summary-row {
  display: flex; justify-content: space-between;
  font-size: 13px; padding: 3px 0;
}
.summary-row .s-label { color: var(--muted); }
.summary-row .s-value { font-weight: 600; }

/* ── Agenda appointments (sidebar) ── */
.appt-list { display: flex; flex-direction: column; gap: 8px; }
.appt {
  display: flex; gap: 12px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  background: #fff;
  transition: all 0.15s;
  position: relative;
  text-decoration: none;
  color: var(--text);
}
.appt:hover { border-color: var(--primary); }
.appt.active {
  border-color: var(--primary);
  background: #E8F5F3;
  box-shadow: 0 0 0 2px rgba(42,157,143,0.15);
}
.appt-time {
  min-width: 50px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: #F0FAF8;
  border-radius: 8px;
  padding: 6px 4px;
  font-weight: 700;
  color: var(--primary-dark);
  font-size: 13px;
}
.appt.active .appt-time { background: var(--primary); color: white; }
.appt-info { flex: 1; min-width: 0; }
.appt-pet  { font-weight: 700; font-size: 14px; }
.appt-owner { font-size: 12px; color: var(--muted); margin-top: 1px; }
.appt-reason {
  display: inline-block;
  font-size: 11px;
  background: #F4F6F8;
  padding: 2px 8px;
  border-radius: 6px;
  margin-top: 4px;
  color: var(--text);
}
.appt.active .appt-reason { background: rgba(255,255,255,0.7); }
.status-dot {
  position: absolute; top: 10px; right: 10px;
  width: 8px; height: 8px; border-radius: 50%;
}
.status-dot.confirmed { background: var(--primary); }
.status-dot.done      { background: var(--muted); }
.status-dot.pending   { background: var(--accent); }

/* ── Patient header ── */
.patient-hdr {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 20px;
  background: linear-gradient(135deg, #F0FAF8 0%, #E8F5F3 100%);
  border-bottom: 1px solid var(--border);
}
.patient-avatar {
  width: 62px; height: 62px;
  border-radius: 16px;
  background: var(--primary);
  color: white;
  display: grid; place-items: center;
  font-size: 28px;
  flex-shrink: 0;
}
.patient-hdr h2 { font-size: 20px; font-weight: 700; }
.patient-hdr .tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.tag {
  font-size: 12px; padding: 3px 10px;
  background: white; border: 1px solid var(--border);
  border-radius: 999px; color: var(--text); font-weight: 500;
}
.tag.owner { background: var(--primary); color: white; border-color: var(--primary); }

/* ── Tabs ── */
.tabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  background: white;
}
.tab-item {
  padding: 11px 15px;
  font-size: 13px; font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  text-decoration: none;
  transition: color 0.15s;
}
.tab-item:hover { color: var(--primary); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Ficha form sections ── */
.f-section {
  padding: 20px;
  border-bottom: 1px dashed var(--border);
}
.f-section:last-child { border-bottom: none; }
.f-section-title {
  font-size: 13px; font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px;
}
.f-section-title .num {
  width: 22px; height: 22px;
  background: var(--primary); color: white;
  border-radius: 6px;
  display: grid; place-items: center;
  font-size: 12px; flex-shrink: 0;
}
.row-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; }
.row-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.f-field { margin-bottom: 12px; }
.f-field label {
  display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px;
}
.f-field input,
.f-field select,
.f-field textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; background: #FAFBFC; outline: none;
  font-family: inherit; resize: vertical;
}
.f-field input:focus,.f-field select:focus,.f-field textarea:focus {
  border-color: var(--primary); background: #fff;
  box-shadow: 0 0 0 3px rgba(42,157,143,0.12);
}
.treatment-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 8px; margin-bottom: 8px; align-items: center;
}
.btn-add-row {
  background: transparent;
  border: 1.5px dashed var(--primary);
  color: var(--primary); padding: 8px 14px;
  border-radius: 8px; cursor: pointer;
  font-size: 13px; font-weight: 600; width: 100%;
}
.btn-rm {
  background: transparent; border: 1px solid var(--border);
  color: var(--danger); width: 34px; height: 34px;
  border-radius: 8px; cursor: pointer; font-size: 15px;
}
.ficha-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 20px;
  background: #FAFBFC;
  border-top: 1px solid var(--border);
}
.ficha-footer .footer-note { font-size: 12px; color: var(--muted); }
.ficha-footer .footer-btns { display: flex; gap: 10px; }

/* ── History items (ficha) ── */
.history-item {
  border: 1px solid var(--border);
  border-radius: 10px; padding: 13px 15px;
  background: #FAFBFC; margin-bottom: 10px;
}
.history-head {
  display: flex; justify-content: space-between;
  margin-bottom: 6px;
}
.history-date { font-weight: 700; font-size: 13px; }
.history-vet  { font-size: 12px; color: var(--muted); }
.history-diag {
  display: inline-block; background: #E8F5F3;
  color: var(--primary-dark); padding: 2px 9px;
  border-radius: 6px; font-size: 12px; font-weight: 600;
  margin-right: 4px; margin-bottom: 4px;
}
.history-note { font-size: 13px; color: var(--text); line-height: 1.4; margin-top: 4px; }

/* ── Product card (inventario) ── */
.product-card {
  border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden;
}
.product-top {
  display: flex; gap: 14px; padding: 16px;
  background: linear-gradient(135deg, #F0FAF8, #E8F5F3);
  border-bottom: 1px solid var(--border);
}
.product-img {
  width: 60px; height: 60px; border-radius: 12px;
  background: white; display: grid; place-items: center;
  font-size: 28px; border: 1px solid var(--border); flex-shrink: 0;
}
.product-info .product-code {
  font-size: 11px; color: var(--muted); font-weight: 600;
  letter-spacing: 0.5px; margin-bottom: 3px;
}
.product-info .product-name { font-size: 17px; font-weight: 700; margin-bottom: 3px; }
.product-info .product-sub  { font-size: 12px; color: var(--muted); }
.stock-section { padding: 16px; }
.stock-label {
  display: flex; justify-content: space-between;
  font-size: 13px; font-weight: 600; margin-bottom: 8px;
}
.stock-label .count b { font-size: 17px; color: var(--primary-dark); }
.stock-bar-full {
  height: 10px; background: #F0F0F0;
  border-radius: 999px; overflow: hidden; position: relative;
}
.stock-bar-full .fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #3ab9aa);
  border-radius: 999px; transition: width 0.3s;
}
.stock-bar-full.low .fill { background: linear-gradient(90deg, var(--accent), var(--danger)); }
.stock-bar-full .min-line {
  position: absolute; top: -3px; bottom: -3px;
  width: 2px; background: var(--danger);
}
.stock-meta {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--muted); margin-top: 5px;
}
.info-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--border);
}
.info-cell {
  padding: 11px 15px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.info-cell:nth-child(2n)  { border-right: none; }
.info-cell:nth-last-child(-n+2) { border-bottom: none; }
.info-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; margin-bottom: 3px; }
.info-value { font-size: 13px; font-weight: 600; }
.info-value.warn { color: #856404; }
.info-value.err  { color: var(--danger); }

/* ── Qty stepper ── */
.qty-stepper {
  display: flex; align-items: stretch;
  border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; background: #FAFBFC;
}
.qty-stepper button {
  background: #F0FAF8; border: none;
  width: 44px; font-size: 18px; font-weight: 700;
  color: var(--primary); cursor: pointer;
}
.qty-stepper button:hover { background: #d4eee9; }
.qty-stepper input {
  flex: 1; border: none !important; border-left: 1px solid var(--border) !important;
  border-right: 1px solid var(--border) !important;
  text-align: center; font-size: 18px; font-weight: 700;
  background: white !important; border-radius: 0 !important;
  box-shadow: none !important; padding: 8px !important;
}

/* ── Simulation box ── */
.simulation {
  background: linear-gradient(135deg,#FFF9EC,#FEF7E3);
  border: 1px dashed #F4D9A0;
  border-radius: 10px; padding: 14px; margin-bottom: 16px;
}
.sim-title {
  font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.5px; color: #8B6914;
  font-weight: 700; margin-bottom: 8px;
  display: flex; align-items: center; gap: 6px;
}
.sim-row {
  display: flex; justify-content: space-between;
  font-size: 14px; padding: 3px 0;
}
.sim-row .s-val { font-weight: 700; }
.sim-result {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid #F4D9A0;
  font-size: 13px; font-weight: 600;
  color: #A13E23; display: flex; align-items: center; gap: 6px;
}

/* ── Recent outflow items ── */
.recent-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px;
  background: #FAFBFC; margin-bottom: 8px;
}
.recent-item .r-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: #F0FAF8; display: grid; place-items: center;
  font-size: 14px; flex-shrink: 0;
}
.recent-item .r-info { flex: 1; }
.recent-item .r-name { font-weight: 600; }
.recent-item .r-meta { color: var(--muted); font-size: 11px; margin-top: 2px; }
.recent-item .r-qty  { font-weight: 700; color: var(--danger); }

/* ── Alert with icon ── */
.alert-icon-box {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 13px 15px; border-radius: 10px; margin-bottom: 16px;
}
.alert-icon-box.warn {
  background: #FEF7E3; border: 1px solid #F4D9A0; color: #8B6914;
}
.alert-icon-box.crit {
  background: #FDECE7; border: 1px solid #F6C6B6; color: #A13E23;
}
.alert-icon-box .aib-icon { font-size: 22px; line-height: 1; }
.alert-icon-box .aib-title { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.alert-icon-box .aib-body  { font-size: 13px; }

/* ── Stat pills (inventario header) ── */
.stat-pill-sm {
  background: white; border: 1px solid var(--border);
  padding: 7px 13px; border-radius: 8px;
  font-size: 12px; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
}
.stat-pill-sm .dot {
  width: 8px; height: 8px; border-radius: 50%;
}
.stat-pill-sm.ok   .dot { background: var(--primary); }
.stat-pill-sm.warn .dot { background: var(--accent); }
.stat-pill-sm.crit .dot { background: var(--danger); }

/* ── Avatar upload ── */
.avatar-upload { position: relative; }
.avatar-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.45);
  border-radius: 16px;
  display: grid; place-items: center;
  font-size: 20px;
  opacity: 0; transition: opacity 0.15s;
}
.avatar-upload:hover .avatar-overlay { opacity: 1; }

/* ── Autocomplete dropdown ── */
.ac-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: white; border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  z-index: 200; overflow: hidden;
}
.ac-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; text-decoration: none; color: var(--text);
  border-bottom: 1px solid var(--border); transition: background 0.1s;
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.ac-active { background: var(--primary-light); }
.ac-icon { font-size: 18px; flex-shrink: 0; width: 28px; text-align: center; }
.ac-body { flex: 1; min-width: 0; }
.ac-label { display: block; font-weight: 600; font-size: 13.5px; }
.ac-sub   { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }
.ac-type  {
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .4px; flex-shrink: 0;
}

/* ── Mini calendar ── */
.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 4px;
}
.cal-month {
  font-size: 14px; font-weight: 700; color: var(--text);
  text-transform: capitalize;
}
.cal-nav {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 7px; border: 1px solid var(--border);
  color: var(--muted); font-size: 15px; font-weight: 700;
  text-decoration: none; cursor: pointer;
  transition: all 0.12s;
}
.cal-nav:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}
.cal-dow {
  font-size: 10px; font-weight: 700;
  color: var(--muted); text-transform: uppercase;
  padding: 2px 0 8px;
}
.cal-day {
  width: 32px; height: 32px; margin: 0 auto;
  border-radius: 8px;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 500;
  text-decoration: none; color: var(--text);
  position: relative; transition: background 0.1s;
}
.cal-day:hover { background: var(--primary-light); color: var(--primary-dark); }
.cal-day.today { font-weight: 800; color: var(--primary-dark); }
.cal-day.today::before {
  content: '';
  position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--primary);
}
.cal-day.selected {
  background: var(--primary); color: white; font-weight: 700;
}
.cal-day.selected::before { background: rgba(255,255,255,0.6); }
.cal-day.has-appt::after {
  content: '';
  position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent);
}
.cal-day.selected.has-appt::after { background: rgba(255,255,255,0.75); }

/* ── Day timeline ── */
.tl-row {
  display: flex; align-items: stretch;
  min-height: 48px;
  border-bottom: 1px solid var(--border);
}
.tl-row:last-child { border-bottom: none; }
.tl-time {
  min-width: 56px; max-width: 56px;
  padding: 14px 10px 14px 0;
  font-size: 11px; font-weight: 700;
  color: var(--muted); text-align: right;
  flex-shrink: 0; letter-spacing: .3px;
}
.tl-slot {
  flex: 1; padding: 6px 0 6px 14px;
  border-left: 2px solid var(--border);
}
.tl-slot-used { border-left-color: var(--primary); }
.tl-card {
  display: flex; align-items: center; gap: 14px;
  background: white; border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 9px; padding: 10px 14px;
  transition: box-shadow 0.15s;
}
.tl-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.08); }
.tl-card.tl-pending { border-left-color: var(--accent); }
.tl-card.tl-done    { border-left-color: var(--muted); background: #FAFBFC; }
.tl-pet   { font-weight: 700; font-size: 14px; }
.tl-owner { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tl-motivo {
  display: inline-block;
  background: var(--primary-light); color: var(--primary-dark);
  padding: 2px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 600; margin-top: 4px;
}
.tl-card.tl-pending .tl-motivo { background: #fff3cd; color: #856404; }
.tl-card.tl-done .tl-motivo    { background: var(--border); color: var(--muted); }


/* ── SOAP section badges ── */
.num.soap-s { background: #2d7dd2; }
.num.soap-o { background: #3bb273; }
.num.soap-a { background: #e63946; }
.num.soap-p { background: #6c5ce7; }

/* ── Notification bell ── */
.notif-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  font-size: 18px;
  text-decoration: none;
  padding: 4px;
  line-height: 1;
}
.notif-badge {
  position: absolute;
  top: -2px;
  right: -4px;
  background: #e63946;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
}
