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

:root {
  --emerald-950: #022c22;
  --emerald-900: #064e3b;
  --emerald-800: #065f46;
  --emerald-700: #047857;
  --emerald-600: #059669;
  --emerald-100: #d1fae5;
  --emerald-50:  #ecfdf5;
  --bg: #f4f7f6;
  --card: #ffffff;
  --border: #e3e8e6;
  --ink: #0f172a;
  --ink-2: #52514e;
  --ink-muted: #898781;
  --grid: #e1e0d9;
  --series: #008300;      /* seri tunggal grafik */
  --danger: #d03b3b;
  --warning: #b45309;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(2, 44, 34, 0.07);
}

html, body { height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
}

.hidden { display: none !important; }

h1, h2, h3 { letter-spacing: -0.01em; }

/* ====== Login ====== */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1000px 500px at 85% -10%, rgba(5, 150, 105, 0.35), transparent 60%),
    radial-gradient(800px 500px at -10% 110%, rgba(6, 95, 70, 0.45), transparent 60%),
    var(--emerald-950);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: 20px;
  padding: 36px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.login-brand h1 { font-size: 19px; }
.login-brand p { font-size: 13px; color: var(--ink-muted); }
.brand-badge {
  display: grid; place-items: center;
  width: 46px; height: 46px; flex: none;
  border-radius: 50%;
  background: var(--emerald-600);
  color: #fff; font-weight: 800; font-size: 17px;
}
#login-form label { display: block; font-size: 13px; font-weight: 600; margin: 14px 0 6px; color: var(--ink-2); }
#login-form input {
  width: 100%; padding: 11px 14px;
  border: 1px solid var(--border); border-radius: 10px;
  font: inherit; font-size: 14px;
}
#login-form input:focus { outline: 2px solid var(--emerald-600); outline-offset: -1px; border-color: transparent; }
.form-error { color: var(--danger); font-size: 13px; margin-top: 12px; }
.login-demo { margin-top: 24px; border-top: 1px solid var(--border); padding-top: 16px; }
.login-demo p { font-size: 12px; color: var(--ink-muted); margin-bottom: 8px; }
.demo-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.demo-chip {
  font-size: 12px; padding: 5px 10px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--emerald-50); color: var(--emerald-800);
}
.demo-chip:hover { background: var(--emerald-100); }

/* ====== Kerangka aplikasi ====== */
#app { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px; flex: none;
  background: var(--emerald-950);
  color: #d7e8e2;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-brand strong { display: block; font-size: 15px; color: #fff; }
.sidebar-brand small { font-size: 11.5px; color: rgba(215, 232, 226, 0.65); }

