:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f6f8;
  color: #18202f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

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

button {
  border: 1px solid #c8d0d9;
  background: #ffffff;
  color: #172033;
  border-radius: 6px;
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 650;
}

button:hover,
button:focus-visible {
  border-color: #167469;
  outline: 2px solid #93d9d1;
  outline-offset: 1px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #c8d0d9;
  border-radius: 6px;
  padding: 9px 10px;
  background: #ffffff;
  color: #172033;
}

label {
  display: grid;
  gap: 6px;
  color: #465366;
  font-size: 0.86rem;
}

.app-shell {
  min-height: 100vh;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(760px, 100%);
  background: #ffffff;
  border: 1px solid #d9dee7;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 18px 45px rgba(25, 35, 56, 0.08);
}

.login-panel h1,
.topbar h1,
.patient-header h2,
.overview-hero h2,
.section-title h2,
.section-title h3 {
  margin: 0;
  letter-spacing: 0;
}

.login-panel h1,
.topbar h1 {
  font-size: 1.35rem;
}

.stack {
  display: grid;
  gap: 14px;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.divider {
  border-top: 1px solid #e3e7ef;
  margin: 22px 0;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 220px;
  background: #202734;
  color: #ffffff;
  padding: 18px 14px;
  display: grid;
  align-content: start;
  gap: 8px;
}

.brand {
  font-weight: 800;
  font-size: 1.2rem;
  padding: 8px 8px 18px;
}

.nav-label {
  margin: 14px 8px 4px;
  color: #aab5c3;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar button {
  width: 100%;
  justify-content: start;
  text-align: left;
  color: #eef3f7;
  background: transparent;
  border-color: transparent;
}

.sidebar button.active,
.sidebar button:hover,
.sidebar button:focus-visible {
  background: #303947;
  border-color: #566170;
}

.workspace {
  margin-left: 220px;
  min-height: 100vh;
  padding: 20px;
}

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

.top-actions,
.case-actions,
.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}

.muted,
td span,
.member-row span,
.panel span,
.section-title p,
.graph-panel p,
.overview-hero p {
  color: #667386;
}

.eyebrow {
  margin: 0 0 8px;
  color: #167469;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.overview-hero,
.patient-header,
.panel,
.graph-panel,
.worklist-card,
.filter-panel,
.empty {
  background: #ffffff;
  border: 1px solid #d9dee7;
  border-radius: 8px;
}

.overview-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
  gap: 20px;
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: 0 16px 34px rgba(25, 35, 56, 0.06);
}

.overview-hero h2 {
  font-size: clamp(1.6rem, 2.4vw, 2.5rem);
  line-height: 1.08;
  max-width: 760px;
}

.hero-metrics,
.patient-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  min-height: 86px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 14px;
  border: 1px solid #e0e5ec;
  border-radius: 8px;
  background: #fbfcfd;
}

.metric strong {
  font-size: 1.55rem;
}

.metric span {
  color: #536174;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric.danger {
  border-color: #f0b3ad;
  background: #fff3f1;
}

.metric.warning {
  border-color: #f1d18b;
  background: #fff9ea;
}

.metric.signal {
  border-color: #a6d8c4;
  background: #f0faf5;
}

