:root {
  color-scheme: light;
  --ink: #10231f;
  --muted: #657773;
  --line: #d5e3df;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: #ffffff;
  --wash: #edf6f3;
  --teal: #11877d;
  --teal-dark: #07554d;
  --blue: #236fa4;
  --gold: #c28a15;
  --red: #c9382c;
  --green: #0f776c;
  --shadow: 0 18px 48px rgba(16, 35, 31, 0.12);
  --shadow-soft: 0 10px 28px rgba(16, 35, 31, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 6%, rgba(17, 135, 125, 0.14), transparent 32%),
    radial-gradient(circle at 88% 18%, rgba(35, 111, 164, 0.12), transparent 32%),
    linear-gradient(135deg, #f8fbfa 0%, #e8f3f0 100%);
  min-height: 100vh;
}

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

button {
  cursor: pointer;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 28px;
  background: rgba(255, 255, 255, 0.82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(145deg, #0a5b53, #1ca295);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 16px 30px rgba(7, 85, 77, 0.26);
}

.brand-mark span {
  width: 29px;
  height: 29px;
  border-radius: 999px;
  border: 4px solid #fff;
  position: relative;
}

.brand-mark span::before,
.brand-mark span::after {
  content: "";
  position: absolute;
  background: #fff;
  border-radius: 999px;
}

.brand-mark span::before {
  width: 18px;
  height: 4px;
  left: 14px;
  top: 10px;
  transform: rotate(18deg);
}

.brand-mark span::after {
  width: 4px;
  height: 18px;
  right: -3px;
  bottom: -12px;
  transform: rotate(-35deg);
}

.brand p {
  margin: 0 0 2px;
  color: var(--green);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brand h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 56px);
  line-height: 0.98;
  letter-spacing: 0;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.credit {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--green);
  font-weight: 900;
  background: rgba(255, 255, 255, 0.72);
}

.main-view {
  padding: 26px 28px 46px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-soft);
}

.hero-login {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
  gap: 22px;
  align-items: stretch;
}

.intro-card {
  padding: 34px;
  color: #fff;
  background:
    linear-gradient(145deg, rgba(7, 85, 77, 0.92), rgba(18, 132, 124, 0.88)),
    radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.22), transparent 32%);
  border: 0;
  min-height: 560px;
}

.intro-card h2,
.login-card h2,
.section-title h2,
.card-title {
  margin: 0;
}

.intro-card h2 {
  font-size: clamp(34px, 5vw, 62px);
  line-height: 1.02;
  max-width: 780px;
}

.intro-card p {
  color: rgba(255, 255, 255, 0.82);
  font-size: 18px;
  line-height: 1.7;
  max-width: 660px;
}

.step-preview {
  display: grid;
  gap: 10px;
  margin-top: 28px;
}

.step-preview div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.login-card {
  padding: 30px;
}

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

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

.field.full {
  grid-column: 1 / -1;
}

.field label {
  font-weight: 850;
  color: #536763;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.9);
  padding: 13px 14px;
  color: var(--ink);
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.field textarea {
  min-height: 132px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: rgba(17, 135, 125, 0.62);
  box-shadow: 0 0 0 4px rgba(17, 135, 125, 0.13);
}

.primary-button,
.ghost-button,
.danger-button {
  border: 1px solid var(--line);
  border-radius: 13px;
  min-height: 46px;
  padding: 0 18px;
  font-weight: 900;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-soft);
}

.primary-button {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.12);
  background: linear-gradient(135deg, var(--teal), var(--blue));
}

.danger-button {
  color: #7c4d00;
  border-color: rgba(194, 138, 21, 0.42);
  background: #fff8e7;
}

.button-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.tabs,
.section-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-soft);
}

.tabs button,
.section-tabs button {
  border: 0;
  border-radius: 12px;
  background: transparent;
  padding: 12px 16px;
  color: #586b67;
  font-weight: 950;
}

.tabs button.active,
.section-tabs button.active {
  color: #fff;
  background: linear-gradient(135deg, var(--teal), var(--blue));
  box-shadow: 0 10px 24px rgba(17, 135, 125, 0.22);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(360px, max-content) minmax(420px, 1fr) auto;
  gap: 14px;
  align-items: end;
  margin: 18px 0;
}

.date-range {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) auto;
  align-items: end;
  gap: 12px;
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  margin: 14px 0 18px;
}

.filter-chip {
  padding: 8px 11px;
  border-radius: 999px;
  background: #e8f4f1;
  color: var(--green);
  font-weight: 900;
  white-space: nowrap;
}

.active-filter-note {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: #5b706b;
  font-weight: 750;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin: 18px 0 12px;
}

.section-title h2 {
  font-size: 24px;
}

.muted {
  color: var(--muted);
}

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

.kpi-card,
.module-card,
.case-card,
.journey-step,
.chat-card,
.patient-card {
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--line);
  border-radius: 17px;
  box-shadow: var(--shadow-soft);
}

.kpi-card {
  min-height: 146px;
  padding: 20px;
  border-left: 7px solid var(--teal);
}

