.medical-logbook {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem 1.25rem 2rem;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(46, 125, 110, 0.12), transparent 40%),
    linear-gradient(180deg, #f7faf8 0%, #eef3f1 100%);
  color: #1c2b27;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}

.ml-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
}

.ml-title {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.ml-subtitle {
  margin: 0.25rem 0 0;
  color: #4c625b;
}

.ml-disclaimer {
  margin: 0;
  font-size: 0.75rem;
  color: #6a7f76;
  max-width: 14rem;
  text-align: right;
}

.ml-allergy-banner {
  padding: 0.65rem 0.9rem;
  background: #fff4e8;
  border: 1px solid #e8c39a;
  border-radius: 0.5rem;
  color: #6a3b10;
}

.ml-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
}

.ml-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.8rem;
  color: #466058;
}

.ml-field-grow {
  flex: 1 1 12rem;
}

.ml-field input,
.ml-field select,
.ml-field textarea,
.ml-refresh,
.ml-export,
.ml-actions button,
.ml-quick-btn,
.ml-view-btn,
.ml-dialog-actions button,
.ml-inbox-toolbar button {
  border: 1px solid #b7c9c2;
  background: #fff;
  border-radius: 0.4rem;
  padding: 0.45rem 0.65rem;
  font: inherit;
  color: inherit;
}

.ml-refresh,
.ml-export,
.ml-actions button,
.ml-quick-btn,
.ml-view-btn,
.ml-dialog-actions button,
.ml-inbox-toolbar button {
  cursor: pointer;
}

.ml-refresh:hover,
.ml-export:hover,
.ml-actions button:hover,
.ml-quick-btn:hover,
.ml-view-btn:hover {
  background: #e7f1ed;
}

.ml-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.ml-quick-label {
  font-size: 0.8rem;
  color: #466058;
  margin-right: 0.25rem;
}

.ml-quick-btn {
  background: #214f44;
  color: #f4fffb;
  border-color: #214f44;
}

.ml-quick-btn:hover {
  background: #2d6a5b;
}

.ml-views {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  border-bottom: 1px solid #d0ddd7;
  padding-bottom: 0.35rem;
}

.ml-view-btn.is-active {
  background: #214f44;
  color: #f4fffb;
  border-color: #214f44;
}

.ml-status {
  min-height: 1.25rem;
  color: #466058;
  font-size: 0.9rem;
}

.ml-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.ml-card {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #d0ddd7;
  border-radius: 0.75rem;
  padding: 0.9rem 1rem;
}

.ml-card-pending {
  border-color: #c9a227;
  box-shadow: inset 3px 0 0 #c9a227;
}

.ml-card-ai {
  border-style: dashed;
  opacity: 0.95;
}

.ml-card-focus {
  outline: 2px solid #214f44;
  outline-offset: 2px;
}

.ml-card-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.55rem;
}

.ml-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: #214f44;
  color: #f4fffb;
  font-size: 0.75rem;
}

.ml-badge-muted {
  background: #d7e5df;
  color: #214f44;
}

.ml-topic {
  background: #3d5b6b;
  color: #f4fffb;
}
.ml-topic-medical { background: #8a4d5b; }
.ml-topic-sports { background: #3d6b8a; }
.ml-topic-nutrition { background: #4d7a4d; }

.ml-review-pending_review {
  background: #c9a227;
  color: #1c2b27;
}

.ml-text {
  margin: 0;
  line-height: 1.45;
  white-space: pre-wrap;
}

.ml-structured-table {
  margin-top: 0.55rem;
  border-collapse: collapse;
  font-size: 0.85rem;
  width: 100%;
  max-width: 28rem;
}

.ml-structured-table th {
  text-align: left;
  color: #466058;
  font-weight: 600;
  padding: 0.15rem 0.5rem 0.15rem 0;
  width: 7rem;
}

.ml-structured-table td {
  padding: 0.15rem 0;
}

.ml-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.ml-evidence {
  margin: 0.75rem 0 0;
  padding: 0.65rem;
  background: #f1f6f4;
  border-radius: 0.5rem;
  font-size: 0.85rem;
}

.ml-evidence-list {
  margin: 0;
  padding-left: 1.1rem;
}

.ml-empty,
.ml-muted {
  color: #5a7169;
}

.ml-inbox-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.ml-check {
  display: inline-flex;
  margin-right: 0.25rem;
}

.ml-timeline-day h3 {
  margin: 1rem 0 0.4rem;
  font-size: 1rem;
}

.ml-timeline-item {
  display: grid;
  grid-template-columns: 7rem 1fr auto;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid #e2ebe7;
  list-style: none;
}

.ml-timeline ul {
  margin: 0;
  padding: 0;
}

.ml-tl-kind {
  font-size: 0.8rem;
  color: #214f44;
  font-weight: 600;
}

.ml-med-list,
.ml-series ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.ml-med-item,
.ml-series-card li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.55rem 0;
  border-bottom: 1px solid #e2ebe7;
}

.ml-med-item.is-ended {
  opacity: 0.65;
}

.ml-series {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 0.85rem;
}

.ml-series-card {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #d0ddd7;
  border-radius: 0.75rem;
  padding: 0.85rem;
}

.ml-series-card header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.ml-series-card h3 {
  margin: 0;
  font-size: 1rem;
  text-transform: capitalize;
}

.ml-spark {
  display: block;
}

.ml-heat {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin: 0.5rem 0 1rem;
}

.ml-heat-cell {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: color-mix(in srgb, #214f44 calc(var(--lvl, 0) * 10%), #e7f1ed);
}

.ml-prep {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid #d0ddd7;
  border-radius: 0.75rem;
  padding: 0.85rem 1rem;
  margin-bottom: 0.85rem;
}

.ml-prep h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
}

.ml-prep ul {
  margin: 0 0 0.65rem;
  padding-left: 1.2rem;
}

.ml-remind-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: #466058;
}

.ml-dialog-root[hidden] {
  display: none !important;
}

.ml-dialog-root {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
}

.ml-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 32, 28, 0.45);
}

.ml-dialog {
  position: relative;
  z-index: 1;
  width: min(28rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow: auto;
  background: #fff;
  border-radius: 0.75rem;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

.ml-dialog h2 {
  margin: 0;
  font-size: 1.15rem;
}

.ml-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.35rem;
}

.ml-danger {
  background: #8b2e2e !important;
  color: #fff !important;
  border-color: #8b2e2e !important;
}

.ml-menu-badge {
  position: absolute;
  top: 0.15rem;
  right: 0.15rem;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  background: #c9a227;
  color: #1c2b27;
  font-size: 0.65rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

@media (max-width: 640px) {
  .ml-timeline-item {
    grid-template-columns: 1fr;
  }

  .ml-disclaimer {
    text-align: left;
    max-width: none;
  }
}
