/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  background: #f5f5f5;
  color: #333;
  line-height: 1.6;
  overflow-x: hidden;
}

/* Navbar */
.navbar {
  background: #2c3e50;
  color: #fff;
  padding: 0 1rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  flex-wrap: nowrap;
}
.navbar-brand {
  color: #fff;
  text-decoration: none;
  font-size: 1.1rem;
  font-weight: bold;
  flex-shrink: 0;
}
.navbar-links {
  display: flex;
  align-items: center;
  gap: 0;
}
.navbar-links a {
  color: #bdc3c7;
  text-decoration: none;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  transition: color 0.2s;
  white-space: nowrap;
}
.navbar-links a:hover,
.navbar-links a.active {
  color: #fff;
}

/* Hamburger button - hidden on desktop */
.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
  flex-direction: column;
  gap: 5px;
}
.hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: #fff;
  transition: transform 0.25s, opacity 0.25s;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Footer */
.site-footer {
  background: #2c3e50;
  padding: 1rem;
  margin-top: 2rem;
  font-size: 0.78rem;
  color: #95a5a6;
}
.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.footer-links { display: flex; gap: 1rem; }
.footer-links a { color: #95a5a6; text-decoration: none; }
.footer-links a:hover { color: #fff; text-decoration: underline; }

/* Container */
.container {
  max-width: 1400px;
  margin: 1.5rem auto;
  padding: 0 1rem;
  min-height: calc(100vh - 56px - 60px);
}

/* Tabs */
.tabs {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.tab-btn {
  padding: 0.5rem 1.3rem;
  border: 1.5px solid #bbb;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  color: #555;
  background: linear-gradient(180deg, #f8f8f8 0%, #e8e8e8 100%);
  box-shadow: 0 2px 4px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.7);
  transition: all 0.15s ease;
  position: relative;
  top: 0;
}
.tab-btn:hover {
  top: -1px;
  box-shadow: 0 3px 6px rgba(0,0,0,0.12), inset 0 1px 0 rgba(255,255,255,0.7);
}
.tab-btn:active {
  top: 1px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1), inset 0 1px 2px rgba(0,0,0,0.06);
}
/* 全て - neutral grey */
.tab-btn[data-filter="all"] {
  border-color: #999;
  background: linear-gradient(180deg, #f0f0f0 0%, #dcdcdc 100%);
  color: #444;
}
.tab-btn[data-filter="all"].active {
  background: linear-gradient(180deg, #6b7b8d 0%, #4a5568 100%);
  color: #fff;
  border-color: #3d4a59;
  box-shadow: 0 2px 6px rgba(74,85,104,0.35), inset 0 1px 0 rgba(255,255,255,0.15);
}
/* マンション - soft blue */
.tab-btn[data-filter="マンション"] {
  border-color: #7baed4;
  background: linear-gradient(180deg, #e8f2fb 0%, #c9dff2 100%);
  color: #2a6496;
}
.tab-btn[data-filter="マンション"].active {
  background: linear-gradient(180deg, #5ba3d9 0%, #3178b5 100%);
  color: #fff;
  border-color: #2868a0;
  box-shadow: 0 2px 6px rgba(49,120,181,0.4), inset 0 1px 0 rgba(255,255,255,0.2);
}
/* 戸建 - warm green */
.tab-btn[data-filter="戸建"] {
  border-color: #88bf8a;
  background: linear-gradient(180deg, #eaf5ea 0%, #cce5cd 100%);
  color: #3a7a3c;
}
.tab-btn[data-filter="戸建"].active {
  background: linear-gradient(180deg, #6abf6e 0%, #459c49 100%);
  color: #fff;
  border-color: #3a8a3e;
  box-shadow: 0 2px 6px rgba(69,156,73,0.4), inset 0 1px 0 rgba(255,255,255,0.2);
}
/* 土地 - earthy orange */
.tab-btn[data-filter="土地"] {
  border-color: #d4a96a;
  background: linear-gradient(180deg, #fdf3e7 0%, #f0ddc0 100%);
  color: #8a6322;
}
.tab-btn[data-filter="土地"].active {
  background: linear-gradient(180deg, #e0a84c 0%, #c08930 100%);
  color: #fff;
  border-color: #a67728;
  box-shadow: 0 2px 6px rgba(192,137,48,0.4), inset 0 1px 0 rgba(255,255,255,0.2);
}
/* 他 - soft purple */
.tab-btn[data-filter="他"] {
  border-color: #b8a0cc;
  background: linear-gradient(180deg, #f3eef8 0%, #ddd0ea 100%);
  color: #6b4d8a;
}
.tab-btn[data-filter="他"].active {
  background: linear-gradient(180deg, #a07cc5 0%, #7b57a6 100%);
  color: #fff;
  border-color: #694a91;
  box-shadow: 0 2px 6px rgba(123,87,166,0.4), inset 0 1px 0 rgba(255,255,255,0.2);
}

/* Tables */
.card {
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
table.dataTable { width: 100% !important; }
table.dataTable thead th {
  background: #f8f9fa;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
}
table.dataTable tbody td {
  font-size: 0.9rem;
  vertical-align: middle;
}

/* Clickable cells */
.cell-link {
  cursor: pointer;
  color: #2980b9;
  text-align: center;
  font-weight: bold;
}
.cell-link:hover {
  background: #eaf2f8;
}
.cell-maru {
  text-align: center;
}
.cell-dash {
  text-align: center;
  color: #ccc;
}

/* Popup / Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 8px;
  padding: 1.5rem;
  min-width: 320px;
  max-width: 500px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.modal-box h3 {
  margin-bottom: 1rem;
  font-size: 1.1rem;
  color: #2c3e50;
}
.modal-box .close-btn {
  float: right;
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: #999;
}
.modal-box .close-btn:hover { color: #333; }
.modal-box ul {
  list-style: none;
  padding: 0;
}
.modal-box ul li {
  padding: 0.4rem 0;
}
.modal-box ul li a {
  color: #2980b9;
  text-decoration: none;
}
.modal-box ul li a:hover {
  text-decoration: underline;
}

/* Forms */
.form-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 0;
}
.form-row > .form-group {
  flex: 1;
  min-width: 0;
}
.badge-optional {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  background: #e2e8f0;
  color: #64748b;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  margin-left: 0.4rem;
  vertical-align: middle;
  letter-spacing: 0.03em;
}
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
}
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="number"],
.form-group input[type="password"],
.form-group input[type="date"],
.form-group input[type="url"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95rem;
}
.form-group input:focus,
.form-group select:focus {
  border-color: #2980b9;
  outline: none;
  box-shadow: 0 0 0 2px rgba(41,128,185,0.15);
}

.btn {
  display: inline-block;
  padding: 0.5rem 1.2rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
  transition: background 0.2s;
}
.btn-primary { background: #2c3e50; color: #fff; }
.btn-primary:hover { background: #34495e; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }

/* Admin add buttons */
.admin-add-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 220px;
  height: 180px;
  border-radius: 12px;
  text-decoration: none;
  font-size: 1.2rem;
  font-weight: 700;
  transition: all 0.15s ease;
  position: relative;
  top: 0;
}
.admin-add-btn:hover {
  top: -3px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}
.admin-add-btn:active {
  top: 1px;
}
.admin-add-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}
.admin-add-property {
  background: linear-gradient(135deg, #4a90d9 0%, #2c5f9e 100%);
  color: #fff;
  border: 2px solid #245685;
  box-shadow: 0 4px 12px rgba(44,95,158,0.3);
}
.admin-add-mansion {
  background: linear-gradient(135deg, #5bb370 0%, #3a8a4e 100%);
  color: #fff;
  border: 2px solid #2e7340;
  box-shadow: 0 4px 12px rgba(58,138,78,0.3);
}
.admin-add-import {
  background: linear-gradient(135deg, #e0a04c 0%, #c07e20 100%);
  color: #fff;
  border: 2px solid #a56b1a;
  box-shadow: 0 4px 12px rgba(192,126,32,0.3);
}
.admin-add-import .admin-add-icon {
  font-size: 1.6rem;
  letter-spacing: 0.05em;
}
.admin-add-obi {
  background: linear-gradient(135deg, #f06292 0%, #c2185b 100%);
  color: #fff;
  border: 2px solid #ad1457;
  box-shadow: 0 4px 12px rgba(194,24,91,0.3);
}
.admin-add-reins {
  background: linear-gradient(135deg, #e04050 0%, #c41e3a 100%);
  color: #fff;
  border: 2px solid #a01830;
  box-shadow: 0 4px 12px rgba(196,30,58,0.3);
}
.admin-add-reins .admin-add-icon {
  font-size: 1.4rem;
  letter-spacing: 0.05em;
}

/* Property detail */
.property-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.property-info dt {
  font-weight: 600;
  color: #666;
  font-size: 0.85rem;
}
.property-info dd {
  margin-bottom: 0.7rem;
  margin-left: 0;
}
/* Mansion detail */
.mansion-detail-card {
  padding: 2rem;
}
.mansion-detail-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.mansion-detail-title h2 {
  margin-bottom: 0.3rem;
}
.mansion-address-link {
  color: #2980b9;
  text-decoration: none;
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.mansion-address-link::before {
  content: '\1F4CD';
  font-size: 0.85rem;
}
.mansion-address-link:hover {
  text-decoration: underline;
  color: #1a5f8a;
}
.mansion-detail-actions {
  flex-shrink: 0;
  display: flex;
  gap: 0.4rem;
  align-items: center;
}
.mansion-specs {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.mansion-spec-item {
  flex: 1 1 auto;
  min-width: 130px;
  padding: 0.75rem 1rem;
  border-right: 1px solid #e5e7eb;
  border-bottom: 1px solid #e5e7eb;
  background: #fafbfc;
  text-align: center;
}
.mansion-spec-item:last-child {
  border-right: none;
}
.mansion-spec-label {
  display: block;
  font-size: 0.75rem;
  color: #888;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.25rem;
}
.mansion-spec-value {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  color: #2c3e50;
}
.mansion-notes {
  background: #f8f9fa;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.75rem 1rem;
}
.mansion-notes p {
  margin-top: 0.25rem;
  font-size: 0.9rem;
  color: #555;
  line-height: 1.7;
}
@media (max-width: 768px) {
  .mansion-detail-top { flex-direction: column; }
  .mansion-spec-item { min-width: 100px; }
}

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}
.file-item {
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 0.75rem;
  text-align: center;
  background: #fafafa;
  position: relative;
}
.file-item img {
  max-width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 3px;
}
.file-item .file-name {
  font-size: 0.8rem;
  margin-top: 0.5rem;
  word-break: break-all;
}
.file-item .delete-file-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: #e74c3c;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  font-size: 0.7rem;
  cursor: pointer;
  display: none;
}
.admin-mode .file-item .delete-file-btn { display: block; }

/* Admin */
.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 900px) {
  .admin-grid { grid-template-columns: 1fr; }
}
.ad-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.ad-row label {
  min-width: 80px;
  font-weight: normal;
}
.ad-row input[type="url"] {
  flex: 1;
  padding: 0.35rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* Login page */
.login-card {
  max-width: 400px;
  margin: 3rem auto;
}

/* Flash messages */
.flash {
  padding: 0.75rem 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
}
.flash-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.flash-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* Confirm date popup */
.confirm-date-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.75rem;
}
.confirm-date-form input[type="date"] {
  padding: 0.4rem;
  border: 1px solid #ccc;
  border-radius: 4px;
}

/* Property detail page */
.property-type-badge {
  display: inline-block;
  background: #e8f0fe;
  color: #1a73e8;
  padding: 0.15rem 0.6rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
  margin-left: 0.5rem;
  vertical-align: middle;
}
.property-price-big {
  font-size: 1.6rem;
  font-weight: bold;
  color: #2c3e50;
}
.property-price-big .price-unit {
  font-size: 0.9rem;
  font-weight: normal;
  color: #666;
}
.property-ads-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.property-ad-tag {
  display: inline-block;
  padding: 0.3rem 0.8rem;
  border-radius: 16px;
  font-size: 0.85rem;
  background: #f0f0f0;
  color: #999;
  text-decoration: none;
}
.property-ad-tag.property-ad-active {
  background: #e8f5e9;
  color: #2e7d32;
  cursor: pointer;
}
.property-ad-tag.property-ad-active:hover {
  background: #c8e6c9;
}

/* Address filter chips */
.address-chip {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  font-size: 0.78rem;
  user-select: none;
}
.address-chip input[type="checkbox"] {
  display: none;
}
.address-chip span {
  padding: 0.2rem 0.55rem;
  border-radius: 12px;
  border: 1px solid #ccc;
  background: #fff;
  color: #666;
  transition: all 0.15s;
}
.address-chip input:checked + span {
  background: #3498db;
  color: #fff;
  border-color: #3498db;
}

/* Responsive */
@media (max-width: 768px) {
  .navbar-inner { flex-wrap: wrap; height: auto; padding: 0.5rem 0; }
  .hamburger { display: flex; }
  .navbar-links {
    display: none;
    flex-direction: column;
    align-items: stretch;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    width: 100%;
    background: #2c3e50;
    padding: 0;
    z-index: 99;
  }
  .navbar-links.nav-open { display: flex; }
  .navbar-links a {
    display: block;
    padding: 0.6rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
  }
  .property-header { flex-direction: column; }
  .footer-inner { flex-direction: column; text-align: center; }

  /* Tables scroll inside card, not the page */
  .card { overflow-x: auto; }

  /* Shrink filter tabs on mobile */
  .tabs {
    gap: 0.3rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    justify-content: flex-start;
    padding-bottom: 0.25rem;
  }
  .tab-btn {
    padding: 0.35rem 0.7rem;
    font-size: 0.75rem;
    flex-shrink: 0;
  }

  /* Mansion tabs: many buttons, allow horizontal scroll */
  .mansion-tabs { flex-wrap: nowrap; }
}

/* Print */
@media print {
  .navbar, .site-footer, .hamburger { display: none !important; }
  .container { max-width: 100%; padding: 0; margin: 0; }
}
