/* =========================================================
   DESIGN TOKENS
   Palet terinspirasi ubin masjid & sampul kitab klasik:
   hijau zamrud tua sebagai identitas, emas sebagai aksen,
   krem hangat sebagai kanvas.
   ========================================================= */
:root {
  --emerald-900: #0B3D33;
  --emerald-800: #0F5C4C;
  --emerald-700: #15715D;
  --emerald-600: #1B8A70;
  --emerald-100: #E4F1EC;
  --gold-600: #C9962C;
  --gold-500: #D4AF37;
  --gold-100: #FBF1DA;
  --cream: #F7F4EC;
  --paper: #FFFFFF;
  --ink-900: #1E2622;
  --ink-600: #55635D;
  --ink-400: #8B968F;
  --line: #E7E2D6;
  --danger: #D64545;
  --danger-bg: #FBE7E7;
  --warn: #D98C1F;
  --warn-bg: #FCF0DC;
  --ok: #1F9D68;
  --ok-bg: #E2F5EC;
  --info: #2E7FBE;
  --info-bg: #E4F0FA;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 8px 24px -8px rgba(11,61,51,0.18), 0 2px 6px -2px rgba(11,61,51,0.08);
  --shadow-lg: 0 20px 48px -12px rgba(11,61,51,0.28);
  --font-display: 'Lora', serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
}

* { box-sizing: border-box; }
html, body { margin:0; padding:0; }
body {
  font-family: var(--font-body);
  color: var(--ink-900);
  background: var(--cream);
  -webkit-tap-highlight-color: transparent;
}
h1,h2,h3,h4 { font-family: var(--font-display); margin: 0; }
p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
::selection { background: var(--gold-100); }

/* Scrollbar minimal */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #D8D2C2; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* =========================================================
   LOGIN PAGE
   ========================================================= */
.login-body {
  min-height: 100vh;
  display: flex;
}
.login-wrap {
  display: flex;
  width: 100%;
  min-height: 100vh;
}
.login-visual {
  flex: 1.15;
  background: linear-gradient(160deg, var(--emerald-900), var(--emerald-700) 70%);
  position: relative;
  display: flex;
  align-items: center;
  padding: 60px;
  overflow: hidden;
  color: #fff;
}
.motif {
  position: absolute;
  inset: 0;
  opacity: 0.14;
  background-image:
    radial-gradient(circle at 20% 20%, transparent 0 38px, var(--gold-500) 39px 41px, transparent 42px),
    radial-gradient(circle at 80% 60%, transparent 0 60px, var(--gold-500) 61px 63px, transparent 64px),
    radial-gradient(circle at 40% 85%, transparent 0 44px, var(--gold-500) 45px 47px, transparent 48px);
  background-size: 300px 300px, 420px 420px, 260px 260px;
  animation: float-motif 30s linear infinite;
}
@keyframes float-motif { from { transform: translate(0,0); } to { transform: translate(-60px,-40px); } }
.login-visual-content { position: relative; z-index: 2; max-width: 480px; }
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 48px; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 12px;
  background: var(--gold-500); color: var(--emerald-900);
  display: flex; align-items: center; justify-content: center; font-size: 20px;
}
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 19px; }
.brand-sub { font-size: 12px; opacity: 0.75; letter-spacing: 0.03em; }
.login-visual h1 {
  font-size: 34px; line-height: 1.28; font-weight: 600; margin-bottom: 18px;
}
.login-visual p { font-size: 14.5px; opacity: 0.82; line-height: 1.7; }
.login-visual-stats { display: flex; gap: 28px; margin-top: 42px; }
.login-visual-stats div { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; font-size: 12.5px; opacity: 0.9; }
.login-visual-stats i { font-size: 18px; color: var(--gold-500); }

