:root {
  --bg: #F6F7F6;
  --panel: #FFFFFF;
  --ink: #1B1F1D;
  --muted: #5B6B68;
  --line: #DCE3E0;
  --accent: #1F5F5B;
  --accent-ink: #FFFFFF;
  --flag: #B4472F;
  --good: #2E7D5B;
  --radius: 3px;
  --sans: -apple-system, "Segoe UI", "IBM Plex Sans", sans-serif;
  --mono: "IBM Plex Mono", "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.5;
}

.app { display: flex; height: 100vh; }

/* Sidebar */
.sidebar {
  width: 300px;
  min-width: 240px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 16px;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sidebar-head h1 { font-size: 16px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }

.search {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13.5px;
  font-family: var(--sans);
  margin-bottom: 10px;
}
.search:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.patient-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.patient-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: none;
  border-radius: var(--radius);
  text-align: left;
  cursor: pointer;
  font-family: var(--sans);
}
.patient-row:hover, .patient-row.active { background: var(--bg); }
.pr-name { font-weight: 600; font-size: 13.5px; }
.pr-meta { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }

.settings-link { margin-top: 10px; }

.btn-ghost {
  background: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 12.5px;
  color: var(--accent);
  cursor: pointer;
  font-family: var(--sans);
}
.btn-ghost:hover { background: var(--bg); }

.btn {
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: var(--radius);
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--sans);
}
.btn:hover { opacity: 0.92; }
.btn.secondary { background: none; color: var(--accent); border: 1px solid var(--accent); }

/* Main */
.main { flex: 1; overflow-y: auto; padding: 28px 36px; max-width: 920px; }
.empty-state { color: var(--muted); margin-top: 60px; text-align: center; }

.patient-header { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid var(--line); padding-bottom: 14px; margin-bottom: 18px; }
.patient-header h2 { margin: 0 0 2px 0; font-size: 21px; }
.patient-header .sub { font-family: var(--mono); font-size: 12.5px; color: var(--muted); }
.patient-header .actions { display: flex; gap: 8px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tab {
  padding: 8px 12px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--muted);
  font-family: var(--sans);
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 22px 0 8px; }
.section-title:first-child { margin-top: 0; }

/* Timeline */
.timeline { display: flex; flex-direction: column; }
.timeline-item { display: grid; grid-template-columns: 110px 1fr; gap: 14px; padding: 10px 0; border-top: 1px solid var(--line); }
.timeline-item:first-child { border-top: none; }
.ti-date { font-family: var(--mono); font-size: 12px; color: var(--muted); padding-top: 2px; }
.ti-body .score { font-weight: 600; color: var(--accent); }
.ti-body .flag { color: var(--flag); }
.ti-body dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 4px 0 0; font-size: 13px; }
.ti-body dt { color: var(--muted); }
.ti-body dd { margin: 0; font-family: var(--mono); }
.ti-thumbs { display: flex; gap: 6px; margin-top: 6px; }
.ti-thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); }

.empty-row { color: var(--muted); font-size: 13px; padding: 10px 0; }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-grid.narrow { grid-template-columns: 1fr; max-width: 420px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.span2 { grid-column: 1 / -1; }
.field label { font-size: 12.5px; color: var(--muted); }
.field input, .field select, .field textarea {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13.5px;
  font-family: var(--sans);
  background: var(--panel);
}
.field textarea { resize: vertical; min-height: 60px; }

.yn-group { display: flex; gap: 6px; flex-wrap: wrap; }
.yn-item { display: flex; align-items: center; justify-content: space-between; border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 10px; gap: 10px; }
.yn-item span { font-size: 13px; }
.yn-buttons, .choice-buttons { display: flex; gap: 4px; flex-wrap: wrap; }
.yn-buttons button, .choice-buttons button {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 3px 9px;
  font-size: 12px;
  cursor: pointer;
  border-radius: var(--radius);
}
.yn-buttons button.selected, .choice-buttons button.selected { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.scale-group { display: flex; flex-direction: column; gap: 6px; }
.scale-row { display: flex; align-items: center; gap: 10px; }
.scale-row label { flex: 0 0 190px; font-size: 13px; }
.scale-row .opts { display: flex; gap: 4px; flex: 1; }
.scale-row .opts button {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 6px 4px;
  font-size: 11.5px;
  cursor: pointer;
  border-radius: var(--radius);
  text-align: center;
}
.scale-row .opts button.selected { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.therapy-current { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; }
.therapy-current .drug { font-weight: 600; }
.therapy-actions { display: flex; gap: 8px; margin-top: 10px; }

.form-actions { display: flex; gap: 10px; margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }

.upload-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.upload-row img { width: 56px; height: 56px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); }

.mandatory-note { font-size: 12px; color: var(--muted); margin-top: -4px; margin-bottom: 4px; }
