/* Modern Elegant Theme */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #14b8a6;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 4px 6px -1px rgba(15,23,42,.08);
  --shadow-lg: 0 10px 15px -3px rgba(15,23,42,.1);
  --shadow-xl: 0 20px 25px -5px rgba(15,23,42,.12);
  --radius: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --sidebar-width: 260px;
  --transition: all .2s ease;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; min-height: 100vh; -webkit-font-smoothing: antialiased; }
.app-layout { display: flex; min-height: 100vh; gap: 24px; padding: 20px; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-width); background: linear-gradient(180deg,#0f172a 0%,#1e293b 100%); color: #fff;
  padding: 24px 16px; border-radius: var(--radius-lg); min-height: calc(100vh - 40px);
  position: sticky; top: 20px; flex-shrink: 0; display: flex; flex-direction: column; box-shadow: var(--shadow-xl); overflow: hidden;
  transition: width 0.3s ease, padding 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
}
.sidebar::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 200px;
  background: linear-gradient(135deg,rgba(37,99,235,.25),rgba(20,184,166,.15)); pointer-events: none;
}
.sidebar-brand { position: relative; text-align: center; padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid rgba(255,255,255,.12); }
.sidebar-brand img { height: 48px; margin-bottom: 12px; filter: brightness(0) invert(1); }
.sidebar-brand h1 { font-size: 13px; font-weight: 700; letter-spacing: .5px; line-height: 1.4; margin: 0; }
.sidebar-profile { position: relative; text-align: center; margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid rgba(255,255,255,.12); }
.sidebar-avatar { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; margin-bottom: 12px; border: 3px solid rgba(255,255,255,.25); box-shadow: 0 4px 12px rgba(0,0,0,.2); }
.sidebar-name { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.sidebar-role { font-size: 12px; color: #94a3b8; text-transform: uppercase; letter-spacing: .5px; }
.sidebar-nav { position: relative; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.sidebar-nav a { display: flex; align-items: center; gap: 12px; padding: 12px 14px; color: #cbd5e1; text-decoration: none; border-radius: var(--radius); font-weight: 500; font-size: 14px; transition: var(--transition); position: relative; }
.sidebar-nav a:hover { background: rgba(255,255,255,.08); color: #fff; transform: translateX(4px); }
.sidebar-nav a.active { background: linear-gradient(90deg,rgba(37,99,235,.25),rgba(20,184,166,.15)); color: #fff; box-shadow: 0 4px 12px rgba(37,99,235,.2); }
.sidebar-nav a.active::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; background: linear-gradient(180deg,var(--primary),var(--accent)); border-radius: 0 4px 4px 0; }
.sidebar-footer { position: relative; margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.12); font-size: 12px; color: #94a3b8; text-align: center; }

/* Main Content */
.main-content { flex: 1; min-width: 0; padding-bottom: 24px; transition: width 0.3s ease; }
.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 26px; font-weight: 800; color: var(--text); margin-bottom: 6px; letter-spacing: -.5px; }
.page-header p { color: var(--muted); font-size: 14px; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; margin-bottom: 20px; box-shadow: var(--shadow); transition: var(--transition); }
.card:hover { box-shadow: var(--shadow-lg); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.card-title { font-size: 18px; font-weight: 700; color: var(--text); margin: 0; }
.card-subtitle { font-size: 13px; color: var(--muted); margin-top: 4px; }
.card-hero { background: linear-gradient(135deg,rgba(37,99,235,.06) 0%,rgba(20,184,166,.06) 100%); border: 1px solid rgba(37,99,235,.12); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--radius-full); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; }
.badge-primary { background: rgba(37,99,235,.1); color: var(--primary-dark); border: 1px solid rgba(37,99,235,.15); }
.badge-accent { background: rgba(20,184,166,.1); color: #0f766e; border: 1px solid rgba(20,184,166,.15); }
.badge-success { background: rgba(34,197,94,.1); color: #15803d; border: 1px solid rgba(34,197,94,.15); }
.badge-danger { background: rgba(239,68,68,.1); color: #b91c1c; border: 1px solid rgba(239,68,68,.15); }
.badge-warning { background: rgba(234,179,8,.1); color: #a16207; border: 1px solid rgba(234,179,8,.15); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border: none; border-radius: var(--radius-full); background: linear-gradient(135deg,var(--primary) 0%,var(--primary-dark) 100%); color: #fff; font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer; transition: var(--transition); box-shadow: 0 4px 12px rgba(37,99,235,.25); white-space: nowrap; }
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(37,99,235,.35); filter: brightness(1.05); }
.btn:active { transform: translateY(0); }
.btn-secondary { background: linear-gradient(135deg,#64748b 0%,#475569 100%); box-shadow: 0 4px 12px rgba(100,116,139,.25); }
.btn-secondary:hover { box-shadow: 0 6px 16px rgba(100,116,139,.35); }
.btn-success { background: linear-gradient(135deg,#10b981 0%,#059669 100%); box-shadow: 0 4px 12px rgba(16,185,129,.25); }
.btn-success:hover { box-shadow: 0 6px 16px rgba(16,185,129,.35); }
.btn-danger { background: linear-gradient(135deg,#ef4444 0%,#dc2626 100%); box-shadow: 0 4px 12px rgba(239,68,68,.25); }
.btn-danger:hover { box-shadow: 0 6px 16px rgba(239,68,68,.35); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: #334155; box-shadow: none; }
.btn-outline:hover { background: #f8fafc; border-color: var(--primary); color: var(--primary); box-shadow: none; }

/* Forms */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 6px; }
.form-control { width: 100%; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: var(--radius); background: #fff; color: var(--text); font-size: 14px; font-family: inherit; transition: var(--transition); }
.form-control:hover { border-color: #cbd5e1; }
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.form-control::placeholder { color: #94a3b8; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 40px; }
textarea.form-control { min-height: 100px; resize: vertical; }

/* Tables */
.table-wrapper { overflow: auto; border-radius: var(--radius); border: 1px solid var(--border); max-height: calc(100vh - 320px); }
.table-wrapper::-webkit-scrollbar { width: 8px; height: 8px; }
.table-wrapper::-webkit-scrollbar-track { background: #f8fafc; }
.table-wrapper::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: var(--radius-full); }
.table-wrapper::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; background: #fff; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: linear-gradient(180deg,#f8fafc 0%,#f1f5f9 100%); color: #334155; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; position: sticky; top: 0; z-index: 10; box-shadow: 0 1px 2px rgba(15,23,42,.05); }
tbody tr:hover td { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }
.table-actions { display: flex; gap: 6px; flex-wrap: nowrap; }

/* Filter row */
.filter-row th { background: #f1f5f9; padding: 6px 4px; vertical-align: top; }
.filter-input { width: 100%; padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; font-size: 11px; font-family: inherit; background: #fff; }
.filter-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,.08); }

/* Status colors */
.status-lancar { color: #15803d; font-weight: 700; }
.status-dpk { color: #a16207; font-weight: 700; }
.status-kl { color: #dc2626; font-weight: 700; }
.status-ragukan { color: #9333ea; font-weight: 700; }
.status-macet { color: #7f1d1d; font-weight: 700; }
.status-belum { color: #dc2626; font-weight: 700; }
.status-sudah { color: #15803d; font-weight: 700; }

/* Modal */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15,23,42,.55); backdrop-filter: blur(4px); z-index: 1000; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.active { display: flex; }
.modal-content { background: #fff; border-radius: var(--radius-lg); padding: 28px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-xl); animation: modalIn .3s ease; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-size: 20px; font-weight: 700; margin: 0; }
.modal-close { background: none; border: none; font-size: 24px; color: var(--muted); cursor: pointer; padding: 0; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: var(--transition); }
.modal-close:hover { background: #f1f5f9; color: var(--text); }

@keyframes modalIn { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }

/* Alerts */
.alert { padding: 14px 18px; border-radius: var(--radius); font-weight: 500; margin-bottom: 20px; }
.alert-success { background: rgba(34,197,94,.1); color: #15803d; border: 1px solid rgba(34,197,94,.2); }
.alert-danger { background: rgba(239,68,68,.1); color: #b91c1c; border: 1px solid rgba(239,68,68,.2); }
.alert-info { background: rgba(37,99,235,.1); color: var(--primary-dark); border: 1px solid rgba(37,99,235,.2); }

/* Utilities */
.muted { color: var(--muted); }
.text-right { text-align: right; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mt-4 { margin-top: 16px; }

/* Login Page */
.login-page { background: linear-gradient(135deg,#eff6ff 0%,#ecfeff 100%); display: flex; flex-direction: column; min-height: 100vh; }
.login-header { width: 100%; background: linear-gradient(90deg,var(--primary),var(--accent)); color: #fff; text-align: center; padding: 24px 16px; box-shadow: var(--shadow-lg); }
.login-header img { height: 56px; margin-bottom: 12px; filter: brightness(0) invert(1); }
.login-header h1 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: .5px; }
.login-container { display: flex; justify-content: center; align-items: center; flex: 1; padding: 40px 20px; }
.login-box { background: #fff; padding: 36px; border-radius: var(--radius-lg); width: 400px; box-shadow: var(--shadow-xl); animation: modalIn .3s ease; }
.login-box h2 { margin-top: 0; color: var(--text); font-size: 22px; font-weight: 700; margin-bottom: 20px; }
.login-box .form-group { margin-bottom: 16px; }
.login-box .btn { width: 100%; padding: 12px; font-size: 15px; }
.login-note { font-size: 12px; margin-top: 16px; color: var(--muted); text-align: center; }

/* Responsive */
@media (max-width: 1024px) {
  .app-layout { flex-direction: column; padding: 12px; gap: 12px; }
  .sidebar { width: 100%; min-height: auto; position: relative; top: 0; border-radius: var(--radius-lg); }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
  .sidebar-nav a { padding: 8px 12px; font-size: 13px; }
  .sidebar-footer { display: none; }
  .table-wrapper { max-height: none; }
  th, td { padding: 8px 10px; }
  .modal-content { max-width: 95%; padding: 20px; }
  .login-box { width: 100%; max-width: 400px; }
}

@media (max-width: 640px) {
  .page-header h2 { font-size: 20px; }
  .card { padding: 16px; }
  .btn { padding: 8px 14px; font-size: 13px; }
  .sidebar-brand h1 { font-size: 11px; }
}

/* Data row clickable */
tbody tr.data-row { cursor: pointer; }
tbody tr.data-row:hover td { background: #eff6ff; }
tbody tr.data-row:focus { outline: 2px solid var(--primary); outline-offset: -2px; }

/* Profile */
.avatar-large { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; border: 3px solid var(--primary); box-shadow: var(--shadow-lg); }

/* Pagination */
.pagination { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pagination-info { font-size: 13px; color: var(--muted); }

/* Sidebar Toggle */
.sidebar-toggle {
  position: fixed;
  top: 24px;
  left: 24px;
  z-index: 1001;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: linear-gradient(135deg,var(--primary) 0%,var(--primary-dark) 100%);
  border: none;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.sidebar-toggle:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-xl);
}
.sidebar-toggle:active {
  transform: scale(0.95);
}

/* Sidebar Hidden State */
.sidebar-hidden .sidebar {
  width: 0;
  padding: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateX(-100%);
}
.sidebar-hidden .main-content {
  width: 100%;
}
.sidebar-hidden .sidebar-toggle {
  left: 24px;
}

/* Sidebar visible - toggle button moves to edge */
.sidebar:not(.sidebar-hidden) ~ .sidebar-toggle,
.app-layout:not(.sidebar-hidden) .sidebar-toggle {
  left: calc(var(--sidebar-width) + 36px);
}

/* Auto-hide on scroll */
.sidebar-auto-hide {
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.sidebar-auto-hide.scrolled {
  transform: translateX(-100%);
  opacity: 0;
}
.sidebar-auto-hide:hover {
  transform: translateX(0);
  opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  .sidebar-toggle {
    top: 16px;
    left: 16px;
  }
  .sidebar-hidden .sidebar {
    display: none;
  }
  .app-layout:not(.sidebar-hidden) .sidebar-toggle {
    left: calc(100% - 60px);
  }
}