/* ============================================================
   JANY CLINIC — Patient Records
   Art Direction: Editorial Minimalism × Modern Swiss
   เปลี่ยนสีแบรนด์ได้ที่ :root ด้านล่างจุดเดียว
   ============================================================ */

:root {
  /* ---- Brand palette — อิงโลโก้ JANY CLINIC (champagne ivory × taupe) ---- */
  --bg: #F8F3E6;            /* warm ivory / champagne */
  --bg-deep: #EFE8D4;       /* cream เข้มกว่าพื้นหลังนิด — section head */
  --surface: #FFFDF7;       /* soft cream — ไม่ใช่ขาวล้วน */
  --ink: #4A443A;           /* taupe-gray เข้มอมน้ำตาล */
  --ink-2: #8D8374;         /* warm taupe — metadata */
  --line: #E6DECB;          /* hairline */
  --accent: #8C7358;        /* soft bronze */
  --accent-deep: #6F5A43;
  --ok: #5E7355;
  --danger: #A15448;

  --font: 'Google Sans', 'Product Sans', 'Noto Sans Thai', 'Segoe UI', system-ui, sans-serif;
  --maxw: 1120px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* attribute hidden ต้องชนะ display จากคลาสเสมอ
   (ไม่งั้น .field / .login-wrap ที่ตั้ง flex/grid จะทับการซ่อน element) */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

html { background: var(--bg); }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;   /* กันคอนเทนต์ล้นแนวนอนบนจอเล็ก */
  min-width: 0;
}

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

/* ---- Typography scale ---- */
.meta {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--ink-2);
  font-weight: 500;
}
.meta--accent { color: var(--accent); }

h1 {
  font-size: clamp(34px, 6vw, 52px);
  line-height: 1.15;
  font-weight: 600;
}
.lede { font-size: 16px; color: var(--ink-2); max-width: 52ch; }

/* ---- Header ---- */
.site-header {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px;
  padding-top: 28px; padding-bottom: 24px;   /* ซ้าย-ขวาใช้ของ .container */
  border-bottom: 1px solid var(--ink);
}
.site-header--center { justify-content: center; }
.wordmark {
  font-weight: 700; font-size: 20px;
  text-transform: uppercase; color: var(--ink); text-decoration: none;
}
.wordmark .sub {
  display: block;
  font-size: 10px; font-weight: 500;
  color: var(--ink-2); margin-top: 1px; text-align: center;
}

/* ---- Brand logo (SVG เลียนแบบโลโก้จริง) ---- */
.brand { display: inline-flex; color: var(--ink); text-decoration: none; }
.brand__logo { height: 56px; width: auto; display: block; }

/* ---- Inline icons ---- */
.icn { width: 20px; height: 20px; flex: none; }
.icn--inline {
  width: 14px; height: 14px; display: inline-block;
  vertical-align: -2px; margin-right: 4px; color: var(--accent);
}
.hint-item {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13.5px; color: var(--ink-2);
}
.hint-item .icn { width: 17px; height: 17px; color: var(--accent); }

/* ---- Intro / hero ---- */
.intro { padding: 64px 0 48px; display: grid; grid-template-columns: 1fr; gap: 20px; }
.intro__row { display: flex; flex-wrap: wrap; gap: 12px 32px; align-items: baseline; }

/* intro จัดกึ่งกลาง */
.intro--center { justify-items: center; text-align: center; }
.intro--center .lede { margin-left: auto; margin-right: auto; }
.intro--center .intro__row { justify-content: center; }

/* ---- Editorial form sections: index ซ้าย / ฟิลด์ขวา ---- */
.section {
  display: grid;
  grid-template-columns: 280px 1fr;
  padding: 52px 0 60px;
  border-top: 1px solid var(--line);
}
.section__head { position: sticky; top: 24px; align-self: start; }
.section__title {
  font-size: 20px; font-weight: 600; line-height: 1.3;
  display: flex; align-items: baseline; gap: 10px;
}
.section__title .icn { width: 22px; height: 22px; color: var(--accent); align-self: center; }
.section__title .no { color: var(--accent); }
.section__hint { margin-top: 10px; font-size: 14px; color: var(--ink-2); max-width: 30ch; }

