:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-soft: #eef6f3;
  --ink: #17211f;
  --muted: #5d6c68;
  --line: #d8e2df;
  --primary: #08735f;
  --primary-dark: #045846;
  --accent: #b84a35;
  --warn: #a06500;
  --danger: #8f2638;
  --shadow: 0 18px 50px rgba(19, 46, 41, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans JP", "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.site-header {
  background: linear-gradient(180deg, #ffffff 0%, #eef6f3 100%);
  border-bottom: 1px solid var(--line);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 16px 0;
  color: var(--muted);
  font-size: 14px;
}

.brand {
  color: var(--primary-dark);
  font-weight: 800;
  text-decoration: none;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 380px);
  align-items: end;
  gap: 32px;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0 34px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(30px, 5vw, 56px);
  line-height: 1.12;
  letter-spacing: 0;
}

.lead {
  max-width: 720px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.8;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.summary-grid div {
  min-width: 0;
  padding: 18px 14px;
  text-align: center;
}

.summary-grid div + div {
  border-left: 1px solid var(--line);
}

.summary-grid strong {
  display: block;
  color: var(--primary-dark);
  font-size: 26px;
  line-height: 1.1;
}

.summary-grid span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 24px auto 48px;
}

.search-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1.35fr) minmax(200px, 1fr) repeat(3, minmax(140px, 0.72fr)) auto;
  gap: 12px;
  align-items: end;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  background: #fbfdfc;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(8, 115, 95, 0.2);
  outline-offset: 2px;
}

.reset-button,
.pager button {
  min-height: 44px;
  padding: 0 16px;
  background: var(--primary);
  border: 1px solid var(--primary);
  border-radius: 6px;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.result-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 18px 0 12px;
  color: var(--muted);
}

.result-meta strong {
  color: var(--primary-dark);
  font-size: 28px;
}

.result-meta p {
  max-width: 720px;
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
  text-align: right;
}

.table-wrap {
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fbfa;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

td {
  line-height: 1.6;
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.status.available {
  background: #e4f6ed;
  color: #046c45;
}

.status.limited {
  background: #fff3d7;
  color: var(--warn);
}

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

.medicine-name,
.pharmacy-name {
  font-weight: 900;
}

.pharmacy-link {
  color: var(--primary-dark);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.pharmacy-link:hover {
  color: var(--accent);
}

.subtext {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.card-list {
  display: none;
}

.empty-state {
  padding: 42px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  text-align: center;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 18px;
}

.pager button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

#pageInfo {
  min-width: 86px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

@media (max-width: 980px) {
  .hero,
  .search-panel {
    grid-template-columns: 1fr 1fr;
  }

  .summary-grid,
  .field.wide,
  .reset-button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .nav {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .hero,
  .search-panel {
    grid-template-columns: 1fr;
  }

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

  .summary-grid div + div {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .result-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .result-meta p {
    text-align: left;
  }

  .table-wrap {
    display: none;
  }

  .card-list {
    display: grid;
    gap: 12px;
  }

  .result-card {
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
  }

  .result-card header {
    display: grid;
    grid-template-columns: 1fr;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 12px;
  }

  .result-card header > div {
    min-width: 0;
  }

  .result-card .medicine-name,
  .result-card .subtext {
    overflow-wrap: anywhere;
  }

  .result-card .status {
    justify-self: start;
  }
}
