:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #667085;
  --line: #d8dee8;
  --panel: #ffffff;
  --page: #f4f7fb;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --accent: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.45;
}

a {
  color: var(--brand-dark);
  text-decoration: none;
}

.app-header {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 24px;
  justify-content: space-between;
  min-height: 72px;
  padding: 14px 28px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  color: var(--ink);
  display: grid;
  font-weight: 700;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.app-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.app-header nav a,
.button,
button {
  background: var(--brand);
  border: 0;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font: 700 14px Arial, Helvetica, sans-serif;
  min-height: 38px;
  padding: 10px 14px;
}

.app-header nav a {
  background: #eef7f6;
  color: var(--brand-dark);
}

.button.secondary,
button.secondary {
  background: #eef2f6;
  color: #344054;
}

.page {
  margin: 0 auto;
  max-width: 1180px;
  padding: 28px;
}

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

h1,
h2,
h3,
p {
  margin-top: 0;
}

.grid {
  display: grid;
  gap: 16px;
}

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

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

.panel,
.stat,
form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.stat strong {
  display: block;
  font-size: 30px;
}

.stat span,
.muted {
  color: var(--muted);
}

label {
  color: #344054;
  display: grid;
  font-size: 13px;
  font-weight: 700;
  gap: 6px;
}

input,
select,
textarea {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  color: var(--ink);
  font: 15px Arial, Helvetica, sans-serif;
  min-height: 40px;
  padding: 9px 10px;
  width: 100%;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

table {
  border-collapse: collapse;
  width: 100%;
}

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

th {
  background: #f8fafc;
  color: #344054;
  font-size: 13px;
}

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

.notice {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  color: #9a3412;
  margin-bottom: 16px;
  padding: 12px;
}

.login-page {
  align-items: center;
  display: flex;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  margin: 0 auto;
  max-width: 430px;
  width: 100%;
}

.login-card label + label,
.login-card .notice + label,
.login-card p + label {
  margin-top: 14px;
}

.bill-items td {
  padding: 6px;
}

.print-body {
  background: #e8edf3;
}

.a4-sheet {
  background: #fff;
  box-shadow: 0 12px 40px rgba(15, 23, 42, .14);
  margin: 24px auto;
  min-height: 11.69in;
  padding: .45in .55in;
  width: 8.27in;
}

.letterhead-space {
  height: 3in;
}

.prescription-sheet {
  --rx-top-offset: 1.34in;
  --rx-side-margin: .32in;
  background: #fff;
  box-shadow: 0 12px 40px rgba(15, 23, 42, .14);
  margin: 24px auto;
  min-height: 11.69in;
  padding: 0;
  width: 8.27in;
}

.rx-patient-band {
  color: #111827;
  display: grid;
  font-size: 14px;
  font-weight: 600;
  gap: .11in;
  line-height: 1.2;
  margin-left: var(--rx-side-margin);
  margin-right: var(--rx-side-margin);
  padding-top: var(--rx-top-offset);
}

.rx-row {
  display: grid;
  gap: .2in;
  grid-template-columns: 1fr 1fr;
}

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

.rx-row-line2 {
  grid-template-columns: 1fr 1fr 1fr 1.2fr;
}

.rx-father-name {
  transform: translateX(-58px);
}

.rx-row-line1,
.rx-row-line2 {
  margin-top: 15px;
}

.rx-row span {
  white-space: nowrap;
}

.rx-row-line1 span:nth-child(1),
.rx-row-line2 span:nth-child(1) {
  text-align: left;
}

.rx-row-line1 span:nth-child(2),
.rx-row-line2 span:nth-child(2) {
  text-align: center;
}

.rx-row-line1 span:nth-child(3),
.rx-row-line2 span:nth-child(3),
.rx-row-line2 span:nth-child(4) {
  text-align: right;
}

.print-title {
  border-bottom: 2px solid #111827;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0;
  margin-bottom: 14px;
  padding-bottom: 8px;
  text-align: center;
  text-transform: uppercase;
}

.patient-strip {
  border: 1px solid #111827;
  display: grid;
  gap: 0;
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: 14px;
}

.patient-strip div {
  border-bottom: 1px solid #111827;
  min-height: 34px;
  padding: 8px;
}

.patient-strip div:nth-child(odd) {
  border-right: 1px solid #111827;
}

.patient-strip b {
  display: inline-block;
  min-width: 105px;
}

.print-section {
  margin-top: 16px;
}

.signature-row {
  display: flex;
  justify-content: space-between;
  margin-top: 60px;
}

.print-actions {
  bottom: 20px;
  position: fixed;
  right: 20px;
}

@page {
  margin: 0;
  size: A4;
}

@media print {
  body,
  .print-body {
    background: #fff;
  }

  .a4-sheet {
    box-shadow: none;
    margin: 0;
    min-height: 11.69in;
    width: 8.27in;
  }

  .prescription-sheet {
    box-shadow: none;
    margin: 0;
    min-height: 11.69in;
    width: 8.27in;
  }

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

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

  .rx-row-line2 {
    grid-template-columns: 1fr 1fr 1fr 1.2fr;
  }

  .rx-father-name {
    transform: translateX(-58px);
  }

  .rx-row-line1 span:nth-child(1),
  .rx-row-line2 span:nth-child(1) {
    text-align: left;
  }

  .rx-row-line1 span:nth-child(2),
  .rx-row-line2 span:nth-child(2) {
    text-align: center;
  }

  .rx-row-line1 span:nth-child(3),
  .rx-row-line2 span:nth-child(3),
  .rx-row-line2 span:nth-child(4) {
    text-align: right;
  }

  .print-actions,
  .app-header {
    display: none;
  }
}

@media screen and (max-width: 760px) {
  .app-header,
  .page-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .grid.two,
  .grid.three,
  .search-row {
    grid-template-columns: 1fr;
  }

  .a4-sheet {
    margin: 0;
    width: 100%;
  }

  .prescription-sheet {
    margin: 0;
    width: 100%;
  }

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

  .rx-row-line1,
  .rx-row-line2 {
    grid-template-columns: 1fr;
  }

  .rx-father-name {
    transform: none;
  }

  .rx-row span {
    text-align: left;
  }
}
