/* ===== CSS Variables ===== */
:root {
  --bg: #f0f2f5;
  --sidebar-bg: #1e293b;
  --sidebar-w: 260px;
  --card-bg: #fff;
  --text: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-light: #dbeafe;
  --primary-dark: #1d4ed8;
  --green: #16a34a;
  --green-light: #dcfce7;
  --orange: #ea580c;
  --orange-light: #fff7ed;
  --red: #dc2626;
  --red-light: #fef2f2;
  --blue: #2563eb;
  --blue-light: #dbeafe;
  --purple: #7c3aed;
  --purple-light: #f3e8ff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.1);
  --transition: .2s ease;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overflow: hidden;
  height: 100vh;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; font: inherit; }
input, select, textarea {
  font: inherit;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  outline: none;
  transition: border-color var(--transition);
  width: 100%;
  background: #fff;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

/* ===== Layout ===== */
#app { display: flex; height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: transform var(--transition);
  z-index: 100;
}
.sidebar-header { padding: 20px; border-bottom: 1px solid rgba(255,255,255,.1); }
.logo { display: flex; align-items: center; gap: 12px; }
.logo-icon {
  width: 40px; height: 40px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-icon svg { width: 22px; height: 22px; color: #fff; }
.logo h1 { font-size: 1.25rem; font-weight: 700; letter-spacing: .5px; }
.logo p { font-size: .75rem; color: rgba(255,255,255,.6); margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.7);
  transition: all var(--transition);
  font-size: .92rem;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.1); }
.user-info { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700;
}
.user-name { font-size: .88rem; font-weight: 600; }
.user-role { font-size: .75rem; color: rgba(255,255,255,.5); }

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ===== Topbar ===== */
.topbar {
  height: 64px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  flex-shrink: 0;
}
.menu-toggle {
  display: none;
  background: none;
  padding: 6px;
}
.menu-toggle svg { width: 24px; height: 24px; color: var(--text); }
.topbar-title { font-size: 1.15rem; font-weight: 700; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  width: 280px;
}
.search-box svg { width: 18px; height: 18px; color: var(--text-secondary); flex-shrink: 0; }
.search-box input { border: none; background: none; padding: 0; width: 100%; font-size: .88rem; }
.search-box input:focus { outline: none; }
.notification-bell { position: relative; padding: 6px; }
.notification-bell svg { width: 22px; height: 22px; color: var(--text-secondary); }
.badge {
  position: absolute; top: 2px; right: 0;
  background: var(--red);
  color: #fff;
  font-size: .65rem; font-weight: 700;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

/* ===== Pages ===== */
.page {
  display: none;
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}
.page.active { display: block; }

/* ===== Stats Grid ===== */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 24px; height: 24px; }
.stat-icon.blue { background: var(--blue-light); color: var(--blue); }
.stat-icon.orange { background: var(--orange-light); color: var(--orange); }
.stat-icon.red { background: var(--red-light); color: var(--red); }
.stat-icon.green { background: var(--green-light); color: var(--green); }
.stat-value { font-size: 1.5rem; font-weight: 800; line-height: 1.2; }
.stat-label { font-size: .82rem; color: var(--text-secondary); margin-top: 2px; }

/* ===== Dashboard Grid ===== */
.dashboard-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }

