@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --border: #E1E4EA;
  --text: #1A2332;
  --text-muted: #616B7A;
  --text-faint: #8A93A2;

  --primary: #1D5AAE;
  --primary-dark: #123E80;
  --primary-tint: #E8F0FC;

  --success: #1B8A5A;
  --success-tint: #E4F5EC;
  --warning: #B9720F;
  --warning-tint: #FCF0DC;
  --danger: #C23B2E;
  --danger-tint: #FBEAE7;
  --neutral-tint: #EEF0F3;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(20, 30, 50, 0.06);
  --shadow: 0 4px 16px rgba(20, 30, 50, 0.08);

  --font-ui: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 8px; font-weight: 600; letter-spacing: -0.01em; }
button, input, select, textarea { font-family: var(--font-ui); font-size: 15px; }

:focus-visible {
  outline: 3px solid #8FB6EA;
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- Layout shell ---------- */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between;
  height: 60px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--text); }
.topbar-brand .mark {
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--primary); color: white; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-weight: 600; font-size: 13px; letter-spacing: -0.02em;
}
.topbar-nav { display: flex; gap: 4px; align-items: center; }
.topbar-nav a {
  color: var(--text-muted); font-weight: 500; font-size: 14px; padding: 8px 12px; border-radius: var(--radius-sm);
}
.topbar-nav a:hover { background: var(--neutral-tint); text-decoration: none; }
.topbar-nav a.active { color: var(--primary); background: var(--primary-tint); }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.user-chip { font-size: 13px; color: var(--text-muted); text-align: right; }
.user-chip strong { color: var(--text); display: block; font-size: 14px; }
.btn-logout { background: none; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 7px 12px; cursor: pointer; font-size: 13px; color: var(--text-muted); }
.btn-logout:hover { background: var(--neutral-tint); }

.main-content { flex: 1; padding: 24px 20px 60px; max-width: 1180px; width: 100%; margin: 0 auto; }

.mobile-tabbar {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.mobile-tabbar-inner { display: flex; justify-content: space-around; }
.mobile-tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11px; color: var(--text-faint); font-weight: 500; padding: 6px 8px; border-radius: var(--radius-sm);
  min-width: 56px;
}
.mobile-tabbar a.active { color: var(--primary); }
.mobile-tabbar svg { width: 22px; height: 22px; }
.mobile-tabbar .fab {
  background: var(--primary); color: white; width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; margin-top: -18px; box-shadow: var(--shadow);
}
.mobile-tabbar .fab svg { width: 22px; height: 22px; }

@media (max-width: 780px) {
  .topbar-nav { display: none; }
  .mobile-tabbar { display: block; }
  .main-content { padding: 16px 12px 90px; }
  .user-chip { display: none; }
}

/* ---------- Flash messages ---------- */
.flash { border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.flash-error { background: var(--danger-tint); color: #7A2A21; border: 1px solid #EFC9C2; }
.flash-success { background: var(--success-tint); color: #145A3B; border: 1px solid #BEE3CE; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header h1 { font-size: 22px; }
.page-subtitle { color: var(--text-muted); font-size: 14px; margin-top: 2px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--radius-sm); border: 1px solid transparent; padding: 10px 16px;
  font-weight: 600; font-size: 14px; cursor: pointer; min-height: 40px; line-height: 1;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--neutral-tint); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline-danger { background: transparent; color: var(--danger); border-color: #EFC9C2; }
.btn-sm { padding: 7px 12px; font-size: 13px; min-height: 34px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--text); }
.field .hint { font-size: 12px; color: var(--text-faint); margin-top: 4px; }
.field input[type=text], .field input[type=number], .field input[type=date], .field input[type=password],
.field select, .field textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
}
.field textarea { resize: vertical; min-height: 80px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.required::after { content: " *"; color: var(--danger); }
.file-drop {
  border: 1.5px dashed var(--border); border-radius: var(--radius); padding: 20px; text-align: center; color: var(--text-muted);
  background: var(--neutral-tint); cursor: pointer; font-size: 13px;
}
.file-drop:hover { border-color: var(--primary); }
.file-preview-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.file-preview-list img { width: 64px; height: 64px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); }

/* ---------- Badges / plates (signage-inspired) ---------- */
.code-plate {
  font-family: var(--font-mono); font-weight: 600; font-size: 12.5px; letter-spacing: 0.02em;
  border: 1.5px solid var(--text); color: var(--text); border-radius: var(--radius-sm);
  padding: 3px 8px; display: inline-block; background: var(--surface);
}
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 100px; white-space: nowrap; }
.pill-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-ok { background: var(--success-tint); color: var(--success); }
.pill-warn { background: var(--warning-tint); color: var(--warning); }
.pill-due { background: var(--warning-tint); color: var(--warning); }
.pill-overdue { background: var(--danger-tint); color: var(--danger); }
.pill-done { background: var(--neutral-tint); color: var(--text-muted); }