/* หน้าบ้าน — หัวข้อกล่องครีมติดกับฟอร์ม แบบหลังบ้าน */
.section--intake {
  grid-template-columns: 1fr;
  gap: 0;
  padding: 18px 0 0;
  border-top: none;
}
.section--intake + .section--intake { margin-top: 8px; }
.section--intake .section__head {
  position: static;
}
.section--intake .section__hint { max-width: none; }
.section--intake .fields {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 20px;
  gap: 22px 24px;
}
.section--intake .field--gender .choices { gap: 8px; }
.section--intake .field--gender .chip span { padding: 9px 12px; }

/* ---- Fields ---- */
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 28px 32px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field--full { grid-column: 1 / -1; }

.field label { font-size: 15px; font-weight: 600; }
.field .req { color: var(--accent); }
.field small { color: var(--ink-2); font-size: 12.5px; }

input[type="text"], input[type="tel"], input[type="email"], input[type="date"],
input[type="number"], input[type="time"], input[type="password"],
select, textarea {
  font-family: var(--font);
  font-size: 16.5px;   /* +1pt จาก 15.5 */
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 12px 14px;
  width: 100%;
  min-height: 48px;
  transition: border-color .15s ease;
  appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%234A443A'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--ink);
}
input:focus-visible, select:focus-visible, textarea:focus-visible,
button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
::placeholder { color: #BAB19E; }

/* ---- Choice chips (radio/checkbox) ---- */
.choices { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip span {
  display: inline-block;
  padding: 9px 18px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 14.5px;
  cursor: pointer;
  transition: all .15s ease;
  user-select: none;
}
.chip input:checked + span {
  background: var(--ink); color: var(--bg); border-color: var(--ink);
}
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip:hover span { border-color: var(--ink); }

/* ---- Consent ---- */
.consent {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 20px; border: 1px solid var(--line); background: var(--surface);
}
.consent input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--accent); flex: none; }
.consent p { font-size: 14px; color: var(--ink-2); }

