/* ==========================================================================
   TDA-OS Design System (blueprint section 8)
   ========================================================================== */
:root {
  --primary: #2E3192;
  --primary-d: #232578;
  --secondary: #D4AC0D;
  --sidebar-bg: #2E3192;
  --sidebar-bg-dark: #232578;
  --sidebar-accent: #C8BFE7;
  --success: #1E8449;
  --danger: #C0392B;
  --warning: #F39C12;
  --info: #2E86C1;
  --bg: #F8F9FA;
  --surface: #ffffff;
  --text: #2C3E50;
  --muted: #7b8794;
  --border: #e4e8ee;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04);
  --shadow-lg: 0 10px 25px rgba(16,24,40,.10);
  --sidebar-w: 256px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
h1,h2,h3,h4,h5 { font-family: "Poppins", "Inter", sans-serif; font-weight: 600; color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: "JetBrains Mono", ui-monospace, monospace; }

/* ----------------------------- Layout ----------------------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-dark) 100%);
  color: #fff;
  position: fixed; top: 0; bottom: 0; left: 0;
  display: flex; flex-direction: column;
  z-index: 40;
  transition: transform .25s ease;
}
.sidebar__brand {
  padding: 16px 18px; font-family: "Poppins",sans-serif; font-weight: 700; font-size: 16px;
  display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar__logo { height: 32px; width: auto; max-width: 168px; object-fit: contain; filter: brightness(1.05); }
.sidebar__brand-text { line-height: 1.2; }
.sidebar__org { padding: 12px 20px; font-size: 12px; color: rgba(255,255,255,.7); border-bottom: 1px solid rgba(255,255,255,.12); }
.sidebar__nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.sidebar__nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 20px; color: rgba(255,255,255,.82);
  font-size: 13.5px; text-decoration: none; border-left: 3px solid transparent;
}
.sidebar__nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar__nav a.active { background: rgba(255,255,255,.12); color: #fff; border-left-color: var(--sidebar-accent); font-weight: 600; }
.sidebar__nav .nav-section { padding: 14px 20px 6px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: rgba(255,255,255,.45); }

/* CSS-only sidebar icons */
.nav-ico { width: 18px; height: 18px; flex-shrink: 0; position: relative; display: inline-block; opacity: .92; }
.nav-ico::before, .nav-ico::after { content: ''; position: absolute; box-sizing: border-box; }
.nav-ico--dashboard::before { inset: 0; border: 2px solid currentColor; border-radius: 3px; opacity: .35; }
.nav-ico--dashboard::after { width: 6px; height: 6px; top: 3px; left: 3px; background: currentColor; border-radius: 1px; box-shadow: 7px 0 0 currentColor, 0 7px 0 currentColor, 7px 7px 0 currentColor; }
.nav-ico--pelayan::before { width: 8px; height: 8px; border: 2px solid currentColor; border-radius: 50%; top: 0; left: 5px; }
.nav-ico--pelayan::after { width: 14px; height: 7px; border: 2px solid currentColor; border-bottom: none; border-radius: 8px 8px 0 0; bottom: 0; left: 2px; }
.nav-ico--struktur::before { width: 2px; height: 14px; background: currentColor; left: 8px; top: 2px; }
.nav-ico--struktur::after { width: 12px; height: 2px; background: currentColor; top: 5px; left: 3px; box-shadow: -4px 8px 0 currentColor, 8px 8px 0 currentColor; }
.nav-ico--divisi::before { width: 14px; height: 10px; border: 2px solid currentColor; border-radius: 2px 2px 0 0; top: 4px; left: 2px; }
.nav-ico--divisi::after { width: 8px; height: 2px; background: currentColor; top: 2px; left: 5px; border-radius: 1px 1px 0 0; }
.nav-ico--jabatan::before { width: 12px; height: 8px; border: 2px solid currentColor; border-radius: 50% 50% 2px 2px; top: 1px; left: 3px; }
.nav-ico--jabatan::after { width: 6px; height: 4px; border: 2px solid currentColor; border-top: none; bottom: 1px; left: 6px; }
.nav-ico--program::before { width: 14px; height: 2px; background: currentColor; top: 3px; left: 2px; box-shadow: 0 5px 0 currentColor, 0 10px 0 currentColor; border-radius: 1px; }
.nav-ico--program::after { width: 4px; height: 4px; border: 2px solid currentColor; border-radius: 50%; top: 1px; left: 1px; box-shadow: 0 5px 0 -1px currentColor, 0 10px 0 -1px currentColor; }
.nav-ico--kegiatan::before { width: 14px; height: 12px; border: 2px solid currentColor; border-radius: 2px; top: 3px; left: 2px; }
.nav-ico--kegiatan::after { width: 2px; height: 4px; background: currentColor; top: 0; left: 8px; box-shadow: -3px 0 0 currentColor, 3px 0 0 currentColor; }
.nav-ico--kalender::before { width: 14px; height: 12px; border: 2px solid currentColor; border-radius: 2px; top: 4px; left: 2px; }
.nav-ico--kalender::after { width: 14px; height: 2px; background: currentColor; top: 4px; left: 2px; }
.nav-ico--absensi::before { width: 8px; height: 14px; border: 2px solid currentColor; border-radius: 1px; top: 1px; left: 5px; transform: rotate(45deg); border-top: none; border-left: none; }
.nav-ico--kpi::before { width: 2px; height: 14px; background: currentColor; bottom: 0; left: 3px; box-shadow: 5px -4px 0 currentColor, 10px -8px 0 currentColor; }
.nav-ico--kas::before { width: 14px; height: 10px; border: 2px solid currentColor; border-radius: 2px; top: 4px; left: 2px; }
.nav-ico--kas::after { width: 8px; height: 2px; background: currentColor; top: 2px; left: 5px; border-radius: 2px; }
.nav-ico--keuangan::before { width: 12px; height: 12px; border: 2px solid currentColor; border-radius: 50%; top: 3px; left: 3px; }
.nav-ico--keuangan::after { width: 6px; height: 2px; background: currentColor; top: 8px; left: 6px; }
.nav-ico--surat::before { width: 14px; height: 10px; border: 2px solid currentColor; border-radius: 1px; top: 4px; left: 2px; }
.nav-ico--surat::after { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 4px solid currentColor; top: 4px; left: 4px; }
.nav-ico--proposal::before { width: 11px; height: 14px; border: 2px solid currentColor; border-radius: 1px; top: 1px; left: 4px; }
.nav-ico--proposal::after { width: 6px; height: 2px; background: currentColor; top: 6px; left: 6px; box-shadow: 0 4px 0 currentColor; }
.nav-ico--laporan::before { width: 12px; height: 14px; border: 2px solid currentColor; border-radius: 1px; top: 1px; left: 3px; }
.nav-ico--laporan::after { width: 6px; height: 2px; background: currentColor; top: 5px; left: 6px; box-shadow: 0 3px 0 currentColor, 0 6px 0 currentColor; }
.nav-ico--member::before { width: 7px; height: 7px; border: 2px solid currentColor; border-radius: 50%; top: 0; left: 1px; box-shadow: 8px 0 0 -1px currentColor; }
.nav-ico--member::after { width: 16px; height: 6px; border: 2px solid currentColor; border-bottom: none; border-radius: 6px 6px 0 0; bottom: 0; left: 1px; }
.nav-ico--mitra::before { width: 8px; height: 8px; border: 2px solid currentColor; border-radius: 50%; top: 5px; left: 0; }
.nav-ico--mitra::after { width: 8px; height: 8px; border: 2px solid currentColor; border-radius: 50%; top: 5px; right: 0; }
.nav-ico--notifikasi::before { width: 12px; height: 10px; border: 2px solid currentColor; border-radius: 4px 4px 2px 2px; top: 2px; left: 3px; }
.nav-ico--notifikasi::after { width: 4px; height: 2px; background: currentColor; bottom: 1px; left: 7px; border-radius: 0 0 2px 2px; }
.nav-ico--audit::before { width: 10px; height: 10px; border: 2px solid currentColor; border-radius: 50%; top: 1px; left: 1px; }
.nav-ico--audit::after { width: 2px; height: 5px; background: currentColor; bottom: 2px; right: 3px; transform: rotate(-45deg); transform-origin: bottom; }
.nav-ico--periode::before { width: 14px; height: 10px; border: 2px solid currentColor; border-radius: 2px; top: 5px; left: 2px; }
.nav-ico--periode::after { width: 14px; height: 2px; background: currentColor; top: 5px; left: 2px; }
.nav-ico--pengaturan::before { width: 12px; height: 12px; border: 2px solid currentColor; border-radius: 50%; top: 3px; left: 3px; }
.nav-ico--pengaturan::after { width: 4px; height: 4px; background: currentColor; border-radius: 50%; top: 7px; left: 7px; box-shadow: 0 -9px 0 -1px currentColor, 0 9px 0 -1px currentColor, -9px 0 0 -1px currentColor, 9px 0 0 -1px currentColor; }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 60px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 30;
}
.topbar__left { display:flex; align-items:center; gap: 14px; }
.topbar__title { font-family:"Poppins",sans-serif; font-weight:600; font-size:16px; }
.topbar__user { display:flex; align-items:center; gap:10px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--secondary); color: var(--primary-d);
  display:flex; align-items:center; justify-content:center; font-weight:700; }
