:root {
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --bg: #f4f6fa;
  --card-bg: #ffffff;
  --border: #e2e6ee;
  --text: #1f2430;
  --text-muted: #6b7280;
  --ok: #16a34a;
  --belum: #dc2626;
  --na: #9ca3af;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1d4ed8, #1e293b);
}
.login-card {
  background: var(--card-bg);
  padding: 40px 36px;
  border-radius: var(--radius);
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card .subtitle { margin: 0 0 24px; color: var(--text-muted); font-size: 13px; }
.login-card form { display: flex; flex-direction: column; gap: 6px; }
.login-card label { font-size: 13px; font-weight: 600; margin-top: 10px; }
.login-card input {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
}
.login-card button {
  margin-top: 18px; padding: 11px; border: none; border-radius: 8px;
  background: var(--brand); color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
}
.login-card button:hover { background: var(--brand-dark); }
.login-card .hint { margin-top: 16px; font-size: 12px; color: var(--text-muted); text-align: center; }
.alert { padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 6px; }
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

/* ---------- Layout ---------- */
.topbar {
  background: #111827;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  flex-wrap: wrap;
  gap: 10px;
}
.topbar-left h1 { margin: 0; font-size: 18px; }
.topbar-left .company { font-size: 12px; color: #9ca3af; }
.topbar-right { display: flex; align-items: center; gap: 16px; font-size: 14px; }
.topbar-right a { color: #d1d5db; text-decoration: none; }
.topbar-right a.active { color: #fff; font-weight: 700; border-bottom: 2px solid var(--brand); padding-bottom: 3px; }
.topbar-right a:hover { color: #fff; }
.topbar-right .user { color: #9ca3af; }
.topbar-right a.user-link { color: #9ca3af; cursor: pointer; }
.topbar-right a.user-link:hover { color: #fff; text-decoration: underline; }
.btn-link {
  background: none; border: none; color: #d1d5db; cursor: pointer; font-size: 14px; padding: 0;
}
.btn-link:hover { color: #fff; }

.container { max-width: 1400px; margin: 0 auto; padding: 24px; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap;
}
.toolbar input, .toolbar select {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
}
#searchBox, #progressSearch { flex: 1; min-width: 220px; }
.hidden { display: none !important; }

.btn-primary, .btn-secondary, .btn-upgrade, .btn-terminasi {
  padding: 9px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; border: none; text-decoration: none; display: inline-flex; align-items: center;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-upgrade { background: #f59e0b; color: #fff; }
.btn-upgrade:hover { background: #d97706; }
.btn-terminasi { background: #dc2626; color: #fff; }
.btn-terminasi:hover { background: #b91c1c; }
.btn-secondary { background: #e5e7eb; color: #1f2937; }
.btn-secondary:hover { background: #d1d5db; }

.type-badge {
  display: inline-block; padding: 6px 12px; border-radius: 6px; font-weight: 700; font-size: 13px; width: fit-content;
}
.badge-install { background: #dbeafe; color: #1d4ed8; }
.badge-upgrade { background: #fef3c7; color: #b45309; }
.badge-terminasi { background: #fee2e2; color: #b91c1c; }

/* ---------- Table ---------- */
.table-scroll {
  overflow-x: auto;
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
table { border-collapse: collapse; width: 100%; font-size: 13px; white-space: nowrap; }
thead th {
  background: #f1f5f9; text-align: center; padding: 10px 12px; font-weight: 700;
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 3;
}
tbody td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: center; }
tbody td.text-left { text-align: left; }

/* Bekukan 6 kolom pertama: No, Customer ID, Site Name, No IM, Tanggal, Jenis */
#checklistTable th:nth-child(1), #checklistTable td:nth-child(1) { position: sticky; left: 0px;   width: 50px;  min-width: 50px;  max-width: 50px; }
#checklistTable th:nth-child(2), #checklistTable td:nth-child(2) { position: sticky; left: 50px;  width: 100px; min-width: 100px; max-width: 100px; }
#checklistTable th:nth-child(3), #checklistTable td:nth-child(3) { position: sticky; left: 150px; width: 160px; min-width: 160px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
#checklistTable th:nth-child(4), #checklistTable td:nth-child(4) { position: sticky; left: 310px; width: 110px; min-width: 110px; max-width: 110px; }
#checklistTable th:nth-child(5), #checklistTable td:nth-child(5) { position: sticky; left: 420px; width: 100px; min-width: 100px; max-width: 100px; }
#checklistTable th:nth-child(6), #checklistTable td:nth-child(6) {
  position: sticky; left: 520px; width: 110px; min-width: 110px; max-width: 110px;
  box-shadow: 4px 0 6px -2px rgba(0,0,0,0.15);
}
#checklistTable td:nth-child(-n+6) { background: #fff; z-index: 1; }
#checklistTable tbody tr:hover td:nth-child(-n+6) { background: #f8fafc; }
#checklistTable th:nth-child(-n+6) { z-index: 4; }
tbody tr:hover { background: #f8fafc; }
.empty-row { text-align: center; color: var(--text-muted); padding: 30px !important; white-space: normal; }

select.status-select {
  border: 1px solid var(--border); border-radius: 6px; padding: 4px 6px; font-size: 12px; font-weight: 700;
}
.status-pill {
  display: inline-block; padding: 3px 10px; border-radius: 12px; font-weight: 700; font-size: 12px;
}
.status-pill.status-OK { background: #dcfce7; color: var(--ok); }
.status-pill.status-Belum { background: #fee2e2; color: var(--belum); }
.status-dash { color: #cbd5e1; font-weight: 700; }

.status-badge-display {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px;
  font-weight: 700; text-align: center; background: #f9fafb;
}
.status-badge-display.status-OK { color: var(--ok); background: #f0fdf4; border-color: #bbf7d0; }
.status-badge-display.status-Belum { color: var(--belum); background: #fef2f2; border-color: #fecaca; }

.status-OK { color: var(--ok); }
.status-Belum { color: var(--belum); }
.status-NA { color: var(--na); }

.progress-cell { display: flex; align-items: center; gap: 6px; min-width: 100px; }
.mini-bar { flex: 1; height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; }
.mini-bar-fill { height: 100%; border-radius: 4px; }

.icon-btn {
  border: none; background: none; cursor: pointer; font-size: 15px; padding: 4px 6px; border-radius: 6px;
}
.icon-btn:hover { background: #e5e7eb; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: #fff; border-radius: var(--radius); padding: 24px 28px; width: 100%; max-width: 720px;
  max-height: 90vh; overflow-y: auto;
}
.modal-sm { max-width: 380px; }
.modal h2 { margin-top: 0; }
.modal h3 { margin: 18px 0 8px; font-size: 14px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.checklist-grid { grid-template-columns: repeat(3, 1fr); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.field input, .field select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

@media (max-width: 720px) {
  .form-grid, .checklist-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Progress page ---------- */
.summary-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; text-align: center;
}
.card-value { font-size: 28px; font-weight: 800; color: var(--brand); }
.card-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.section-title { font-size: 16px; margin: 24px 0 12px; }
.progress-list {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 20px;
}
.progress-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border);
}
.progress-row:last-child { border-bottom: none; }
.progress-meta { width: 380px; display: flex; gap: 10px; align-items: center; flex-shrink: 0; }
.progress-no { color: var(--text-muted); font-size: 12px; width: 20px; }
.progress-cust { font-size: 12px; color: var(--text-muted); }
.progress-site { font-weight: 600; font-size: 14px; }
.progress-bar-track { flex: 1; height: 10px; background: #e5e7eb; border-radius: 5px; overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 5px; transition: width 0.3s; }
.progress-pct { width: 50px; text-align: right; font-weight: 700; font-size: 13px; }

@media (max-width: 720px) {
  .summary-cards { grid-template-columns: repeat(2, 1fr); }
  .progress-meta { width: 160px; }
  .progress-site { font-size: 12px; }
}

/* ---------- Dokumentasi ---------- */
.docs-upload-form {
  display: flex; gap: 12px; align-items: flex-end; padding: 14px; background: #f8fafc;
  border: 1px solid var(--border); border-radius: 8px; margin: 16px 0; flex-wrap: wrap;
}
.docs-upload-form input[type="file"] { font-size: 13px; }
.docs-hint { font-size: 12px; color: var(--text-muted); margin: -8px 0 12px; }
.docs-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px;
  max-height: 340px; overflow-y: auto; padding: 4px;
}
.doc-card {
  position: relative; border: 1px solid var(--border); border-radius: 8px; padding: 8px;
  text-align: center; background: #fff;
}
.doc-card img {
  width: 100%; height: 90px; object-fit: cover; border-radius: 6px; display: block;
}
.doc-file-icon {
  width: 100%; height: 90px; display: flex; align-items: center; justify-content: center;
  font-size: 36px; background: #f1f5f9; border-radius: 6px;
}
.doc-name {
  font-size: 11px; color: var(--text-muted); margin-top: 6px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.doc-tag {
  position: absolute; top: 6px; left: 6px; background: rgba(37,99,235,0.9); color: #fff;
  font-size: 10px; padding: 2px 6px; border-radius: 4px; font-weight: 600;
}
.btn-del-doc {
  position: absolute; top: 4px; right: 4px; background: rgba(255,255,255,0.9); font-size: 13px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 12px 20px; border-radius: 8px; font-size: 14px; z-index: 100;
}
.toast.hidden { display: none; }
.toast.error { background: #b91c1c; }
