/* 道の駅TRIP Partner — 道の駅TRIPの配色(night / dawn / ember / gold / paper)に合わせた、落ち着いた業務UI */
:root {
  color-scheme: light;
  --night: #0b2a6b;
  --night-2: #12357f;
  --dawn: #2e7bff;
  --dawn-soft: #e4eeff;
  --ember: #ff8a00;
  --ember-soft: #ffe7c7;
  --gold: #b8932a;
  --gold-soft: #f3e9c7;
  --paper: #f6f2ea;
  --surface: #fffdf9;
  --ink: #17233a;
  --muted: #6b7686;
  --line: #e6dfd2;
  --line-strong: #d6cdbd;
  --danger: #b4232a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(23, 35, 58, 0.04), 0 4px 16px rgba(23, 35, 58, 0.05);
  --font: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif;
  --font-num: "Montserrat", "Noto Sans JP", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
}
[hidden] { display: none !important; }
a { color: var(--night); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* top bar */
.topbar { background: var(--night); color: #fff; }
.topbar-inner {
  max-width: 1200px; margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 50% 70%, var(--ember) 0 38%, transparent 40%), linear-gradient(180deg, var(--dawn), var(--night-2));
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.85);
}
.brand-name { font-weight: 700; letter-spacing: 0.04em; }
.brand-tag {
  font-family: var(--font-num); font-weight: 600; font-size: 12px; letter-spacing: 0.08em;
  padding: 2px 10px; border-radius: 999px; background: var(--gold-soft); color: var(--night);
}
.user-box { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-email { font-size: 12px; opacity: 0.85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
.topbar .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, 0.35); background: transparent; }

