:root {
  --bg: #f4f0e7;
  --surface: #fffdf8;
  --surface-soft: #f8f5ee;
  --ink: #223025;
  --muted: #667366;
  --line: rgba(70, 91, 66, 0.12);
  --brand: #456246;
  --brand-light: #6f8c68;
  --gold: #b8955f;
  --danger: #b96255;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(69, 98, 70, 0.09), transparent 34%),
    linear-gradient(180deg, #fbf8f1 0%, var(--bg) 100%);
}

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

button {
  border: 0;
  cursor: pointer;
}

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

.app-shell {
  width: min(100%, 560px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 12px max(24px, env(safe-area-inset-bottom));
}

.site-footer {
  margin-top: 28px;
  padding: 10px 0 2px;
  text-align: center;
}

.site-footer a {
  color: rgba(102, 115, 102, 0.86);
  font-size: 12px;
  text-decoration: none;
}

.login-layout {
  min-height: calc(100vh - 42px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
}

h1,
h2,
p {
  margin: 0;
}

.page-header p,
.panel-title p,
.empty,
label span,
small {
  color: var(--muted);
}

.panel {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 12px 30px rgba(70, 91, 66, 0.08);
}

.login-panel {
  margin-top: 0;
}

.panel-title,
.page-header,
.compact-row,
.patient-row,
.entitlement-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-title {
  margin-bottom: 16px;
}

.panel-title h2 {
  font-size: 20px;
}

.panel-title span,
.brand-pill {
  flex-shrink: 0;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(69, 98, 70, 0.1);
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
}

label {
  display: block;
  margin-top: 14px;
}

label span {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  outline: none;
}

input,
select {
  height: 50px;
  padding: 0 14px;
}

textarea {
  min-height: 96px;
  resize: vertical;
  padding: 14px;
  line-height: 1.6;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(69, 98, 70, 0.42);
  box-shadow: 0 0 0 3px rgba(69, 98, 70, 0.08);
}

.primary-action,
.search-row button,
.ghost-action {
  height: 50px;
  border-radius: 18px;
  font-weight: 800;
}

.primary-action {
  width: 100%;
  margin-top: 18px;
  color: white;
  background: linear-gradient(135deg, var(--brand-light), var(--brand));
  box-shadow: 0 12px 22px rgba(69, 98, 70, 0.2);
}

.primary-action:disabled {
  opacity: 0.68;
}

.assist-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.assist-line button,
.ghost-action {
  color: var(--brand);
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.assist-line button {
  flex: 1;
  height: 42px;
  border-radius: 8px;
}

.code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 10px;
  align-items: end;
}

.code-row label {
  margin-top: 14px;
}

.code-row button {
  height: 46px;
  border-radius: 8px;
  color: var(--brand);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  font-weight: 800;
}

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

.inline-subpanel {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background:
    radial-gradient(circle at 12% 0%, rgba(184, 149, 95, 0.12), transparent 34%),
    linear-gradient(135deg, rgba(250, 248, 241, 0.9), rgba(255, 255, 255, 0.76));
}

.mobile-form {
  padding: 16px;
}

.mobile-form label span {
  color: rgba(34, 48, 37, 0.72);
  font-size: 13px;
  font-weight: 800;
}

.form-section-head {
  display: grid;
  gap: 6px;
  margin-bottom: 6px;
}

.form-section-head strong {
  color: var(--ink);
  font-size: 20px;
  line-height: 1.25;
}

.form-section-head small {
  line-height: 1.55;
}

.form-section-head.compact {
  margin-bottom: 12px;
}

.grant-subpanel {
  margin-left: -2px;
  margin-right: -2px;
}

.project-create-form {
  display: grid;
  gap: 2px;
}

.project-create-form .form-note {
  margin-top: 12px;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 0;
  color: var(--brand);
  font-weight: 800;
}

.check-line input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
}

.check-line span {
  margin-bottom: 0;
  font-size: 14px;
}

.action-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

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

.soft-action {
  height: 42px;
  border-radius: 999px;
  color: var(--brand);
  background: var(--surface-soft);
  border: 1px solid var(--line);
  font-weight: 800;
}

.result-card,
.success-panel {
  background:
    linear-gradient(135deg, rgba(111, 140, 104, 0.12), transparent),
    var(--surface-soft);
}

.result-card {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.result-card strong,
.result-card span,
.result-card small {
  display: block;
}

.result-card span {
  margin-top: 6px;
}

.result-card small {
  margin-top: 4px;
  color: var(--brand);
  font-weight: 800;
}

.success-panel p {
  color: var(--muted);
  line-height: 1.7;
}

.compact-action {
  margin-top: 14px;
}

.scan-action {
  margin-top: 0;
  margin-bottom: 8px;
}

.inline-form {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.inline-form input,
.inline-form select {
  min-width: 0;
}

.inline-form label {
  margin-top: 0;
}

.field-help {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.tag-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 4px 6px 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
}

.tag-item strong {
  color: var(--brand);
  font-size: 13px;
}

.tag-item button {
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  color: var(--brand);
  background: white;
  font-weight: 800;
  font-size: 12px;
}

.tag-item button:last-child {
  color: #a25b2a;
  background: #fff4ea;
}

.compact-select {
  height: 40px;
  margin-top: 12px;
  border-radius: 999px;
  font-weight: 800;
  color: var(--brand);
  background: var(--surface-soft);
}

.form-note {
  margin: 2px 0 0;
  padding: 10px 12px;
  border-radius: 14px;
  color: var(--muted);
  background: rgba(69, 98, 70, 0.06);
  font-size: 12px;
  line-height: 1.6;
}

.package-form,
.package-base-grid,
.package-item-picker,
.package-selected-items {
  display: grid;
  gap: 12px;
}

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

.package-base-grid label {
  margin-top: 0;
}

.package-base-grid label:first-child {
  grid-column: 1 / -1;
}

.package-item-picker {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}

.picker-head strong,
.picker-head small {
  display: block;
}

.picker-head small {
  margin-top: 5px;
  line-height: 1.5;
}

.package-select-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px;
  gap: 10px;
  align-items: center;
}

.multi-grant-box {
  margin-top: 14px;
  border: 1px solid rgba(70, 91, 66, 0.1);
  border-radius: 20px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.62);
}

.grant-items {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.grant-item-row {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(70, 91, 66, 0.1);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.92);
}

.grant-item-row:first-child {
  padding-top: 12px;
}

.grant-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.grant-item-top strong {
  font-size: 14px;
  line-height: 1.2;
}

.grant-item-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.grant-project-field,
.grant-times-field {
  margin-top: 0;
}

.grant-project-field span,
.grant-times-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.grant-item-row select,
.grant-item-row input {
  width: 100%;
  height: 48px;
  border-radius: 16px;
  background: white;
}

.grant-item-row input {
  max-width: 128px;
  text-align: center;
  font-weight: 800;
}

.grant-row-remove {
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--danger);
  background: rgba(185, 98, 85, 0.08);
  font-size: 13px;
  font-weight: 800;
}

.package-select-row select,
.package-select-row input {
  height: 42px;
  background: white;
}

.package-select-row input {
  text-align: center;
  font-weight: 800;
}

.package-add-action {
  width: 100%;
  margin-top: 12px;
  border-radius: 18px;
  background: rgba(69, 98, 70, 0.08);
}

.package-items-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.package-items-preview span {
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--brand);
  background: rgba(69, 98, 70, 0.1);
  font-size: 12px;
  font-weight: 800;
}