.kpi-card.blue {
  border-left-color: var(--blue);
}

.kpi-card.gold {
  border-left-color: var(--gold);
}

.kpi-card.red {
  border-left-color: var(--red);
}

.kpi-card p {
  margin: 0 0 12px;
  color: var(--muted);
  font-weight: 800;
}

.kpi-card strong {
  display: block;
  font-size: clamp(34px, 4vw, 54px);
  line-height: 1;
}

.kpi-card span {
  display: block;
  margin-top: 12px;
  color: var(--muted);
}

.work-grid {
  display: grid;
  grid-template-columns: minmax(340px, 0.82fr) minmax(460px, 1.18fr);
  gap: 18px;
  align-items: start;
}

.case-list {
  display: grid;
  gap: 10px;
  max-height: 660px;
  overflow: auto;
  padding-right: 4px;
}

.case-card {
  border: 1px solid var(--line);
  padding: 14px;
  text-align: left;
  width: 100%;
  background: rgba(255, 255, 255, 0.86);
}

.case-card.active {
  border-color: rgba(17, 135, 125, 0.65);
  box-shadow: 0 0 0 4px rgba(17, 135, 125, 0.12), var(--shadow-soft);
}

.case-card header,
.journey-step header,
.chat-message header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.case-card strong {
  font-size: 18px;
}

.case-meta,
.mini-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  background: #eef5f3;
  color: #526b66;
  font-size: 13px;
  font-weight: 850;
}

.pill.done {
  color: #086050;
  background: #dcf3ed;
}

.pill.pending,
.pill.needs-input {
  color: #845c00;
  background: #fff4d8;
}

.pill.blocked {
  color: #9b1c14;
  background: #ffe4e0;
}

.pill.in-progress {
  color: #175d8d;
  background: #e1eff9;
}

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

.journey-step {
  padding: 16px;
}

.journey-step h3 {
  margin: 0;
  font-size: 17px;
}

.journey-step p {
  color: var(--muted);
  min-height: 42px;
}

.step-actions {
  display: grid;
  grid-template-columns: 150px 1fr auto;
  gap: 8px;
  align-items: end;
}

.module-card {
  padding: 16px;
  margin-top: 12px;
}

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

.table-panel {
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  color: #536763;
  background: rgba(238, 245, 243, 0.8);
  font-weight: 950;
}

.chat-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.32fr) minmax(420px, 0.68fr);
  gap: 18px;
}

.chat-card {
  min-height: 570px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-card header {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.chat-stream {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  overflow: auto;
  flex: 1;
  background: rgba(237, 246, 243, 0.42);
}

.chat-message {
  max-width: 82%;
  padding: 12px 14px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}

.chat-message.patient {
  margin-left: auto;
  background: #e8f6ff;
}

.chat-message.staff {
  background: #e8f7f3;
}

.chat-message p {
  margin: 8px 0 0;
  color: #1c302c;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.patient-search {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
  padding: 18px;
  margin-bottom: 16px;
}

.loading-card {
  display: flex;
  align-items: center;
  gap: 15px;
  border: 1px solid rgba(17, 135, 125, 0.25);
  background: rgba(235, 249, 246, 0.92);
  padding: 18px;
  border-radius: 18px;
  margin: 12px 0;
}

.loading-card p {
  margin: 3px 0 0;
  color: var(--muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 4px solid #d8ebe7;
  border-top-color: var(--teal);
  animation: spin 0.82s linear infinite;
  flex: 0 0 auto;
}

.empty {
  padding: 24px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.56);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 80;
  max-width: min(460px, calc(100vw - 32px));
  border-radius: 15px;
  padding: 14px 16px;
  background: #10231f;
  color: #fff;
  box-shadow: var(--shadow);
}

.toast.error {
  background: #8c1d18;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1180px) {
  .toolbar,
  .work-grid,
  .chat-layout,
  .hero-login {
    grid-template-columns: 1fr;
  }

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

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

@media (max-width: 760px) {
  .topbar {
    position: relative;
    align-items: flex-start;
    padding: 14px;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 15px;
  }

  .brand p {
    font-size: 12px;
  }

  .brand h1 {
    font-size: 30px;
  }

  .top-actions {
    gap: 6px;
  }

  .credit {
    display: none;
  }

  .main-view {
    padding: 14px 12px 34px;
  }

  .intro-card {
    min-height: auto;
    padding: 24px;
  }

  .login-grid,
  .date-range,
  .patient-search,
  .module-grid,
  .step-actions,
  .journey-grid {
    grid-template-columns: 1fr;
  }

  .filter-bar {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 12px;
  }

  .filter-bar .danger-button {
    grid-column: 1 / -1;
  }

  .filter-bar select,
  .filter-bar input {
    min-height: 46px;
  }

  .tabs,
  .section-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .tabs button,
  .section-tabs button {
    padding: 12px 8px;
  }

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

  .kpi-card {
    min-height: 126px;
  }

  .chat-form {
    grid-template-columns: 1fr;
  }

  .chat-message {
    max-width: 100%;
  }

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

  .data-table {
    min-width: 860px;
  }
}