/* ---- Buttons ---- */
.btn {
  font-family: var(--font);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font-size: 16px; font-weight: 600;   /* +1pt จาก 15 */
  padding: 12px 14px;
  min-height: 48px;                    /* เท่ากับ textbox */
  background: var(--ink); color: var(--bg);
  border: 1px solid var(--ink);
  border-radius: 0;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
  text-decoration: none;
}
.btn:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn--ghost { background: transparent; color: var(--ink); }
.btn--ghost:hover { background: var(--ink); color: var(--bg); }
.btn--sm { padding: 12px 14px; font-size: 14.5px; min-height: 48px; } /* +1pt / เท่า textbox */
.btn--accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--accent:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn--danger { background: transparent; border-color: var(--line); color: var(--danger); }
.btn--danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--back {
  background: transparent; color: var(--ink); border-color: var(--ink);
  font-size: 14.5px; padding: 10px 14px; min-height: 42px; margin-bottom: 18px;
}
.btn--back:hover { background: var(--ink); color: var(--bg); }
.btn--back .icn { width: 18px; height: 18px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---- Consent (เต็มความกว้าง) ---- */
.consent-row {
  border-top: 1px solid var(--line);
  padding-top: 40px;
}

/* ---- Submit row ---- */
.submit-row {
  padding: 28px 0 80px;
  display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: center;
}
.btn--submit { font-size: 16.5px; }

/* ---- Success page ---- */
.success-wrap {
  min-height: 60vh; display: grid; place-items: center; padding: 48px 0;
}
.success {
  border: 1px solid var(--ink);
  background: var(--surface);
  padding: 56px 40px;
  max-width: 640px; width: 100%;
  display: grid; gap: 14px;
}
.success .ref {
  font-size: clamp(28px, 5vw, 44px);
  font-weight: 700; color: var(--accent);
}
.success__icon { width: 44px; height: 44px; color: var(--ok); }
.success__actions { margin-top: 12px; }

/* ---- Alerts ---- */
.alert {
  padding: 14px 18px; font-size: 14.5px;
  border: 1px solid var(--danger); color: var(--danger); background: #FBF2EC;
}
.alert--ok { border-color: var(--ok); color: var(--ok); background: #F3F6EF; }

/* ---- Footer ---- */
.site-footer {
  border-top: 1px solid var(--ink);
  padding-top: 28px; padding-bottom: 48px;   /* ซ้าย-ขวาใช้ของ .container */
  display: flex; flex-wrap: wrap; gap: 12px 32px;
  justify-content: space-between; align-items: baseline;
}

/* ============================================================
   ADMIN
   ============================================================ */

.admin-bar {
  background: var(--ink); color: var(--bg);
  position: sticky; top: 0; z-index: 20;
}
.admin-bar .container {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 14px; padding-bottom: 14px;
}
.admin-bar .wordmark { color: var(--bg); font-size: 15px; }
.admin-bar .meta { color: #BEB5A5; }
.admin-bar__actions { display: flex; gap: 8px; align-items: center; }
.admin-bar .icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0;
  background: none; border: 1px solid #6E6656; color: var(--bg);
  font-family: var(--font); cursor: pointer;
}
.admin-bar .icon-btn:hover { border-color: var(--bg); background: rgba(255,255,255,.06); }
.admin-bar .icon-btn .icn { width: 18px; height: 18px; }

/* login */
.login-wrap {
  min-height: 78vh; display: grid; place-items: center; padding: 40px 24px;
}
.login-card { width: 100%; max-width: 420px; display: grid; gap: 18px; }
.login-card h1 { font-size: 30px; }

/* index toolbar */
.toolbar {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between;
  padding: 36px 0 20px;
}
.toolbar input[type="text"] { max-width: 360px; }
.index-list-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 12px;
}
.count { font-size: 13.5px; color: var(--ink-2); }

/* patient index cards */
.patient-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding-bottom: 40px;
}
.patient-card {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.patient-card:hover,
.patient-card:focus-visible {
  border-color: var(--ink);
  outline: none;
}
.patient-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.patient-card__name {
  font-size: 17px; font-weight: 600; line-height: 1.35;
  flex: 1; min-width: 0;
}
.patient-card__ids {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex: none;
  text-align: right;
}
.patient-card__hn {
  font-size: 13.5px; font-weight: 700;
  color: var(--accent);
}
.patient-card__hn--none { color: var(--ink-2); font-weight: 500; }
.patient-card__ref {
  font-size: 12.5px; color: var(--ink-2);
}
.patient-card__rule {
  border: none; border-top: 1px solid var(--line);
  margin: 12px 0;
}
.patient-card__line {
  font-size: 14.5px; line-height: 1.55; color: var(--ink);
}
.patient-card__line + .patient-card__line { margin-top: 2px; }
.patient-card__dim { color: var(--ink-2); font-size: 13.5px; }

/* legacy table (unused on index, keep for safety) */
.index-table { width: 100%; border-collapse: collapse; }
.index-table th {
  text-align: left; font-size: 12px; text-transform: uppercase;
  color: var(--ink-2); font-weight: 500; padding: 10px 14px;
  border-bottom: 1px solid var(--ink);
}
.index-table td {
  padding: 16px 14px; border-bottom: 1px solid var(--line);
  font-size: 15px; vertical-align: top;
}
.index-table tbody tr { cursor: pointer; transition: background .12s ease; }
.index-table tbody tr:hover { background: var(--surface); }
.index-table .hn { font-weight: 700; }
.index-table .hn--none { color: var(--ink-2); font-weight: 400; }
.index-table .t-name { font-weight: 600; }
.index-table .t-dim { color: var(--ink-2); font-size: 13.5px; }

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

/* ---- Patient chart ---- */
.chart-head {
  margin-top: 28px;
  padding: 24px 22px 22px;
  border: 1px solid var(--ink);
  background: transparent;   /* กล่องมีแค่ border ไม่มีพื้นหลัง */
}
.chart-head__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.chart-head__row .btn--back { margin-bottom: 0; flex: none; }
.chart-head__label {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  text-align: right;
  flex: none;
  line-height: 1.35;
}
.chart-head__label-prefix { display: block; }
.chart-head__ref { display: block; font-size: 12px; color: var(--ink-2); text-transform: none; }
.chart-head__main { text-align: center; }
.chart-head h1 { font-size: clamp(26px, 4vw, 40px); }
.chart-head .facts {
  display: flex; flex-wrap: wrap; gap: 8px 28px; margin-top: 14px;
  justify-content: center;
}
.fact { display: flex; gap: 8px; align-items: baseline; font-size: 15.5px; }
.fact b { font-weight: 600; }

/* chart tabs */
.chart-tabs {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0;
  margin-top: 20px;
  border: 1px solid var(--ink);
  overflow-x: auto;
}
.chart-tab {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font); font-size: 13.5px; font-weight: 600;
  padding: 14px 8px; min-height: 48px;
  background: transparent; color: var(--ink-2);
  border: none; border-right: 1px solid var(--ink);
  cursor: pointer; transition: background .15s ease, color .15s ease;
  white-space: nowrap;
}
.chart-tab:last-child { border-right: none; }
.chart-tab .icn { width: 17px; height: 17px; flex: none; }
.chart-tab:hover { color: var(--ink); background: var(--surface); }
.chart-tab.is-active,
.chart-tab[aria-selected="true"] {
  background: var(--ink); color: var(--bg);
}
.chart-panel { padding-bottom: 40px; }