.toolbar {
  display: grid;
  grid-template-columns: 1.5fr repeat(4, minmax(130px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.filter-panel {
  padding: 14px;
}

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

.overview-graphs .graph-panel:nth-child(2),
.overview-graphs .graph-panel:nth-child(5),
.overview-graphs .graph-panel:nth-child(6),
.patient-graphs .graph-panel:nth-child(2),
.patient-graphs .graph-panel:nth-child(5) {
  grid-column: span 2;
}

.graph-panel {
  min-height: 274px;
  padding: 16px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
}

.graph-panel h3 {
  margin: 0;
  font-size: 1rem;
}

.graph-panel p {
  margin: 4px 0 0;
  font-size: 0.86rem;
}

.chart-box {
  position: relative;
  height: 178px;
  min-height: 178px;
  width: 100%;
}

.overview-graphs .graph-panel:nth-child(2) .chart-box,
.overview-graphs .graph-panel:nth-child(5) .chart-box,
.overview-graphs .graph-panel:nth-child(6) .chart-box,
.patient-graphs .graph-panel:nth-child(2) .chart-box,
.patient-graphs .graph-panel:nth-child(5) .chart-box {
  height: 206px;
}

.chart-box canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.bar-chart {
  display: grid;
  gap: 10px;
  align-content: center;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(86px, 0.8fr) minmax(110px, 1fr) 34px;
  gap: 8px;
  align-items: center;
}

.bar-row span,
.bar-row strong {
  font-size: 0.82rem;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: #ecf0f4;
  overflow: hidden;
}

.bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #167469;
}

.ring-wrap {
  position: relative;
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 12px;
  align-items: center;
}

.ring-chart {
  width: 132px;
  height: 132px;
  transform: rotate(-90deg);
}

.ring-base,
.ring-segment {
  fill: none;
  stroke-width: 12;
}

.ring-base {
  stroke: #ecf0f4;
}

.ring-segment {
  stroke-linecap: round;
}

.segment-0,
.segment-bg-0 {
  stroke: #b83a2f;
  background: #b83a2f;
}

.segment-1,
.segment-bg-1 {
  stroke: #d18b00;
  background: #d18b00;
}

.segment-2,
.segment-bg-2 {
  stroke: #167469;
  background: #167469;
}

.segment-3,
.segment-bg-3 {
  stroke: #4d6fb3;
  background: #4d6fb3;
}

.segment-4,
.segment-bg-4 {
  stroke: #7b5aa6;
  background: #7b5aa6;
}

.ring-center {
  position: absolute;
  left: 30px;
  top: 42px;
  width: 72px;
  text-align: center;
  display: grid;
  gap: 2px;
}

.ring-center strong {
  font-size: 1.4rem;
}

.ring-center span {
  font-size: 0.72rem;
}

.legend {
  display: grid;
  gap: 7px;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
}

.legend i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.sparkline {
  width: 100%;
  height: 118px;
}

.sparkline polyline {
  fill: none;
  stroke: #167469;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sparkline circle {
  fill: #ffffff;
  stroke: #167469;
  stroke-width: 2;
}

.timeline-bars {
  min-height: 128px;
  display: flex;
  align-items: end;
  gap: 6px;
  padding: 8px 0;
}

.timeline-bars span {
  position: relative;
  flex: 1;
  min-width: 8px;
  border-radius: 6px 6px 2px 2px;
  background: #4d6fb3;
}

.timeline-bars i {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.worklist-card {
  overflow: hidden;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  padding: 16px 16px 0;
}

.section-title:only-child,
.panel .section-title {
  padding: 0;
}

.section-title p {
  margin: 4px 0 0;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid #e6eaf0;
  vertical-align: top;
}

th {
  font-size: 0.76rem;
  color: #536174;
  text-transform: uppercase;
  background: #f9fafb;
}

tr[data-profile-id] {
  cursor: pointer;
}

tr[data-profile-id]:hover,
tr[data-profile-id]:focus-visible {
  background: #f0faf8;
  outline: 2px solid #93d9d1;
  outline-offset: -2px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: capitalize;
  border: 1px solid transparent;
}

.badge.danger,
.alert.danger {
  background: #fff0ee;
  color: #9d2115;
  border-color: #f0b3ad;
}

.badge.warning {
  background: #fff7e6;
  color: #805100;
  border-color: #efd086;
}

.badge.neutral {
  background: #edf1f7;
  color: #465366;
  border-color: #d7dee8;
}

.alert {
  border: 1px solid;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.alert.success {
  background: #ecf9f2;
  border-color: #a8dfbf;
  color: #195f35;
}

.patient-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.8fr) auto;
  align-items: center;
  gap: 16px;
  padding: 16px;
  margin-bottom: 14px;
}

.patient-header.refined h2 {
  margin-top: 8px;
  font-size: 1.55rem;
}

.text-button {
  min-height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #167469;
}

.detail-grid,
.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.admin-overview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.promotions-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.8fr) minmax(0, 1.4fr);
  gap: 14px;
  align-items: start;
}

.promotion-list {
  display: grid;
  gap: 8px;
}

