* { box-sizing: border-box; }
html, body { overflow-x: hidden; max-width: 100%; }
body { font-family: system-ui, sans-serif; margin: 0; background: #f7f7f7; color: #1a1a1a; }

.topnav { display: flex; gap: 16px; align-items: center; padding: 12px 20px; background: #1f2937; }
.topnav .brand { color: #fff; font-weight: 700; font-size: 15px; letter-spacing: 0.02em; margin-right: 8px; }
.topnav a { color: #fff; text-decoration: none; font-size: 14px; }
.topnav a:hover { text-decoration: underline; }
.topnav .logout { margin-left: auto; opacity: 0.8; }

.layout { display: flex; height: calc(100vh - 48px); }
#map-wrap { flex: 2; position: relative; }
#map { position: absolute; inset: 0; }

.map-toggle { position: absolute; top: 12px; left: 50px; z-index: 500; display: flex; background: #fff; border-radius: 6px; box-shadow: 0 1px 6px rgba(0,0,0,.3); overflow: hidden; }
.map-toggle button { border: none; background: none; padding: 8px 14px; font-size: 13px; cursor: pointer; color: #333; }
.map-toggle button.active { background: #1f2937; color: #fff; }
.map-toggle button:not(.active):hover { background: #eee; }

.district-select { top: 56px; padding: 8px 10px; border: none; font-size: 13px; color: #333; cursor: pointer; }
.panel { flex: 1; min-width: 280px; overflow-y: auto; padding: 16px; background: #fff; border-left: 1px solid #e5e5e5; }
.panel h2 { margin-top: 0; font-size: 16px; }

.panel-header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.criticality-info { position: relative; }
.criticality-info summary { list-style: none; cursor: pointer; font-size: 12px; color: #1f2937; background: #eef1f6; border-radius: 12px; padding: 3px 10px; user-select: none; white-space: nowrap; }
.criticality-info summary::-webkit-details-marker { display: none; }
.criticality-info summary:hover { background: #e2e6ee; }
.criticality-info-body { position: absolute; right: 0; z-index: 600; width: 300px; max-width: calc(100vw - 32px); margin-top: 6px; padding: 12px 14px; background: #fff; border: 1px solid #e0e0e0; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.12); font-size: 12.5px; line-height: 1.5; color: #333; }
.criticality-info-body p { margin: 0 0 8px; }
.criticality-info-body ul { margin: 0 0 8px; padding-left: 18px; }
.criticality-info-body li { margin-bottom: 6px; }
.criticality-info-body p:last-child { margin-bottom: 0; }

.defects-panel { border-left: none; border-right: 1px solid #e5e5e5; max-width: 340px; transition: flex-basis .15s ease, max-width .15s ease, min-width .15s ease, padding .15s ease; }
.defects-panel .hint { color: #777; font-size: 13px; }

.defects-panel-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.defects-panel-header h2 { margin: 0; }
#defects-panel-toggle { flex-shrink: 0; border: none; background: #eee; border-radius: 4px; width: 28px; height: 28px; font-size: 16px; line-height: 1; cursor: pointer; color: #333; }
#defects-panel-toggle:hover { background: #ddd; }

.defects-panel.collapsed { flex: 0 0 44px; min-width: 44px; max-width: 44px; padding: 16px 8px; overflow: hidden; }
.defects-panel.collapsed #defects-panel-title,
.defects-panel.collapsed #defects-panel-content { display: none; }
.defects-panel.collapsed .defects-panel-header { justify-content: center; }

.defect-card { border: 1px solid #e5e5e5; border-radius: 8px; padding: 10px; margin-bottom: 12px; }
.defect-card.is-fixing { opacity: 0.5; pointer-events: none; }
.defect-card-photos { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.defect-card-photos img { width: calc(50% - 3px); border-radius: 4px; object-fit: cover; aspect-ratio: 4/3; }
.defect-card-photos .no-photo { width: 100%; padding: 20px 0; text-align: center; background: #f2f2f2; border-radius: 4px; color: #999; font-size: 13px; }
.defect-card-info { font-size: 13px; color: #444; line-height: 1.5; margin-bottom: 8px; }
.defect-card .fix-btn { margin-top: 0; }

.page { padding: 24px; }
.hint { color: #777; font-size: 13px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #eee; font-size: 14px; }
#priority-table tbody tr { cursor: pointer; }
#priority-table tbody tr:hover { background: #f0f4ff; }

.band-low { color: #4caf50; font-weight: 600; }
.band-medium { color: #ffb300; font-weight: 600; }
.band-high { color: #fb8c00; font-weight: 600; }
.band-critical { color: #e53935; font-weight: 700; }

.login-box { max-width: 320px; margin: 80px auto; padding: 24px; background: #fff; border-radius: 8px; box-shadow: 0 2px 12px rgba(0,0,0,.08); }
.login-box input { width: 100%; padding: 8px; margin: 8px 0; }
.login-box button { width: 100%; padding: 8px; background: #1f2937; color: #fff; border: none; border-radius: 4px; cursor: pointer; }
.login-box .hint-link { margin-top: 12px; font-size: 13px; text-align: center; }
.error { color: #e53935; }

.form-card { max-width: 480px; padding: 20px; background: #fff; border-radius: 8px; box-shadow: 0 1px 6px rgba(0,0,0,.08); margin-bottom: 24px; }
.form-card h2 { margin-top: 0; }
.form-card label { display: block; font-size: 13px; color: #444; margin: 10px 0 4px; }
.form-card input, .form-card textarea, .form-card select { width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 4px; font: inherit; }
.form-card .geo-row { display: flex; gap: 8px; align-items: center; margin: 10px 0 4px; }
.form-card .geo-row button { flex-shrink: 0; padding: 8px 12px; border: 1px solid #1f2937; background: #fff; color: #1f2937; border-radius: 4px; cursor: pointer; }
.form-card .geo-status { font-size: 12px; color: #777; margin: 4px 0; }
.form-card .submit-btn { margin-top: 14px; padding: 9px; width: 100%; background: #1f2937; color: #fff; border: none; border-radius: 4px; cursor: pointer; font-size: 14px; }

.status-badge { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; }
.status-pending { background: #fff3cd; color: #8a6500; }
.status-approved { background: #d4edda; color: #2e7d32; }
.status-rejected { background: #fde0e0; color: #c62828; }

.report-card { border: 1px solid #e5e5e5; border-radius: 8px; padding: 12px; margin-bottom: 10px; background: #fff; }
.report-card-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.report-card img.thumb { max-width: 220px; max-height: 160px; border-radius: 4px; display: block; margin: 8px 0; }
.report-card .meta { font-size: 12.5px; color: #666; line-height: 1.6; }
.report-card .actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.report-card .actions form { display: flex; gap: 6px; }
.report-card .actions input[type="text"] { padding: 6px 8px; border: 1px solid #ddd; border-radius: 4px; font-size: 13px; }
.report-card .actions button { padding: 6px 14px; border: none; border-radius: 4px; cursor: pointer; font-size: 13px; white-space: nowrap; }
.report-card .approve-btn { background: #2e7d32; color: #fff; }
.report-card .reject-btn { background: #c62828; color: #fff; }

details.fix-defect summary { cursor: pointer; padding: 8px 0; }

#worker-map { height: 320px; border-radius: 8px; margin-bottom: 16px; box-shadow: 0 1px 6px rgba(0,0,0,.08); }

.role-form { display: flex; gap: 6px; align-items: center; }
.role-form select { padding: 4px 6px; }
.role-form button { padding: 4px 10px; border: 1px solid #1f2937; background: #fff; color: #1f2937; border-radius: 4px; cursor: pointer; font-size: 12.5px; }
.role-form button:hover { background: #1f2937; color: #fff; }

.fix-btn { margin-top: 12px; width: 100%; padding: 8px; background: #2e7d32; color: #fff; border: none; border-radius: 4px; cursor: pointer; }
.fix-btn:disabled { background: #9e9e9e; cursor: default; }

@media (max-width: 700px) {
  .layout { flex-direction: column; height: auto; }
  #map-wrap { height: 50vh; min-height: 280px; order: -1; }
  .role-form { flex-wrap: wrap; }
  .defects-panel { max-width: none; max-height: 40vh; }
  .defects-panel.collapsed { max-width: none; max-height: 44px; min-width: 0; }
  .topnav { flex-wrap: wrap; gap: 10px 16px; padding: 10px 14px; }
  .topnav .logout { margin-left: 0; }
  .page { padding: 16px; }
  table { display: block; overflow-x: auto; white-space: nowrap; }
}
