:root {
  --bg: #f5f7f8;
  --panel: #fff;
  --text: #17222b;
  --muted: #687783;
  --line: #dde5e8;
  --accent: #0f8f83;
  --accent-dark: #087167;
  --blue: #2364aa;
  --warning: #fff4da;
  --error: #ba2d2d;
  --shadow: 0 12px 30px rgba(18, 38, 63, .08);
}

* {
  box-sizing: border-box;
}

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

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.loading,
.fatal {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  color: var(--muted);
  font-weight: 800;
}

.fatal {
  color: var(--error);
  white-space: pre-line;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  text-align: left;
}

.link-button,
.text-button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.topnav,
.eyebrow,
.doctor-meta,
.metric span,
td small,
.demo-logins,
.login-copy p,
.formula,
.goal-card p {
  color: var(--muted);
}

.topnav {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
}

.text-button {
  color: var(--accent-dark);
  font-weight: 800;
}

.shell {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.login-layout {
  display: grid;
  grid-template-columns: 1.1fr 420px;
  align-items: center;
  gap: clamp(28px, 6vw, 72px);
  min-height: 100vh;
}

.login-copy h1,
.page-head h1 {
  margin: 0;
  max-width: 780px;
  font-size: clamp(32px, 5vw, 58px);
  line-height: 1.02;
}

.login-copy p {
  max-width: 620px;
  font-size: 18px;
  line-height: 1.6;
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.panel,
.doctor-card,
.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: clamp(18px, 3vw, 28px);
  margin-bottom: 20px;
}

.login-form,
.stack-form {
  display: grid;
  gap: 16px;
}

.login-form h2,
.panel h2 {
  margin: 0;
  font-size: 22px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 12px 14px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 143, 131, .14);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 16px;
  cursor: pointer;
  font-weight: 850;
  white-space: nowrap;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button:hover,
.row-actions button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.button.primary:hover {
  background: var(--accent-dark);
  color: #fff;
}

.form-error,
.warning,
.notice {
  border-radius: 8px;
  padding: 12px 14px;
  font-weight: 800;
  white-space: pre-line;
}

.form-error {
  margin-bottom: 18px;
  background: #ffe9e9;
  color: var(--error);
}

.warning {
  margin-bottom: 20px;
  background: var(--warning);
  color: #7c5200;
}

.notice {
  margin-bottom: 20px;
  background: #e6f7f4;
  color: var(--accent-dark);
}

.demo-logins {
  display: grid;
  gap: 5px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  font-size: 13px;
}

.demo-logins strong {
  color: var(--text);
}

.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.period-tools,
.toolbar-row,
.export-actions,
.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.period-tools input {
  min-width: 160px;
}

.period-tools .year-input {
  width: 110px;
  min-width: 110px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}

.tabs button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  padding: 0 14px;
  cursor: pointer;
  font-weight: 850;
}

.tabs button.active {
  border-color: var(--accent);
  background: #e6f7f4;
  color: var(--accent-dark);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.doctor-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric {
  display: grid;
  gap: 8px;
  padding: 22px;
}

.metric strong {
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1.1;
}

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

.doctor-card {
  display: grid;
  gap: 12px;
  padding: 22px;
}

.doctor-card-button {
  width: 100%;
  border: 1px solid var(--line);
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: border-color .16s ease, transform .16s ease;
}

.doctor-card-button:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.table-link {
  color: var(--accent-dark);
  font-weight: 850;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.doctor-name {
  min-height: 48px;
  font-size: 20px;
  font-weight: 850;
  line-height: 1.2;
}

.doctor-revenue {
  color: var(--blue);
  font-size: 28px;
  font-weight: 900;
}

.progress {
  display: block;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eef1;
}

.progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.split {
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-head strong {
  color: var(--blue);
  font-size: 24px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

td small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
}

.row-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.row-actions button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 10px;
  cursor: pointer;
  font-weight: 750;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.toolbar-row {
  justify-content: space-between;
  margin-bottom: 16px;
}

.maintenance-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.formula {
  max-width: 720px;
  line-height: 1.5;
  font-weight: 750;
}

.goal-card {
  display: flex;
  align-items: center;
  gap: 24px;
}

.goal-card p {
  margin: 8px 0 0;
  line-height: 1.6;
}

.goal-ring {
  --value: 0;
  display: grid;
  place-items: center;
  flex: 0 0 132px;
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--value) * 1%), #e8eef1 0);
}

.goal-ring span {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: #fff;
  color: var(--accent-dark);
  font-size: 22px;
  font-weight: 900;
}

@media (max-width: 960px) {
  .login-layout,
  .split {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 680px) {
  .topbar,
  .page-head,
  .goal-card {
    align-items: stretch;
    flex-direction: column;
  }

  .topnav,
  .period-tools,
  .period-tools input,
  .period-tools .year-input,
  .button,
  .tabs button,
  .export-actions {
    width: 100%;
  }

  .topnav {
    align-items: flex-start;
  }

  .shell {
    width: min(100% - 24px, 1220px);
    padding-top: 22px;
  }

  .login-copy h1,
  .page-head h1 {
    font-size: 34px;
  }

  .metrics,
  .doctor-grid,
  .doctor-metrics {
    grid-template-columns: 1fr;
  }

  .metric,
  .doctor-card,
  .panel {
    padding: 18px;
  }

  .goal-ring {
    align-self: center;
  }
}