/* layout */
.page { max-width: 1200px; margin: 0 auto; padding: 28px 24px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.eyebrow { margin: 0 0 2px; font-size: 12px; color: var(--muted); letter-spacing: 0.08em; }
.page-title { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: 0.02em; }
.page-title .num { font-family: var(--font-num); font-weight: 700; color: var(--night); margin: 0 2px; }
.source-badge {
  font-size: 12px; padding: 4px 12px; border-radius: 999px;
  background: var(--ember-soft); color: #8a4a00; border: 1px solid #f5c98d; white-space: nowrap;
}
.data-warning { background: #fdeceb; color: var(--danger); border: 1px solid #f3c2bf; padding: 10px 14px; border-radius: 10px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.panel-title { margin: 0 0 14px; font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.panel-title::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--ember); }

/* dashboard */
.stats { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 10px; }
.stat {
  appearance: none; font: inherit; color: inherit; text-align: left; cursor: pointer;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 12px 10px;
  display: flex; flex-direction: column; gap: 4px; transition: border-color 0.15s, box-shadow 0.15s;
}
.stat:hover { border-color: var(--line-strong); }
.stat:focus-visible { outline: 2px solid var(--dawn); outline-offset: 2px; }
.stat.is-active { border-color: var(--night); box-shadow: inset 0 0 0 1px var(--night); }
.stat-label { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-value { font-family: var(--font-num); font-weight: 700; font-size: 22px; line-height: 1.2; }
.stat--partner .stat-value { color: var(--gold); }
.stat-sub { margin: 10px 0 0; font-size: 12px; color: var(--muted); }

/* filters */
.filters { display: grid; grid-template-columns: minmax(200px, 2fr) repeat(4, minmax(0, 1fr)) auto; gap: 10px; align-items: center; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span:not(.sr-only) { font-size: 12px; color: var(--muted); }
input, select {
  font: inherit; color: var(--ink); width: 100%; min-width: 0;
  height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-strong); background: #fff;
}
select { appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px; background-size: 5px 5px; background-repeat: no-repeat; }
input:focus, select:focus { outline: none; border-color: var(--dawn); box-shadow: 0 0 0 3px var(--dawn-soft); }
.field-search input { padding-left: 36px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236b7686' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 12px center; }

.btn {
  font: inherit; font-weight: 500; height: 40px; padding: 0 16px; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent; white-space: nowrap; display: inline-flex; align-items: center; justify-content: center;
}
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-sm { height: 30px; padding: 0 12px; font-size: 12px; }
.btn-primary { background: var(--night); color: #fff; }
.btn-primary:hover { background: var(--night-2); }
.btn-ghost { background: #fff; border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover:not(:disabled) { border-color: var(--night); }
.btn-link { background: none; color: var(--night); height: auto; padding: 6px 0; font-size: 13px; white-space: normal; }
.btn-block { width: 100%; }

.result-count { margin: 14px 0 10px; color: var(--muted); }
.result-count strong { font-family: var(--font-num); color: var(--ink); font-size: 16px; }
.result-count .sep { margin: 0 6px; color: var(--line-strong); }

/* table */
.table-wrap { border: 1px solid var(--line); border-radius: 12px; overflow: auto; max-height: 70vh; background: #fff; }
.stations { width: 100%; border-collapse: collapse; }
.stations th {
  position: sticky; top: 0; z-index: 1; background: #faf7f1; text-align: left; font-size: 12px; font-weight: 500;
  color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.stations td { padding: 10px 14px; border-bottom: 1px solid #f0ebe1; vertical-align: middle; }
.stations tbody tr:last-child td { border-bottom: 0; }
.stations tbody tr:hover td { background: #fcfaf5; }
.st-name { font-weight: 500; }
.st-muni { font-size: 12px; color: var(--muted); }
.col-pref, .col-block, .col-priority { white-space: nowrap; }

.stage { display: inline-block; font-size: 12px; padding: 2px 10px; border-radius: 999px; background: #f1ede5; color: #5b6472; white-space: nowrap; }
.stage--researching { background: #eef2f8; color: #3b4f73; }
.stage--ready { background: var(--dawn-soft); color: #1f56b8; }
.stage--contacted { background: #e7f0ff; color: var(--night); }
.stage--replied { background: #e6f5ee; color: #1d6b48; }
.stage--interested { background: var(--ember-soft); color: #8a4a00; }
.stage--meeting { background: #fff1dc; color: #a35400; }
.stage--partner { background: var(--gold-soft); color: #6f5512; font-weight: 700; }
.stage--hold { background: #f2f2f2; color: #6b6b6b; }
.stage--declined { background: #f6eaea; color: #8b3a3a; }

.prio { font-family: var(--font-num); font-weight: 700; font-size: 12px; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; background: #f1ede5; color: #5b6472; }
.prio--A { background: var(--night); color: #fff; }
.prio--B { background: var(--dawn-soft); color: var(--night); }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }

/* centered views */
.center-view { min-height: calc(100vh - 60px); display: grid; place-items: center; align-content: center; gap: 12px; padding: 24px 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; width: 100%; max-width: 400px; }
.login-card { display: flex; flex-direction: column; gap: 14px; }
.login-title { margin: 0; font-size: 22px; }
.login-title span { font-family: var(--font-num); color: var(--gold); }
.login-lead { margin: 0; font-size: 13px; }
.login-message { margin: 0; min-height: 1.6em; font-size: 13px; color: var(--muted); }
.login-message.is-error { color: var(--danger); }
.error-card h1 { margin: 0 0 8px; font-size: 18px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--night); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* responsive */
@media (max-width: 1080px) {
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-search { grid-column: 1 / -1; }
  #btn-reset { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .topbar-inner, .page { padding-left: 16px; padding-right: 16px; }
  .page { padding-top: 20px; }
  .page-title { font-size: 24px; }
  .page-head { flex-wrap: wrap; align-items: flex-start; }
  .panel { padding: 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-value { font-size: 20px; }
  .user-email { display: none; }

  /* 表をカード表示に */
  .table-wrap { max-height: none; border: 0; background: transparent; overflow: visible; }
  .stations thead { display: none; }
  .stations, .stations tbody, .stations tr, .stations td { display: block; width: 100%; }
  .stations tr { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
  .stations tbody tr:hover td { background: transparent; }
  .stations td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; }
  .stations td::before { content: attr(data-label); font-size: 12px; color: var(--muted); flex: none; }
  .stations td.col-name { display: block; padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px solid #f0ebe1; }
  .stations td.col-name::before { content: none; }
  .stations tr.empty-row { padding: 0; }
  .stations tr.empty-row td { display: block; }
  .stations tr.empty-row td::before { content: none; }
}