/* floating toast */
.toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  z-index: 100;
  max-width: min(92vw, 420px);
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 500;
  text-align: center;
  border: 1px solid var(--ok);
  color: var(--ok);
  background: #F3F6EF;
  box-shadow: 0 10px 28px rgba(74, 68, 58, .16);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast--show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.toast--err {
  border-color: var(--danger);
  color: var(--danger);
  background: #FBF2EC;
}

.btn.is-loading { opacity: .72; cursor: wait; pointer-events: none; }

/* admin chart sections — head เป็นกล่องครีมเข้มกว่าพื้นหลัง */
.section--chart {
  grid-template-columns: 1fr;
  gap: 0;
  padding: 18px 0 0;
  border-top: none;
}
.section--chart + .section--chart { margin-top: 8px; }
.section__head--boxed {
  position: static;
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-bottom: none;
  padding: 18px 20px 16px;
}
.section__head--boxed .section__hint { margin-top: 6px; }
.add-form__lead {
  grid-column: 1 / -1;
  font-size: 14px;
  color: var(--ink-2);
  margin: 0 0 4px;
}
.add-form-panel {
  border-bottom: 1px solid var(--line);
}
.add-form__toolbar {
  display: flex;
  justify-content: flex-start;
  padding: 12px 16px;
  background: var(--surface);
}
.section__toggle {
  flex: none;
  min-height: 36px;
  padding: 6px 12px;
  font-size: 13.5px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);
}
.section__toggle:hover {
  background: var(--ink);
  color: var(--bg);
}
.section__toggle[aria-expanded="true"] {
  background: var(--ink);
  color: var(--bg);
}
.section--chart .section__body {
  border: 1px solid var(--line);
  background: var(--surface);
}
.section--chart .section__body > .add-form-panel {
  border-bottom: 1px solid var(--line);
}
.section--chart .section__body > .add-form-panel > .add-form {
  margin-top: 0;
  border: none;
  border-top: 1px solid var(--line);
}
.section--chart .section__body > .record-list {
  background: var(--surface);
}
.section--chart .section__body > .record-list .record-cards {
  padding: 16px;
}
.section--chart .section__body > .record-list .empty-note {
  padding: 22px 18px;
  margin: 0;
}
.section--chart > .add-form {
  margin-top: 0;
  border-top: none;
}
.section--chart .add-form[hidden] {
  display: none !important;
}
.section--chart .empty-note {
  padding: 22px 18px;
  margin: 0;
}
.section--chart .empty-note {
  padding: 22px 18px;
  margin: 0;
}
.section--chart .add-form__actions {
  display: flex; flex-direction: column; flex-wrap: wrap;
  gap: 10px; align-items: center; justify-content: center;
  text-align: center;
}
.add-form__actions .btn { width: auto; min-width: min(100%, 280px); }

