/* vetlog — calm clinical front end. No CDN, no webfonts: system stack only. */

:root {
  --bg: #f4f6f7;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --ink: #18222a;
  --ink-soft: #51626d;
  --ink-faint: #8a98a2;
  --line: #e3e9ec;
  --accent: #0d7a73;        /* veterinary teal */
  --accent-soft: #d6edeb;
  --accent-ink: #0a5d57;
  --danger: #b4322a;
  --danger-soft: #fbe7e5;
  --warn: #b5730a;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20, 40, 50, .05), 0 8px 24px rgba(20, 40, 50, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
          "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

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

/* --- top bar ------------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px clamp(14px, 4vw, 32px);
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  font-size: 26px;
  line-height: 1;
  filter: saturate(.9);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name {
  font-weight: 700;
  letter-spacing: -.02em;
  font-size: 19px;
}
.brand-sub {
  font-size: 13px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* --- buttons ------------------------------------------------------------ */

.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .05s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); }
.btn-ghost { background: var(--surface); color: var(--ink-soft); border-color: var(--line); }
.btn-ghost:hover { color: var(--ink); border-color: #cdd7db; }

/* --- pills -------------------------------------------------------------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.pill-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); }
.pill-ok { color: var(--accent-ink); background: #e7f4f2; border-color: #bfe3de; }
.pill-ok .pill-dot { background: var(--accent); }
.pill-bad { color: var(--danger); background: var(--danger-soft); border-color: #f0c9c5; }
.pill-bad .pill-dot { background: var(--danger); }
.pill-muted { color: var(--ink-faint); }

/* --- layout ------------------------------------------------------------- */

.layout {
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(16px, 3vw, 28px);
  display: grid;
  grid-template-columns: minmax(300px, 360px) 1fr;
  gap: clamp(16px, 2.5vw, 24px);
  align-items: start;
}
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(16px, 2.5vw, 22px);
}
.add-panel { position: sticky; top: 78px; }
@media (max-width: 820px) { .add-panel { position: static; } }

.panel-title {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* --- add panel ---------------------------------------------------------- */

.quick { display: flex; gap: 8px; }
.quick .input { flex: 1; }

.input {
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  width: 100%;
}
.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 122, 115, .15);
  background: #fff;
}
.input-sm { font-size: 13px; padding: 7px 9px; width: auto; }
textarea.input { resize: vertical; }

.full { margin-top: 14px; }
.full > summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-ink);
  padding: 6px 0;
  user-select: none;
}
.full-form { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.field em { color: var(--ink-faint); font-style: normal; font-weight: 500; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.note-line { min-height: 18px; font-size: 13px; margin: 12px 0 0; }
.note-line.ok { color: var(--accent-ink); }
.note-line.err { color: var(--danger); }

.constitution {
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  font-size: 12.5px;
  color: var(--ink-faint);
  line-height: 1.55;
}

/* --- timeline ----------------------------------------------------------- */

.timeline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.timeline-head .panel-title { margin: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }

.timeline { margin-top: 10px; }

.day { margin-top: 18px; }
.day:first-child { margin-top: 6px; }
.day-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-faint);
  letter-spacing: .03em;
  position: sticky;
  top: 70px;
  background: linear-gradient(var(--surface) 70%, transparent);
  padding: 4px 0 6px;
}

.entry {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.day .entry:first-of-type { border-top: none; }
.entry-time { font-size: 13px; font-weight: 600; color: var(--ink-soft); padding-top: 1px; }
.entry-body { min-width: 0; }
.entry-summary { font-size: 14.5px; color: var(--ink); }
.entry-detail {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 4px;
  white-space: pre-wrap;
}
.entry-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 7px; }

.chip {
  display: inline-flex;
  align-items: center;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.chip-cat { background: #eef4f3; color: var(--accent-ink); border-color: #d3e7e4; text-transform: capitalize; }
.chip-tag { color: var(--ink-faint); }
.chip-id { color: var(--ink-faint); font-variant-numeric: tabular-nums; }

.sev { text-transform: uppercase; letter-spacing: .03em; }
.sev-low    { background: #eef4f3; color: var(--accent-ink); border-color: #d3e7e4; }
.sev-medium { background: #fdf3e3; color: var(--warn); border-color: #f0ddbc; }
.sev-high   { background: #fbe9e6; color: var(--danger); border-color: #f1cac4; }
.sev-urgent { background: var(--danger); color: #fff; border-color: var(--danger); }

.mark { font-style: normal; }
.mark-correction { background: #eef2fb; color: #3a55a8; border-color: #d3ddf3; }
.mark-superseded { background: #f1f1f0; color: var(--ink-faint); border-color: var(--line); }

.entry-superseded .entry-summary { color: var(--ink-faint); text-decoration: line-through; text-decoration-color: #c9d2d6; }

.empty { color: var(--ink-faint); font-size: 14px; padding: 24px 0; text-align: center; }

/* --- dialog ------------------------------------------------------------- */

.dialog {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  width: min(560px, 92vw);
  box-shadow: 0 24px 60px rgba(10, 30, 40, .28);
  color: var(--ink);
}
.dialog::backdrop { background: rgba(15, 30, 38, .42); backdrop-filter: blur(2px); }
.profile-form { padding: 22px; }
.profile-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 14px 0 18px;
}
@media (max-width: 520px) { .profile-fields { grid-template-columns: 1fr; } }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* --- PWA: backup bar + safe-area + print ------------------------------- */

.backup-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.backup-bar .btn { flex: 1 1 auto; text-align: center; }

/* respect the iPhone notch / home indicator in standalone mode */
.topbar { padding-top: max(12px, env(safe-area-inset-top)); }
.layout { padding-bottom: max(28px, env(safe-area-inset-bottom)); }

@media print {
  .topbar-actions, .add-panel, .filters, .backup-bar { display: none !important; }
  .layout { display: block; max-width: none; padding: 0; }
  .panel { border: none; box-shadow: none; }
  .timeline-panel { break-inside: auto; }
  .day-label { position: static; }
  body { background: #fff; }
}
