:root {
  --bg: #f4f5f7;
  --card-bg: #ffffff;
  --text: #1b1e23;
  --muted: #6b7280;
  --border: #e3e5e9;
  --accent: #2f6feb;
  --active: #1a9e5c;
  --idle: #d9a005;
  --offline: #9aa0a8;
  --inactive-tracking: #7c5cbf;
  --cat-productive: #1a9e5c;
  --cat-jembatan: #3f8fbf;
  --cat-distracting: #d64545;
  --cat-uncategorized: #c7cad1;
  --cat-no-activity: #d9a005;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}

.topbar h1 { font-size: 18px; margin: 0; }
.back-link { text-decoration: none; color: var(--text); margin-right: 6px; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.link-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  color: var(--muted);
}

.secondary-btn {
  display: inline-block;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  text-decoration: none;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 20px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

.card h3 { margin: 0 0 8px; font-size: 16px; }
.card a { color: inherit; text-decoration: none; }

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  color: #fff;
}
.badge.active { background: var(--active); }
.badge.idle { background: var(--idle); }
.badge.offline { background: var(--offline); }
.badge.inactive-tracking { background: var(--inactive-tracking); }
/* Dihentikan karyawan -- sengaja BEDA warna dari offline: yang satu
   keputusan orangnya, yang satu lagi alatnya mati. */
.badge.dihentikan { background: #8a6d3b; }
.badge.assignable { background: var(--accent); margin-left: 4px; }

.card .meta { color: var(--muted); font-size: 13px; margin-top: 8px; }

.panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
.panel h2 { font-size: 15px; margin: 0 0 10px; }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  cursor: pointer;
  font-size: 14px;
}
button:disabled { opacity: 0.6; cursor: default; }

.muted { color: var(--muted); font-size: 13px; }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.data-table th { color: var(--muted); font-weight: 600; }

.screenshot-preview {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 10px;
  border: 1px solid var(--border);
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.gallery img {
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
}
.gallery .shot-time { font-size: 11px; color: var(--muted); margin-top: 3px; }

.empty-state { color: var(--muted); text-align: center; padding: 40px 0; }

.bq-block { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.bq-score { font-size: 34px; font-weight: 700; line-height: 1; }

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-bq {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}

.timeline-wrap { margin-bottom: 6px; }
.timeline-bar {
  position: relative;
  height: 28px;
  background: var(--bg);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.timeline-segment {
  position: absolute;
  top: 0;
  bottom: 0;
}
.timeline-hours {
  position: relative;
  height: 16px;
  font-size: 11px;
  color: var(--muted);
}
.timeline-hours span {
  position: absolute;
  transform: translateX(-50%);
}

.timeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  margin: 10px 0;
}
.timeline-legend .dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 4px;
}
.dot.productive { background: var(--cat-productive); }
.dot.jembatan { background: var(--cat-jembatan); }
.dot.distracting { background: var(--cat-distracting); }
.dot.uncategorized { background: var(--cat-uncategorized); }
.dot.no-activity { background: var(--cat-no-activity); }

.attendance-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  font-size: 13px;
  margin-top: 8px;
}

.order-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
}
.order-row.flagged { border-left: 4px solid var(--idle); }
.order-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.reasons {
  margin: 8px 0 6px;
  padding-left: 18px;
  font-size: 13px;
  color: var(--text);
}
.reasons li { margin-bottom: 2px; }

/* Tabel lebar digeser di dalam kotaknya sendiri, supaya halaman tidak
   ikut menggeser ke samping di layar ponsel. */
.table-scroll { overflow-x: auto; }
.data-table.wide { min-width: 560px; }

.cat-buttons { display: flex; gap: 4px; flex-wrap: nowrap; }
.cat-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
}
.cat-btn.on-productive { background: var(--cat-productive); border-color: var(--cat-productive); color: #fff; }
.cat-btn.on-jembatan { background: var(--cat-jembatan); border-color: var(--cat-jembatan); color: #fff; }
.cat-btn.on-distracting { background: var(--cat-distracting); border-color: var(--cat-distracting); color: #fff; }
.cat-btn.on-neutral { background: var(--bg); color: var(--text); }
.tiny { font-size: 11px; margin-top: 3px; }

.rule-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}
.rule-form input {
  flex: 1;
  min-width: 200px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}
.rule-form select {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 280px;
  text-align: center;
}
.login-card h1 { margin: 0 0 2px; }
.login-card .subtitle { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.login-card input {
  width: 100%;
  padding: 10px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}
.login-card button { width: 100%; }
.login-card .error { color: #d64545; font-size: 13px; margin-bottom: 10px; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --card-bg: #1d2025;
    --text: #e7e9ec;
    --muted: #9aa0a8;
    --border: #2c3036;
  }
}
