/* ═══════════════════════════════════════
   components.css — buttons, cards, forms,
   badges, tables, toggles
   ═══════════════════════════════════════ */

/* ── Section label ── */
.sec-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin: 20px 0 10px;
}
.sec-label:first-child { margin-top: 0; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 18px;
}

.card-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 16px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
}
.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:disabled { background: var(--blue-mid); cursor: not-allowed; }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1.5px solid var(--border-input);
}
.btn-secondary:hover { background: var(--bg-subtle); }

.btn-green {
  background: var(--bg-card);
  color: var(--green);
  border: 1.5px solid var(--green-border);
}
.btn-green:hover { background: var(--green-light); }

.btn-danger {
  background: var(--bg-card);
  color: var(--red);
  border: 1.5px solid var(--red-border);
}
.btn-danger:hover { background: var(--red-light); }

.btn-full {
  width: 100%;
  height: 46px;
  font-size: 15px;
  font-weight: 700;
}

/* ── Form fields ── */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.field label small {
  font-size: 10px;
  color: var(--text-faint);
  font-weight: 400;
}

.field input,
.field select {
  width: 100%;
  height: 38px;
  padding: 0 11px;
  border: 1.5px solid var(--border-input);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color .15s;
}

.field select:required:invalid {
  color: var(--text-faint);
}

.field select option {
  color: var(--text-primary);
}

.field input:focus,
.field select:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}

.field input[readonly] {
  background: var(--bg-subtle);
  color: var(--text-muted);
}

.field input.error {
  border-color: #e24b4a;
}

/* ── Toggle buttons ── */
.tog {
  display: flex;
  border: 1.5px solid var(--border-input);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.tog button {
  flex: 1;
  height: 38px;
  border: none;
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
  border-right: 1px solid var(--border-input);
  transition: background .12s;
}

.tog button:last-child { border-right: none; }

.tog button.on {
  background: var(--blue-light);
  color: var(--blue);
  font-weight: 700;
}

.tog button:hover:not(.on) { background: var(--bg-subtle); }

/* ── BMI display box ── */
.bmi-box {
  height: 38px;
  padding: 0 11px;
  display: flex;
  align-items: center;
  border: 1.5px solid var(--border-input);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  font-size: 14px;
}

/* ── Badges ── */
.badge {
  font-size: 11px;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-weight: 700;
}

.badge-under  { background: #dbeafe; color: #1d4ed8; }
.badge-normal { background: var(--green-light); color: var(--green); }
.badge-over   { background: var(--amber-light); color: var(--amber); }
.badge-obese  { background: var(--red-light); color: var(--red); }

.pill {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-weight: 700;
}
.pill-green  { background: var(--green-light); color: var(--green); }
.pill-yellow { background: var(--amber-light); color: var(--amber); }
.pill-red    { background: var(--red-light);   color: var(--red); }

/* ── Blood pressure row ── */
.bp-row {
  display: grid;
  grid-template-columns: 1fr 16px 1fr;
  gap: 6px;
  align-items: center;
}

.bp-sep {
  text-align: center;
  color: var(--text-faint);
  font-size: 16px;
}

.bp-tag {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  display: inline-block;
  margin-top: 5px;
  font-weight: 700;
}
.bp-hi { background: var(--red-light);   color: var(--red); }
.bp-ok { background: var(--green-light); color: var(--green); }

/* ── Action bar ── */
.abar {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  align-items: center;
  flex-wrap: wrap;
}

.cnt-lbl {
  font-size: 12px;
  color: var(--text-faint);
  margin-left: auto;
}

/* ── Entry table ── */
.etable-wrap { overflow-x: auto; margin-top: 14px; }

.etable {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.etable th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 11px;
  white-space: nowrap;
  background: var(--bg-hover);
}

.etable td {
  padding: 8px 10px;
  border-bottom: 1px solid #f0f0f0;
  color: var(--text-primary);
  white-space: nowrap;
}

.etable tr:hover td { background: var(--bg-hover); }

.etable .bp-high-cell {
  color: var(--red);
  font-weight: 700;
}

.del-btn {
  border: none;
  background: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 14px;
  padding: 0 3px;
  line-height: 1;
}
.del-btn:hover { color: #e24b4a; }

/* ── Summary tables ── */
.stab {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.stab th {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  background: var(--bg-hover);
}

.stab th:first-child { text-align: left; }

.stab td {
  padding: 9px 12px;
  border-bottom: 1px solid #f0f0f0;
  color: var(--text-primary);
  text-align: center;
}

.stab td:first-child { text-align: left; font-weight: 700; }

.stab tr:last-child td {
  border-bottom: none;
  background: #f0f7ff;
  font-weight: 700;
}

.stab .tot { background: #f0f7ff; font-weight: 700; }

/* ── Radio rows ── */
.radio-row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.radio-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.radio-item input[type="radio"] {
  width: 14px;
  height: 14px;
  accent-color: var(--blue);
  cursor: pointer;
}

/* ── Hospital info bar ── */
.hbar {
  background: var(--blue-light);
  border: 1.5px solid var(--blue-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.hbar-name {
  font-size: 14px;
  font-weight: 800;
  color: #1d4ed8;
}

.hbar-sn {
  font-size: 12px;
  color: var(--blue);
  background: var(--bg-card);
  border: 1px solid var(--blue-border);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}

.fy-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
}

.fy-row label {
  font-size: 12px;
  font-weight: 700;
  color: #1d4ed8;
}

.fy-row input {
  height: 32px;
  padding: 0 10px;
  border: 1.5px solid var(--blue-mid);
  border-radius: 7px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font);
  outline: none;
  width: 95px;
}

.fy-row span {
  font-size: 12px;
  color: #1d4ed8;
  font-weight: 600;
}

/* ── Warn banner ── */
.warn-banner {
  background: var(--amber-light);
  border: 1.5px solid var(--amber-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--amber);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Note box ── */
.note-box {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--amber-light);
  border: 1px solid var(--amber-border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: #78350f;
  line-height: 1.7;
}

/* ── Save dot indicator ── */
.save-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background .3s;
  flex-shrink: 0;
}
.save-dot.saving { background: #f59e0b; }
.save-dot.saved  { background: #22c55e; }
.save-dot.error  { background: #ef4444; }

/* ── Admin stat cards ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}

.stat-lbl {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
}

.stat-val {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
}

.summary-filter-card {
  padding: 18px;
}

.summary-filter-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 8px 12px;
  white-space: nowrap;
}

.field select:disabled {
  background: var(--bg-subtle);
  color: var(--text-faint);
  cursor: not-allowed;
}

/* ── Hospital admin table ── */
.htable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.htable th {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  background: var(--bg-hover);
}

.htable td {
  padding: 10px 14px;
  border-bottom: 1px solid #f0f0f0;
  color: var(--text-primary);
}

.htable tr:hover td { background: var(--bg-hover); }

/* ── Grids ── */
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.g3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.g4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 12px; }

@media (max-width: 600px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr 1fr; }
  .summary-filter-grid { grid-template-columns: 1fr; }
  .summary-filter-label { white-space: normal; }
}

/* ── Error box ── */
.err-box {
  background: var(--red-light);
  color: var(--red);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
}

/* ── Divider ── */
.divider {
  border: none;
  border-top: 1px solid #efefed;
  margin: 22px 0;
}
