/* ===== Reset & Base ===== */
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Yu Gothic UI', sans-serif;
  background: #f2f4f8;
  color: #1a1a2e;
  line-height: 1.5;
  min-height: 100vh;
}

/* ===== Color Variables ===== */
:root {
  --primary: #1a5f7a;
  --primary-light: #e8f4f8;
  --primary-dark: #134d63;
  --accent: #00b4d8;
  --success: #06d6a0;
  --warning: #f4a261;
  --danger: #ef476f;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-400: #94a3b8;
  --gray-600: #475569;
  --gray-800: #1e293b;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1), 0 4px 10px rgba(0,0,0,0.05);
  --radius: 14px;
  --radius-sm: 8px;
}

/* ===== Navbar ===== */
.navbar {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  padding: 16px 20px;
  font-size: 17px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(26,95,122,0.3);
  letter-spacing: 0.3px;
}
.navbar a { color: rgba(255,255,255,0.9); text-decoration: none; font-size: 13px; }
.navbar .back-link {
  margin-left: 0;
  margin-right: 8px;
  font-size: 22px;
  font-weight: 300;
  line-height: 1;
  opacity: 0.9;
  transition: opacity 0.15s;
}
.navbar .back-link:hover { opacity: 1; }

/* ===== Container ===== */
.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 16px;
}

/* ===== Cards ===== */
.card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0,0,0,0.04);
  transition: box-shadow 0.2s;
}
.card:has(input:focus), .card:has(textarea:focus), .card:has(select:focus) {
  box-shadow: var(--shadow);
}
.card h2 {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--primary-light);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ===== Forms ===== */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--gray-800);
  background: var(--gray-50);
  -webkit-appearance: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: white;
  box-shadow: 0 0 0 3px rgba(0,180,216,0.12);
}
.form-group input::placeholder { color: var(--gray-400); }
.form-group textarea { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 13px 24px;
  border-radius: 50px;
  font-size: 15px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  transition: all 0.2s;
  letter-spacing: 0.3px;
  font-family: inherit;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  width: 100%;
  box-shadow: 0 4px 14px rgba(26,95,122,0.35);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(26,95,122,0.45); }
.btn-success {
  background: linear-gradient(135deg, #06d6a0 0%, #05a87e 100%);
  color: white;
  box-shadow: 0 4px 14px rgba(6,214,160,0.35);
}
.btn-danger {
  background: linear-gradient(135deg, var(--danger) 0%, #c73158 100%);
  color: white;
  box-shadow: 0 4px 14px rgba(239,71,111,0.3);
}
.btn-secondary {
  background: white;
  color: var(--primary);
  border: 1.5px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { border-color: var(--accent); background: var(--primary-light); }
.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  border: 1.5px solid var(--gray-200);
}
.btn + .btn { margin-top: 10px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

/* ===== Property Cards ===== */
.property-card {
  background: white;
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0,0,0,0.04);
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s, transform 0.15s;
  cursor: pointer;
}
.property-card:active { transform: scale(0.99); box-shadow: var(--shadow); }
.property-card .main { font-size: 15px; font-weight: 700; color: var(--gray-800); }
.property-card .sub { font-size: 12px; color: var(--gray-400); margin-top: 4px; }
.property-card .arrow { font-size: 20px; color: var(--gray-200); font-weight: 300; }

/* ===== Radio / Checkbox ===== */
.radio-group { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.radio-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-800);
  padding: 7px 14px;
  border-radius: 50px;
  border: 1.5px solid var(--gray-200);
  cursor: pointer;
  transition: all 0.15s;
  background: var(--gray-50);
}
.radio-group label:has(input:checked) {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}
.radio-group input[type=radio] { width: 0; height: 0; opacity: 0; position: absolute; }

.check-group { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.check-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-800);
  padding: 7px 14px;
  border-radius: 50px;
  border: 1.5px solid var(--gray-200);
  cursor: pointer;
  transition: all 0.15s;
  background: var(--gray-50);
}
.check-group label:has(input:checked) {
  background: #e8f8f3;
  border-color: var(--success);
  color: #05a87e;
}
.check-group input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--success); }

/* ===== Section Divider ===== */
.section-divider {
  background: linear-gradient(90deg, var(--primary-light), transparent);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  margin: 20px 0 12px;
  letter-spacing: 0.5px;
  border-left: 3px solid var(--primary);
}

/* ===== Defect / Cross Items ===== */
.defect-item, .cross-item {
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
  position: relative;
  border: 1px solid var(--gray-200);
}
.remove-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(239,71,111,0.3);
}