/* record cards (visits / courses / appointments) */
.record-cards {
  display: grid;
  gap: 12px;
  padding: 16px;
}
.record-card {
  position: relative;
  border: 1px solid var(--line);
  background: var(--bg);
  padding: 14px 16px;
}
.record-card__del {
  position: absolute;
  top: 10px;
  right: 10px;
}
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0;
  background: transparent; border: 1px solid var(--line);
  color: var(--ink-2); cursor: pointer;
  font-family: var(--font);
}
.btn-icon .icn { width: 17px; height: 17px; }
.btn-icon:hover { border-color: var(--ink); color: var(--ink); }
.btn-icon--danger { color: var(--danger); border-color: transparent; }
.btn-icon--danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.record-card__title {
  font-size: 16.5px; font-weight: 600; line-height: 1.35; display: block;
  padding-right: 40px;
}
.record-card__actions { display: flex; flex-wrap: wrap; gap: 8px; flex: none; }
.record-card__body { min-width: 0; }
.record-card__line {
  margin-top: 4px; font-size: 14.5px; line-height: 1.55; color: var(--ink);
}
.record-card__rule {
  border: none; border-top: 1px solid var(--line);
  margin: 10px 0;
}
.record-card__row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.record-card__text { flex: 1; min-width: 0; }
.record-card__text .record-card__line:first-child { margin-top: 0; }
.record-card__use {
  flex: none;
  min-height: 36px; padding: 6px 12px; font-size: 13.5px;
}
.record-card .status-select {
  display: inline-block; width: auto; min-width: 120px;
  min-height: 36px; padding: 6px 28px 6px 10px; font-size: 14px;
  margin-left: 4px; vertical-align: middle;
}