.content { padding: 24px; flex: 1; }
.breadcrumb { font-size: 12.5px; color: var(--muted); margin-bottom: 16px; }
.breadcrumb a { color: var(--muted); }

.menu-toggle { display:none; background:none; border:none; cursor:pointer; color: var(--text); width:36px; height:36px; padding:6px; flex-direction:column; justify-content:center; gap:5px; }
.menu-toggle span { display:block; height:2px; background:currentColor; border-radius:2px; transition:.2s; }

.sidebar-backdrop { display:none; position:fixed; inset:0; background:rgba(16,24,40,.45); z-index:35; }
body.sidebar-open { overflow:hidden; }
body.sidebar-open .sidebar-backdrop { display:block; }
body.sidebar-open .sidebar { transform:none; }

/* ----------------------------- Cards/Grid ----------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card__head { padding: 16px 20px; border-bottom: 1px solid var(--border); display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.card__title { font-size: 15px; font-weight: 600; margin: 0; }
.card__body { padding: 20px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px){ .grid-4 { grid-template-columns: repeat(2,1fr);} .grid-3{grid-template-columns:repeat(2,1fr);} }
@media (max-width: 720px){ .grid-2,.grid-3,.grid-4 { grid-template-columns: 1fr; } }

.stat { background: var(--surface); border:1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat__label { color: var(--muted); font-size: 12.5px; }
.stat__value { font-size: 26px; font-weight: 700; font-family:"Poppins",sans-serif; margin-top: 4px; }
.stat__icon { float:right; width:44px;height:44px;border-radius:10px;display:flex;align-items:center;justify-content:center;font-size:20px; }

/* ----------------------------- Buttons ----------------------------- */
.btn { display:inline-flex; align-items:center; gap:8px; padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  font-size: 13.5px; font-weight: 600; cursor: pointer; background: var(--primary); color: #fff; text-decoration: none; transition: .15s; }
.btn:hover { filter: brightness(1.07); text-decoration:none; }
.btn:active { transform: translateY(1px); }
.btn--secondary { background: var(--secondary); color: var(--primary-d); }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn--danger { background: var(--danger); }
.btn--success { background: var(--success); }
.btn--sm { padding: 6px 11px; font-size: 12.5px; }
.btn--block { width: 100%; justify-content: center; }
.btn--icon { padding: 6px 9px; }

/* ----------------------------- Forms ----------------------------- */
.form-group { margin-bottom: 16px; }
.form-row { display:grid; gap:16px; grid-template-columns: repeat(2,1fr); }
.form-row-3 { display:grid; gap:16px; grid-template-columns: repeat(3,1fr); }
@media (max-width:720px){ .form-row,.form-row-3{ grid-template-columns:1fr; } }
label { display:block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.req { color: var(--danger); }
.input, select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
  font-family: inherit; background: #fff; color: var(--text); transition: .15s;
}
.input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(27,79,114,.12); }
textarea { resize: vertical; min-height: 90px; }
.input.is-invalid { border-color: var(--danger); }
.help { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ----------------------------- Tables / DataTable ----------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; position: relative; }
.table-wrap::after { content:''; position:absolute; top:0; right:0; bottom:0; width:24px; pointer-events:none;
  background: linear-gradient(to right, transparent, rgba(248,249,250,.9)); opacity:0; transition:.2s; }
