:root {
  --bg-main: #f1f5f9;
  --bg-card: #ffffff;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; }
body { background: var(--bg-main); color: var(--text-main); font-size: 14px; overflow-x: hidden; }
.hidden { display: none !important; }

/* LOGIN SCREEN */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: url('https://i.ibb.co.com/tpQCB0Xs/Construction-Sunset-Corporate-Blueprint-1.png') center/cover no-repeat;
}
.login-card {
  background: transparent !important;
  backdrop-filter: none !important;
  border: none !important;
  box-shadow: none !important;
}
.login-card h1,
.login-card p {
  text-align: center !important;
}

.login-card h1 {
  color: #ffffff !important;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

/* LAYOUT UTAMA */
.app-layout { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
  width: 260px; background: var(--sidebar-bg); color: #f8fafc;
  display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0;
  z-index: 1000; transition: transform 0.25s ease;
}
.sidebar-header {
  padding: 18px 20px; border-bottom: 1px solid #1e293b;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { font-size: 18px; font-weight: 700; letter-spacing: 0.3px; }
.brand span { color: #60a5fa; }
.btn-close-sidebar { display: none; background: none; border: none; color: #94a3b8; font-size: 22px; cursor: pointer; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.nav-item {
  width: 100%; text-align: left; background: none; border: none; color: #cbd5e1;
  padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 14px;
  display: flex; align-items: center; gap: 10px; margin-bottom: 4px; transition: 0.15s;
}
.nav-item:hover, .nav-item.active { background: var(--sidebar-hover); color: #fff; font-weight: 600; }
.nav-group-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: #64748b;
  padding: 14px 12px 6px; font-weight: 700;
}
.nav-sub-list { padding-left: 10px; }
.nav-sub-item {
  width: 100%; text-align: left; background: none; border: none; color: #94a3b8;
  padding: 8px 12px; border-radius: 6px; cursor: pointer; font-size: 13px;
  display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px;
}
.nav-sub-item:hover, .nav-sub-item.active { background: #1e293b; color: #60a5fa; font-weight: 600; }
.nav-add-project { color: #38bdf8; font-weight: 600; }

/* SIDEBAR FOOTER (STATUS ONLINE / OFFLINE) */
.sidebar-footer { padding: 14px 16px; border-top: 1px solid #1e293b; background: #0b1120; }
.user-info { font-size: 12px; color: #94a3b8; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.user-info strong { color: #f8fafc; display: block; font-size: 13px; }
.btn-logout { background: #1e293b; color: #f87171; border: none; padding: 4px 8px; border-radius: 6px; cursor: pointer; font-size: 11px; }

.status-badge {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-radius: 8px; font-size: 12px; font-weight: 600;
}
.status-online { background: rgba(22, 163, 74, 0.15); color: #4ade80; border: 1px solid rgba(74, 222, 128, 0.3); }
.status-offline { background: rgba(220, 38, 38, 0.15); color: #f87171; border: 1px solid rgba(248, 113, 113, 0.3); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.status-online .status-dot { background: #4ade80; }
.status-offline .status-dot { background: #f87171; }

/* MAIN CONTENT */
.main-content { flex: 1; margin-left: 260px; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: #fff; padding: 14px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.btn-menu { display: none; background: var(--bg-main); border: 1px solid var(--border); padding: 6px 10px; border-radius: 8px; font-size: 18px; cursor: pointer; }
.page-title { font-size: 18px; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.content-body { padding: 20px 24px; max-width: 1400px; width: 100%; }

/* CARDS & GRID */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.card { background: var(--bg-card); border-radius: var(--radius); padding: 18px; border: 1px solid var(--border); margin-bottom: 16px; }
.kpi-label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.kpi-value { font-size: 20px; font-weight: 700; color: var(--text-main); }
.kpi-sub { font-size: 11px; margin-top: 4px; color: var(--text-muted); }

/* TABS PROYEK */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tab-btn {
  padding: 8px 14px; border: none; background: transparent; color: var(--text-muted);
  font-weight: 600; cursor: pointer; border-radius: 8px; white-space: nowrap; font-size: 13px;
}
.tab-btn.active { background: var(--primary); color: #fff; }

/* TABLES */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 650px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
th { background: #f8fafc; font-weight: 600; color: var(--text-muted); font-size: 12px; text-transform: uppercase; }
.text-right { text-align: right; }

/* BUTTONS & INPUTS */
.btn {
  padding: 8px 14px; border-radius: 8px; border: none; font-weight: 600; cursor: pointer;
  font-size: 13px; display: inline-flex; align-items: center; gap: 6px; transition: 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--text-main); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 5px; color: var(--text-main); }
.form-control {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; outline: none; background: #fff;
}
.form-control:focus { border-color: var(--primary); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* BADGES & PROGRESS */
.badge { padding: 3px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; display: inline-block; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #dbeafe; color: #1e40af; }

.progress-bar { height: 8px; background: #e2e8f0; border-radius: 99px; overflow: hidden; margin-top: 6px; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 99px; }

/* MODAL */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.6); z-index: 2000;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal-box {
  background: #fff; border-radius: 14px; width: 100%; max-width: 500px;
  max-height: 90vh; overflow-y: auto; padding: 20px;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header h3 { font-size: 16px; }
.btn-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 999; }

/* RESPONSIVE TABLET & MOBILE */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .btn-menu, .btn-close-sidebar { display: block; }
  .main-content { margin-left: 0; }
  .topbar { padding: 12px 16px; }
  .content-body { padding: 16px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
/* Perbaikan warna teks form login mode gelap */
.login-card h1 {
  color: #ffffff !important;
}
.login-card h1 span {
  color: #60a5fa !important;
}
.login-card p {
  color: #cbd5e1 !important;
}
.login-card .form-group label {
  color: #e2e8f0 !important;
}

.login-logo {
  display: block;
  margin: 14px auto 14px auto;
  width: 150px;
  height: 150px;
  object-fit: contain;
  border-radius: 14px;
}

.login-logo {
  display: block;
  margin: 0 auto 20px auto !important; /* Angka 20px = jarak bawah Logo ke teks/form */
}

/* Jarak antara Nama Usaha, Logo, dan Form Login */
.login-card h1 {
  margin-bottom: 10px !important; /* Jarak bawah Nama Usaha ke Logo */
}

.login-card p {
  margin-bottom: 35px !important; /* Jarak bawah teks deskripsi ke kolom Username */
}

/* Ukuran font Nama Usaha dan Deskripsi di Form Login */
.login-card h1 {
  font-size: 38px !important; /* Ukuran font Nama Usaha */
  letter-spacing: 1px;        /* Opsional: jarak antar huruf agar lebih tegas */
}

.login-card p {
  font-size: 14px !important; /* Ukuran font Deskripsi di bawahnya */
}
/* Fix Full-Screen & Lebar Proporsional di HP */
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden;
}

.login-screen {
  min-height: 100dvh !important; /* Pas 1 layar HP termasuk address bar */
  width: 100% !important;
  padding: 16px !important;
  box-sizing: border-box;
}

.login-card {
  width: 100% !important;
  max-width: 420px !important;
  padding: 20px 12px !important; /* Kurangi padding samping agar form lebih lebar */
  box-sizing: border-box;
}

.login-card .form-control,
.login-card button[type="submit"] {
  width: 100% !important;
  box-sizing: border-box;
}
/* ==========================================
   CUSTOM PROFESSIONAL POPUP & TOAST
   ========================================== */
.ui-dialog-backdrop {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; animation: uiFadeIn 0.18s ease-out;
}

.ui-dialog-box {
  background: #ffffff; color: #0f172a;
  width: 100%; max-width: 360px; border-radius: 16px;
  padding: 24px 20px 20px; text-align: center;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.25);
  animation: uiScaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.ui-dialog-icon {
  width: 52px; height: 52px; margin: 0 auto 14px;
  border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 24px;
}
.ui-icon-danger  { background: #fee2e2; color: #dc2626; }
.ui-icon-warning { background: #fef3c7; color: #d97706; }
.ui-icon-info    { background: #dbeafe; color: #2563eb; }
.ui-icon-success { background: #dcfce7; color: #16a34a; }

.ui-dialog-title {
  font-size: 17px; font-weight: 700; margin: 0 0 6px; color: #0f172a;
}

.ui-dialog-msg {
  font-size: 13.5px; color: #64748b; line-height: 1.5; margin: 0 0 18px;
}

.ui-dialog-input {
  width: 100%; box-sizing: border-box; padding: 10px 12px;
  border: 1.5px solid #cbd5e1; border-radius: 10px;
  font-size: 14px; margin-bottom: 18px; outline: none;
}
.ui-dialog-input:focus { border-color: #2563eb; }

.ui-dialog-actions {
  display: flex; gap: 10px; justify-content: center;
}
.ui-dialog-actions button {
  flex: 1; padding: 10px 14px; border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer; border: none;
  transition: opacity 0.15s, transform 0.1s;
}
.ui-dialog-actions button:active { transform: scale(0.97); }
.ui-btn-cancel  { background: #f1f5f9; color: #475569; }
.ui-btn-primary { background: #2563eb; color: #ffffff; }
.ui-btn-danger  { background: #dc2626; color: #ffffff; }

/* Floating Toast Notification */
.ui-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 10000; padding: 11px 18px; border-radius: 12px;
  font-size: 13.5px; font-weight: 600; color: #ffffff;
  background: #0f172a; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
  display: flex; align-items: center; gap: 8px;
  max-width: 90vw; animation: uiSlideUp 0.22s ease-out;
}
.ui-toast-success { background: #15803d; }
.ui-toast-warning { background: #b45309; }
.ui-toast-danger  { background: #b91c1c; }

@keyframes uiFadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes uiScaleIn { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }
@keyframes uiSlideUp { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ==========================================
   STYLE KARTU KPI HALAMAN FINANCE
   ========================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 20px !important;
}

.kpi-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.kpi-label {
  font-size: 12.5px;
  font-weight: 600;
  color: #64748b;
  letter-spacing: 0.2px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
  line-height: 1.25;
  margin: 2px 0;
}

.kpi-card small {
  font-size: 12px;
  line-height: 1.4;
  padding-top: 6px;
  border-top: 1px dashed #e2e8f0;
}

/* Highlight Khusus Kartu Saldo Kas Riil */
.kpi-card:last-child {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%) !important;
  border: 1.5px solid #93c5fd !important;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.12);
}

.kpi-card:last-child small {
  border-top-color: #bfdbfe;
}

/* Responsif di Layar HP */
@media (max-width: 600px) {
  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .kpi-card {
    padding: 15px 16px;
  }
  .kpi-value {
    font-size: 21px;
  }
}

.hidden { display: none !important; }