/* ===== Sections ===== */
.section {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }
.section-header h2 { font-size: 1.05rem; font-weight: 700; }
.section-desc { color: var(--text-secondary); font-size: .88rem; margin-top: 4px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: .88rem;
  transition: all var(--transition);
}
.btn-sm { padding: 7px 14px; font-size: .82rem; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--text); }
.btn-secondary:hover { background: var(--border); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

/* ===== Process List (Dashboard) ===== */
.process-list { display: flex; flex-direction: column; gap: 10px; }
.process-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: all var(--transition);
}
.process-card:hover { border-color: var(--primary); background: var(--primary-light); }
.process-card .pc-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.process-card .pc-info { flex: 1; min-width: 0; }
.process-card .pc-title { font-weight: 600; font-size: .92rem; }
.process-card .pc-meta { font-size: .78rem; color: var(--text-secondary); margin-top: 2px; }
.process-card .pc-progress { width: 120px; flex-shrink: 0; }
.progress-bar {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar .fill {
  height: 100%;
  border-radius: 3px;
  transition: width .4s ease;
}
.progress-text { font-size: .72rem; color: var(--text-secondary); text-align: right; margin-top: 4px; }

/* ===== Activity Feed ===== */
.activity-feed { display: flex; flex-direction: column; gap: 0; }
.activity-item {
  display: flex; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: .88rem;
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}
.activity-dot.blue { background: var(--blue); }
.activity-dot.green { background: var(--green); }
.activity-dot.orange { background: var(--orange); }
.activity-dot.red { background: var(--red); }
.activity-time { font-size: .75rem; color: var(--text-secondary); margin-top: 2px; }

/* ===== Form ===== */
.form-container { max-width: 800px; }
.form-step { display: none; margin-top: 20px; }
.form-step.active { display: block; }
.form-step-title {
  display: flex; align-items: center; gap: 12px;
  font-size: 1.05rem; font-weight: 700;
  margin-bottom: 20px;
}
.step-number {
  width: 32px; height: 32px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .88rem; font-weight: 700;
  flex-shrink: 0;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: .82rem; font-weight: 600; color: var(--text-secondary); }
.form-group.full-width { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 12px; margin-top: 24px; justify-content: flex-end; }

/* ===== Service Grid ===== */
.service-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.service-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}
.service-card:hover { border-color: var(--primary); background: var(--primary-light); }
.service-card.selected { border-color: var(--primary); background: var(--primary-light); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.service-card .sc-icon { font-size: 2rem; margin-bottom: 10px; }
.service-card .sc-name { font-weight: 700; font-size: .95rem; }
.service-card .sc-steps { font-size: .78rem; color: var(--text-secondary); margin-top: 6px; }

/* ===== Tracking List ===== */
.tracking-list { display: flex; flex-direction: column; gap: 12px; }
.tracking-card {
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  cursor: pointer;
  transition: all var(--transition);
}
.tracking-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.tracking-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.tracking-id { font-weight: 700; font-size: .95rem; }
.tracking-badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}
.tracking-badge.in-progress { background: var(--blue-light); color: var(--blue); }
.tracking-badge.completed { background: var(--green-light); color: var(--green); }
.tracking-badge.overdue { background: var(--red-light); color: var(--red); }
.tracking-info { display: flex; gap: 24px; font-size: .85rem; color: var(--text-secondary); flex-wrap: wrap; }
.tracking-info span { display: flex; align-items: center; gap: 4px; }
.tracking-steps { margin-top: 14px; }
.mini-timeline { display: flex; align-items: center; gap: 0; }
.mini-step {
  flex: 1; height: 6px;
  background: var(--border);
  position: relative;
}
.mini-step:first-child { border-radius: 3px 0 0 3px; }
.mini-step:last-child { border-radius: 0 3px 3px 0; }
.mini-step.done { background: var(--green); }
.mini-step.active { background: var(--primary); animation: pulse-step 1.5s infinite; }
@keyframes pulse-step { 0%,100% { opacity: 1; } 50% { opacity: .5; } }
.tracking-step-label {
  display: flex; justify-content: space-between;
  font-size: .72rem; color: var(--text-secondary);
  margin-top: 6px;
}

/* ===== Archive List ===== */
.archive-list { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.archive-card {
  width: 100%;
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: all var(--transition);
}
.archive-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.archive-main { min-width: 0; }
.archive-title { font-weight: 700; font-size: .96rem; }
.archive-meta { color: var(--text-secondary); font-size: .82rem; margin-top: 2px; }
.archive-stats { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; justify-content: flex-end; }
.archive-stat-item { display: flex; flex-direction: column; gap: 2px; font-size: .82rem; }
.archive-stat-label { color: var(--text-secondary); font-size: .74rem; }

.archive-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.archive-summary-item {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: .85rem;
}
.archive-summary-label { color: var(--text-secondary); font-size: .76rem; }
.archive-history-list { display: flex; flex-direction: column; gap: 10px; }
.archive-history-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.archive-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.archive-history-title { font-weight: 700; font-size: .9rem; }
.archive-history-meta {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--text-secondary);
  font-size: .8rem;
}
.archive-history-actions { margin-top: 10px; }