.login-panel {
  flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--cream);
}
.login-card { width: 100%; max-width: 400px; }
.tabs { display: flex; background: var(--paper); border-radius: 12px; padding: 4px; margin-bottom: 28px; box-shadow: var(--shadow); }
.tab-btn {
  flex: 1; border: none; background: none; padding: 11px 8px; border-radius: 9px;
  font-size: 13px; font-weight: 600; color: var(--ink-400); transition: all .2s;
}
.tab-btn.active { background: var(--emerald-800); color: #fff; }
.login-form { display: none; }
.login-form.active { display: block; animation: fadeUp .35s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px);} to {opacity:1; transform:translateY(0);} }
.login-form h2 { font-size: 22px; margin-bottom: 4px; color: var(--emerald-900); }
.muted { color: var(--ink-600); font-size: 13px; margin-bottom: 22px; }
.muted.small { font-size: 11.5px; margin-top: 14px; }
.login-form label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--ink-600); }
.input-icon { position: relative; margin-bottom: 18px; }
.input-icon i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-400); font-size: 13px; }
.input-icon input {
  width: 100%; padding: 12px 14px 12px 38px; border-radius: 10px; border: 1.5px solid var(--line);
  font-size: 14px; background: var(--paper); transition: border .2s;
}
.input-icon input:focus { outline: none; border-color: var(--emerald-600); }
.btn-primary {
  width: 100%; padding: 13px; border: none; border-radius: 10px; background: var(--emerald-800); color: #fff;
  font-weight: 700; font-size: 14px; display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .15s, background .2s;
}
.btn-primary:hover { background: var(--emerald-700); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary.gold { background: var(--gold-600); }
.btn-primary.gold:hover { background: #b8851f; }
.btn-primary:disabled { opacity: 0.7; }
.form-msg { font-size: 12.5px; margin-bottom: 12px; min-height: 0; }
.form-msg.error { color: var(--danger); background: var(--danger-bg); padding: 8px 12px; border-radius: 8px; }
.login-footer { margin-top: 28px; text-align: center; }
.btn-install {
  border: 1.5px dashed var(--gold-600); background: var(--gold-100); color: var(--emerald-900);
  padding: 10px 16px; border-radius: 10px; font-size: 12.5px; font-weight: 600; margin-bottom: 6px;
}

@media (max-width: 860px) {
  .login-visual { display: none; }
  .login-panel { padding: 24px 18px; }
}

/* =========================================================
   APP SHELL (Dashboard)
   ========================================================= */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 268px; background: var(--emerald-900); color: #fff; flex-shrink: 0;
  display: flex; flex-direction: column; position: fixed; top:0; left:0; height: 100vh; z-index: 40;
  transition: transform .25s ease;
}
.sidebar-head { display: flex; align-items: center; gap: 12px; padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-head .brand-mark { background: var(--gold-500); color: var(--emerald-900); width: 38px; height:38px; font-size: 16px; }
.sidebar-head .brand-name { font-size: 15.5px; }
.sidebar-head .brand-sub { font-size: 10.5px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 10px 20px; }
.nav-group { margin-bottom: 2px; }
.nav-parent {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: none; background: none;
  color: rgba(255,255,255,0.82); font-size: 13.3px; font-weight: 600; border-radius: 9px; text-align: left;
  transition: background .15s;
}
.nav-parent i.ic { width: 18px; text-align: center; color: var(--gold-500); }
.nav-parent .chev { margin-left: auto; font-size: 10px; transition: transform .2s; opacity: 0.6; }
.nav-parent:hover { background: rgba(255,255,255,0.06); }
.nav-group.open .nav-parent .chev { transform: rotate(90deg); }
.nav-group.active-group .nav-parent { background: rgba(212,175,55,0.14); color: #fff; }
.nav-children { list-style: none; margin: 0; padding: 0; max-height: 0; overflow: hidden; transition: max-height .25s ease; }
.nav-group.open .nav-children { max-height: 600px; }
.nav-children li a, .nav-single {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px 9px 42px; font-size: 12.8px;
  color: rgba(255,255,255,0.65); border-radius: 8px; margin: 1px 0; cursor: pointer;
}
.nav-single { padding-left: 12px; font-weight: 600; }
.nav-children li a:hover, .nav-single:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-children li a.active, .nav-single.active { background: var(--gold-500); color: var(--emerald-900); font-weight: 700; }
.sidebar-foot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,0.08); }
.btn-logout {
  display: flex; align-items: center; gap: 10px; width: 100%; border: none; background: rgba(255,255,255,0.06);
  color: #fff; padding: 10px 12px; border-radius: 9px; font-size: 12.8px; font-weight: 600;
}
.btn-logout:hover { background: rgba(255,255,255,0.12); }

.main {
  flex: 1; margin-left: 268px; display: flex; flex-direction: column; min-height: 100vh; min-width: 0;
}
.topbar {
  height: 68px; background: var(--paper); border-bottom: 1px solid var(--line); display: flex; align-items: center;
  padding: 0 24px; gap: 16px; position: sticky; top: 0; z-index: 30;
}
.btn-hamburger { display: none; border: none; background: none; font-size: 18px; color: var(--emerald-900); }
.page-title { font-family: var(--font-display); font-size: 19px; color: var(--emerald-900); font-weight: 600; }
.topbar-search { flex: 1; max-width: 340px; position: relative; margin-left: 12px; }
.topbar-search i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--ink-400); font-size: 12.5px; }
.topbar-search input { width: 100%; padding: 9px 12px 9px 34px; border-radius: 9px; border: 1.5px solid var(--line); font-size: 13px; background: var(--cream); }
.topbar-search input:focus { outline: none; border-color: var(--emerald-600); background: #fff; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--emerald-100); color: var(--emerald-800); display:flex; align-items:center; justify-content:center; font-weight: 700; font-size: 13px; }
.topbar-user .u-name { font-size: 13px; font-weight: 700; color: var(--ink-900); }
.topbar-user .u-role { font-size: 11px; color: var(--ink-400); text-transform: capitalize; }

.content { padding: 24px; flex: 1; }

/* Dashboard cards */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 22px; }
.stat-card {
  background: var(--paper); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
  border: 1px solid var(--line); position: relative; overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; right: -20px; top: -20px; width: 100px; height: 100px; border-radius: 50%;
  background: var(--accent, var(--emerald-100)); opacity: 0.5;
}
.stat-card .s-icon {
  width: 42px; height: 42px; border-radius: 11px; display: flex; align-items: center; justify-content: center;
  font-size: 17px; margin-bottom: 14px; color: #fff; background: var(--accent-solid, var(--emerald-700)); position: relative; z-index: 1;
}
.stat-card .s-value { font-family: var(--font-display); font-size: 25px; font-weight: 700; color: var(--ink-900); position: relative; z-index:1; }
.stat-card .s-label { font-size: 12px; color: var(--ink-600); margin-top: 4px; position: relative; z-index:1; }
.stat-card .s-sub { font-size: 11px; margin-top: 8px; font-weight: 600; position: relative; z-index:1; }
.stat-card.c-blue { --accent-solid: #2E7FBE; --accent: #E4F0FA; }
.stat-card.c-amber { --accent-solid: #D98C1F; --accent: #FCF0DC; }
.stat-card.c-green { --accent-solid: #1F9D68; --accent: #E2F5EC; }
.stat-card.c-gold { --accent-solid: #C9962C; --accent: #FBF1DA; }

.panel-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.panel {
  background: var(--paper); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); border: 1px solid var(--line);
}
.panel h3 { font-size: 15.5px; color: var(--emerald-900); margin-bottom: 4px; }
.panel .panel-sub { font-size: 12px; color: var(--ink-400); margin-bottom: 16px; }
.mini-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.mini-list li { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.mini-list .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold-500); flex-shrink: 0; }
.mini-list .mtitle { flex: 1; color: var(--ink-900); }
.mini-list .mtime { color: var(--ink-400); font-size: 11.5px; }

/* Module (CRUD) toolbar */
.module-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.module-toolbar .search-box { position: relative; flex: 1; max-width: 300px; }
.module-toolbar .search-box i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-400); font-size: 12px; }
.module-toolbar .search-box input { width: 100%; padding: 9px 12px 9px 32px; border-radius: 9px; border: 1.5px solid var(--line); font-size: 13px; }
.btn { border: none; border-radius: 9px; padding: 10px 16px; font-size: 12.8px; font-weight: 700; display: inline-flex; align-items: center; gap: 8px; transition: transform .1s, opacity .2s; }
.btn:active { transform: scale(0.97); }
.btn-add { background: var(--emerald-800); color: #fff; margin-left: auto; }
.btn-add:hover { background: var(--emerald-700); }
.btn-ghost { background: var(--cream); color: var(--ink-900); border: 1px solid var(--line); }
.btn-sm { padding: 6px 10px; font-size: 11.5px; border-radius: 7px; }
.btn-edit { background: var(--info-bg); color: var(--info); }
.btn-delete { background: var(--danger-bg); color: var(--danger); }
.btn-approve { background: var(--ok-bg); color: var(--ok); }
.btn-reject { background: var(--danger-bg); color: var(--danger); }

.table-wrap { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table thead th {
  text-align: left; padding: 13px 16px; background: var(--emerald-100); color: var(--emerald-900);
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; white-space: nowrap;
}
table.data-table tbody td { padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--ink-900); vertical-align: middle; }
table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover { background: #FBFAF6; }
.actions-cell { display: flex; gap: 6px; }
.badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.info { background: var(--info-bg); color: var(--info); }
.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-400); }
.empty-state i { font-size: 34px; margin-bottom: 12px; display: block; color: var(--line); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(11,61,51,0.45); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.show { opacity: 1; pointer-events: all; }
.modal-box { background: var(--paper); border-radius: var(--radius); width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg); transform: translateY(10px); transition: transform .2s; }
.modal-overlay.show .modal-box { transform: translateY(0); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 16.5px; color: var(--emerald-900); }
.modal-close { border: none; background: var(--cream); width: 30px; height: 30px; border-radius: 50%; color: var(--ink-600); }
.modal-body { padding: 20px 22px; }
.form-row { margin-bottom: 15px; }
.form-row label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 6px; color: var(--ink-600); }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; padding: 10px 12px; border-radius: 9px; border: 1.5px solid var(--line); font-size: 13.5px; font-family: inherit; background: #fff;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { outline: none; border-color: var(--emerald-600); }
.modal-foot { padding: 16px 22px 20px; display: flex; gap: 10px; justify-content: flex-end; }

.toast-wrap { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--emerald-900); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px; animation: fadeUp .25s ease; }
.toast.error { background: var(--danger); }
.toast i { color: var(--gold-500); }
.toast.error i { color: #fff; }

.print-report { background: var(--paper); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.report-head { text-align: center; border-bottom: 2px solid var(--emerald-800); padding-bottom: 16px; margin-bottom: 20px; }
.report-head h2 { color: var(--emerald-900); font-size: 19px; }
.report-head p { color: var(--ink-400); font-size: 12px; margin-top: 4px; }

.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 39; }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2,1fr); }
  .panel-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .btn-hamburger { display: block; }
  .sidebar-backdrop.show { display: block; }
  .topbar-search { display: none; }
}
@media (max-width: 560px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .content { padding: 16px; }
  .topbar { padding: 0 14px; }
  table.data-table { font-size: 12px; }
}
