﻿:root {
  color-scheme: light;
  --navy-950: #061944;
  --navy-900: #082151;
  --navy-850: #0a285d;
  --amber-500: #e9a91b;
  --text-primary: #071b49;
  --text-secondary: #55575a;
  --text-muted: #66686b;
  --surface: #fff;
  --surface-soft: #f5f6f7;
  --border: #dfe0e2;
  --success: #00a85a;
  --warning: #ffd400;
  --danger: #ed1717;
  --neutral: #626466;
  --content-left: clamp(22px, 4.26vw, 60px);
  --content-right: clamp(22px, 2.42vw, 34px);
  --header-art-width: 116px;
  --header-art-height: 170px;
  --back-button-left: 15px;
  --back-button-top: 42px;
  --back-button-size: 51px;
  --focus: #4c83dd;
  font-family: "Poppins", "Century Gothic", "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100dvh;
  overflow: hidden;
  color: var(--text-primary);
  background: #fff;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 60%, transparent);
  outline-offset: 2px;
}

.svg-definitions {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.app-shell {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-rows: calc(112px + env(safe-area-inset-top)) minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  background: #fff;
}

.app-header {
  position: relative;
  z-index: 2;
  min-width: 0;
  overflow: visible;
  background: transparent;
}

.header-yellow-shape {
  position: absolute;
  z-index: 0;
  top: 0;
  left: -15px;
  width: var(--header-art-width);
  height: var(--header-art-height);
  display: block;
  pointer-events: none;
  user-select: none;
}

.back-button {
  position: absolute;
  z-index: 3;
  top: calc(var(--back-button-top) + env(safe-area-inset-top));
  left: var(--back-button-left);
  display: grid;
  width: var(--back-button-size);
  height: var(--back-button-size);
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  overflow: visible;
  background: transparent;
  box-shadow: none;
}

.page-title {
  position: absolute;
  z-index: 2;
  top: calc(50px + env(safe-area-inset-top));
  left: 140px;
  margin: 0;
  color: var(--text-primary);
  font-size: clamp(29px, 2.35vw, 36px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -.5px;
}

.menu-button {
  position: absolute;
  z-index: 3;
  top: calc(46px + env(safe-area-inset-top));
  right: max(38px, env(safe-area-inset-right));
  display: grid;
  width: 42px;
  height: 42px;
  place-content: center;
  gap: 6px;
  padding: 5px;
  border: 0;
  background: transparent;
}

.menu-button span {
  display: block;
  width: 29px;
  height: 5px;
  border-radius: 4px;
  background: var(--navy-950);
}

.app-content {
  position: relative;
  z-index: 1;
  min-width: 0;
  min-height: 0;
  padding: 2px var(--content-right) 38px var(--content-left);
  overflow: auto;
  scrollbar-width: thin;
  background: transparent;
}

.search-toolbar {
  display: grid;
  grid-template-columns: minmax(190px, 1.15fr) minmax(190px, 1.13fr) minmax(170px, .9fr) minmax(220px, 1fr) minmax(140px, 180px);
  gap: 18px;
  align-items: center;
  min-height: 94px;
  margin: 0;
  padding: 20px;
  border: 1px solid #e6e6e6;
  border-radius: 13px;
  background: rgb(255 255 255 / 96%);
  box-shadow: 0 3px 10px rgb(0 0 0 / 8%);
}

.form-control {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 20px;
  gap: 10px;
  align-items: center;
  height: 49px;
  padding: 0 13px;
  border: 1.5px solid #d6d7da;
  border-radius: 8px;
  color: #54565a;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 1%);
}

.form-control:focus-within {
  border-color: #8098c2;
}

.form-control > svg:first-child {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.form-control select,
.form-control input {
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  color: #505257;
  background: transparent;
  font-size: 16px;
  appearance: none;
}

.form-control input::placeholder {
  color: #505257;
  opacity: 1;
}

.code-filter-control {
  grid-template-columns: 42px minmax(0, 1fr);
}

.code-filter-control > svg:first-child {
  width: 36px;
}

.search-toolbar .select2-container {
  min-width: 0;
  width: 100% !important;
}

.search-toolbar .select2-container .select2-selection--single {
  height: 47px;
  border: 0;
  background: transparent;
}

.search-toolbar .select2-container .select2-selection--single .select2-selection__rendered {
  padding: 0;
  color: #505257;
  line-height: 47px;
}

.search-toolbar .select2-container .select2-selection--single .select2-selection__placeholder {
  color: #505257;
}

.search-toolbar .select2-container .select2-selection--single .select2-selection__arrow {
  display: none;
}

.mobile-prescriptions-page .select2-dropdown {
  border-color: #8098c2;
  font-size: 16px;
}

.select-chevron {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.scan-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  height: 49px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(100deg, var(--navy-950), #092357);
  box-shadow: 0 3px 8px rgb(4 22 62 / 14%);
  font-size: 16px;
  font-weight: 700;
}

.scan-button:hover {
  background: #0b2d69;
}

.scan-button svg {
  width: 56px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
}

.search-actions {
  display: flex;
  gap: 8px;
  min-width: 0;
}

.search-actions .scan-button {
  flex: 1 1 auto;
  min-width: 0;
  padding-right: 12px;
  padding-left: 12px;
}

.clear-filters-button {
  border: 1px solid #b9c0cd;
  color: var(--navy-950);
  background: #fff;
  box-shadow: none;
}

.clear-filters-button:hover {
  background: #f0f2f6;
}

.result-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  margin-top: 23px;
  padding: 0 27px;
  border: 1px solid #e5e6e8;
  border-radius: 11px;
  background: linear-gradient(100deg, #f3f4f5, #f7f8f9);
  color: var(--text-primary);
  font-size: 16px;
}

.result-summary p {
  margin: 0;
}

.result-summary strong {
  font-weight: 700;
}

.prescription-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 18px;
  margin-top: 20px;
}

.prescription-card {
  position: relative;
  min-width: 0;
  height: 163px;
  padding: 0 22px 16px 20px;
  overflow: hidden;
  border: 1px solid #dedfe1;
  border-radius: 14px;
  color: var(--text-secondary);
  background: linear-gradient(115deg, #fff 0%, #fbfbfb 100%);
  box-shadow: 0 1px 3px rgb(0 0 0 / 3%);
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.prescription-card:hover {
  border-color: #bdc9dc;
  box-shadow: 0 3px 10px rgb(5 29 70 / 10%);
}

.prescription-card.is-selected {
  border-color: #6d8fca;
  box-shadow: 0 0 0 2px rgb(77 119 190 / 18%);
}

.card-select-button {
  position: absolute;
  z-index: 5;
  inset: 0;
  width: 100%;
  border: 0;
  background: transparent;
}

.card-top,
.patient-row,
.card-counters {
  position: relative;
  z-index: 2;
  pointer-events: none;
}

.card-top {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 168px;
  align-items: center;
  height: 42px;
  margin-right: 1px;
}

.status-cell {
  display: grid;
  place-items: center;
  transform: translateX(-15px);
}

.status-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--status-color);
  box-shadow: 0 0 0 7px #f5f6f6;
}

.code-ribbon,
.date-ribbon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 41px;
  color: #fff;
}

.code-ribbon {
  z-index: 2;
  gap: 14px;
  min-width: 0;
  margin-right: -15px;
  padding: 0 31px 0 38px;
  clip-path: polygon(0 0, 94.5% 0, 100% 100%, 7% 100%);
  background: linear-gradient(105deg, #0b2b63 0%, var(--navy-950) 70%, #071b48 100%);
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
}

.code-ribbon svg {
  flex: 0 0 auto;
  width: 29px;
  height: 24px;
  fill: #fff;
  stroke: none;
}

.date-ribbon {
  z-index: 1;
  gap: 10px;
  padding: 0 15px 0 28px;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 17% 100%);
  border-radius: 0 8px 8px 0;
  background: linear-gradient(115deg, #e8a71a, #efb324);
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
}

.date-ribbon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.patient-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 15px;
  padding: 0 2px 0 4px;
}

.patient-name {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: #56585b;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.patient-location {
  flex: 0 0 auto;
  color: #686a6d;
  font-size: 15px;
  white-space: nowrap;
}

.card-counters {
  display: grid;
  grid-template-columns: 1.05fr 1.06fr 1fr;
  gap: 18px;
  margin-top: 17px;
}

.counter {
  display: flex;
  min-width: 0;
  height: 43px;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  overflow: hidden;
  border: 1px solid #dfe0e2;
  border-radius: 8px;
  color: var(--text-primary);
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 2%);
  font-size: 15px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.counter svg {
  flex: 0 0 auto;
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.counter .fill-current {
  fill: currentColor;
  stroke: none;
}

.counter.pending svg {
  color: var(--danger);
  stroke-width: 1.9;
}

.selection-hint {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 75px;
  margin-top: 22px;
  padding: 0 21px;
  border: 1px solid #9db5d9;
  border-radius: 11px;
  color: var(--text-primary);
  background: linear-gradient(100deg, #fafcfe, #f5f9fd);
  font-size: 16px;
}

.selection-hint svg {
  flex: 0 0 auto;
  width: 35px;
  height: 35px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 1199px) {
  .app-shell {
    grid-template-rows: calc(112px + env(safe-area-inset-top)) minmax(0, 1fr);
  }

  .search-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .prescription-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 410px), 1fr));
  }

  .prescription-card {
    height: 164px;
  }
}

