:root {
  --primary: #000f4f;
  --primary-strong: #132bd9;
  --primary-soft: #e5eaff;
  --primary-faint: #f5f7ff;
  --page-bg: #f3f4f8;
  --surface: #ffffff;
  --surface-muted: #fafbff;
  --line: #e8eaf2;
  --line-strong: #d8dce8;
  --ink: #121827;
  --ink-soft: #626a79;
  --ink-muted: #8a8a8a;
  --success-design: #16846f;
  --warning-design: #bd6b13;
  --danger-design: #c43c4b;
  --shadow-design: 0 4px 12px rgba(0, 51, 122, 0.08);
}

html {
  background: var(--page-bg);
}

body {
  background: var(--page-bg);
  color: var(--ink);
  font-family: "Inter", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font-family: inherit;
  letter-spacing: 0;
}

.layout {
  min-height: 100vh;
  align-items: stretch;
}

.sidebar {
  width: 300px;
  height: 100vh;
  padding: 28px 28px 24px;
  background: #fafbff;
  color: var(--ink);
  box-shadow: 0 4px 12px 4px rgba(0, 51, 122, 0.1);
  overflow-x: hidden;
  overflow-y: auto;
  z-index: 50;
}

.sidebar-logo {
  min-height: 64px;
  padding: 0 4px 18px;
  border-bottom: 1px solid rgba(0, 15, 79, 0.08);
  gap: 12px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--primary);
  box-shadow: none;
}

.logo-name {
  max-width: 190px;
  color: var(--primary);
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  white-space: normal;
}

.logo-tagline {
  margin-top: 3px;
  color: #526092;
  font-size: 9px;
  letter-spacing: 0.04em;
}

.sidebar-section {
  padding: 28px 10px 8px;
  color: #686e7c;
  font-family: "Inter", sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}

.nav-item {
  min-height: 46px;
  margin: 3px 0;
  padding: 0 14px;
  border-radius: 6px;
  color: #172033;
  font-size: 14px;
  font-weight: 500;
  gap: 14px;
}

.nav-item svg {
  width: 19px;
  height: 19px;
  color: var(--primary);
  stroke-width: 1.8;
}

.nav-item:hover {
  background: #eef1fb;
  color: var(--primary);
}

.nav-item.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 6px 14px rgba(0, 15, 79, 0.16);
}

.nav-item.active svg {
  color: #fff;
}

.sidebar-footer {
  position: static;
  margin-top: 28px;
  padding: 18px 0 0;
  border-top-color: var(--line);
  background: transparent;
}

.doctor-pill {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
}

.doctor-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
}

.doctor-name {
  color: var(--ink);
  font-size: 12px;
}

.doctor-role {
  color: var(--ink-muted);
  font-size: 10px;
}

.main {
  min-width: 0;
  background: var(--page-bg);
}

.topbar {
  min-height: 98px;
  padding: 22px clamp(22px, 3vw, 48px);
  border-bottom: 0;
  background: transparent;
  box-shadow: none;
  align-items: center;
  z-index: 30;
}

.topbar-left {
  align-items: center;
  gap: 12px;
}

.breadcrumb {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}

.breadcrumb #currentViewLabel {
  color: var(--ink);
  font-family: "Plus Jakarta Sans", sans-serif;
  font-size: clamp(22px, 2.2vw, 34px);
  font-weight: 700;
  line-height: 1;
}

.breadcrumb #brandBreadcrumb {
  color: #656b78;
  font-size: 13px;
  font-weight: 400;
}

.topbar-right {
  gap: 8px;
}

.status-pill {
  min-height: 48px;
  max-width: 300px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: none;
  font-family: "Inter", sans-serif;
  white-space: normal;
}

.status-dot {
  background: var(--primary-strong);
}

.status-pill.live {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.status-pill.live .status-dot {
  background: var(--success-design);
  box-shadow: 0 0 0 3px rgba(22, 132, 111, 0.12);
  animation: none;
}

.mobile-menu-btn {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--primary);
  place-items: center;
  cursor: pointer;
}

.content {
  width: min(100%, 1440px);
  padding: 0 clamp(22px, 3vw, 48px) 42px;
  gap: 22px;
}

.view-panel {
  display: none;
}

.view-panel.active {
  display: flex;
}

.top-strips {
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 18px;
}

.summary-strip,
.setup-card,
.panel,
.billable-panel,
.info-card,
.chart-block {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  box-shadow: var(--shadow-design);
}

