:root{
  --accent:#059669;      /* emerald-600 */
  --accent-dark:#047857; /* emerald-700 */
  --accent-light:#d1fae5;/* emerald-100 */
  --ink:#1e293b;         /* slate-800 */
  --muted:#64748b;       /* slate-500 */
  --line:#e2e8f0;        /* slate-200 */
  --danger:#ef4444;      /* red-500 */
  --danger-light:#fee2e2;/* red-100 */
}

*{ -webkit-tap-highlight-color: transparent; }
.hidden{ display:none !important; }

/* ---------- Custom scrollbar (dari cache.html) ---------- */
::-webkit-scrollbar{ width:8px; height:8px; }
::-webkit-scrollbar-track{ background:#f0fdf4; }
::-webkit-scrollbar-thumb{ background:#86efac; border-radius:10px; }
::-webkit-scrollbar-thumb:hover{ background:#4ade80; }

/* ---------- Animasi ---------- */
.fade-in{ animation:fadeIn .3s ease-out forwards; }
@keyframes fadeIn{ from{opacity:0; transform:translateY(10px);} to{opacity:1; transform:translateY(0);} }

/* ---------- Nav pill ---------- */
.nav-scroll{ -webkit-overflow-scrolling:touch; scrollbar-width:none; }
.nav-scroll::-webkit-scrollbar{ display:none; }

.nav-item{
  display:flex; align-items:center; gap:6px; flex-shrink:0;
  background:none; border:none; color:var(--muted);
  padding:9px 14px; border-radius:12px; font-size:13.5px; font-weight:600;
  white-space:nowrap; transition:background .15s ease,color .15s ease;
}
.nav-item i{ font-size:16px; }
.nav-item:active{ background:#f1f5f9; }
.nav-item.active{ background:var(--accent); color:#fff; }

/* ---------- Page sections ---------- */
.page{ display:none; }
.page.active{ display:block; }
.page > *{ margin-bottom:16px; }
.page > *:last-child{ margin-bottom:0; }

/* ---------- Cards ---------- */
.card{
  background:#fff; border:1px solid var(--line); border-radius:1rem;
  padding:20px; box-shadow:0 1px 2px rgba(0,0,0,.03);
}
.card h3{
  margin:0 0 6px; font-size:16px; font-weight:700; color:var(--ink);
  display:flex; align-items:center; gap:8px;
}
.card .muted{ color:var(--muted); font-size:13px; margin:0 0 14px; line-height:1.5; }
.card-table{ padding:14px; }
.card-table h3{ padding:6px 6px 0; }

/* ---------- Stat grid ---------- */
.stat-grid{ display:grid; grid-template-columns:repeat(2,1fr); gap:10px; }
@media (min-width:480px){ .stat-grid{ grid-template-columns:repeat(3,1fr); } }
.stat-card{
  background:#fff; border:1px solid var(--line); border-radius:1rem; padding:16px;
}
.stat-num{ font-size:24px; font-weight:800; color:var(--accent-dark); line-height:1; }
.stat-label{ font-size:11.5px; color:var(--muted); margin-top:6px; }

/* ---------- Page actions bar ---------- */
.page-actions{ display:flex; gap:8px; margin-bottom:14px; }
.page-actions select{ flex:1; min-width:0; }
.page-actions .btn{ flex-shrink:0; }

/* ---------- Table (dibungkus .table-scroll agar scroll horizontal di HP) ---------- */
.table-scroll{ overflow-x:auto; -webkit-overflow-scrolling:touch; }
.table{ width:100%; border-collapse:collapse; font-size:13px; min-width:480px; }
.table th{
  text-align:left; color:var(--muted); font-weight:700; font-size:10.5px;
  text-transform:uppercase; letter-spacing:.04em;
  padding:9px 10px; border-bottom:1px solid var(--line); white-space:nowrap;
}
.table td{ padding:11px 10px; border-bottom:1px solid #f1f5f9; vertical-align:top; }
.table tr:last-child td{ border-bottom:none; }

.badge{ display:inline-block; padding:3px 10px; border-radius:999px; font-size:11px; font-weight:700; white-space:nowrap; }
.badge.on{ background:var(--accent-light); color:var(--accent-dark); }
.badge.off{ background:var(--danger-light); color:#b91c1c; }
.badge.student{ background:#fef3c7; color:#92400e; }
.badge.public{ background:#e0f2fe; color:#075985; }

.row-actions{ display:flex; gap:6px; flex-wrap:wrap; }
.icon-btn{
  display:inline-flex; align-items:center; gap:4px;
  border:1px solid var(--line); background:#fff; border-radius:8px;
  padding:6px 10px; font-size:12px; color:var(--muted); font-weight:600;
}
.icon-btn:active{ background:#f8fafc; }
.icon-btn.danger{ color:#b91c1c; border-color:#fecaca; }

/* ---------- Buttons ---------- */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:6px;
  border:none; border-radius:12px; padding:11px 18px; font-size:14px; font-weight:700;
  transition:background .15s ease, transform .05s ease;
}
.btn:active{ transform:scale(0.98); }
.btn-primary{ background:var(--accent); color:#fff; box-shadow:0 2px 8px rgba(5,150,105,.25); }
.btn-primary:active{ background:var(--accent-dark); }
.btn-ghost{ background:#f1f5f9; color:var(--muted); }

/* ---------- Form fields (dipakai di card & modal, termasuk yang di-generate JS) ---------- */
.card label, .modal-body label{
  display:block; font-size:12px; font-weight:700; color:var(--muted);
  margin:14px 0 6px; text-transform:uppercase; letter-spacing:.03em;
}
.card label:first-of-type, .modal-body label:first-of-type{ margin-top:0; }

input[type=text], input[type=file], textarea, select{
  width:100%; padding:11px 13px; border:1px solid var(--line); border-radius:10px;
  outline:none; font-size:15px; font-family:inherit; resize:vertical; background:#fff; color:var(--ink);
}
input[type=text]:focus, textarea:focus, select:focus{ border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-light); }
input[type=checkbox]{ width:18px; height:18px; accent-color:var(--accent); vertical-align:middle; }
.checkbox-row{ display:flex; align-items:center; gap:8px; margin-top:14px; }
.checkbox-row label{ margin:0; text-transform:none; font-size:14px; font-weight:500; color:var(--ink); }

/* ---------- Menu tree (dashboard) ---------- */
.menu-tree{ display:flex; flex-direction:column; gap:3px; font-size:13px; }
.tree-cat{ color:var(--ink); font-weight:700; margin-top:10px; display:flex; align-items:center; gap:6px; }
.tree-cat:first-child{ margin-top:0; }
.tree-sub{ color:var(--accent-dark); margin-left:16px; }
.tree-faq{ color:var(--muted); margin-left:32px; }
.tree-faq::before{ content:"↳ "; }
.tree-faq-link{ cursor:pointer; border-radius:6px; padding:2px 6px; margin-left:26px; transition:background .12s ease, color .12s ease; }
.tree-faq-link:hover{ background:var(--accent-light); color:var(--accent-dark); }
.tree-faq-link .tree-date{ font-size:11px; opacity:.7; white-space:nowrap; }

/* ---------- Daily activity chart (bar chart CSS murni) ---------- */
.daily-chart{
  display:flex; align-items:flex-end; gap:4px; height:110px; margin-top:8px;
  border-bottom:1px solid var(--line); padding-bottom:2px;
}
.daily-chart-bar{
  flex:1; min-width:6px; background:var(--accent); border-radius:4px 4px 0 0;
  position:relative; transition:background .15s ease;
}
.daily-chart-bar:hover{ background:var(--accent-dark); }
.daily-chart-bar .bar-tooltip{
  position:absolute; bottom:100%; left:50%; transform:translateX(-50%);
  background:var(--ink); color:#fff; font-size:10px; padding:3px 6px; border-radius:6px;
  white-space:nowrap; opacity:0; pointer-events:none; transition:opacity .1s ease; margin-bottom:4px;
}
.daily-chart-bar:hover .bar-tooltip{ opacity:1; }
.daily-chart-labels{ display:flex; gap:4px; margin-top:4px; }
.daily-chart-labels span{ flex:1; min-width:6px; text-align:center; font-size:9px; color:var(--muted); }

/* ---------- Analytics list (FAQ populer, progress bar) ---------- */
.analytics-list{ display:flex; flex-direction:column; gap:12px; }
.analytics-item .analytics-head{ display:flex; justify-content:space-between; gap:8px; font-size:13px; margin-bottom:5px; }
.analytics-item .analytics-title{ color:var(--ink); font-weight:600; }
.analytics-item .analytics-sub{ color:var(--muted); font-size:11.5px; }
.analytics-item .analytics-pct{ color:var(--accent-dark); font-weight:700; white-space:nowrap; }
.analytics-bar-track{ background:#f1f5f9; border-radius:999px; height:8px; overflow:hidden; }
.analytics-bar-fill{ background:var(--accent); height:100%; border-radius:999px; }

/* ---------- Nav badge (jumlah pesan belum dibaca) ---------- */
.nav-item{ position:relative; }
.nav-badge{
  background:#ef4444; color:#fff; font-size:10px; font-weight:700;
  min-width:16px; height:16px; border-radius:999px; display:flex; align-items:center; justify-content:center;
  padding:0 4px; margin-left:2px;
}

/* ---------- Inbox: daftar percakapan ---------- */
.conversation-list{ display:flex; flex-direction:column; }
.conversation-item{
  display:flex; align-items:center; gap:12px; padding:14px 16px;
  border-bottom:1px solid #f1f5f9; cursor:pointer; transition:background .1s ease;
}
.conversation-item:last-child{ border-bottom:none; }
.conversation-item:active{ background:#f8fafc; }
.conv-avatar{
  width:42px; height:42px; border-radius:50%; background:var(--accent-light); color:var(--accent-dark);
  display:flex; align-items:center; justify-content:center; font-weight:700; font-size:15px; flex-shrink:0;
}
.conv-info{ flex:1; min-width:0; }
.conv-name-row{ display:flex; justify-content:space-between; gap:8px; align-items:baseline; }
.conv-name{ font-weight:700; font-size:14px; color:var(--ink); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.conv-time{ font-size:11px; color:var(--muted); flex-shrink:0; }
.conv-preview{ font-size:12.5px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; margin-top:2px; }
.conv-unread-dot{
  background:var(--accent); color:#fff; font-size:10.5px; font-weight:700;
  min-width:19px; height:19px; border-radius:999px; display:flex; align-items:center; justify-content:center; flex-shrink:0;
}
.conv-empty{ padding:40px 20px; text-align:center; color:var(--muted); font-size:13px; }

/* Ikon "balas" eksplisit per percakapan - selalu terlihat (bukan cuma saat hover), jadi konsisten di desktop & mobile */
.conv-reply-btn{
  flex-shrink:0; width:34px; height:34px; border-radius:50%; border:1px solid var(--line); background:#fff;
  color:var(--accent-dark); display:flex; align-items:center; justify-content:center; font-size:15px;
}
.conv-reply-btn:active{ background:var(--accent-light); }

/* ---------- Inbox: thread percakapan (bubble chat) ---------- */
.chat-thread-card{
  background:#fff; border:1px solid var(--line); border-radius:1rem; overflow:hidden;
  display:flex; flex-direction:column; height:calc(100vh - 230px); min-height:420px;
}
.chat-thread-header{
  display:flex; align-items:center; gap:10px; padding:12px 14px; border-bottom:1px solid var(--line); flex-shrink:0;
}
.chat-thread-title{ font-weight:700; font-size:14.5px; color:var(--ink); }
.chat-messages{
  flex:1; overflow-y:auto; padding:14px; display:flex; flex-direction:column; gap:8px;
  background:#f8faf9;
  background-image: radial-gradient(circle, #e2e8f0 1px, transparent 1px);
  background-size: 16px 16px;
}
.chat-bubble{ max-width:78%; padding:9px 12px; border-radius:14px; font-size:13.5px; line-height:1.45; word-wrap:break-word; }
.chat-bubble.from-user{ align-self:flex-start; background:#fff; border:1px solid var(--line); border-bottom-left-radius:4px; }
.chat-bubble.from-admin{ align-self:flex-end; background:var(--accent); color:#fff; border-bottom-right-radius:4px; }
.chat-bubble .chat-time{ display:block; font-size:10px; margin-top:4px; opacity:.7; text-align:right; }
.chat-bubble .chat-img-flag{ display:flex; align-items:center; gap:5px; font-size:11.5px; opacity:.85; margin-bottom:4px; }

.chat-view-photo-btn{
  display:flex; align-items:center; justify-content:center; gap:6px; width:100%; margin-top:7px;
  padding:9px 10px; border-radius:9px; font-size:12.5px; font-weight:600; border:none; cursor:pointer;
  background:#f1f5f9; color:var(--ink);
}
.chat-bubble.from-admin .chat-view-photo-btn{ background:rgba(255,255,255,.18); color:#fff; }
.chat-view-photo-btn:disabled{ opacity:.6; cursor:default; }

@keyframes spin{ from{ transform:rotate(0deg); } to{ transform:rotate(360deg); } }

.lightbox-overlay{
  position:fixed; inset:0; background:rgba(0,0,0,.88); z-index:300;
  display:none; align-items:center; justify-content:center; padding:24px;
}
.lightbox-overlay.active{ display:flex; }
.lightbox-overlay img{ max-width:100%; max-height:90vh; border-radius:10px; box-shadow:0 10px 40px rgba(0,0,0,.4); }
.lightbox-close{
  position:absolute; top:18px; right:18px; width:40px; height:40px; border-radius:50%;
  background:rgba(255,255,255,.12); border:none; color:#fff; font-size:20px;
  display:flex; align-items:center; justify-content:center;
}
.chat-bubble .chat-link-btn{
  display:flex; align-items:center; justify-content:center; gap:6px; margin-top:7px;
  padding:7px 10px; border-radius:9px; font-size:12.5px; font-weight:600; text-decoration:none;
}
.chat-bubble.from-admin .chat-link-btn{ background:rgba(255,255,255,.18); color:#fff; }
.chat-bubble.from-user .chat-link-btn{ background:var(--accent-light); color:var(--accent-dark); }

.chat-attach-preview{ padding:8px 10px 0; display:flex; gap:8px; flex-wrap:wrap; flex-shrink:0; background:#fff; }
.attach-chip{
  display:flex; align-items:center; gap:6px; background:#f1f5f9; border-radius:10px; padding:5px 8px; font-size:12px; color:var(--ink);
}
.attach-chip img{ width:24px; height:24px; border-radius:5px; object-fit:cover; }
.attach-chip button{ background:none; border:none; color:var(--muted); display:flex; padding:2px; }
.chat-toolbar{ display:flex; gap:4px; padding:6px 10px 0; flex-shrink:0; background:#fff; }
.chat-tool-btn{
  width:34px; height:34px; border-radius:9px; border:none; background:none; color:var(--muted);
  display:flex; align-items:center; justify-content:center; font-size:17px; cursor:pointer;
}
.chat-tool-btn:active{ background:#f1f5f9; color:var(--accent-dark); }

.chat-input-row{ display:flex; gap:8px; padding:10px; border-top:1px solid var(--line); flex-shrink:0; background:#fff; }
.chat-input-row textarea{ flex:1; margin:0; resize:none; max-height:90px; }
.chat-send-btn{ flex-shrink:0; width:46px; height:46px; padding:0; border-radius:50%; }

/* ---------- Broadcast preview ---------- */
.broadcast-preview{
  max-width:100%; max-height:220px; border-radius:12px; border:1px solid var(--line);
  display:block; margin:10px 0; object-fit:cover;
}

/* ---------- Modal ---------- */
.modal-overlay{
  position:fixed; inset:0; background:rgba(15,23,42,.45); backdrop-filter:blur(2px);
  display:flex; align-items:flex-end; justify-content:center; z-index:100;
}
@media (min-width:640px){ .modal-overlay{ align-items:center; padding:20px; } }
.modal{
  background:#fff; border-radius:1.25rem 1.25rem 0 0; width:100%; max-width:480px;
  max-height:88vh; display:flex; flex-direction:column; box-shadow:0 -10px 40px rgba(0,0,0,.2);
}
@media (min-width:640px){ .modal{ border-radius:1.25rem; } }
.modal-head{ display:flex; justify-content:space-between; align-items:center; padding:18px 20px; border-bottom:1px solid var(--line); }
.modal-head h3{ margin:0; font-size:16px; font-weight:700; }
.modal-close{ background:#f1f5f9; border:none; width:32px; height:32px; border-radius:9px; color:var(--muted); display:flex; align-items:center; justify-content:center; }
.modal-body{ padding:18px 20px; overflow-y:auto; }
.modal-foot{ display:flex; gap:10px; padding:16px 20px; border-top:1px solid var(--line); }
.modal-foot .btn{ flex:1; }

/* ---------- Toast (pill style, seperti cache.html) ---------- */
.toast{
  position:fixed; top:16px; left:50%; transform:translateX(-50%);
  background:#1e293b; color:#fff; padding:11px 18px; border-radius:999px;
  font-size:13px; font-weight:600; z-index:200; box-shadow:0 10px 30px rgba(0,0,0,.25);
  max-width:90vw; text-align:center;
}
.toast.error{ background:#b91c1c; }

/* ---------- Setup screen text color inside dark bg ---------- */
.setup-screen code{ color:#334155; }


/* ---------- Editor teks kaya (broadcast) ---------- */
.rte-toolbar{
  display:flex; flex-wrap:wrap; align-items:center; gap:3px; padding:6px;
  border:1px solid var(--line); border-bottom:none; border-radius:10px 10px 0 0; background:#f8fafc;
}
.rte-btn{
  width:34px; height:34px; border:none; border-radius:8px; background:none; color:var(--ink);
  font-size:16px; display:flex; align-items:center; justify-content:center; cursor:pointer;
}
.rte-btn:hover{ background:#e2e8f0; }
.rte-btn.active{ background:var(--accent-light); color:var(--accent-dark); }
.rte-sep{ width:1px; height:20px; background:var(--line); margin:0 3px; }
.rte-editor{
  min-height:130px; max-height:320px; overflow-y:auto; padding:12px 13px;
  border:1px solid var(--line); border-radius:0 0 10px 10px; outline:none;
  font-size:15px; line-height:1.5; background:#fff; white-space:pre-wrap; word-wrap:break-word;
}
.rte-editor:focus{ border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-light); }
.rte-editor:empty::before{ content:attr(data-placeholder); color:#94a3b8; pointer-events:none; }
.rte-editor code{ background:#f1f5f9; padding:1px 5px; border-radius:4px; font-family:monospace; font-size:.92em; }
.rte-editor a{ color:#0369a1; text-decoration:underline; }
.rte-counter{ text-align:right; font-size:11.5px; color:var(--muted); margin:4px 2px 14px; }
.rte-counter.over{ color:#b91c1c; font-weight:700; }

/* ---------- Daftar tombol link ---------- */
.btn-list{ display:flex; flex-direction:column; gap:6px; margin-bottom:8px; }
.btn-list:empty{ display:none; }
.btn-list-item{ display:flex; align-items:center; gap:8px; background:#f1f5f9; border-radius:10px; padding:7px 10px; font-size:12.5px; }
.btn-list-item .bl-text{ font-weight:700; white-space:nowrap; }
.btn-list-item .bl-url{ color:var(--muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; flex:1; min-width:0; }
.btn-editor-row{ display:flex; gap:6px; align-items:center; margin-bottom:8px; flex-wrap:wrap; }
.btn-editor-row input{ flex:1 1 140px; width:auto; margin:0; }

/* ---------- Saran jawaban FAQ di balasan ---------- */
.faq-suggest{ padding:8px 10px 0; background:#fff; border-top:1px solid var(--line); flex-shrink:0; }
.faq-suggest-head{ display:flex; justify-content:space-between; align-items:center; font-size:12px; font-weight:700; color:var(--muted); margin-bottom:6px; gap:8px; }
.faq-suggest-head .ph-fill{ color:#f59e0b; }
.faq-suggest-list{ display:flex; gap:8px; overflow-x:auto; padding-bottom:8px; align-items:stretch; min-height:20px; }
.faq-chip{
  flex:0 0 auto; max-width:240px; text-align:left; background:#f0fdf4; border:1px solid #bbf7d0;
  border-radius:10px; padding:7px 10px; cursor:pointer; font-size:12.5px; color:var(--ink);
}
.faq-chip:hover{ background:var(--accent-light); }
.faq-chip.top{ border-color:var(--accent); }
.faq-chip .fc-q{ font-weight:700; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.faq-chip .fc-sub{ font-size:10.5px; color:var(--muted); margin-top:2px; }
.chat-input-row textarea{ max-height:150px; }


/* ---------- Editor balasan (kaya teks) ---------- */
.chat-toolbar-wrap{ flex-wrap:wrap; align-items:center; }
.reply-editor{
  flex:1; min-width:0; min-height:42px; max-height:150px; padding:10px 12px;
  border-radius:12px; margin:0; font-size:14px;
}
.chat-input-row{ align-items:flex-end; }
.chat-bubble .chat-text.pre{ white-space:pre-wrap; }
.chat-bubble.from-admin a{ color:#fff; text-decoration:underline; }
.chat-bubble code{ background:rgba(0,0,0,.08); padding:1px 5px; border-radius:4px; font-family:monospace; font-size:.92em; }
.attach-chip img.hidden, .attach-chip i.hidden{ display:none; }

/* ---------- Pustaka dokumen ---------- */
.file-list{ display:flex; flex-direction:column; }
.file-row{ display:flex; align-items:center; gap:12px; padding:12px 10px; border-bottom:1px solid #f1f5f9; }
.file-row:last-child{ border-bottom:none; }
.file-icon{
  width:42px; height:42px; border-radius:11px; flex-shrink:0; display:flex; align-items:center; justify-content:center;
  font-size:21px; background:var(--accent-light); color:var(--accent-dark);
}
.file-icon.pdf{ background:#fee2e2; color:#b91c1c; }
.file-icon.video{ background:#ede9fe; color:#6d28d9; }
.file-icon.image{ background:#e0f2fe; color:#0369a1; }
.file-info{ flex:1; min-width:0; }
.file-name{ font-weight:700; font-size:13.5px; color:var(--ink); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.file-meta{ font-size:11.5px; color:var(--muted); margin-top:2px; }
.file-desc{ font-size:12px; color:var(--muted); margin-top:2px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.file-actions{ display:flex; gap:5px; flex-shrink:0; flex-wrap:wrap; justify-content:flex-end; }
@media (max-width:560px){ .file-row{ flex-wrap:wrap; } .file-actions{ width:100%; justify-content:flex-start; } }
.upload-progress{ margin-top:14px; }
.upload-bar{ height:9px; background:#e2e8f0; border-radius:999px; overflow:hidden; }
.upload-bar > div{ height:100%; width:0; background:var(--accent); transition:width .15s ease; }
.upload-pct{ font-size:12px; color:var(--muted); margin-top:5px; }

/* ---------- Progress broadcast bertahap ---------- */
.bc-progress{ margin-top:16px; padding:14px; border:1px solid var(--line); border-radius:14px; background:#f8fafc; }
.bc-progress-head{ display:flex; justify-content:space-between; align-items:center; gap:10px; margin-bottom:8px; font-size:14px; color:var(--ink); }
.bc-progress-head span{ font-weight:700; color:var(--accent-dark); font-variant-numeric:tabular-nums; }
.bc-progress-stats{ font-size:13px; color:var(--ink); margin-top:8px; font-variant-numeric:tabular-nums; }
.bc-progress-note{ font-size:12px; color:var(--muted); margin:6px 0 10px; line-height:1.5; }
.bc-progress.done .upload-bar > div{ background:var(--accent-dark); }