@media (max-width: 900px), (orientation: portrait) {
  .app-shell {
    grid-template-rows: calc(108px + env(safe-area-inset-top)) minmax(0, 1fr);
  }

  .app-content {
    padding-bottom: 24px;
  }

  .prescription-grid {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 767px) {
  :root {
    --content-left: 14px;
    --content-right: 14px;
    --header-art-width: 100px;
    --header-art-height: 146.55px;
    --back-button-left: 15px;
    --back-button-top: 36.21px;
    --back-button-size: 44px;
  }

  .app-shell {
    grid-template-rows: calc(96px + env(safe-area-inset-top)) minmax(0, 1fr);
  }

  .page-title {
    top: calc(45px + env(safe-area-inset-top));
    left: 84px;
    max-width: calc(100% - 145px);
    overflow: hidden;
    font-size: clamp(22px, 6vw, 28px);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .menu-button {
    top: calc(39px + env(safe-area-inset-top));
    right: max(15px, env(safe-area-inset-right));
    width: 35px;
    height: 35px;
  }

  .menu-button span {
    width: 25px;
    height: 4px;
  }

  .search-toolbar {
    grid-template-columns: 1fr;
    gap: 11px;
    padding: 14px;
  }

  .result-summary {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    margin-top: 14px;
    padding: 12px 16px;
  }

  .prescription-grid {
    margin-top: 14px;
  }

  .selection-hint {
    min-height: 66px;
    margin-top: 14px;
    padding: 12px 15px;
  }

}

@media (max-width: 560px) {
  .prescription-card {
    height: auto;
    min-height: 166px;
    padding-right: 14px;
    padding-left: 12px;
  }

  .card-top {
    grid-template-columns: 38px minmax(0, 1fr) 128px;
  }

  .code-ribbon {
    gap: 7px;
    padding-right: 18px;
    padding-left: 24px;
    font-size: 14px;
  }

  .code-ribbon svg {
    width: 23px;
  }

  .date-ribbon {
    gap: 6px;
    padding-right: 8px;
    padding-left: 19px;
    font-size: 13px;
  }

  .date-ribbon svg {
    width: 18px;
  }

  .patient-name {
    font-size: 17px;
  }

  .card-counters {
    gap: 7px;
  }

  .counter {
    justify-content: center;
    gap: 5px;
    padding: 0 6px;
    font-size: 13px;
  }

  .counter svg {
    width: 21px;
    height: 21px;
  }
}

@media (max-width: 410px) {
  .card-top {
    grid-template-columns: 34px minmax(0, 1fr) 111px;
  }

  .code-ribbon {
    padding-right: 15px;
    padding-left: 20px;
  }

  .code-ribbon span {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .date-ribbon {
    padding-left: 16px;
  }

  .date-ribbon svg {
    display: none;
  }

  .patient-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .patient-name {
    width: 100%;
  }

  .card-counters {
    grid-template-columns: 1fr;
  }

  .prescription-card {
    min-height: 270px;
  }

  .counter {
    justify-content: flex-start;
    padding: 0 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}

@media print {
  body {
    overflow: visible;
    background: #fff;
  }

  .app-shell {
    display: block;
    overflow: visible;
  }

}