.summary-strip {
  min-height: 154px;
  padding: 16px;
}

.summary-strip-title,
.card-title,
.panel-title {
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
}

.patient-strip-grid {
  grid-template-columns: repeat(5, minmax(100px, 1fr));
  gap: 10px;
}

.summary-cell {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.summary-cell-label,
.form-label {
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
}

.summary-cell-input,
.form-input,
.form-select,
input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-muted);
  color: #001880;
  box-shadow: none;
}

.summary-cell-input,
.form-input,
.form-select {
  min-height: 38px;
}

.summary-cell-value {
  min-height: 38px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-muted);
  color: #001880;
}

input:focus,
select:focus,
textarea:focus,
.summary-cell-input:focus,
.form-input:focus,
.form-select:focus {
  border-color: #6072d7;
  outline: 2px solid rgba(19, 43, 217, 0.09);
}

.tiny-note,
.helper-text,
.card-subtitle {
  color: var(--ink-soft);
}

.revenue-strip-grid {
  height: calc(100% - 28px);
  gap: 10px;
}

.revenue-mini {
  min-height: 98px;
  padding: 18px 16px;
  border: 0;
  border-radius: 7px;
  background: #c7cde3;
}

.revenue-mini:first-child {
  background: linear-gradient(130deg, #071477 0%, #1934e8 100%);
  color: #fff;
}

.revenue-mini:first-child .metric-label,
.revenue-mini:first-child .metric-value {
  color: #fff !important;
}

.revenue-mini .metric-label {
  color: #28324f;
  font-size: 12px;
}

.revenue-mini .metric-value {
  margin-top: 10px;
  color: #111b3b;
  font-size: clamp(24px, 2.8vw, 40px);
  font-weight: 500;
}

.metric-label-dot {
  display: none;
}

.setup-card {
  overflow: visible;
}

.card-header,
.panel-header {
  min-height: 62px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.card-title-icon {
  width: 38px;
  height: 38px;
  border-radius: 4px;
  background: var(--primary-faint);
  color: var(--primary);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.06);
}

.setup-body {
  padding: 18px 16px;
}

.form-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.form-field {
  gap: 6px;
}

.form-row-bottom {
  align-items: center;
  gap: 14px;
}

.consent-label {
  color: var(--ink-soft);
}

.consent-label input {
  accent-color: var(--primary-strong);
}

.consent-badge,
.panel-badge,
.pill {
  border-color: #d7dcf1;
  border-radius: 999px;
  background: var(--primary-soft);
  color: #001880;
}

.recording-indicator {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-muted);
}

.recording-indicator-label {
  color: #001880;
}

.waveform .bar {
  background: #70b8ff;
}

.btn {
  min-height: 40px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: none;
}