/* ===== Catalog Grid ===== */
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; margin-top: 20px; }
.catalog-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
}
.catalog-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.catalog-card-header {
  padding: 24px;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.catalog-card-header::after {
  content: '';
  position: absolute; right: -20px; top: -20px;
  width: 100px; height: 100px;
  background: rgba(255,255,255,.1);
  border-radius: 50%;
}
.catalog-card-header .cc-icon { font-size: 2rem; margin-bottom: 8px; }
.catalog-card-header h3 { font-size: 1.1rem; font-weight: 700; }
.catalog-card-header p { font-size: .82rem; opacity: .85; margin-top: 4px; }
.catalog-card-body { padding: 20px; }
.catalog-card-body .cc-stat { display: flex; justify-content: space-between; font-size: .85rem; padding: 6px 0; }
.catalog-card-body .cc-stat:not(:last-child) { border-bottom: 1px solid var(--border); }
.catalog-card-body .cc-stat-label { color: var(--text-secondary); }
.catalog-card-body .cc-stat-value { font-weight: 600; }

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal.modal-wide { max-width: 800px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--card-bg);
  z-index: 1;
}
.modal-header h2 { font-size: 1.1rem; font-weight: 700; }
.modal-close {
  width: 32px; height: 32px;
  background: var(--bg);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; color: var(--text-secondary);
  transition: all var(--transition);
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-body { padding: 24px; }

/* ===== Timeline (modal detail) ===== */
.timeline { position: relative; padding-left: 32px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 11px; top: 0; bottom: 0;
  width: 2px;
  background: var(--border);
}
.timeline-item { position: relative; padding-bottom: 24px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute;
  left: -32px; top: 2px;
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700; color: #fff;
  z-index: 1;
}
.timeline-dot.done { background: var(--green); }
.timeline-dot.active { background: var(--primary); box-shadow: 0 0 0 4px var(--primary-light); }
.timeline-dot.pending { background: var(--border); color: var(--text-secondary); }
.timeline-content h4 { font-size: .92rem; font-weight: 600; }
.timeline-content .tl-role {
  display: inline-block;
  padding: 2px 10px;
  background: var(--purple-light);
  color: var(--purple);
  border-radius: 12px;
  font-size: .72rem;
  font-weight: 600;
  margin-top: 4px;
}
.timeline-content .tl-section {
  font-size: .78rem;
  color: var(--text-secondary);
  margin-top: 2px;
}
.timeline-content .tl-date {
  font-size: .75rem;
  color: var(--text-secondary);
  margin-top: 4px;
}
.timeline-actions { margin-top: 8px; }

/* ===== Table ===== */
.table-container { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.data-table thead { background: var(--bg); }
.data-table th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: .8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.data-table tbody tr:hover { background: #f8fafc; }
.status-dot {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .82rem; font-weight: 500;
}
.status-dot::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.dipinjam::before { background: var(--orange); }
.status-dot.proses::before { background: var(--blue); }
.status-dot.selesai::before { background: var(--green); }
.status-dot.terlambat::before { background: var(--red); }

/* ===== Filter Bar ===== */
.filter-bar { display: flex; align-items: center; gap: 10px; }
.filter-bar select, .filter-bar input[type="date"] { width: auto; min-width: 160px; font-size: .85rem; }
.filter-sep { font-size: .82rem; color: var(--text-secondary); }

/* ===== Toast ===== */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--sidebar-bg);
  color: #fff;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  box-shadow: var(--shadow-lg);
  animation: toast-in .3s ease;
  max-width: 360px;
}
.toast.success { border-left: 4px solid var(--green); }
.toast.error { border-left: 4px solid var(--red); }
.toast.info { border-left: 4px solid var(--blue); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .catalog-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: block; }
  .search-box { width: 180px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .tracking-info { flex-direction: column; gap: 6px; }
  .archive-card { flex-direction: column; align-items: flex-start; }
  .archive-stats { justify-content: flex-start; gap: 14px; }
  .archive-summary-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .search-box { display: none; }
  .topbar { padding: 0 16px; }
  .page { padding: 16px; }
  .service-grid { grid-template-columns: 1fr; }
}