.priority-Kritis { background: var(--danger-tint); color: var(--danger); }
.priority-Tinggi { background: var(--warning-tint); color: var(--warning); }
.priority-Sedang { background: var(--primary-tint); color: var(--primary); }
.priority-Rendah { background: var(--neutral-tint); color: var(--text-muted); }

.status-pill { background: var(--neutral-tint); color: var(--text); }
.status-Closed { background: var(--success-tint); color: var(--success); }
.status-Menunggu-Verifikasi { background: var(--primary-tint); color: var(--primary); }
.status-Perlu-Perbaikan-Ulang { background: var(--danger-tint); color: var(--danger); }

/* ---------- Timeline / cards grid ---------- */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; align-items: center; }
.filter-bar select, .filter-bar input[type=text] {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font-size: 13px;
}
.filter-chip {
  border: 1px solid var(--border); border-radius: 100px; padding: 6px 12px; font-size: 13px; font-weight: 500;
  background: var(--surface); color: var(--text-muted); cursor: pointer;
}
.filter-chip.active { background: var(--primary); color: white; border-color: var(--primary); }

.findings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.finding-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; transition: box-shadow 0.15s; }
.finding-card:hover { box-shadow: var(--shadow); text-decoration: none; }
.finding-card .thumb { height: 140px; background: var(--neutral-tint) center/cover no-repeat; position: relative; }
.finding-card .thumb .no-photo { display: flex; height: 100%; align-items: center; justify-content: center; color: var(--text-faint); font-size: 12px; }
.finding-card .body { padding: 14px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.finding-card .top-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.finding-card .desc { color: var(--text); font-size: 13.5px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.finding-card .meta { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; color: var(--text-muted); }
.finding-card .meta span { display: inline-flex; align-items: center; gap: 4px; }
.progress-bar { height: 6px; border-radius: 100px; background: var(--neutral-tint); overflow: hidden; }
.progress-bar > div { height: 100%; background: var(--primary); }
.finding-card .bottom-row { display: flex; justify-content: space-between; align-items: center; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state svg { width: 56px; height: 56px; color: var(--text-faint); margin-bottom: 14px; }

/* ---------- Detail page ---------- */
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.detail-section { padding: 18px; border-bottom: 1px solid var(--border); }
.detail-section:last-child { border-bottom: none; }
.detail-section h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); margin-bottom: 10px; }
.kv-grid { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; font-size: 14px; }
.kv-grid dt { color: var(--text-muted); }
.kv-grid dd { margin: 0; }

.photo-tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 14px; overflow-x: auto; }
.photo-tabs button { background: none; border: none; padding: 10px 4px; font-weight: 600; font-size: 13px; color: var(--text-faint); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; margin-right: 14px; }
.photo-tabs button.active { color: var(--primary); border-color: var(--primary); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.photo-grid figure { margin: 0; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); background: var(--neutral-tint); }
.photo-grid img { width: 100%; height: 120px; object-fit: cover; display: block; cursor: zoom-in; }
.photo-grid figcaption { font-size: 11px; padding: 5px 7px; color: var(--text-muted); }
.photo-panel { display: none; }
.photo-panel.active { display: block; }

