/* Dentilus application layer - sits on top of industry.css (the design tokens).
   Everything here is structure the designs specify but the token sheet does not:
   the desktop shell, the blueprint frame's usage patterns, flag cards, meters.

   Values are taken from design_handoff_dentilus 4 (SCREENS.md + the .dc.html
   prototypes), not invented. Where a number looks arbitrary it is the design's. */

/* ── ground ─────────────────────────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5 { font-family: var(--font-heading); font-weight: 600; line-height: 1.15; }
a { color: inherit; }
.muted { color: color-mix(in srgb, var(--color-text) 55%, transparent); }
.mono  { font-family: ui-monospace, Menlo, monospace; }
.cond  { font-family: var(--font-heading); font-weight: 600; }
.tnum  { font-variant-numeric: tabular-nums; }

/* Chrome type: all-caps kickers and labels. .07em-.12em per the spec. */
.kicker {
  font-family: var(--font-heading); font-weight: 600;
  font-size: 10px; letter-spacing: .11em; text-transform: uppercase;
  color: var(--color-accent-700);
}
.field-label {
  display: block; font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase;
  color: color-mix(in srgb, var(--color-text) 55%, transparent); margin-bottom: 5px;
}

/* ── the desktop shell ──────────────────────────────────────────────────── */
.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* macOS window chrome, 40px. Names the machine and states LOCAL ONLY - the product's
   claim, made visible in the furniture rather than in marketing copy. */
.winbar {
  flex: none; height: 40px; display: flex; align-items: center; gap: 9px;
  padding: 0 16px; background: #1b1c1d; color: #c9c9cb;
}
.winbar .dot { width: 11px; height: 11px; border-radius: 50%; }
.winbar .title { font-family: var(--font-heading); font-size: 13px; letter-spacing: .03em; }
.winbar .local {
  margin-left: auto; font-family: var(--font-heading);
  font-size: 11px; letter-spacing: .08em; opacity: .6;
}

.shell { flex: 1; display: flex; min-height: 0; }

