:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --surface: #ffffff;
  --surface-2: #f0f4f2;
  --ink: #18211f;
  --muted: #66716d;
  --line: #d8ded9;
  --accent: #0b6b58;
  --accent-2: #9a5b13;
  --danger: #9b2f2f;
  --shadow: 0 14px 40px rgba(20, 31, 28, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1680px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 20px 0;
}

.topbar {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 4px 16px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.45rem, 2.2vw, 2.15rem);
  line-height: 1.1;
}

h2 {
  font-size: 1.02rem;
  line-height: 1.15;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(112px, 1fr));
  gap: 8px;
}

.stats div {
  min-height: 64px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.stats span {
  display: block;
  font-size: 1.28rem;
  font-weight: 800;
  line-height: 1.1;
}

.stats label {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 1.18fr) minmax(360px, 1fr) minmax(280px, 0.58fr);
  gap: 12px;
  align-items: stretch;
  min-height: calc(100vh - 126px);
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, #f8faf8 100%);
}

.panel-head.tight {
  min-height: 58px;
}

.note-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.control-stack {
  display: grid;
  gap: 6px;
}

.segmented {
  display: inline-flex;
  min-height: 36px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.choice-button {
  min-width: 72px;
  min-height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 760;
}

.choice-button.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 4px rgba(20, 31, 28, 0.12);
}

.transcript {
  height: calc(100vh - 212px);
  min-height: 560px;
  overflow: auto;
  padding: 14px;
}

.turn,
.stage,
.section-label {
  max-width: 74ch;
}

.section-label {
  margin: 18px 0 9px;
  padding: 7px 9px;
  border-left: 3px solid var(--accent);
  background: var(--surface-2);
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
}

.turn {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 10px;
  margin: 0 0 8px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
}

.turn.doctor {
  background: #eef6f3;
}

.turn.patient {
  background: #fff7eb;
}

.speaker {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.speech {
  font-size: 0.93rem;
  line-height: 1.42;
}

.stage {
  margin: 9px 0;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-style: italic;
}

.hide-stage .stage {
  display: none;
}

.note-editor {
  display: block;
  width: 100%;
  height: calc(100vh - 212px);
  min-height: 560px;
  padding: 18px;
  border: 0;
  resize: none;
  outline: none;
  color: var(--ink);
  background: #fffdf8;
  font-family: "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  font-size: 0.98rem;
  line-height: 1.52;
}

.side-panel {
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 12px;
  min-width: 0;
}

.compact {
  min-height: 0;
}

.billing-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.run-info {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.run-title {
  margin: 0;
  font-weight: 820;
  line-height: 1.25;
}

.run-pill {
  display: inline-flex;
  width: fit-content;
  min-height: 26px;
  align-items: center;
  padding: 0 9px;
  border-radius: 6px;
  background: #e6f2ef;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 820;
}

.run-meta {
  display: grid;
  gap: 8px;
  margin: 0;
}

.run-meta div {
  display: grid;
  gap: 3px;
}

.run-meta dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 820;
  text-transform: uppercase;
}

.run-meta dd {
  margin: 0;
  color: var(--ink);
  font-size: 0.86rem;
  line-height: 1.38;
}

.billing-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.billing-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  height: 28px;
  margin-bottom: 8px;
  border-radius: 6px;
  background: #e6f2ef;
  color: var(--accent);
  font-weight: 850;
}

.billing-title {
  margin: 0 0 5px;
  font-weight: 780;
  line-height: 1.25;
}

.billing-reason {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.4;
}

.check-list {
  margin: 0;
  padding: 14px 18px 16px 32px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.check-list li + li {
  margin-top: 8px;
}

.icon-button,
.text-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.icon-button {
  width: 40px;
  padding: 0;
  font-size: 1.1rem;
  font-weight: 900;
}

.text-button {
  padding: 0 12px;
  color: #ffffff;
  border-color: var(--accent);
  background: var(--accent);
  font-weight: 760;
}

.text-button.copied {
  border-color: var(--accent-2);
  background: var(--accent-2);
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 1fr 1fr;
  }

  .side-panel {
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto;
  }

  .transcript,
  .note-editor {
    height: 58vh;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 20px, 720px);
    padding: 12px 0;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .note-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .segmented {
    width: 100%;
  }

  .choice-button {
    flex: 1;
    min-width: 0;
  }

  .text-button {
    width: 100%;
  }

  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stats div {
    min-height: 58px;
    padding: 9px;
  }

  .stats span {
    font-size: 1.02rem;
  }

  .stats label {
    font-size: 0.68rem;
  }

  .workspace,
  .side-panel {
    grid-template-columns: 1fr;
  }

  .transcript,
  .note-editor {
    height: 62vh;
    min-height: 420px;
  }

  .turn {
    grid-template-columns: 66px 1fr;
    padding: 9px;
  }
}