.page-header {
  align-items: flex-start;
  margin: 6px 0 18px;
}

.page-header h1 {
  margin-top: 10px;
  font-size: 28px;
}

.page-header p {
  margin-top: 8px;
}

.ghost-action {
  padding: 0 14px;
}

.page-actions {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
}

.page-actions .ghost-action {
  min-width: 62px;
  padding: 0 12px;
}

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

.entry-grid {
  display: grid;
  gap: 12px;
}

.entry-card {
  position: relative;
  width: 100%;
  min-height: 92px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  text-align: left;
  color: var(--ink);
  background:
    radial-gradient(circle at 100% 0%, rgba(184, 149, 95, 0.16), transparent 35%),
    var(--surface-soft);
}

.entry-card strong,
.entry-card small {
  display: block;
}

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

.entry-card small {
  width: calc(100% - 72px);
  margin-top: 8px;
  line-height: 1.5;
}

.entry-card em {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  min-width: 54px;
  padding: 8px 10px;
  border-radius: 999px;
  color: white;
  background: var(--brand);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
  text-align: center;
}

.metric {
  position: relative;
  min-height: 86px;
  padding: 16px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: left;
}

.metric-button {
  width: 100%;
  color: var(--ink);
  box-shadow: 0 10px 20px rgba(69, 98, 70, 0.06);
}