.table-wrap.is-scrollable::after { opacity:1; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 520px; }
table.data th, table.data td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data th { background: #f4f6f9; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; position: sticky; top: 0; z-index: 1; }
table.data tbody tr:nth-child(even) { background: #fbfcfd; }
table.data tbody tr:hover { background: #f3f6fb; }
table.data td.actions { white-space: nowrap; }
.dt-toolbar { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; margin-bottom:12px; }
.dt-toolbar .input { max-width:280px; min-width:180px; flex:1; }
.dt-pager { display:flex; align-items:center; gap:6px; flex-wrap:wrap; padding-top:12px; border-top:1px solid var(--border); margin-top:12px; }
.dt-pager .btn[disabled] { opacity:.45; cursor:not-allowed; }
.empty { text-align:center; padding: 40px 20px; color: var(--muted); }
.empty-ico { width:40px; height:40px; margin:0 auto 10px; border:2px dashed var(--border); border-radius:8px; position:relative; opacity:.5; }
.empty-ico::before { content:''; position:absolute; width:16px; height:2px; background:var(--muted); top:50%; left:50%; transform:translate(-50%,-50%); }

/* ----------------------------- Tabs ----------------------------- */
.tabs-bar { display:flex; gap:0; overflow-x:auto; -webkit-overflow-scrolling:touch; scrollbar-width:none; }
.tabs-bar::-webkit-scrollbar { display:none; }
.tabbtn { border:none; border-bottom:3px solid transparent; border-radius:0; padding:14px 18px; background:none; cursor:pointer; font-weight:600; color:var(--muted); font-size:13.5px; white-space:nowrap; font-family:inherit; transition:.15s; }
.tabbtn:hover { color:var(--primary); }
.tabbtn.active { border-bottom-color:var(--primary); color:var(--primary); }
.tab { display:none; }
.tab.active { display:block; }
.card__head.tabs-head { padding:0; }

/* ----------------------------- Badges ----------------------------- */
.badge { display:inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge--success { background: #e6f4ea; color: var(--success); }
.badge--danger { background: #fbeae8; color: var(--danger); }
.badge--warning { background: #fef5e7; color: #b9770e; }
.badge--info { background: #e8f1fb; color: var(--info); }
.badge--muted { background: #eef1f4; color: var(--muted); }
.badge--primary { background: #e7eef4; color: var(--primary); }

/* ----------------------------- Alerts / Toast ----------------------------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13.5px; border:1px solid transparent; }
.alert--success { background:#e6f4ea; color:#14633a; border-color:#bfe3cd; }
.alert--danger { background:#fbeae8; color:#922; border-color:#f3c4be; }
.alert--info { background:#e8f1fb; color:#1b5e8a; border-color:#c5ddf3; }
#toast-wrap { position: fixed; top: 18px; right: 18px; z-index: 9999; display:flex; flex-direction:column; gap:10px; }
.toast { background:#222; color:#fff; padding: 12px 18px; border-radius: 8px; box-shadow: var(--shadow-lg); font-size:13.5px; min-width:240px; animation: slidein .25s ease; }
.toast--success { background: var(--success); } .toast--danger { background: var(--danger); } .toast--info { background: var(--info); }
@keyframes slidein { from { transform: translateX(40px); opacity:0; } to { transform:none; opacity:1; } }

/* ----------------------------- Modal ----------------------------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(16,24,40,.5); display:none; align-items:center; justify-content:center; z-index: 1000; padding: 20px; }
.modal-backdrop.open { display: flex; }
.modal { background:#fff; border-radius: 12px; width: 100%; max-width: 640px; max-height: 90vh; overflow:auto; box-shadow: var(--shadow-lg); }
.modal__head { padding: 16px 20px; border-bottom: 1px solid var(--border); display:flex; justify-content:space-between; align-items:center; }
.modal__body { padding: 20px; }
.modal__foot { padding: 14px 20px; border-top: 1px solid var(--border); display:flex; justify-content:flex-end; gap:10px; }
.modal--sm { max-width: 420px; }
.close-x { background:none;border:none;font-size:22px;cursor:pointer;color:var(--muted); }

/* ----------------------------- Auth pages ----------------------------- */
.auth-wrap { min-height: 100vh; display:flex; }
.auth-side { flex: 1; background: linear-gradient(135deg, var(--sidebar-bg), var(--sidebar-bg-dark)); color:#fff; padding: 56px; display:flex; flex-direction:column; justify-content:center; }
.auth-side__logo { height: 48px; width: auto; max-width: 260px; object-fit: contain; margin-bottom: 24px; }
.auth-side h1 { color:#fff; font-size: 34px; line-height:1.2; }
.auth-side .tagline { color: rgba(255,255,255,.8); font-size: 16px; margin-top: 12px; max-width: 420px; }
.auth-side .feat { margin-top: 28px; display:flex; flex-direction:column; gap:12px; }
.auth-side .feat div { display:flex; gap:10px; align-items:center; color: rgba(255,255,255,.92); }
.feat-ico { width:16px; height:16px; flex-shrink:0; border:2px solid rgba(255,255,255,.7); border-top:none; border-left:none; transform:rotate(45deg); margin-top:-2px; }
.auth-main { width: 480px; max-width: 100%; display:flex; align-items:center; justify-content:center; padding: 40px; background: var(--surface); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h2 { font-size: 24px; margin-bottom: 6px; }
.auth-card .sub { color: var(--muted); margin-bottom: 24px; }
.auth-demo-hint { display:flex; flex-direction:column; gap:4px; line-height:1.45; }
.auth-demo-hint code { font-size:12.5px; background:rgba(27,94,138,.08); padding:1px 6px; border-radius:4px; }
@media (max-width: 880px){ .auth-side { display:none; } .auth-main{ width:100%; } }

.text-muted { color: var(--muted); }
.text-right { text-align: right; } .text-center { text-align: center; }
.mt-0{margin-top:0}.mt-1{margin-top:8px}.mt-2{margin-top:16px}.mt-3{margin-top:24px}
.mb-0{margin-bottom:0}.mb-1{margin-bottom:8px}.mb-2{margin-bottom:16px}.mb-3{margin-bottom:24px}
.flex { display:flex; } .items-center{align-items:center} .justify-between{justify-content:space-between} .gap-2{gap:8px} .gap-3{gap:16px}
.flex-wrap{flex-wrap:wrap}
.w-full{width:100%}
.empty { text-align:center; padding: 40px 20px; color: var(--muted); }
.empty .ico { font-size: 40px; opacity:.4; }

/* progress bar */
.progress { height: 10px; background: #eef1f4; border-radius: 999px; overflow: hidden; }
.progress > span { display:block; height:100%; background: var(--success); border-radius: 999px; }

/* chips/filters */
.filters { display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
.filters .input, .filters select { width:auto; }

@media (max-width: 980px){
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .menu-toggle { display:flex; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .topbar__user > div:first-child { display:none; }
  .dt-toolbar .input { max-width:100%; }
  .grid[style*="420px"] { grid-template-columns: 1fr !important; }
  .grid[style*="280px"] { grid-template-columns: 1fr !important; }
}