.promotion-row {
  display: grid;
  justify-items: start;
  gap: 5px;
  min-height: auto;
  padding: 12px;
  text-align: left;
  border-color: #d9dee7;
}

.promotion-row.active {
  border-color: #167469;
  background: #f0faf8;
}

.promotion-row span,
.promotion-row small {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.promotion-form {
  display: grid;
  gap: 14px;
}

.form-grid,
.locale-grid,
.preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

fieldset {
  border: 1px solid #d9dee7;
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 10px;
  min-width: 0;
}

legend {
  padding: 0 6px;
  color: #465366;
  font-weight: 800;
}

.promotion-preview {
  display: grid;
  gap: 8px;
  min-height: 188px;
  border: 1px solid #d9dee7;
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfd;
}

.promotion-preview.rtl {
  direction: rtl;
  text-align: right;
}

.promotion-preview span,
.badge {
  width: fit-content;
  border-radius: 999px;
  background: #eaf4f2;
  color: #167469;
  padding: 3px 8px;
  font-size: 0.75rem;
  font-weight: 800;
}

.badge.warning {
  background: #fff5d7;
  color: #8a5b00;
}

.badge.danger {
  background: #ffe4e0;
  color: #a72f25;
}

.badge.success {
  background: #e6f5ec;
  color: #1f7a46;
}

.badge.info {
  background: #eaf0ff;
  color: #3454a4;
}

.promotion-preview h3,
.promotion-preview p {
  margin: 0;
}

.promotion-preview strong {
  font-size: 1.15rem;
}

.audit-list {
  display: grid;
  gap: 8px;
}

.validation-ok {
  color: #1f7a46;
  font-weight: 800;
}

.validation-error {
  color: #a72f25;
  font-weight: 800;
}

.timeline-panel {
  grid-column: 1 / -1;
}

.panel {
  padding: 16px;
  display: grid;
  align-content: start;
  gap: 12px;
}

.panel h2,
.panel h3 {
  margin: 0;
}

.case-item,
.member-row {
  border-top: 1px solid #e6eaf0;
  padding-top: 12px;
  display: grid;
  gap: 8px;
}

.case-item.danger {
  border-top-color: #f0b3ad;
}

.case-item.warning {
  border-top-color: #efd086;
}

.timeline-line {
  display: grid;
  gap: 3px;
  margin: 0;
}

.one-time-code {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px dashed #167469;
  border-radius: 8px;
  background: #f0faf8;
}

.one-time-code strong {
  font-size: 1.3rem;
  letter-spacing: 0;
}

.spinner {
  color: #465366;
}

.empty,
.no-data {
  padding: 24px;
}

.no-data {
  display: grid;
  min-height: 118px;
  place-items: center;
  border: 1px dashed #c8d0d9;
  border-radius: 8px;
  color: #667386;
  background: #fbfcfd;
}

@media (max-width: 1180px) {
  .graph-grid,
  .overview-hero,
  .patient-header {
    grid-template-columns: 1fr;
  }

  .overview-graphs .graph-panel:nth-child(2),
  .overview-graphs .graph-panel:nth-child(5),
  .overview-graphs .graph-panel:nth-child(6),
  .patient-graphs .graph-panel:nth-child(2),
  .patient-graphs .graph-panel:nth-child(5) {
    grid-column: auto;
  }
}

@media (max-width: 980px) {
  .sidebar {
    position: static;
    width: auto;
    display: flex;
    overflow-x: auto;
  }

  .workspace {
    margin-left: 0;
  }

  .toolbar,
  .detail-grid,
  .admin-grid,
  .admin-overview,
  .promotions-layout,
  .form-grid,
  .locale-grid,
  .preview-grid,
  .hero-metrics,
  .patient-metrics {
    grid-template-columns: 1fr;
  }

  .topbar,
  .two-col {
    grid-template-columns: 1fr;
    display: grid;
  }

  .ring-wrap {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .ring-center {
    left: calc(50% - 36px);
  }
}

@media (max-width: 680px) {
  .workspace {
    padding: 12px;
  }

  .overview-hero,
  .panel,
  .graph-panel,
  .patient-header {
    padding: 14px;
  }

  .bar-row {
    grid-template-columns: 1fr 34px;
  }

  .bar-row .bar-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}