/* Sidebar, 208px, accent-900 ground with reversed type. */
.sidebar {
  flex: none; width: 208px; background: var(--color-accent-900); color: var(--color-bg);
  display: flex; flex-direction: column; padding: 20px 0 18px;
}
.sidebar .brand { display: flex; align-items: center; gap: 11px; padding: 0 20px 22px; }
.sidebar .brand .mark {
  width: 34px; height: 34px; flex: none; display: grid; place-items: center;
  border: 1px solid color-mix(in srgb, #f2f2f3 45%, transparent);
  font-family: var(--font-heading); font-size: 17px;
}
.navrow {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 11px 20px; background: none; border: 0; border-left: 2px solid transparent;
  color: inherit; font-family: var(--font-heading); font-weight: 600;
  font-size: 14px; letter-spacing: .02em; text-align: left;
  text-decoration: none; opacity: .66; cursor: pointer;
}
.navrow:hover { opacity: .9; }
.navrow.active {
  opacity: 1; border-left-color: #f2f2f3;
  background: color-mix(in srgb, #f2f2f3 13%, transparent);
}
.sidebar .foot {
  margin-top: auto; padding: 16px 20px 0;
  border-top: 1px solid color-mix(in srgb, #f2f2f3 18%, transparent);
}

/* Header bar, 60px. */
.header {
  flex: none; height: 60px; display: flex; align-items: center; gap: 14px;
  padding: 0 24px; border-bottom: 1px solid var(--color-divider);
}
.header h4 { font-size: 21px; letter-spacing: -.01em; }
.header .right {
  margin-left: auto; display: flex; align-items: center; gap: 16px;
  font-size: 12px; color: color-mix(in srgb, var(--color-text) 55%, transparent);
}
.header .vrule { width: 1px; height: 18px; background: var(--color-divider); }
.header .initials {
  width: 30px; height: 30px; display: grid; place-items: center;
  border: 1px solid var(--color-divider);
  font-family: var(--font-heading); font-size: 12px;
}

.main { flex: 1; min-height: 0; display: flex; }
.scroll { overflow: auto; min-height: 0; }

/* ── blueprint frame ────────────────────────────────────────────────────── */
/* .blueprint and .corner come from industry.css. These are the variants the
   designs use. A framed object without its four marks reads as a generic card and
   breaks the system - the partial always emits them. */
.bp-accent { border: 2px solid var(--color-accent) !important; }
.bp-alarm  { border-color: var(--alarm) !important; }
.bp-tint   { background: color-mix(in srgb, var(--color-accent) 8%, transparent); }

:root { --alarm: #b00020; }
.alarm-text { color: var(--alarm); }

/* ── flag cards ─────────────────────────────────────────────────────────── */
.flag {
  border: 1px solid var(--color-divider); border-left: 3px solid var(--color-neutral-400);
  background: var(--color-bg); padding: 10px 12px; margin-bottom: 9px;
}
.flag.sev-critical  { border-left-color: var(--alarm); }
.flag.sev-important { border-left-color: var(--color-accent-600); }
.flag.sev-info      { border-left-color: var(--color-neutral-400); }
.flag.acked { opacity: .55; }
.flag .sev {
  font-family: var(--font-heading); font-weight: 600;
  font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase;
}
.flag.sev-critical .sev  { color: var(--alarm); }
.flag.sev-important .sev { color: var(--color-accent-600); }
.flag.sev-info .sev      { color: var(--color-neutral-600); }
.flag .detail { font-size: 12.5px; line-height: 1.45; margin: 4px 0 0; }
.flag .ackrow { display: flex; align-items: center; gap: 8px; margin-top: 7px; font-size: 12px; }
.flag .ackrow input { width: 20px; height: 20px; accent-color: var(--color-accent); }
.flag.sev-critical .ackrow input { accent-color: var(--alarm); }
.flag.clickable { cursor: pointer; }
.flag.active { border-color: var(--color-accent); background: color-mix(in srgb, var(--color-accent) 8%, transparent); }
.flag .showev {
  font-family: var(--font-heading); font-weight: 600; font-size: 10.5px;
  letter-spacing: .06em; color: var(--color-accent-700); margin-top: 6px; display: block;
}

.section-head {
  font-family: var(--font-heading); font-weight: 600;
  font-size: 12px; letter-spacing: .07em; text-transform: uppercase; margin: 16px 0 2px;
}
.group-head {
  font-family: var(--font-heading); font-weight: 600; font-size: 12.5px; letter-spacing: .04em;
  border-top: 1px solid var(--color-divider); padding-top: 9px; margin: 14px 0 8px;
}

/* ── note fields ────────────────────────────────────────────────────────── */
textarea.note, input.note {
  width: 100%; font-family: var(--font-body); font-size: 13px; line-height: 1.5;
  padding: 8px 10px; border: 1px solid var(--color-divider); border-radius: 0;
  background: var(--color-bg); color: inherit; resize: vertical;
}
textarea.note:focus, input.note:focus { outline: 2px solid var(--color-accent); outline-offset: -2px; }
/* A contradiction: words the note CONTAINS that the consultation does not support.
   Absences get no highlight - there is nothing to point at, and colouring them too
   would drown this signal. */
textarea.note.contradicted, input.note.contradicted {
  border: 2px solid var(--alarm);
  background: color-mix(in srgb, var(--alarm) 5%, transparent);
}
.contra-marker {
  font-family: var(--font-heading); font-weight: 600; font-size: 11px;
  letter-spacing: .04em; color: var(--alarm); margin-left: 8px;
}

/* The paste box: the thing the clinician came for, so it is first and it is framed
   in the accent - the one emphasised object on the page. */
#nhsnote {
  width: 100%; background: var(--color-surface); border: 1px solid var(--color-divider);
  font-family: ui-monospace, Menlo, monospace; font-size: 12px; line-height: 1.6;
  padding: 10px 12px; color: inherit; resize: none; overflow: hidden; white-space: pre-wrap;
}
/* When the formatted view is shown, the plain box is only the copy source. */
#nhsnote.nhsnote-plain { display: none; }
/* The formatted note: heading bold and green, the value as written. */
#nhsnote-view {
  width: 100%; background: var(--color-surface); border: 1px solid var(--color-divider);
  font-family: var(--font-body, inherit); font-size: 13.5px; line-height: 1.55;
  padding: 12px 14px; color: inherit;
}
#nhsnote-view .nl { margin: 0 0 6px; }
#nhsnote-view .nh { font-weight: 700; color: #1f7a3a; }
#nhsnote-view .nv { }
#nhsnote-view .nconfirm { font-weight: 700; color: var(--alarm); margin-left: 4px; }

/* Provenance chip - kept from the old base sheet. Shown only when the match is
   confident: a citation pointing at the wrong moment is worse than none, because it
   looks like evidence. */
.heard {
  display: inline-flex; align-items: center; font-family: var(--font-heading);
  font-weight: 600; font-size: 10px; letter-spacing: .06em; text-transform: uppercase;
  padding: 2px 7px; margin-left: 8px;
  background: var(--color-accent-100); color: var(--color-accent-800);
}

/* ── transcript + evidence linking ──────────────────────────────────────── */
.tline { display: flex; gap: 10px; margin-bottom: 7px; font-size: 12.5px; line-height: 1.5; }
.tline .who {
  flex: none; width: 38px; font-family: var(--font-heading); font-weight: 600;
  font-size: 10.5px; letter-spacing: .07em; padding-top: 2px;
}
.tline.dent .who { color: var(--color-accent-700); }
.tline.pat  .who { color: var(--color-neutral-600); }
.evidence-on .tline { opacity: .4; }
.evidence-on .tline.ev {
  opacity: 1; background: color-mix(in srgb, var(--color-accent) 16%, transparent);
  border-left: 2px solid var(--color-accent); padding: 6px 8px; margin: 0 -8px 7px;
}

/* ── meters (recording) ─────────────────────────────────────────────────── */
/* Segmented, never a solid fill; and the SCALE IS LOGARITHMIC - a linear bar looks
   dead during normal speech and gets read as a broken microphone. See pct() in app.js. */
.meter {
  flex: 1; height: 22px;
  background: repeating-linear-gradient(90deg,
    color-mix(in srgb, var(--color-text) 11%, transparent) 0 7px, transparent 7px 11px);
}
.meter > i {
  display: block; height: 100%;
  background: repeating-linear-gradient(90deg, var(--color-accent) 0 7px, transparent 7px 11px);
}
.meter.alarm > i { background: repeating-linear-gradient(90deg, var(--alarm) 0 7px, transparent 7px 11px); }

@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }
@keyframes sweep { from { transform: translateX(-100%) } to { transform: translateX(400%) } }
.pulse { animation: pulse 1.4s infinite; }

/* ── tables ─────────────────────────────────────────────────────────────── */
.dtable { width: 100%; border-collapse: collapse; }
.dtable th {
  text-align: left; font-family: var(--font-body); font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; color: color-mix(in srgb, var(--color-text) 60%, transparent);
  padding: 8px 10px; border-bottom: 1px solid var(--color-divider); font-weight: 500;
}
.dtable td {
  padding: 12px 10px; font-size: 13px;
  border-bottom: 1px solid color-mix(in srgb, var(--color-text) 8%, transparent);
}
.dtable tbody tr:hover { background: color-mix(in srgb, var(--color-text) 4%, transparent); }

/* ── buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-heading); font-weight: 600; letter-spacing: .04em;
  font-size: 13px; padding: 0 16px; height: 38px;
  border: 1px solid var(--color-divider); background: none; color: inherit;
  border-radius: 0; cursor: pointer; text-decoration: none;
}
.btn:hover { background: color-mix(in srgb, var(--color-text) 6%, transparent); }
.btn-primary {
  background: var(--color-accent); border-color: var(--color-accent); color: var(--color-bg);
}
.btn-primary:hover { background: var(--color-accent-600); }
.btn[disabled], .btn-primary[disabled] { opacity: .45; cursor: not-allowed; }
.btn-ghost { border-color: transparent; }

.tag {
  display: inline-flex; align-items: center; font-family: var(--font-heading);
  font-weight: 600; font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 0;
}
.tag-accent  { background: var(--color-accent-100); color: var(--color-accent-800); }
.tag-neutral { background: var(--color-neutral-100); color: var(--color-neutral-800); }
.tag-outline { border: 1px solid var(--color-accent); color: var(--color-accent-700); }
.tag-alarm   { background: var(--alarm); color: #fff; }

/* A field that just received the exposure line. It is the only content in a note the
   clinician places by hand, so the eye has to be taken to where it landed. */
.note.just-added { outline: 2px solid var(--color-accent); outline-offset: 1px; }
@media (prefers-reduced-motion: no-preference) {
  .note.just-added { transition: outline-color .3s ease; }
}
