:root {
  --bg: #f4f5fb;
  --card: #ffffff;
  --ink: #1e2333;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-soft: #eef0ff;
  --green: #16a34a;
  --green-soft: #e8f7ee;
  --amber: #d97706;
  --amber-soft: #fdf3e3;
  --blue: #2563eb;
  --red: #dc2626;
  --border: #e5e7eb;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(30, 35, 51, .07), 0 8px 24px rgba(30, 35, 51, .06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 2px rgba(30, 35, 51, .04);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.brand h1 { font-size: 20px; }
.subtitle { font-size: 12.5px; color: var(--muted); }

.controls { display: flex; align-items: center; gap: 10px; }
.select-wrap {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--muted);
}
.select-wrap select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  font-size: 13.5px;
  color: var(--ink);
  cursor: pointer;
}
#refreshBtn {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  font-size: 17px;
  cursor: pointer;
  color: var(--primary);
  transition: transform .3s;
}
#refreshBtn:hover { background: var(--primary-soft); }
#refreshBtn.spin { animation: spin .6s linear; }
@keyframes spin { to { transform: rotate(360deg); } }

.live-badge {
  font-size: 12px;
  color: var(--green);
  background: var(--green-soft);
  padding: 5px 10px;
  border-radius: 999px;
  font-weight: 600;
}
.live-badge.off { color: var(--muted); background: #f3f4f6; }

/* ---------- Layout ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 24px 20px 40px; }

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.stat-label { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.stat-value { font-size: 30px; font-weight: 700; margin-top: 4px; }
.stat-value.green { color: var(--green); }
.stat-value.amber { color: var(--amber); }
.stat-value.blue { color: var(--blue); }

/* ---------- Kartu minggu ---------- */
.weeks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.week-card { position: relative; }
.week-card .wk-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.week-card .wk-title { font-weight: 600; font-size: 14.5px; }
.week-card .wk-count { font-size: 12px; color: var(--muted); }

.progress-track {
  height: 9px;
  background: #eceef5;
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0 10px;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), #7c3aed);
  transition: width .5s ease;
}
.progress-fill.done { background: linear-gradient(90deg, var(--green), #22c55e); }

.wk-done { font-size: 12.5px; color: var(--green); font-weight: 600; }

/* ---------- Grid 2 kolom ---------- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 14px;
}
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

.grid-2 h2 { font-size: 15px; margin-bottom: 14px; }
.chart-box { position: relative; height: 300px; }

/* ---------- Tabel ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
td { padding: 9px 10px; border-bottom: 1px solid #f0f1f6; }
tbody tr:hover { background: #fafaff; }

.badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge.done { background: var(--green-soft); color: var(--green); }
.badge.run { background: var(--amber-soft); color: var(--amber); }

.mini-progress { min-width: 110px; }
.mini-progress .progress-track { margin: 4px 0 0; }
.prog-text { font-size: 12px; color: var(--muted); }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 30px 10px;
  font-size: 14px;
}

/* ---------- Form tambah proker ---------- */
.add-card { margin-bottom: 14px; }
.add-card h2 { font-size: 15px; margin-bottom: 12px; }
.add-form { display: flex; gap: 10px; flex-wrap: wrap; }
.add-form input[type="text"] { flex: 1 1 260px; }
.add-form input[type="number"] { width: 110px; }
.add-form input {
  padding: 10px 13px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
}
.add-form input:focus { border-color: var(--primary); }
.add-form button {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity .2s;
}
.add-form button:hover { opacity: .9; }
.add-hint { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ---------- Aksi di tabel ---------- */
.actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.prog-input {
  width: 64px;
  padding: 6px 8px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
  outline: none;
}
.prog-input:focus { border-color: var(--primary); }
.btn {
  padding: 6px 10px;
  font-size: 12.5px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: opacity .2s;
  white-space: nowrap;
}
.btn:hover { opacity: .85; }
.btn-add-prog { background: var(--primary-soft); color: var(--primary); }
.btn-copy { background: var(--blue); color: #fff; }
.btn-del { background: #fee2e2; color: var(--red); }
.btn-week { margin-top: 8px; background: var(--primary-soft); color: var(--primary); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e2333;
  color: #fff;
  font-size: 13.5px;
  padding: 12px 20px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  z-index: 200;
  max-width: 90vw;
  transition: opacity .3s, transform .3s;
}
.toast.hidden { opacity: 0; transform: translateX(-50%) translateY(10px); pointer-events: none; }
.toast.err { background: var(--red); }

/* ---------- Footer ---------- */
footer {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 18px;
}

/* ---------- Layar login ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 35, 51, .55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}
.overlay.hidden { display: none; }
.login-card {
  width: 100%;
  max-width: 340px;
  text-align: center;
  padding: 30px 26px;
}
.login-card h2 { font-size: 18px; margin-bottom: 4px; }
.login-hint { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.login-card input {
  width: 100%;
  padding: 11px 14px;
  font-size: 18px;
  letter-spacing: 6px;
  text-align: center;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  margin-bottom: 12px;
  outline: none;
  transition: border-color .2s;
}
.login-card input:focus { border-color: var(--primary); }
.login-card button {
  width: 100%;
  padding: 11px;
  font-size: 14.5px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity .2s;
}
.login-card button:hover { opacity: .9; }
.login-msg { font-size: 12.5px; margin-top: 10px; min-height: 18px; }
.login-msg.err { color: var(--red); }
.login-msg.ok { color: var(--green); }

@media (max-width: 520px) {
  .topbar { padding: 14px 16px; }
  .controls { width: 100%; justify-content: space-between; }
}