#sidebar-nav { flex: 1; padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: 10px;
  color: rgba(215, 232, 226, 0.85);
  text-decoration: none; font-size: 14px; font-weight: 500;
}
.nav-link .nav-ico { width: 20px; text-align: center; font-size: 16px; }
.nav-link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.nav-link.active { background: var(--emerald-700); color: #fff; }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.user-avatar {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--emerald-600); color: #fff;
  font-weight: 700; font-size: 14px;
}
.user-meta { min-width: 0; flex: 1; }
.user-meta strong { display: block; font-size: 13px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small { font-size: 11.5px; color: rgba(215, 232, 226, 0.65); }
.btn-icon {
  border: none; background: rgba(255, 255, 255, 0.08); color: #fff;
  width: 32px; height: 32px; border-radius: 8px; cursor: pointer; font-size: 15px;
}
.btn-icon:hover { background: var(--danger); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 19px; }
.topbar-date { font-size: 13px; color: var(--ink-muted); }

#view { padding: 26px 28px 40px; }

/* ====== Komponen umum ====== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.card + .card, .section-gap { margin-top: 20px; }
.card h2 { font-size: 16px; margin-bottom: 4px; }
.card .card-sub { font-size: 13px; color: var(--ink-muted); margin-bottom: 14px; }

.grid-stats {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-bottom: 20px;
}
.stat-tile { display: flex; gap: 14px; align-items: center; }
.stat-ico {
  width: 46px; height: 46px; flex: none;
  display: grid; place-items: center;
  font-size: 20px; border-radius: 12px;
  background: var(--emerald-50); color: var(--emerald-700);
}
.stat-tile .stat-val { font-size: 26px; font-weight: 800; line-height: 1.1; }
.stat-tile .stat-label { font-size: 12.5px; color: var(--ink-muted); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 16px; }
.toolbar .field { display: flex; flex-direction: column; gap: 5px; }
.toolbar label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.toolbar .spacer { flex: 1; }

select, input[type="text"], input[type="email"], input[type="password"], input[type="number"], textarea {
  padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 9px;
  font: inherit; font-size: 14px; background: #fff; color: var(--ink);
}
select:focus, input:focus, textarea:focus { outline: 2px solid var(--emerald-600); outline-offset: -1px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px;
  border: 1px solid transparent; border-radius: 9px;
  font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--emerald-600); color: #fff; }
.btn-primary:hover { background: var(--emerald-700); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--ink-2); }
.btn-outline:hover { border-color: var(--emerald-600); color: var(--emerald-700); }
.btn-danger-outline { background: #fff; border-color: var(--border); color: var(--danger); }
.btn-danger-outline:hover { border-color: var(--danger); background: #fef2f2; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; margin-top: 18px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.seg-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.seg-toggle button {
  border: none; background: #fff; padding: 8px 14px;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer;
}
.seg-toggle button.active { background: var(--emerald-600); color: #fff; }

/* ====== Tabel ====== */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--ink-muted); font-weight: 600;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--emerald-50); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-role-admin { background: #ede9fe; color: #5b21b6; }
.badge-role-kepala { background: #dbeafe; color: #1d4ed8; }
.badge-role-koordinator { background: #fef3c7; color: #92400e; }
.badge-role-pelaksana { background: var(--emerald-100); color: var(--emerald-800); }
.badge-periode { background: #f1f5f9; color: #334155; }
.badge-klaster { background: #ede9fe; color: #5b21b6; cursor: default; }
.badge-jenis-harian { background: #ffedd5; color: #9a3412; }
.badge-jenis-umum { background: #e0f2fe; color: #075985; }

.badge-status-terjadwal { background: #dbeafe; color: #1d4ed8; }
.badge-status-berlangsung { background: #fef3c7; color: #92400e; }
.badge-status-selesai { background: var(--emerald-100); color: var(--emerald-800); }

.progress { height: 8px; background: var(--grid); border-radius: 999px; min-width: 90px; overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: var(--series); }
.progress-cell { display: flex; align-items: center; gap: 10px; }
.progress-cell .pct { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; min-width: 52px; }
.text-muted { color: var(--ink-muted); }
.small { font-size: 12.5px; }

/* ====== Grid checklist ====== */
.check-grid-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
table.check-grid { border-collapse: collapse; font-size: 13px; width: 100%; }
table.check-grid th, table.check-grid td {
  border: 1px solid var(--border);
  padding: 6px 8px; text-align: center; min-width: 34px;
}
table.check-grid th { background: #f8faf9; font-size: 11.5px; color: var(--ink-2); font-weight: 600; }
table.check-grid th.today-col, table.check-grid td.today-col { background: var(--emerald-50); }
table.check-grid .item-col {
  text-align: left; min-width: 220px; max-width: 320px;
  position: sticky; left: 0; background: #fff; z-index: 2;
  font-weight: 500;
}
table.check-grid th.item-col { background: #f8faf9; z-index: 3; }
table.check-grid input[type="checkbox"] {
  width: 17px; height: 17px; accent-color: var(--emerald-600); cursor: pointer;
}
.mark-yes { color: var(--series); font-weight: 700; }
.mark-no { color: var(--grid); }

/* ====== Grafik ====== */
.charts-row { display: grid; gap: 20px; grid-template-columns: 2fr 1fr; margin-top: 20px; }
@media (max-width: 1000px) { .charts-row { grid-template-columns: 1fr; } }
.chart-box { position: relative; height: 280px; }
.chart-box-sm { position: relative; height: 240px; }

/* ====== Form ====== */
.form-grid { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
.form-grid .full { grid-column: 1 / -1; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.form-field .hint { font-size: 12px; color: var(--ink-muted); }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }

.item-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.item-row .item-no {
  width: 28px; height: 28px; flex: none;
  display: grid; place-items: center;
  background: var(--emerald-50); color: var(--emerald-800);
  border-radius: 8px; font-size: 12.5px; font-weight: 700;
}
.item-row input { flex: 1; }
.item-row .btn-remove {
  border: none; background: none; color: var(--ink-muted);
  font-size: 17px; cursor: pointer; width: 30px; height: 30px; border-radius: 8px;
}
.item-row .btn-remove:hover { background: #fef2f2; color: var(--danger); }

.radio-cards { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.radio-card {
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; cursor: pointer; display: block;
}
.radio-card input { margin-right: 8px; accent-color: var(--emerald-600); }
.radio-card.selected { border-color: var(--emerald-600); background: var(--emerald-50); }
.radio-card.disabled { opacity: 0.5; cursor: not-allowed; }
.radio-card strong { font-size: 14px; }
.radio-card p { font-size: 12px; color: var(--ink-muted); margin-top: 3px; }

/* ====== Kartu pilihan monitoring ====== */
.pick-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.pick-card { display: flex; flex-direction: column; gap: 8px; }
.pick-card h3 { font-size: 15px; }
.pick-card .badges { display: flex; gap: 6px; flex-wrap: wrap; }
.pick-card .desc { font-size: 13px; color: var(--ink-muted); flex: 1; }
.pick-card .btn { align-self: flex-start; margin-top: 6px; }

/* ====== Toast ====== */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff;
  padding: 11px 20px; border-radius: 10px;
  font-size: 14px; z-index: 100;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
.toast.toast-error { background: var(--danger); }

.lockbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: 10px; margin-bottom: 16px;
}
.lockbar .lock-ico { font-size: 22px; }
.lockbar-locked { background: #fef3c7; border: 1px solid #fcd34d; color: #92400e; }
.lockbar-locked strong { color: #78350f; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-muted); }
.empty-state .big { font-size: 34px; margin-bottom: 10px; }

/* ====== Notulensi Rapat ====== */
.editor-toolbar {
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
  border: 1px solid var(--border); border-bottom: none;
  border-radius: 10px 10px 0 0; padding: 6px; background: #f8faf9;
}
.editor-toolbar button {
  min-width: 32px; height: 30px; padding: 0 8px;
  border: 1px solid transparent; background: none; border-radius: 6px;
  font: inherit; font-size: 13px; cursor: pointer; color: var(--ink-2);
}
.editor-toolbar button:hover { background: #fff; border-color: var(--border); }
.editor-toolbar .tb-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.editor {
  border: 1px solid var(--border); border-radius: 0 0 10px 10px;
  padding: 14px 16px; min-height: 220px; font-size: 14px; line-height: 1.6;
  outline: none; overflow-y: auto; max-height: 460px;
}
.editor:focus { border-color: var(--emerald-600); box-shadow: inset 0 0 0 1px var(--emerald-600); }
.editor h2, .editor-readonly h2 { font-size: 17px; margin: 12px 0 6px; }
.editor h3, .editor-readonly h3 { font-size: 15px; margin: 10px 0 5px; }
.editor p, .editor-readonly p { margin: 6px 0; }
.editor ul, .editor ol, .editor-readonly ul, .editor-readonly ol { margin: 6px 0 6px 22px; }
.editor-readonly { font-size: 14px; line-height: 1.6; min-height: 120px; }

.qr-box { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.qr-img { width: 100%; max-width: 220px; height: auto; border: 1px solid var(--border); border-radius: 10px; padding: 8px; background: #fff; }
.qr-box a { word-break: break-all; color: var(--emerald-700); }

.sig-thumb {
  height: 40px; max-width: 130px; object-fit: contain;
  border: 1px solid var(--border); border-radius: 6px; background: #fff;
}

/* ====== Signature pad (halaman publik) ====== */
.sigpad-wrap { position: relative; }
.sigpad {
  width: 100%; height: 180px; touch-action: none;
  border: 1px dashed var(--border); border-radius: 10px; background: #fff; cursor: crosshair;
}
.sigpad-clear { position: absolute; top: 8px; right: 8px; }

/* ====== Halaman publik hadir ====== */
.hadir-page {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(180deg, var(--emerald-50), #fff 60%);
}
.hadir-card { width: 100%; max-width: 480px; }
.hadir-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.hadir-brand strong { display: block; font-size: 16px; }
.hadir-brand small { font-size: 12px; color: var(--ink-muted); }
.hadir-meta h2 { font-size: 18px; margin: 8px 0 6px; }
.hadir-foot { margin-top: 18px; font-size: 12px; color: var(--ink-muted); text-align: center; }

@media (max-width: 820px) {
  #app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  #sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  #view { padding: 18px 14px 32px; }
  .form-grid { grid-template-columns: 1fr; }
}
