:root {
  --bg: #f2f4f7;
  --card-bg: #ffffff;
  --text: #1f2530;
  --text-muted: #6b7280;
  --border: #e2e5ea;
  --good: #4caf50;
  --good-bg: #dff3e0;
  --warn: #f2a900;
  --warn-bg: #fdecc8;
  --bad: #e05252;
  --bad-bg: #fbdede;
  --brand: #1F4E96;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 20px; background: var(--card-bg); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-size: 18px; font-weight: 700; color: var(--brand); display: flex; align-items: center; gap: 10px; }
.brand-logo { height: 44px; width: auto; display: block; }
.brand-title { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title .brand-main { font-size: 17px; font-weight: 800; color: var(--brand); }
.brand-title .brand-sub { font-size: 11px; font-weight: 500; color: var(--text-muted); }
.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.controls label { color: var(--text-muted); }
select, input, button { font-family: inherit; font-size: 14px; }
select#tanggalPicker, .trend-controls select {
  padding: 6px 10px; border-radius: 6px; border: 1px solid var(--border); background: #fff;
}
.btn-admin, .btn {
  display: inline-block; padding: 7px 14px; border-radius: 6px; background: var(--brand);
  color: #fff; text-decoration: none; border: none; cursor: pointer; font-weight: 600;
}
.btn-admin:hover, .btn:hover { opacity: 0.9; }
.btn-secondary { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn-danger { background: var(--bad); }
main, .table-wrap, .trend-section, .chart-section, .summary-cards, .admin-wrap {
  max-width: 1400px; margin: 0 auto; padding: 16px 20px;
}
.summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; padding-bottom: 0; }
.summary-card {
  background: var(--card-bg); border-radius: 10px; padding: 14px 16px; border-left: 6px solid var(--brand);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06); display: flex; align-items: center; gap: 14px;
}
.summary-card .gauge-box { position: relative; width: 96px; height: 96px; flex-shrink: 0; }
.summary-card .gauge-box canvas { width: 96px !important; height: 96px !important; display: block; }
.summary-card .gauge-fallback {
  width: 96px; height: 96px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; background: #f0f2f5;
}
.summary-card .gauge-label {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 15px; font-weight: 800; text-align: center; pointer-events: none; white-space: nowrap;
}
.summary-card .card-text { min-width: 0; }
.summary-card .pilar-name { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); margin-bottom: 4px; white-space: normal; }
.summary-card .pct { font-size: 22px; font-weight: 800; }
.summary-card .detail { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.dash-table { border-collapse: collapse; width: 100%; min-width: 1300px; background: var(--card-bg); border-radius: 10px; overflow: hidden; font-size: 13px; }
table.dash-table th, table.dash-table td { border: 1px solid var(--border); padding: 6px 8px; text-align: right; white-space: nowrap; }
table.dash-table th.cabang-col, table.dash-table td.cabang-col { text-align: left; position: sticky; left: 0; background: #fff; z-index: 5; font-weight: 600; min-width: 120px; }
table.dash-table thead th { color: #fff; font-weight: 700; }
table.dash-table thead tr.pilar-row th { text-align: center; font-size: 12px; padding: 8px; }
table.dash-table thead tr.sub-row th { font-size: 11px; font-weight: 600; color: #fff; opacity: 0.95; }
table.dash-table tbody tr:nth-child(even) td.cabang-col { background: #fafbfc; }
table.dash-table tfoot td { font-weight: 800; background: #f5f6f8; }
.pct-good { background: var(--good-bg); color: #1e6b23; font-weight: 700; }
.pct-warn { background: var(--warn-bg); color: #8a5c00; font-weight: 700; }
.pct-bad { background: var(--bad-bg); color: #a11f1f; font-weight: 700; }
.trend-section, .chart-section { padding-top: 8px; }
.trend-section h2, .chart-section h2 { font-size: 16px; margin: 8px 0 12px; }
.trend-controls { margin-bottom: 10px; }
.trend-chart-box { background: var(--card-bg); border-radius: 10px; padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); position: relative; }
.chart-empty-msg { color: var(--text-muted); font-size: 13px; text-align: center; padding: 40px 0; }
footer.hint { text-align: center; color: var(--text-muted); font-size: 12px; padding: 20px; }
.login-box { max-width: 360px; margin: 80px auto; background: var(--card-bg); padding: 28px; border-radius: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.08); text-align: center; }
.login-box .brand-logo { height: 56px; margin-bottom: 16px; }
.login-box h1 { font-size: 18px; margin-bottom: 18px; color: var(--brand); }
.login-box input { width: 100%; padding: 10px; border-radius: 6px; border: 1px solid var(--border); margin-bottom: 12px; }
.login-box .btn { width: 100%; padding: 10px; }
.error-msg { color: var(--bad); font-size: 13px; margin-top: 6px; min-height: 18px; }
.success-msg { color: var(--good); font-size: 13px; margin-top: 6px; min-height: 18px; }
.warn-msg { color: #a15c00; font-size: 13px; margin: 8px 0; padding: 8px 10px; background: #fdecc8; border-radius: 6px; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tab-btn { padding: 10px 16px; border: none; background: none; cursor: pointer; font-weight: 600; color: var(--text-muted); border-bottom: 3px solid transparent; }
.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.admin-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
input[type="number"], input[type="text"], input[type="date"] { padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border); width: 100%; }
table.admin-table input[type="number"] { width: 110px; text-align: right; }
table.admin-table th, table.admin-table td { border: 1px solid var(--border); padding: 4px 6px; }
table.admin-table td.readonly-val { color: var(--text-muted); text-align: right; padding: 4px 8px; }
.cabang-manage-row { display: grid; grid-template-columns: 2fr repeat(6, 1fr) auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.cabang-manage-row.header-row { font-weight: 700; font-size: 12px; color: var(--text-muted); }
.periode-box { background: var(--card-bg); border-radius: 10px; padding: 16px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); }
.periode-box h3 { margin: 0 0 10px; font-size: 14px; }
.periode-fields { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.periode-field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.periode-field input { width: auto; }
.periode-normal-table { border-collapse: collapse; margin-top: 16px; max-width: 340px; font-size: 14px; }
.periode-normal-table th, .periode-normal-table td { border: 1px solid var(--border); padding: 8px 12px; text-align: center; }
.periode-normal-table th { background: #3d4457; color: #fff; font-size: 15px; letter-spacing: 0.5px; }
.periode-normal-table td:first-child { font-weight: 700; text-align: left; }
.periode-normal-table .pn-highlight { background: #f2c48a; font-weight: 700; }
.periode-normal-table .pn-box { font-weight: 700; outline: 2px solid #2e7d46; outline-offset: -2px; }
@media (max-width: 640px) {
  .topbar { padding: 8px 12px; }
  .brand-logo { height: 36px; }
  .brand-title .brand-main { font-size: 15px; }
  .brand-title .brand-sub { display: none; }
  main, .table-wrap, .trend-section, .chart-section, .summary-cards, .admin-wrap { padding: 12px; }
  .login-box { margin: 40px 16px; }
  .summary-card { flex-direction: column; text-align: center; }
}
