/* ==========================================================================
   1. SYSTEM VARIABLES & MODERN DESIGN SYSTEM
   ========================================================================== */
:root {
  --primary: #4f46e5;          /* Electric Indigo */
  --primary-hover: #4338ca;
  --bg-main: #f8fafc;
  --sidebar-bg: #0f172a;       /* Deep Slate */
  --card-bg: #ffffff;
  --text-dark: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 10px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body { min-width: 320px; }
button, input, select { font: inherit; }
button { min-height: 38px; }
button:disabled { opacity: 0.55; cursor: not-allowed; }

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background-color: var(--bg-main);
  color: var(--text-dark);
  line-height: 1.5;
}

.is-hidden { display: none !important; }

i[data-lucide] {
  width: 18px;
  height: 18px;
  vertical-align: middle;
  display: inline-block;
}

/* ==========================================================================
   2. MODERN LOGIN CARD
   ========================================================================== */
#login-section {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
}

.login-card {
  width: 100%;
  max-width: 460px;
  background: #ffffff;
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.brand-icon-lg {
  width: 56px;
  height: 56px;
  background: #e0e7ff;
  color: var(--primary);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}

.login-header h2 { font-size: 22px; font-weight: 800; color: var(--text-dark); }
.login-header p, .sub-title, .sub-text { font-size: 13px; color: var(--text-muted); }

.demo-login-box {
  background: #f1f5f9;
  padding: 12px;
  border-radius: 10px;
  margin-bottom: 20px;
}

.demo-title { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }

.demo-btn-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 8px;
}