.btn-primary {
  border-color: var(--primary);
  background: linear-gradient(130deg, #00106a, #1935eb);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  border-color: #00106a;
  background: linear-gradient(130deg, #001780, #2945f2);
  transform: none;
  box-shadow: 0 5px 12px rgba(0, 16, 106, 0.16);
}

.btn-ghost {
  border-color: var(--line-strong);
  background: #f7f8fc;
  color: var(--primary);
}

.btn-ghost:hover:not(:disabled) {
  border-color: #8e9ad0;
  background: #eef1fb;
  color: var(--primary);
}

.btn-danger {
  border-color: #f0ccd1;
  background: #fff3f4;
  color: var(--danger-design);
}

.workspace,
.workspace-live {
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.85fr);
  gap: 12px;
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.panel-header {
  background: var(--surface);
}

.panel-title svg {
  color: var(--primary);
}

.panel-body {
  padding: 16px;
}

.soap-grid {
  gap: 12px;
}

.soap-grid .form-field {
  min-height: 150px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.soap-grid .form-label {
  width: fit-content;
  min-height: 36px;
  padding: 9px 12px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
}

.soap-textarea {
  min-height: 88px;
  border: 0;
  background: transparent;
  color: var(--ink);
  resize: vertical;
}

.soap-textarea:focus {
  outline: 0;
}

.divider {
  background: var(--line);
}

.empty-state {
  color: var(--ink-muted);
}

.suggestion-card,
.message,
.audit-item,
.evidence-item {
  border-color: var(--line);
  border-radius: 4px;
  background: var(--surface-muted);
}

.billable-panel {
  overflow: hidden;
}

.table-header {
  background: #eceff8;
  color: #191f33;
}

.table-row {
  border-bottom-color: var(--line);
}

.list-table {
  min-width: 680px;
  border-collapse: collapse;
}

.list-table thead th {
  height: 48px;
  padding: 12px 14px;
  border-bottom: 0;
  background: #eceff8;
  color: #191f33;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.list-table tbody td {
  height: 52px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  color: #626a79;
  font-size: 12px;
  vertical-align: middle;
}

.list-table tbody tr:hover {
  background: #fafbff;
}

.table-body,
.codebook-table-scroller {
  overflow-x: auto;
}

.settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.info-card {
  padding: 18px;
}

.info-card h3,
.chart-block h3 {
  color: var(--primary);
  font-size: 15px;
  font-weight: 600;
}

.stats-grid {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
}

.metric-tile {
  min-height: 122px;
  padding: 20px 16px;
  border: 0;
  border-radius: 6px;
  background: #dfe3f2;
}

.metric-tile:first-child {
  background: var(--primary);
  color: #fff;
}

.metric-tile:first-child .metric-label,
.metric-tile:first-child .metric-value {
  color: #fff;
}

.metric-tile .metric-label {
  color: #3f485e;
}

.metric-tile .metric-value {
  margin-top: 12px;
  color: var(--primary);
  font-size: 27px;
}

.filters-row {
  grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(150px, 0.55fr)) auto;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-muted);
}

.split-two {
  gap: 16px;
}

.codebook-toolbar,
.codebook-config-section {
  border-color: var(--line);
  background: var(--surface);
}

.codebook-tab {
  border-radius: 4px 4px 0 0;
  color: var(--ink-soft);
}

.codebook-tab.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.kv-row {
  border-bottom-color: var(--line);
}

.chart-block {
  padding: 18px;
}

.chart-grid {
  border-color: var(--line);
  border-radius: 4px;
  background-color: #fbfcff;
}

.auth-overlay,
.cb-modal-overlay {
  background: rgba(0, 7, 34, 0.58);
  backdrop-filter: blur(3px);
}

.auth-card,
.cb-modal-box {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 22px 60px rgba(0, 15, 79, 0.24);
}

.auth-card h3,
.cb-modal-title {
  color: var(--primary);
  font-family: "Plus Jakarta Sans", sans-serif;
}

.cb-modal-header,
.cb-modal-footer {
  border-color: var(--line);
  background: var(--surface);
}

.cb-modal-close {
  border-radius: 4px;
  color: var(--primary);
}

.hidden {
  display: none !important;
}

@media (max-width: 1240px) {
  .sidebar {
    width: 264px;
    padding-inline: 20px;
  }

  .patient-strip-grid {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }

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

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

@media (max-width: 1040px) {
  .top-strips,
  .workspace,
  .workspace-live {
    grid-template-columns: 1fr;
  }

  .settings-grid,
  .split-two {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }
}

@media (max-width: 920px) {
  .sidebar {
    display: flex;
    position: fixed;
    inset: 0 auto 0 0;
    width: min(320px, 88vw);
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  body.sidebar-open::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(0, 7, 34, 0.46);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .mobile-menu-btn {
    display: grid;
  }

  .topbar {
    min-height: 84px;
  }

  .topbar-right .status-pill {
    max-width: 220px;
  }
}

@media (max-width: 700px) {
  .topbar {
    padding: 16px;
  }

  .breadcrumb #currentViewLabel {
    font-size: 20px;
  }

  .breadcrumb #brandBreadcrumb {
    display: none;
  }

  .topbar-right .status-pill {
    width: 12px;
    min-width: 12px;
    min-height: 12px;
    padding: 0;
    border: 0;
    background: transparent;
  }

  .topbar-right .status-pill span {
    display: none;
  }

  .topbar-right .status-dot {
    width: 10px;
    height: 10px;
  }

  #logoutBtn {
    min-height: 36px !important;
    padding-inline: 10px !important;
  }

  .content {
    padding: 0 14px 28px;
    gap: 14px;
  }

  .patient-strip-grid,
  .form-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .revenue-strip-grid {
    grid-template-columns: 1fr;
  }

  .form-row-bottom,
  .card-header,
  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .btn-group,
  .inline-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .btn-group .btn {
    flex: 1 1 150px;
  }

  .recording-indicator {
    width: 100%;
  }

  .soap-grid {
    grid-template-columns: 1fr;
  }

  .soap-grid .full-width {
    grid-column: auto;
  }

  .filters-row {
    grid-template-columns: 1fr;
  }

  .auth-card {
    width: calc(100vw - 28px);
    padding: 20px;
  }
}