.metric-button em {
  position: absolute;
  right: 14px;
  top: 14px;
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--brand);
  background: rgba(69, 98, 70, 0.1);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.metric span,
.info-grid span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

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

.search-row button {
  color: white;
  background: var(--brand);
}

.patient-list {
  display: grid;
  gap: 10px;
}

.patient-row,
.list-card {
  width: 100%;
  padding: 14px;
  text-align: left;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.list-card {
  display: block;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-head strong {
  display: block;
  font-size: 16px;
}

.card-head small {
  display: block;
  margin-top: 5px;
  line-height: 1.5;
}

.card-head em {
  flex-shrink: 0;
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--brand);
  background: rgba(69, 98, 70, 0.1);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.mini-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.mini-actions button {
  height: 34px;
  border-radius: 999px;
  color: var(--brand);
  background: white;
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 800;
}

.patient-row strong,
.entitlement-row strong {
  display: block;
  font-size: 16px;
}

.patient-row small,
.entitlement-row small {
  display: block;
  margin-top: 5px;
}

.patient-row em,
.entitlement-row em {
  flex-shrink: 0;
  font-style: normal;
  color: var(--brand);
  font-weight: 800;
}

.soft-action.danger {
  color: var(--danger);
  background: #fff5ed;
}

.compact-row {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.compact-row:first-of-type {
  border-top: 0;
}

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

.info-grid div {
  padding: 14px;
  border-radius: 10px;
  background: var(--surface-soft);
}

.info-grid strong {
  display: block;
  margin-top: 6px;
}

.qr-panel {
  text-align: center;
}

.qr-panel .panel-title {
  text-align: left;
}

.qr-panel img {
  display: block;
  width: 220px;
  height: 220px;
  margin: 12px auto 4px;
  border: 10px solid white;
  border-radius: 10px;
}

.entitlement-row {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.entitlement-row.as-button {
  width: 100%;
  background: transparent;
  text-align: left;
}

.row-button {
  width: 100%;
  color: var(--ink);
  background: transparent;
}

.text-action {
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--brand);
  background: rgba(69, 98, 70, 0.08);
  font-size: 12px;
  font-weight: 800;
}

.entitlement-row:first-of-type {
  border-top: 0;
}

.empty {
  padding: 14px 0 2px;
  line-height: 1.6;
}

.empty.tiny {
  padding-top: 8px;
  font-size: 12px;
}

.detail-list {
  margin-top: 14px;
  border-top: 1px solid var(--line);
}

.detail-list p {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  line-height: 1.6;
}

.detail-list span {
  color: var(--muted);
  font-weight: 700;
}

.daily-writeoff-notice {
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid rgba(69, 98, 70, 0.16);
  border-radius: 14px;
  color: var(--ink);
  background: #f0f5ed;
  line-height: 1.55;
}

.doctor-tag-editor {
  margin: 14px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #faf9f5;
}

.doctor-tag-title {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.doctor-tag-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.doctor-tag-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  font-size: 13px;
}

.doctor-tag-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  accent-color: #456246;
}

.doctor-tag-option span {
  margin: 0;
  font-size: inherit;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(calc(100% - 36px), 460px);
  padding: 12px 14px;
  border-radius: 10px;
  color: white;
  text-align: center;
  background: rgba(34, 48, 37, 0.9);
  box-shadow: 0 12px 26px rgba(34, 48, 37, 0.22);
  z-index: 20;
}

.toast-loading {
  background: rgba(69, 98, 70, 0.92);
}

@media (min-width: 760px) {
  .app-shell {
    padding-top: 36px;
    padding-bottom: 36px;
    padding-left: 18px;
    padding-right: 18px;
  }

  .panel {
    padding: 18px;
  }

  .inline-subpanel {
    padding: 14px;
  }

  .multi-grant-box {
    padding: 16px;
  }

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

  .inline-form .compact-action {
    grid-column: 1 / -1;
  }

  .inline-form .form-note {
    grid-column: 1 / -1;
  }

  .grant-item-fields {
    grid-template-columns: minmax(0, 1fr) 128px;
    align-items: end;
    gap: 12px;
  }
}