/* key-value grid for read-only patient data */
.kv-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0;
  border-top: 1px solid var(--line); border-left: 1px solid var(--line);
}
.kv {
  padding: 14px 16px;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.kv .meta { display: block; margin-bottom: 4px; }
.kv .v { font-size: 15px; white-space: pre-line; }
.kv .v:empty::after { content: "—"; color: var(--ink-2); }

/* admin sub-tables */
.sub-table { width: 100%; border-collapse: collapse; }
.sub-table th {
  text-align: left; font-size: 12px; text-transform: uppercase;
  color: var(--ink-2); font-weight: 500; padding: 8px 12px; border-bottom: 1px solid var(--ink);
}
.sub-table td { padding: 12px; border-bottom: 1px solid var(--line); font-size: 14.5px; vertical-align: top; }
.sub-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.sub-table th.num { text-align: right; }

.progress { font-variant-numeric: tabular-nums; font-weight: 600; }
.progress .of { color: var(--ink-2); font-weight: 400; }

.status { font-size: 12.5px; padding: 3px 10px; border: 1px solid var(--line); }
.status--done { color: var(--ok); border-color: var(--ok); }
.status--cancel { color: var(--danger); border-color: var(--danger); }

/* add-record inline forms */
.add-form {
  margin-top: 18px; padding: 20px; background: var(--surface); border: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; align-items: end;
}
.add-form .field--full { grid-column: 1 / -1; }
.add-form .field label { font-size: 13.5px; }   /* +1pt จาก 12.5 */

.empty-note { padding: 22px 0; color: var(--ink-2); font-size: 14.5px; }

.loading { padding: 80px 0; text-align: center; color: var(--ink-2); }

/* ============================================================
   Responsive — tablet
   ============================================================ */
@media (max-width: 900px) {
  .container { padding: 0 20px; }
  .site-header { padding-top: 18px; padding-bottom: 14px; }
  .brand__logo { height: 48px; }
  .intro { padding: 36px 0 26px; gap: 14px; }
  .section { grid-template-columns: 1fr; gap: 0; }
  .section__head { position: static; }
  .section__hint { max-width: none; }   /* คำอธิบายใต้หัวข้อเต็มความกว้าง */
  .submit-row { padding: 28px 0 48px; }
  .site-footer { padding-top: 18px; padding-bottom: 28px; }
  .toolbar { padding: 24px 0 14px; }
  .chart-head { margin-top: 20px; padding: 20px 18px 18px; }
  .chart-tab { font-size: 13.5px; padding: 12px 8px; gap: 6px; }
  .add-form { grid-template-columns: 1fr 1fr; }
  .login-wrap { min-height: 70vh; padding: 32px 20px; }
}

/* ============================================================
   Responsive — mobile
   ============================================================ */
@media (max-width: 600px) {
  .container { padding: 0 18px; }
  body { font-size: 15px; }
  .site-header { padding-top: 14px; padding-bottom: 10px; }
  .site-header__tag { display: none; }   /* ซ่อนป้าย Patient Intake Form ให้โลโก้เด่น */
  .brand__logo { height: 44px; }
  .intro { padding: 26px 0 18px; gap: 12px; }
  h1 { font-size: 34px; }                /* หัวข้อใหญ่ชัดกว่าเนื้อความ */
  .lede { font-size: 15px; }
  .intro__row { gap: 10px 20px; }

  /* ฟิลด์สั้น (วันเกิด/เบอร์/น้ำหนัก/ส่วนสูง) ยังจับคู่ 2 คอลัมน์บนมือถือ */
  .fields { grid-template-columns: 1fr 1fr; gap: 18px 12px; }
  .section--intake .fields { padding: 16px; }
  .field { grid-column: 1 / -1; }
  .field--half { grid-column: span 1; }

  /* กัน iPhone Safari ซูมอัตโนมัติเมื่อแตะช่องกรอก (ต้อง >= 16px) */
  input[type="text"], input[type="tel"], input[type="email"], input[type="date"],
  input[type="number"], input[type="time"], input[type="password"],
  select, textarea { font-size: 16px; }

  .submit-row { padding: 22px 0 36px; }
  .btn--submit { width: 100%; justify-content: center; padding: 16px 30px; }
  .site-footer { padding-top: 16px; padding-bottom: 24px; }
  .success { padding: 32px 20px; }
  .success-wrap { padding: 24px 0; }
  .success__actions .btn { width: 100%; justify-content: center; }
  .add-form { grid-template-columns: 1fr; padding: 16px; }
  .kv-grid { grid-template-columns: 1fr; }
  .patient-cards { grid-template-columns: 1fr; gap: 12px; padding-bottom: 28px; }
  .index-list-head { margin-bottom: 10px; }
  .chart-head { margin-top: 16px; padding: 16px 14px 14px; }
  .chart-head__row { align-items: flex-start; margin-bottom: 14px; }
  .chart-head__label { font-size: 11px; max-width: 46%; }
  .chart-tabs { margin-top: 14px; }
  .chart-tab { font-size: 12px; flex-direction: column; gap: 4px; min-height: 58px; padding: 10px 4px; }
  .chart-tab .icn { width: 18px; height: 18px; }
  .chart-tab__text { font-size: 11px; line-height: 1.25; white-space: normal; text-align: center; }
  .section--chart { padding: 18px 0 0; }
  .section__head--boxed { padding: 14px 14px 12px; }
  .record-card__row { align-items: flex-end; }
  .login-wrap { min-height: 62vh; padding: 24px 16px; }
}

/* ============================================================
   Responsive — จอแคบ (≤500px): ช่องกรอกเหลือคอลัมน์เดียว
   ============================================================ */
@media (max-width: 500px) {
  .fields { grid-template-columns: 1fr; gap: 18px; }
  .field, .field--half { grid-column: 1 / -1; }
  .btn--back__text { display: none; }
  .chart-head__row .btn--back {
    min-width: 42px; min-height: 42px; padding: 10px;
    gap: 0;
  }
}
