:root {
    --bg: #0f172a;
    --bg-soft: #111827;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --accent: #e5a33d;
    --danger: #b91c1c;
    --warn: #b45309;
    --ok: #166534;
    --shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}
* { box-sizing: border-box; }
body {
    margin: 0;
    background: #eef2f7;
    color: var(--text);
    font-family: Inter, Arial, sans-serif;
    line-height: 1.45;
}
a { color: inherit; text-decoration: none; }
.wrap { width: min(1200px, calc(100% - 32px)); margin: 0 auto; }
.topbar {
    background: linear-gradient(180deg, #0b1220 0%, #111827 100%);
    color: #fff;
    padding: 18px 0;
    box-shadow: var(--shadow);
}
.topbar-inner {
    display: flex;
    gap: 20px;
    justify-content: space-between;
    align-items: center;
}
.brand {
    display: inline-block;
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: .02em;
}
.subbrand {
    font-size: .92rem;
    color: #cbd5e1;
    margin-top: 4px;
}
.navlinks {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    align-items: center;
}
.navlinks a {
    color: #fff;
    padding: 10px 12px;
    border-radius: 10px;
}
.navlinks a:hover {
    background: rgba(255,255,255,.08);
}
.page { padding: 24px 0 40px; }
.footer {
    background: #0f172a;
    color: #cbd5e1;
    padding: 18px 0;
    margin-top: 40px;
}
.footer-inner {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
h1, h2, h3 { margin: 0 0 12px; line-height: 1.15; }
p { margin: 0 0 14px; }
.muted { color: var(--muted); }
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 18px;
}
.card + .card { margin-top: 18px; }
.grid {
    display: grid;
    gap: 18px;
}
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi {
    background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 18px;
}
.kpi strong { display: block; font-size: 2rem; margin-bottom: 4px; }
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    font-weight: 700;
    font-size: .9rem;
}
.grade-1 { background: #fee2e2; color: #991b1b; }
.grade-2 { background: #ffedd5; color: #9a3412; }
.grade-3 { background: #fef3c7; color: #92400e; }
.grade-4 { background: #dcfce7; color: #166534; }
.grade-5 { background: #dbeafe; color: #1d4ed8; }
.grade-none { background: #e2e8f0; color: #334155; }
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
}
th, td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}
th { font-size: .9rem; color: var(--muted); }
label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
}
input[type="text"], input[type="password"], input[type="date"], input[type="number"], textarea, select {
    width: 100%;
    border: 1px solid #cbd5e1;
    background: #fff;
    border-radius: 12px;
    padding: 11px 12px;
    font: inherit;
}
textarea { min-height: 120px; resize: vertical; }
button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 12px;
    background: #111827;
    color: #fff;
    font-weight: 700;
    padding: 11px 16px;
    cursor: pointer;
}
.button-secondary {
    background: #e2e8f0;
    color: #0f172a;
}
.button-accent {
    background: var(--accent);
    color: #111827;
}
.button-danger {
    background: #b91c1c;
}
.filters {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 12px;
    align-items: end;
}
.flash {
    padding: 14px 16px;
    border-radius: 14px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
}
.flash-success { background: #ecfdf5; color: #166534; border-color: #bbf7d0; }
.flash-error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.flash-info { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.hero {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: end;
    margin-bottom: 18px;
}
.hero .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}
.photo-grid img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: 14px;
    border: 1px solid var(--border);
}
.inline-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin: 8px 0 0;
    color: var(--muted);
}
.help {
    font-size: .92rem;
    color: var(--muted);
}
.notice {
    padding: 12px 14px;
    border-radius: 14px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
}
.road-name a {
    font-weight: 800;
}
.status-strip {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 8px;
}
.small { font-size: .92rem; }
.defect-grid {
    display: grid;
    grid-template-columns: 2fr .8fr;
    gap: 10px 12px;
    align-items: center;
}
.section-title {
    margin-bottom: 10px;
    font-size: 1.15rem;
}
@media (max-width: 900px) {
    .grid-4, .grid-3, .grid-2, .filters {
        grid-template-columns: 1fr;
    }
    .hero { display: block; }
    .topbar-inner { align-items: flex-start; }
}

.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.panel-soft { background:#f8fafc; }
.inspect-card { max-width: 980px; margin: 0 auto; }
.compact-grid { gap: 14px; }
.hazard-boxes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.tick-card {
    display:flex;
    align-items:center;
    gap:10px;
    border:1px solid var(--border);
    background:#f8fafc;
    border-radius:14px;
    padding:12px 14px;
    font-weight:600;
}
.tick-card input { width:auto; }
.quick-panel {
    border:1px solid var(--border);
    background:#f8fafc;
    border-radius:18px;
    padding:18px;
}
.quick-panel-head {
    display:flex;
    align-items:end;
    justify-content:space-between;
    gap:16px;
    margin-bottom:14px;
}
.defect-quick-grid {
    display:grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap:12px;
}
.defect-quick-item {
    display:grid;
    grid-template-columns: minmax(0, 1fr) 110px;
    gap:12px;
    align-items:center;
    border:1px solid var(--border);
    background:#fff;
    border-radius:14px;
    padding:12px 14px;
}
.defect-quick-item label { margin-bottom:4px; }
.compact-photo-grid img { height: 110px; }
.badge-hazard { background:#fee2e2; color:#991b1b; }
.stack-badges { display:flex; gap:6px; flex-wrap:wrap; }
.table-actions { display:flex; gap:8px; flex-wrap:wrap; }
.dashboard-kpis { margin-bottom:18px; }
@media (max-width: 1000px) {
    .grid-5, .defect-quick-grid, .hazard-boxes { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
    .defect-quick-item { grid-template-columns: 1fr; }
}

.filters-public {
    grid-template-columns: 2fr 1fr 1fr auto;
}
.filters-roads {
    grid-template-columns: 2fr 1fr 1fr auto;
}
.form-card {
    border-radius: 22px;
}
.road-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
}
.road-card {
    display: block;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 18px;
    padding: 16px;
    box-shadow: var(--shadow);
}
.road-card:hover {
    transform: translateY(-1px);
}
.road-card h3 {
    margin-top: 12px;
    margin-bottom: 8px;
}
.map-card {
    overflow: hidden;
}
.roads-map {
    width: 100%;
    height: 420px;
    border-radius: 18px;
    border: 1px solid var(--border);
    overflow: hidden;
    background: #e2e8f0;
}
.road-map-single {
    height: 300px;
}
.map-popup a {
    color: #1d4ed8;
    font-weight: 700;
}
.badge-popup {
    display: inline-block;
    margin-top: 6px;
    font-weight: 700;
}
.road-detail-grid {
    align-items: stretch;
}
.table-actions form {
    margin: 0;
}
.table-actions .button,
.table-actions button {
    padding: 9px 12px;
}
@media (max-width: 900px) {
    .filters-public,
    .filters-roads {
        grid-template-columns: 1fr;
    }
    .roads-map {
        height: 320px;
    }
}


.section-header {
    display:flex;
    justify-content:space-between;
    gap:16px;
    align-items:flex-start;
    margin-bottom:14px;
}
.leaderboard-grid {
    align-items:stretch;
    margin-bottom:18px;
}
.leaderboard-list {
    display:grid;
    gap:10px;
}
.leaderboard-item {
    display:grid;
    grid-template-columns: 44px 1fr auto;
    gap:12px;
    align-items:center;
    border:1px solid var(--border);
    background:linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-radius:16px;
    padding:12px 14px;
}
.leaderboard-item:hover {
    transform: translateY(-1px);
}
.leaderboard-rank {
    width:32px;
    height:32px;
    border-radius:999px;
    background:#111827;
    color:#fff;
    display:flex;
    align-items:center;
    justify-content:center;
    font-weight:800;
}
.leaderboard-meta {
    display:flex;
    gap:8px;
    flex-wrap:wrap;
    justify-content:flex-end;
}
.map-legend {
    display:flex;
    gap:8px;
    flex-wrap:wrap;
}
.legend-pill {
    display:inline-flex;
    align-items:center;
    gap:6px;
    font-size:.85rem;
    color:var(--muted);
}
.legend-dot {
    width:10px;
    height:10px;
    border-radius:999px;
    display:inline-block;
}
.legend-dot.grade-1 { background:#b91c1c; }
.legend-dot.grade-2 { background:#ea580c; }
.legend-dot.grade-3 { background:#d97706; }
.legend-dot.grade-4 { background:#16a34a; }
.legend-dot.grade-5 { background:#2563eb; }
.legend-dot.grade-none { background:#64748b; }
.grade-map-marker-wrapper {
    background: transparent;
    border: 0;
}
.grade-map-marker {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: .85rem;
    border: 2px solid rgba(255,255,255,.95);
    box-shadow: 0 3px 10px rgba(15,23,42,.28);
}
.grade-map-marker.grade-1 { background:#b91c1c; }
.grade-map-marker.grade-2 { background:#ea580c; }
.grade-map-marker.grade-3 { background:#d97706; }
.grade-map-marker.grade-4 { background:#16a34a; }
.grade-map-marker.grade-5 { background:#2563eb; }
.grade-map-marker.grade-none { background:#64748b; }
.history-chart {
    width:100%;
    height:auto;
    display:block;
}
.chart-grid-line {
    stroke:#e2e8f0;
    stroke-width:1;
}
.chart-axis-label {
    fill:#64748b;
    font-size:12px;
    font-family:Inter, Arial, sans-serif;
}
.chart-empty {
    min-height:220px;
    display:flex;
    align-items:center;
    justify-content:center;
    border:1px dashed var(--border);
    border-radius:18px;
    color:var(--muted);
    background:#f8fafc;
    padding:18px;
    text-align:center;
}
.bulk-textarea {
    min-height:340px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (max-width: 900px) {
    .leaderboard-item {
        grid-template-columns: 36px 1fr;
    }
    .leaderboard-meta {
        grid-column: 1 / -1;
        justify-content:flex-start;
    }
    .section-header {
        display:block;
    }
}

.risk-preview {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 16px;
    padding: 14px;
}
.risk-preview-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}
.risk-preview-grid > div {
    border: 1px solid var(--border);
    background: #f8fafc;
    border-radius: 14px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.risk-preview-grid strong {
    font-size: .86rem;
    color: var(--muted);
}
.risk-static-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.risk-static-grid .risk-action {
    grid-column: 1 / -1;
}
.risk-cat-1 { background:#7f1d1d; color:#fff; }
.risk-cat-2 { background:#b91c1c; color:#fff; }
.risk-cat-3 { background:#ea580c; color:#fff; }
.risk-cat-4 { background:#facc15; color:#111827; }
.risk-cat-5 { background:#22c55e; color:#052e16; }
.risk-cat-none { background:#e2e8f0; color:#334155; }
@media (max-width: 900px) {
    .risk-preview-grid,
    .risk-static-grid {
        grid-template-columns: 1fr;
    }
    .risk-static-grid .risk-action {
        grid-column: auto;
    }
}

.road-hero {
    align-items: center;
}
.road-summary-shell {
    padding: 22px;
}
.road-summary-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}
.summary-pill {
    border: 1px solid var(--border);
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 16px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.summary-pill-label {
    font-size: .84rem;
    color: var(--muted);
    font-weight: 700;
}
.summary-pill strong {
    font-size: 1.4rem;
    line-height: 1;
}
.road-panel {
    padding: 18px;
}
.road-note-box {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 16px;
    padding: 14px 16px;
    margin-bottom: 14px;
}
.road-map-panel {
    margin-top: 16px;
}
.road-photo-section {
    margin-top: 18px;
}
.section-header-tight {
    align-items: center;
    margin-bottom: 12px;
}
.photo-grid-large {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.photo-card-link {
    display: block;
}
.photo-card {
    margin: 0;
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.05);
}
.photo-card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    height: auto;
    object-fit: cover;
    display: block;
    background: #e2e8f0;
}
.photo-card figcaption {
    padding: 10px 12px;
    font-size: .9rem;
    color: var(--muted);
    font-weight: 600;
}
.photo-empty {
    min-height: 170px;
}
input[type="file"] {
    display: block;
    width: 100%;
    border: 1px dashed #cbd5e1;
    background: #fff;
    border-radius: 12px;
    padding: 12px;
}
@media (max-width: 1000px) {
    .road-summary-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (max-width: 700px) {
    .road-summary-kpis,
    .photo-grid-large {
        grid-template-columns: 1fr;
    }
}

.form-save-bar {
    margin: 0 0 18px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    box-shadow: var(--shadow);
}
.form-save-bar-bottom {
    margin-top: 18px;
}
.publish-toggle-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}
.publish-toggle-inline input {
    width: auto;
}
@media (max-width: 700px) {
    .form-save-bar {
        align-items: stretch;
    }
    .form-save-bar .table-actions {
        width: 100%;
    }
    .form-save-bar .table-actions > * {
        flex: 1 1 auto;
        text-align: center;
    }
}


.road-note-box-inline { margin-bottom: 18px; }
.road-photo-section-top { margin-bottom: 18px; }
.road-detail-grid-balanced > .road-panel { min-height: 100%; }
.road-bottom-grid { margin-top: 18px; }
.section-title { margin-top: 0; }
.photo-grid-large { display:grid; gap:14px; grid-template-columns:repeat(auto-fill,minmax(240px,1fr)); }
.photo-card { height:100%; }
.photo-empty { display:flex; align-items:center; justify-content:center; text-align:center; }
.road-map-single { min-height: 260px; border-radius: 16px; overflow: hidden; border:1px solid var(--border); }
@media (max-width: 1000px) {
  .road-detail-grid-balanced, .road-bottom-grid, .road-photo-section-top { grid-template-columns: 1fr; }
}

.defect-case-list {
    display: grid;
    gap: 12px;
}
.defect-case-card {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
}
.defect-case-card:hover {
    border-color: #cbd5e1;
    transform: translateY(-1px);
}
.defect-case-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}
.detail-list {
    display: grid;
    gap: 10px;
}
.detail-list > div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
}
.detail-list > div strong { min-width: 120px; }
.compact-detail-list { margin-bottom: 14px; }
.compact-detail-list > div { padding: 8px 10px; }
.defect-timeline {
    display: grid;
    gap: 16px;
}
.timeline-item {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
}
.timeline-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 12px;
}
.photo-grid-admin-delete {
    gap: 10px;
}
.photo-delete-card {
    display: grid;
    gap: 8px;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px;
    background: #fff;
}
.photo-delete-card img {
    width: 100%;
    height: 130px;
    object-fit: cover;
    border-radius: 10px;
    display: block;
}
.photo-delete-card span {
    font-size: .92rem;
    color: var(--text);
}
@media (max-width: 900px) {
    .defect-case-card,
    .timeline-head,
    .detail-list > div {
        grid-template-columns: 1fr;
        display: grid;
    }
    .defect-case-meta {
        justify-content: flex-start;
    }
}

.form-section {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 16px;
    padding: 14px;
    margin-top: 12px;
}
.form-section h2,
.form-section h3 {
    font-size: 1rem;
    margin-bottom: 6px;
}
.form-section .help {
    margin-bottom: 10px;
}
.label-row {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.label-row label {
    margin: 0;
}
.help-marker {
    width: 20px;
    height: 20px;
    border-radius: 999px;
    border: 0;
    background: #111827;
    color: #fff;
    font-size: .8rem;
    font-weight: 800;
    padding: 0;
    line-height: 1;
}
.help-popover {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 1000;
}
.help-popover[hidden] {
    display: none;
}
.help-popover-card {
    width: min(460px, 100%);
    background: #fff;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 14px;
    position: relative;
}
.help-popover-close {
    position: absolute;
    right: 10px;
    top: 10px;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    color: #111827;
    padding: 0;
}
.help-popover-title {
    font-weight: 800;
    padding-right: 32px;
    margin-bottom: 10px;
}
.help-popover-section + .help-popover-section {
    margin-top: 10px;
}
.help-popover-section strong {
    display: block;
    margin-bottom: 4px;
}
.help-popover-section p,
.help-popover-body p {
    margin: 0;
    color: var(--text);
}
.field-hint,
.inline-summary {
    font-size: .9rem;
    color: var(--muted);
    margin-top: 4px;
}
.type-preview {
    border: 1px solid var(--border);
    background: #f8fafc;
    border-radius: 14px;
    padding: 12px;
}
.tight-stack {
    display: grid;
    gap: 10px;
}
.response-box {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 14px;
    padding: 12px;
}
.response-box strong {
    display: block;
    margin-bottom: 4px;
}
.photo-upload-box {
    border: 1px solid var(--border);
    background: #f8fafc;
    border-radius: 14px;
    padding: 12px;
}
.photo-upload-box input[type="file"] {
    margin-top: 6px;
}
.compact-form .form-save-bar {
    margin-bottom: 12px;
}
.compact-form textarea {
    min-height: 90px;
}
.inline-note {
    border-left: 3px solid var(--accent);
    padding-left: 10px;
    color: var(--muted);
}
.compact-notice {
    padding: 10px 12px;
}
.action-path-box {
    border: 1px solid var(--border);
    background: #f8fafc;
    border-radius: 14px;
    padding: 12px;
}
.action-steps {
    margin: 6px 0 0;
    padding-left: 18px;
}
.action-steps li + li {
    margin-top: 6px;
}
.stack-actions {
    flex-direction: column;
    align-items: stretch;
}
.stack-actions .button {
    justify-content: center;
}
.defect-case-card-rich {
    align-items: flex-start;
}
.defect-case-meta-stack {
    display: grid;
    gap: 6px;
    justify-items: end;
}
.grid-span-2 {
    grid-column: 1 / -1;
}
@media (max-width: 900px) {
    .defect-case-meta-stack {
        justify-items: start;
    }
    .grid-span-2 {
        grid-column: auto;
    }
}