.compare-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.compare-row figure { margin: 0; }
.compare-row img { width: 100%; height: 180px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.compare-row figcaption { text-align: center; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-top: 4px; }
@media (max-width: 640px) { .compare-row { grid-template-columns: 1fr; } }

.lightbox-overlay { position: fixed; inset: 0; background: rgba(10,15,25,0.9); display: none; align-items: center; justify-content: center; z-index: 200; padding: 24px; }
.lightbox-overlay.open { display: flex; }
.lightbox-overlay img { max-width: 100%; max-height: 90vh; border-radius: 6px; }
.lightbox-close { position: absolute; top: 18px; right: 20px; color: white; background: rgba(255,255,255,0.12); border: none; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: 18px; }

.timeline-log { list-style: none; margin: 0; padding: 0; }
.timeline-log li { position: relative; padding: 0 0 16px 20px; border-left: 2px solid var(--border); }
.timeline-log li:last-child { border-color: transparent; padding-bottom: 0; }
.timeline-log li::before { content: ''; position: absolute; left: -5px; top: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.timeline-log .time { font-size: 11.5px; color: var(--text-faint); }
.timeline-log .action { font-weight: 600; font-size: 13.5px; }
.timeline-log .detail { font-size: 13px; color: var(--text-muted); }

.comment { padding: 10px 0; border-bottom: 1px solid var(--border); }
.comment:last-child { border-bottom: none; }
.comment .who { font-weight: 600; font-size: 13px; }
.comment .when { font-size: 11.5px; color: var(--text-faint); margin-left: 6px; }
.comment .text { font-size: 13.5px; margin-top: 3px; }

.side-action-card { margin-bottom: 14px; }
.side-action-card h4 { font-size: 13.5px; margin-bottom: 10px; }

/* ---------- Dashboard ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
@media (max-width: 900px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card { padding: 16px; }
.stat-card .value { font-size: 26px; font-weight: 700; font-family: var(--font-mono); }
.stat-card .label { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.stat-card.tone-danger .value { color: var(--danger); }
.stat-card.tone-success .value { color: var(--success); }
.stat-card.tone-warning .value { color: var(--warning); }

.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } }
.bar-chart { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 36px; align-items: center; gap: 8px; font-size: 12.5px; }
.bar-row .track { height: 10px; background: var(--neutral-tint); border-radius: 100px; overflow: hidden; }
.bar-row .track > div { height: 100%; background: var(--primary); border-radius: 100px; }
.bar-row .label { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .num { text-align: right; font-family: var(--font-mono); color: var(--text-muted); }

/* ---------- Tables (admin) ---------- */
table.simple-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.simple-table th { text-align: left; color: var(--text-muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.02em; padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.simple-table td { padding: 10px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.simple-table tbody tr:hover { background: var(--neutral-tint); }
.table-scroll { overflow-x: auto; }

.tabs { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs a { padding: 10px 14px; font-weight: 600; font-size: 13.5px; color: var(--text-muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--primary); border-color: var(--primary); }

.modal-overlay { position: fixed; inset: 0; background: rgba(10,15,25,0.45); display: none; align-items: center; justify-content: center; z-index: 150; padding: 16px; }
.modal-overlay.open { display: flex; }
.modal-box { background: var(--surface); border-radius: var(--radius); padding: 20px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; }
.modal-box h3 { margin-bottom: 14px; }
.modal-close-row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.skeleton { background: linear-gradient(90deg, var(--neutral-tint) 25%, #E4E7EC 37%, var(--neutral-tint) 63%); background-size: 400% 100%; animation: skeleton 1.4s ease infinite; border-radius: var(--radius-sm); }
@keyframes skeleton { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.offline-banner { background: var(--warning-tint); color: var(--warning); font-size: 13px; padding: 8px 16px; text-align: center; display: none; }
.offline-banner.show { display: block; }

.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 20px; }
.login-box { width: 100%; max-width: 380px; }
.login-brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 24px; }
.login-brand .mark { width: 38px; height: 38px; border-radius: 9px; background: var(--primary); color: white; display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-weight: 600; }
.login-brand span { font-weight: 700; font-size: 19px; }
.login-demo { font-size: 12px; color: var(--text-muted); background: var(--neutral-tint); border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 16px; }
.login-demo code { font-family: var(--font-mono); background: var(--surface); padding: 1px 5px; border-radius: 4px; }

.error-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 24px; }
.error-box { max-width: 460px; text-align: center; }
.error-box .code { font-family: var(--font-mono); color: var(--text-faint); font-size: 13px; margin-top: 14px; }

.text-muted { color: var(--text-muted); }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.section-divider { height: 1px; background: var(--border); margin: 20px 0; }