.btn-add {
  background: var(--primary-light);
  color: var(--primary);
  border: 2px dashed var(--accent);
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  letter-spacing: 0.3px;
}
.btn-add:active { background: #d6edf5; }

/* ===== Status Badge ===== */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 11px;
  font-weight: 700;
  background: var(--primary-light);
  color: var(--primary);
  letter-spacing: 0.3px;
}
.badge-success { background: #e8f8f3; color: #05a87e; }
.badge-warning { background: #fef3e2; color: #d97706; }
.badge-danger  { background: #fde8ef; color: #c73158; }

/* ===== Alerts ===== */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  border-left: 4px solid;
}
.alert-success {
  background: #ecfdf5;
  color: #065f46;
  border-color: var(--success);
}
.alert-error {
  background: #fef2f2;
  color: #991b1b;
  border-color: var(--danger);
}

/* ===== Fixed Bottom Bar ===== */
.fixed-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 10px 20px calc(10px + env(safe-area-inset-bottom));
  box-shadow: 0 -1px 0 rgba(0,0,0,0.06), 0 -8px 24px rgba(0,0,0,0.08);
  display: flex;
  gap: 10px;
}
.fixed-bottom .btn { flex: 1; padding: 10px; font-size: 13px; }
.pb-80 { padding-bottom: 90px; }

/* ===== Photo thumbs ===== */
.photo-thumb {
  width: 80px; height: 80px; object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--gray-200);
  cursor: pointer;
  transition: transform 0.15s;
}
.photo-thumb:active { transform: scale(0.95); }
.photo-list { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.photo-slot { position: relative; display: inline-block; }
.photo-slot .del-photo {
  position: absolute; top: -6px; right: -6px;
  background: var(--danger); color: white; border: none;
  border-radius: 50%; width: 22px; height: 22px;
  font-size: 11px; cursor: pointer; line-height: 22px;
  text-align: center; padding: 0; font-weight: 700;
  box-shadow: 0 2px 6px rgba(239,71,111,0.4);
}
.upload-label {
  display: flex; align-items: center; justify-content: center;
  width: 80px; height: 80px;
  border: 2px dashed var(--accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 28px;
  font-weight: 300;
  transition: background 0.15s;
}
.upload-label:active { background: #d6edf5; }

/* ===== Nego number field ===== */
.nego-no-wrap { display: none; margin-top: 10px; }
.nego-no-wrap.show { display: block; }

/* ===== Schedule cards ===== */
.schedule-card {
  background: white;
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(0,0,0,0.04);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.15s;
}
.schedule-card:active { transform: scale(0.99); }
.schedule-card.today { border-left: 4px solid var(--success); }
.schedule-card.upcoming { border-left: 4px solid var(--primary); }
.schedule-card.past { border-left: 4px solid var(--gray-200); opacity: 0.65; }

.date-badge {
  display: inline-flex; align-items: center;
  padding: 4px 12px; border-radius: 50px;
  font-size: 11px; font-weight: 700;
  margin-bottom: 5px; letter-spacing: 0.3px;
}
.badge-today { background: #ecfdf5; color: #059669; }
.badge-upcoming { background: var(--primary-light); color: var(--primary); }
.badge-past { background: var(--gray-100); color: var(--gray-400); }

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  background: var(--gray-100);
  padding: 4px;
  border-radius: 50px;
}
.tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  border-radius: 50px;
  background: transparent;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: all 0.2s;
}
.tab.active {
  background: white;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* ===== Table ===== */
table { width: 100%; border-collapse: collapse; }
table th, table td { padding: 8px 10px; font-size: 13px; border-bottom: 1px solid var(--gray-100); }
table th { font-size: 11px; font-weight: 700; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.5px; background: var(--gray-50); }

/* ===== Utilities ===== */
.text-muted { color: var(--gray-400); font-size: 12px; }

/* ===== ロールベース表示制御 ===== */
/* worker には非表示にする要素 */
.role-worker .admin-only { display: none !important; }
/* system_admin のみ表示する要素 */
.role-worker .sysadmin-only { display: none !important; }
.role-manager .sysadmin-only { display: none !important; }

/* ===== ロール別 navbar 配色 ===== */
.role-system_admin .navbar { background: #4a4a4a !important; }
.role-manager .navbar { background: #3d5a6e !important; }
.role-worker .navbar { background: #4a6355 !important; }

/* ===== navbar右側グループ ===== */
.navbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
/* ===== navbar内ロールバッジ ===== */
.navbar-role-badge {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #fff;
  white-space: nowrap;
  margin-left: 10px;
  padding: 3px 10px;
  border: 1.5px solid rgba(255,255,255,0.5);
  border-radius: 4px;
  background: rgba(255,255,255,0.1);
}
/* ===== navbarナビボタン（右寄り統一） ===== */
.navbar-nav-btn, .navbar-right a {
  padding: 4px 10px;
  font-size: 11px;
  background: rgba(255,255,255,0.15);
  color: #fff !important;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 5px;
  text-decoration: none;
  white-space: nowrap;
}
/* ===== navbarログアウト ===== */
.navbar-logout {
  padding: 4px 10px;
  font-size: 11px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 5px;
  cursor: pointer;
  flex-shrink: 0;
}

/* ===== worker: グレーアウト（操作不可） ===== */
.role-worker .worker-disabled {
  opacity: 0.35;
  pointer-events: none;
  user-select: none;
  position: relative;
}
.role-worker .worker-disabled::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 4px,
    rgba(0,0,0,0.06) 4px,
    rgba(0,0,0,0.06) 8px
  );
  border-radius: inherit;
  pointer-events: none;
}
.divider { height: 1px; background: var(--gray-100); margin: 16px 0; }
