:root {
  --bg: #e8f3f1;
  --bg-deep: #d2e8e3;
  --ink: #14332e;
  --muted: #4a6b64;
  --line: #b7d4cd;
  --surface: rgba(255, 255, 255, 0.82);
  --teal: #0f766e;
  --teal-deep: #0b5a54;
  --teal-soft: #ccfbf1;
  --warn: #9a3412;
  --shadow: 0 18px 40px rgba(15, 70, 62, 0.12);
  --radius: 14px;
  --font: "Sarabun", "Segoe UI", sans-serif;
  --display: "Bai Jamjuree", "Sarabun", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #b8ebe0 0%, transparent 55%),
    radial-gradient(900px 420px at 100% 0%, #9fd4c8 0%, transparent 50%),
    linear-gradient(165deg, var(--bg), var(--bg-deep));
  line-height: 1.55;
}

.bg-glow {
  position: fixed;
  inset: auto -10% -20% 40%;
  height: 50vh;
  background: radial-gradient(circle, rgba(15, 118, 110, 0.18), transparent 65%);
  pointer-events: none;
  z-index: 0;
}

.topbar,
.shell,
.toast {
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid rgba(183, 212, 205, 0.7);
  backdrop-filter: blur(8px);
  background: rgba(255, 255, 255, 0.45);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.7rem;
  background:
    linear-gradient(145deg, #14b8a6, #0f766e 60%, #115e59);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25);
}

.brand-name {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
}

.brand-sub,
.lede,
.session-meta,
.context-line {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.shell {
  width: min(960px, calc(100% - 2rem));
  margin: 1.5rem auto 3rem;
  padding: 1.5rem 1.4rem 1.7rem;
  background: var(--surface);
  border: 1px solid rgba(183, 212, 205, 0.85);
  border-radius: calc(var(--radius) + 4px);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.view[hidden] {
  display: none !important;
}

h1 {
  margin: 0 0 0.35rem;
  font-family: var(--display);
  font-size: clamp(1.55rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.view-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-start;
}

.form {
  display: grid;
  gap: 1rem;
  max-width: 34rem;
  margin-top: 1rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field > span,
.field > legend {
  font-weight: 600;
  font-size: 0.92rem;
}

fieldset.field {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  margin: 0;
}

.choice {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-right: 1rem;
  font-weight: 500;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}

input:user-invalid,
select:user-invalid {
  border-color: var(--warn);
  outline-color: color-mix(in srgb, var(--warn) 40%, white);
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.65rem 1.15rem;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(160deg, #0d9488, var(--teal-deep));
  color: #fff;
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.28);
}

.btn-secondary {
  background: var(--teal-soft);
  color: var(--teal-deep);
  border-color: #99f6e4;
}

.btn-ghost {
  background: transparent;
  color: var(--teal-deep);
  border-color: var(--line);
}

.btn-back {
  padding-left: 0.2rem;
  margin-bottom: 0.35rem;
}

.stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.75rem 0 1.1rem;
}

.stat {
  min-width: 7.5rem;
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  background: linear-gradient(180deg, #f0fdfa, #e6f7f3);
  border: 1px solid var(--line);
}

.stat strong {
  display: block;
  font-family: var(--display);
  font-size: 1.35rem;
  color: var(--teal-deep);
}

.stat span {
  color: var(--muted);
  font-size: 0.88rem;
}

.facility-list {
  display: grid;
  gap: 0.65rem;
}

.facility-row {
  width: 100%;
  text-align: left;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem 1rem;
  align-items: center;
  padding: 0.95rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.facility-row:hover,
.facility-row:focus-visible {
  border-color: #5eead4;
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.12);
  transform: translateY(-1px);
  outline: none;
}

.facility-row .name {
  margin: 0;
  font-family: var(--display);
  font-weight: 650;
  font-size: 1.05rem;
}

.facility-row .meta {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.facility-row .chip {
  justify-self: end;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-deep);
  font-size: 0.82rem;
  font-weight: 600;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

th,
td {
  padding: 0.75rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid #e5eeeb;
  vertical-align: top;
}

th {
  font-size: 0.85rem;
  letter-spacing: 0.02em;
  color: var(--muted);
  background: #f4fbf9;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.empty {
  color: var(--muted);
  padding: 1rem 0.2rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  font-size: 0.95rem;
  box-shadow: var(--shadow);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.badge-pass {
  background: #d1fae5;
  color: #065f46;
}

.badge-fail {
  background: #fee2e2;
  color: #991b1b;
}

.result-preview {
  margin: 0;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #f8fffd;
  font-weight: 600;
}

.result-preview.is-pass {
  background: #ecfdf5;
  border-color: #6ee7b7;
  color: #065f46;
}

.result-preview.is-fail {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}

.result-preview.is-idle {
  color: var(--muted);
  font-weight: 500;
}

.form-inline-panel {
  max-width: none;
  margin: 0 0 1rem;
  padding: 1rem;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #f8fffd;
}

.field-inline {
  min-width: 10rem;
}

.hint-line {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.chart-panel {
  margin: 0 0 1.1rem;
  padding: 0.9rem 1rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.chart-title {
  margin: 0 0 0.65rem;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 650;
}

.chart-panel canvas {
  max-height: 280px;
}

@media (max-width: 640px) {
  .shell {
    width: calc(100% - 1rem);
    margin-top: 0.85rem;
    padding: 1.1rem 0.95rem 1.25rem;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .facility-row {
    grid-template-columns: 1fr;
  }

  .facility-row .chip {
    justify-self: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn,
  .facility-row {
    transition: none;
  }

  .btn:hover,
  .facility-row:hover {
    transform: none;
  }
}
