:root {
  color-scheme: light;
  --bg: #eef7ff;
  --bg-soft: #f8fbff;
  --card: #ffffff;
  --text: #10243f;
  --muted: #60738c;
  --line: #d9e8f6;
  --blue: #145ea8;
  --blue-soft: #e2f2ff;
  --cyan: #30a6d9;
  --shadow: 0 12px 32px rgba(22, 74, 124, 0.11);
  font-family: "Noto Sans Thai", "Leelawadee UI", "Tahoma", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, #e7f5ff 0%, #f8fbff 38%, #ffffff 100%);
  color: var(--text);
}

button {
  font: inherit;
}

.shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 14px 36px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 2px 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--blue);
  font-size: 0.77rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.36rem, 1.22rem + 0.7vw, 1.8rem);
  line-height: 1.28;
  font-weight: 800;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border: 1px solid rgba(20, 94, 168, 0.16);
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(20, 94, 168, 0.12);
  color: var(--blue);
  cursor: pointer;
}

.icon-button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.refresh-icon {
  width: 20px;
  height: 20px;
  border: 2px solid currentColor;
  border-left-color: transparent;
  border-radius: 50%;
  position: relative;
}

.refresh-icon::after {
  content: "";
  position: absolute;
  right: -3px;
  top: 1px;
  width: 7px;
  height: 7px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: rotate(18deg);
}

.loading .refresh-icon {
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.metric,
.updated {
  min-height: 82px;
  padding: 13px;
  border: 1px solid rgba(20, 94, 168, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 8px 24px rgba(22, 74, 124, 0.08);
}

.updated {
  grid-column: 1 / -1;
  min-height: 66px;
}

.metric span,
.updated span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.metric strong {
  font-size: 1.9rem;
  line-height: 1;
  color: var(--blue);
}

.updated strong {
  font-size: 1rem;
  line-height: 1.45;
}

.notice {
  margin: 0 0 12px;
  padding: 11px 13px;
  border-radius: 14px;
  background: #e8f4ff;
  border: 1px solid #cde8fb;
  color: #164a76;
  font-size: 0.9rem;
}

.notice[data-tone="warn"] {
  background: #fff8e8;
  border-color: #f3dfaa;
  color: #76530b;
}

.notice[data-tone="error"] {
  background: #fff0f0;
  border-color: #f1c5c5;
  color: #7f1e1e;
}

.cards {
  display: grid;
  gap: 12px;
}

.day-card {
  overflow: hidden;
  border: 1px solid rgba(20, 94, 168, 0.13);
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.day-toggle {
  width: 100%;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 15px 13px;
  border: 0;
  background: linear-gradient(180deg, #ffffff, #f8fcff);
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.date-text {
  font-size: 1.05rem;
  line-height: 1.28;
  font-weight: 800;
}

.count-badge {
  min-width: 56px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  text-align: center;
  font-size: 0.86rem;
  font-weight: 800;
  white-space: nowrap;
}

.people {
  display: none;
  padding: 0 15px 4px;
}

.open .people {
  display: block;
}

.person {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 9px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.person-index {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-top: 1px;
  border-radius: 50%;
  background: #f1f8ff;
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 800;
}

.person-body h2 {
  margin: 0 0 5px;
  font-size: 1.02rem;
  line-height: 1.38;
  font-weight: 800;
}

.status {
  margin: 0 0 7px;
  color: #425a75;
  font-size: 0.92rem;
  line-height: 1.4;
}

.clinic {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  margin: 0;
  padding: 5px 10px;
  border-radius: 999px;
  background: #edf8fc;
  color: #176b91;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.35;
}

.clinic span {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: var(--cyan);
}

.empty-state {
  padding: 28px 18px;
  border: 1px dashed #b9d8ef;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  text-align: center;
}

.empty-state strong,
.empty-state span {
  display: block;
}

.empty-state strong {
  margin-bottom: 5px;
}

.empty-state span {
  color: var(--muted);
  font-size: 0.92rem;
}

.skeleton {
  padding: 15px;
}

.skeleton .day-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.skeleton span,
.skeleton i,
.person-line {
  display: block;
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(90deg, #e6f0fa, #f5faff, #e6f0fa);
  background-size: 240% 100%;
  animation: shimmer 1.35s linear infinite;
}

.skeleton span {
  width: 58%;
}

.skeleton i {
  width: 54px;
}

.person-line {
  width: 84%;
  margin: 10px 0;
}

.person-line.short {
  width: 52%;
}

@keyframes shimmer {
  to { background-position: -240% 0; }
}

@media (min-width: 720px) {
  .shell {
    padding-top: 30px;
  }

  .summary {
    grid-template-columns: 150px 150px 1fr;
  }

  .updated {
    grid-column: auto;
  }
}