.btn-demo {
  padding: 6px;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-demo:hover { background: #e0e7ff; border-color: var(--primary); }

.form-group { margin-bottom: 16px; }

.form-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background-color: #fff;
  outline: none;
  font-family: inherit;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.btn-primary {
  width: 100%;
  padding: 10px 16px;
  background-color: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}

.btn-primary:hover { background-color: var(--primary-hover); }

.btn-danger {
  padding: 10px 16px;
  background-color: #ef4444;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}

/* ==========================================================================
   3. APP LAYOUT & SIDEBAR
   ========================================================================== */
.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.mobile-header {
  display: none;
  background-color: var(--sidebar-bg);
  color: #fff;
  padding: 14px 20px;
  justify-content: space-between;
  align-items: center;
}

.sidebar {
  width: 270px;
  background-color: var(--sidebar-bg);
  color: #94a3b8;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100vh;
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
  margin-bottom: 28px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-text { display: flex; flex-direction: column; }
.brand-name { color: #fff; font-weight: 800; font-size: 16px; }
.brand-badge { color: #818cf8; font-size: 9px; font-weight: 800; letter-spacing: 1px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }

.sidebar-nav a {
  color: #94a3b8;
  text-decoration: none;
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s;
}

.sidebar-nav a.active, .sidebar-nav a:hover {
  background-color: #1e293b;
  color: #818cf8;
}

.sidebar-footer {
  border-top: 1px solid #1e293b;
  padding-top: 16px;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #1e293b;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-det { display: flex; flex-direction: column; overflow: hidden; }
.u-name { font-size: 12px; font-weight: 700; color: #fff; white-space: nowrap; }
.u-role { font-size: 10px; color: #818cf8; font-weight: 700; }

.btn-logout {
  width: 100%;
  padding: 9px;
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  transition: all 0.2s;
}

.btn-logout:hover { background: #ef4444; color: #fff; }

.main-content {
  flex: 1;
  padding: 32px;
  background-color: var(--bg-main);
  overflow-y: auto;
  overflow-x: hidden;
  height: 100vh;
  min-width: 0;
}
.main-content > section > .card-header,
.main-content > section > .page-header {
  position: sticky;
  top: -32px;
  z-index: 10;
  padding: 10px 0;
  background: rgba(248, 250, 252, 0.96);
  backdrop-filter: blur(8px);
}
.status-select {
  border: 1px solid transparent;
  font-weight: 700;
  cursor: pointer;
  appearance: auto;
}

/* ==========================================================================
   4. CARDS & METRICS
   ========================================================================== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 16px;
}

.page-header > div:first-child,
.card-header > div:first-child { min-width: 0; }

h2, h3, h4 { line-height: 1.25; }

.role-pill-indicator {
  background: #e0e7ff;
  color: var(--primary);
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.role-pill-indicator .dot {
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.shortcut-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.btn-shortcut {
  padding: 14px;
  background-color: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-weight: 700;
  color: var(--text-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}

.btn-shortcut:hover {
  border-color: var(--primary);
  color: var(--primary);
  background-color: #e0e7ff;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.stat-card {
  padding: 16px;
  background-color: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-blue { background: #e0e7ff; color: var(--primary); }
.icon-green { background: #dcfce7; color: #16a34a; }
.icon-purple { background: #f3e8ff; color: #9333ea; }

.stat-card h4 { font-size: 11px; color: var(--text-muted); text-transform: uppercase; font-weight: 700; }
.stat-card p { font-size: 22px; font-weight: 800; color: var(--text-dark); }

/* ==========================================================================
   5. PROJECT CARDS & TABLES
   ========================================================================== */
.project-list-wrapper { display: flex; flex-direction: column; gap: 16px; }

.project-item-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  background-color: #fff;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}

.project-number {
  background-color: var(--primary);
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 800;
  margin-right: 8px;
}

.progress-bar-container {
  width: 100%;
  background-color: #f1f5f9;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background-color: var(--primary);
  transition: width 0.3s ease;
}

.search-box { position: relative; margin: 16px 0; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-input { padding-left: 42px; }

.table-responsive { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; text-align: left; }
.data-table th, .data-table td { white-space: nowrap; }
.data-table th, .data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.data-table th { background-color: #f8fafc; font-weight: 700; color: var(--text-muted); }

.badge { padding: 4px 8px; font-size: 11px; font-weight: 700; border-radius: 6px; display: inline-flex; align-items: center; gap: 4px; }
.badge-indigo { background: #e0e7ff; color: var(--primary); }
.badge-tag { background-color: #e0f2fe; color: #0369a1; }
.badge-pending { background-color: #fef3c7; color: #b45309; }
.badge-success { background-color: #dcfce7; color: #15803d; }
.badge-danger { background-color: #ffe4e6; color: #be123c; }

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }

.select-inline { width: auto; min-width: 160px; }

/* ==========================================================================
   6. NOTIFIKASI & ERROR ITEM
   ========================================================================== */
.notif-list { list-style: none; }
.notif-item {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
}

.notif-item:hover { background-color: #f8fafc; }
.notif-item.is-error { background-color: #fef2f2; border-color: #fca5a5; }

/* ==========================================================================
   7. MODALS
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal-card {
  background: #fff;
  padding: 24px;
  border-radius: 14px;
  width: 90%;
  max-width: 500px;
  box-shadow: var(--shadow-md);
}

.modal-card.modal-large {
  max-width: 850px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 16px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.inner-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.inner-tab-btn {
  padding: 8px 14px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.inner-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.upload-box-local {
  background: #f8fafc;
  border: 1px dashed #94a3b8;
  padding: 16px;
  border-radius: 10px;
}

.upload-form-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.filter-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.audit-summary-box {
  background: #e0e7ff;
  border: 1px solid #c7d2fe;
  padding: 14px;
  border-radius: 8px;
  margin-top: 16px;
  font-size: 13px;
  color: #3730a3;
}

.invoice-preview-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: 8px;
  font-size: 13px;
}

.comments-box {
  max-height: 180px;
  overflow-y: auto;
  background: #f8fafc;
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: 6px;
  margin-bottom: 12px;
}

.comment-input-row { display: flex; gap: 8px; align-items: flex-start; }
.backup-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.scroll-top-button {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-md);
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease, background-color 0.2s ease;
  z-index: 100;
}
.scroll-top-button.is-visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
.scroll-top-button:hover { background: var(--primary-hover); }

/* Responsive */
@media (max-width: 768px) {
  body { overflow-x: hidden; }
  .app-container { flex-direction: column; height: auto; min-height: 100vh; overflow: visible; }
  .mobile-header { display: flex; min-height: 56px; padding: 12px 16px; }
  .menu-toggle { min-height: 34px; padding: 6px 10px; }
  .sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    width: 100%;
    height: calc(100vh - 56px);
    z-index: 99;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    padding: 20px 16px;
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { padding: 20px 12px 32px; height: auto; overflow: visible; }
  .page-header,
  .card-header { align-items: stretch; flex-direction: column; }
  .page-header { margin-bottom: 18px; }
    .main-content > section > .card-header,
    .main-content > section > .page-header { top: -20px; padding: 8px 0; }
  .role-pill-indicator { align-self: flex-start; }
  .shortcut-grid,
  .stats-grid { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .upload-form-row,
  .filter-row,
  .comment-input-row { flex-direction: column; align-items: stretch; }
  .upload-form-row > *,
  .filter-row > *,
  .comment-input-row > * { width: 100% !important; }
  .btn-group { width: 100%; }
  .btn-group > button { flex: 1 1 140px; justify-content: center; }
  .select-inline { min-width: 0; }
  .modal-backdrop { align-items: flex-start; padding: 12px; overflow-y: auto; }
  .modal-card,
  .modal-card.modal-large { width: 100%; max-width: none; max-height: calc(100vh - 24px); padding: 16px; }
  .modal-header-row { gap: 12px; }
  .modal-header-row > button { flex-shrink: 0; }
  .inner-tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  .inner-tab-btn { flex: 0 0 auto; white-space: nowrap; }
  .backup-grid { grid-template-columns: 1fr; }
  .notif-item { align-items: flex-start; gap: 12px; }
  .notif-item > button { flex-shrink: 0; }
}

@media (max-width: 480px) {
  .login-card { padding: 24px 18px; }
  .demo-btn-grid { grid-template-columns: repeat(2, 1fr); }
  .page-header h2,
  .card-header h2 { font-size: 20px; }
  .btn-group > button { flex-basis: 100%; }
  .modal-header-row { align-items: flex-start; }
  .modal-header-row h3 { font-size: 18px; }
  .scroll-top-button { right: 16px; bottom: 16px; }
}