:root {
  --bg: #eef5f3;
  --panel: #ffffff;
  --ink: #153834;
  --muted: #607571;
  --line: #d9e8e5;
  --brand: #15776f;
  --brand-2: #24998f;
  --gold: #d8902f;
  --danger: #b83232;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, "Nirmala UI", sans-serif;
}

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 260px;
  background: #0f403c;
  color: #fff;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand.large {
  margin-bottom: 22px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand), var(--gold));
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}

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

.brand small {
  color: rgba(255, 255, 255, 0.72);
  margin-top: 3px;
}

nav {
  display: grid;
  gap: 8px;
}

nav a,
.logout {
  color: #d8efeb;
  padding: 11px 12px;
  border-radius: 8px;
}

nav a.active,
nav a:hover,
.logout:hover {
  background: rgba(255, 255, 255, 0.11);
  color: #fff;
}

.logout {
  margin-top: auto;
}

.main {
  margin-left: 260px;
  padding: 28px;
}

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

.topbar h1 {
  margin: 0;
  font-size: 28px;
}

.topbar p {
  margin: 5px 0 0;
  color: var(--muted);
}

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

.stats-grid div,
.table-card,
.form-card,
.profile,
.prescription,
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(16, 64, 60, 0.07);
}

.stats-grid div {
  padding: 18px;
}

.stats-grid span {
  color: var(--muted);
  display: block;
}

.stats-grid strong {
  display: block;
  font-size: 34px;
  margin-top: 8px;
}

.quick-actions {
  display: flex;
  gap: 12px;
  margin: 18px 0;
}

.quick-actions a,
.button,
button {
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  padding: 11px 15px;
  font-weight: 700;
  cursor: pointer;
  display: inline-block;
}

.quick-actions a:nth-child(2),
.button.secondary {
  background: var(--gold);
}

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

.toolbar form {
  display: flex;
  gap: 10px;
  flex: 1;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbdedb;
  border-radius: 8px;
  padding: 11px 12px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

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

.table-card {
  overflow: hidden;
  padding: 0;
}

.table-card h2 {
  margin: 0;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  font-size: 18px;
}

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

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

th {
  background: #f6faf9;
  color: #506b67;
  font-size: 13px;
}

.form-card {
  padding: 22px;
}

.form-card + .table-card,
.prescription table + .rx-footer {
  margin-top: 18px;
}

.form-card h2 {
  margin: 0 0 16px;
  font-size: 18px;
}

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

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

.wide {
  grid-column: 1 / -1;
}

.alert {
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
  background: #e8f6f3;
  color: #0f5f58;
  border: 1px solid #bfe2dc;
}

.alert.danger {
  background: #fff0f0;
  color: var(--danger);
  border-color: #f1c3c3;
}

.profile {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.profile h2 {
  margin: 7px 0;
}

.profile p {
  color: var(--muted);
  margin: 4px 0;
}

.status {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 9px;
  background: #edf7f4;
  color: #14766d;
  font-size: 12px;
  font-weight: 700;
}

.danger-status {
  background: #fff0f0;
  color: var(--danger);
}

.checkline {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkline input {
  width: auto;
}

.medicine-builder {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}

.medicine-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.signature-box {
  min-width: 220px;
  text-align: center;
  border-top: 1px solid var(--ink);
  padding-top: 10px;
  white-space: pre-line;
}

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

.login-card {
  width: min(420px, 100%);
  padding: 26px;
}

.login-card .brand small {
  color: var(--muted);
}

.login-card form {
  display: grid;
  gap: 15px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  margin: 16px 0 0;
}

.prescription {
  max-width: 900px;
  padding: 28px;
  margin: 0 auto;
}

.rx-head,
.rx-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}

.rx-head h2 {
  margin: 0;
  color: var(--brand);
}

.rx-head p {
  color: var(--muted);
  margin: 5px 0 0;
}

.rx-meta,
.rx-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 24px 0;
}

.rx-meta span,
.rx-grid div,
.rx-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.rx-grid p,
.rx-section p {
  margin: 8px 0 0;
  color: var(--muted);
  white-space: pre-wrap;
}

.rx-section {
  margin-bottom: 14px;
}

@media (max-width: 900px) {
  .sidebar {
    position: static;
    width: auto;
  }

  .main {
    margin-left: 0;
    padding: 18px;
  }

  .stats-grid,
  .grid-form,
  .rx-meta,
  .rx-grid {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .topbar,
  .profile,
  .quick-actions {
    align-items: stretch;
    flex-direction: column;
  }
}

@media print {
  body {
    background: #fff;
  }

  .sidebar,
  .topbar,
  .alert,
  .rx-head button {
    display: none;
  }

  .main {
    margin: 0;
    padding: 0;
  }

  .prescription {
    border: 0;
    box-shadow: none;
    max-width: none;
  }
}
