:root {
  --bg: #f6f7f9;
  --fg: #1f2329;
  --muted: #5b6470;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --danger: #b91c1c;
  --warning: #b45309;
  --border: #e3e6ea;
  --row-hover: #f0f4ff;
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Noto Sans JP", Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
}

/* --- Login --- */
.login {
  max-width: 360px;
  margin: 10vh auto;
  background: #fff;
  padding: 28px 24px;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.06);
}
.login h1 {
  margin: 0 0 16px;
  font-size: 22px;
}
.login form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login label {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  color: var(--muted);
  gap: 4px;
}
.login input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}
.login button {
  margin-top: 8px;
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}
.login button:disabled { opacity: 0.6; cursor: not-allowed; }

/* --- Listings --- */
.listings { padding: 0 24px 40px; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 0;
}
.topbar h1 { margin: 0; font-size: 18px; }
.topbar .user {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}
.topbar .user button {
  background: transparent;
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.tab {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  gap: 6px;
  align-items: center;
}
.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.tab .badge {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 12px;
}
.tab.active .badge {
  background: var(--accent);
  color: #fff;
}

.controls {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 8px 0 16px;
  font-size: 13px;
  color: var(--muted);
}
.controls select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}
.controls button {
  padding: 5px 12px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
}

.listing-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.listing-table th,
.listing-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 13px;
  vertical-align: top;
}
.listing-table th {
  background: #fafbfc;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.listing-table tbody tr:hover { background: var(--row-hover); }
.listing-table .num { white-space: nowrap; }
.listing-table a {
  color: var(--accent);
  text-decoration: none;
}
.listing-table a:hover { text-decoration: underline; }
.site-badge {
  display: inline-block;
  margin-left: 6px;
  font-size: 11px;
  color: var(--muted);
  background: var(--accent-soft);
  padding: 1px 6px;
  border-radius: 4px;
}

.actions {
  white-space: nowrap;
  display: flex;
  gap: 4px;
}
.actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 0 4px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.actions button .label { display: none; }
.actions button .icon { font-size: 14px; }
.actions .btn-interested:hover { background: #fff7e6; border-color: var(--warning); color: var(--warning); }
.actions .btn-excluded:hover   { background: #fef2f2; border-color: var(--danger);  color: var(--danger); }
.actions .btn-reset:hover      { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
}
.error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
}

/* ---------- スマホ表示（カード型） ---------- */
@media (max-width: 768px) {
  body { font-size: 15px; }
  .listings { padding: 0 12px 40px; }

  .topbar { padding: 12px 0; }
  .topbar h1 { font-size: 16px; }
  .topbar .user { gap: 8px; font-size: 12px; }
  .topbar .user span { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* タブを横スクロール可能に */
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }
  .tab { flex: 0 0 auto; padding: 10px 12px; font-size: 13px; }

  .controls {
    flex-wrap: wrap;
    gap: 8px;
    font-size: 13px;
  }

  /* テーブルをカードに変換 */
  .listing-table,
  .listing-table thead,
  .listing-table tbody,
  .listing-table tr,
  .listing-table th,
  .listing-table td {
    display: block;
    width: 100%;
  }
  .listing-table { background: transparent; box-shadow: none; }
  .listing-table thead { display: none; }
  .listing-table tbody tr {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    padding: 14px;
    margin-bottom: 12px;
  }
  .listing-table tbody tr:hover { background: #fff; }
  .listing-table td {
    padding: 6px 0;
    border-bottom: 1px dashed var(--border);
    font-size: 14px;
  }
  .listing-table td:last-child { border-bottom: 0; }

  /* 物件名（一番目の td）は大きく */
  .listing-table td:first-child {
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
    margin-bottom: 4px;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.4;
  }
  .listing-table td:first-child a { display: inline; }
  .listing-table td:first-child::before { display: none; }

  /* 他の td に左ラベルを表示 */
  .listing-table td::before {
    content: attr(data-label);
    display: inline-block;
    width: 64px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
  }
  .listing-table td.num { text-align: left; }
  .listing-table td.actions { padding-top: 12px; border-bottom: 0; }
  .listing-table td.actions::before { display: none; }

  /* タップしやすい大きめのボタン */
  .actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }
  .actions button {
    flex: 1 1 auto;
    height: 42px;
    padding: 0 12px;
    font-size: 14px;
    gap: 6px;
  }
  .actions button .label { display: inline; }
  .actions .btn-interested { background: #fff7e6; border-color: var(--warning); color: var(--warning); }
  .actions .btn-excluded   { background: #fef2f2; border-color: var(--danger);  color: var(--danger); }
  .actions .btn-reset      { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
}

/* ---------- 細スマホ（〜400px） ---------- */
@media (max-width: 400px) {
  .actions button { flex: 1 1 100%; }
}
