/* ============================================
   Dapur MBG — Premium Dark Finance UI
   ============================================ */

:root {
  --bg:        #07090F;
  --surface:   #0D1117;
  --panel:     #111620;
  --border:    #1E2535;
  --border2:   #263045;
  --accent:    #00C9A7;
  --accent2:   #0EA5E9;
  --warn:      #F59E0B;
  --danger:    #EF4444;
  --success:   #22C55E;
  --text:      #E8EDF5;
  --muted:     #6B7A99;
  --faint:     #2A3350;
  --sidebar-w: 240px;
  --topbar-h:  56px;
  --radius:    10px;
  --radius-lg: 16px;
  --font:      'Plus Jakarta Sans', sans-serif;
  --mono:      'JetBrains Mono', monospace;
  --shadow:    0 4px 24px rgba(0,0,0,.5);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
  overflow: hidden;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  transition: transform .3s ease;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
}
.brand-icon { font-size: 28px; }
.brand-name { font-weight: 800; font-size: 15px; letter-spacing: -.3px; }
.brand-sub  { font-size: 10px; color: var(--muted); }
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all .2s;
}
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active { background: rgba(0,201,167,.12); color: var(--accent); }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
}

/* ---- Main Wrap ---- */
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ---- Topbar ---- */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
}
.menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}
.topbar-title { font-weight: 700; font-size: 16px; }
.topbar-right { margin-left: auto; }
.clock { font-family: var(--mono); font-size: 12px; color: var(--muted); }

/* ---- Page Content ---- */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ---- Cards / Panels ---- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-weight: 700; font-size: 14px; }

/* ---- KPI Grid ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.kpi-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent-color, var(--accent));
}
.kpi-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 8px; }
.kpi-value { font-family: var(--mono); font-size: 20px; font-weight: 700; color: var(--text); }
.kpi-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }
.num { font-family: var(--mono); text-align: right; }

/* ---- Badges ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-lunas   { background: rgba(34,197,94,.15); color: #22C55E; }
.badge-sebagian{ background: rgba(245,158,11,.15); color: #F59E0B; }
.badge-belum   { background: rgba(239,68,68,.15);  color: #EF4444; }
.badge-info    { background: rgba(14,165,233,.15); color: #0EA5E9; }
.badge-muted   { background: var(--faint); color: var(--muted); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { background: #00b899; }
.btn-secondary { background: var(--faint); color: var(--text); }
.btn-secondary:hover { background: var(--border2); }
.btn-danger { background: rgba(239,68,68,.15); color: var(--danger); }
.btn-danger:hover { background: rgba(239,68,68,.25); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }

/* ---- Forms ---- */
.form-grid { display: grid; gap: 14px; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.form-control {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 9px 12px;
  transition: border-color .2s;
  width: 100%;
}
.form-control:focus { outline: none; border-color: var(--accent); }
.form-control::placeholder { color: var(--muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ---- Search bar ---- */
.search-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.search-input {
  flex: 1;
  min-width: 180px;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  padding: 8px 12px;
  font-family: var(--font);
}
.search-input:focus { outline: none; border-color: var(--accent); }

/* ---- Progress Bar ---- */
.progress-bar { height: 6px; background: var(--faint); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width .4s; }
.progress-fill.warn  { background: var(--warn); }
.progress-fill.full  { background: var(--success); }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay[hidden] {
  display: none !important;
}
.modal-box {
  background: var(--panel);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  width: 100%;
  /*max-width: 640px;*/
  max-height: 88vh;
  overflow-y: auto;
  padding: 28px;
  position: relative;
}
.modal-box.modal-lg  { max-width: 900px; }
.modal-box.modal-xl  { max-width: 1200px; width: 97vw; }
.modal-close {
  position: absolute;
  top: 16px; right: 16px;
  background: var(--faint);
  border: none;
  color: var(--muted);
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}
.modal-close:hover { background: var(--danger); color: #fff; }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 20px; }

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  left: auto; top: auto;
  background: var(--panel);
  border: 1px solid var(--border2);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 500;
  z-index: 9999;
  min-width: 240px;
  max-width: 360px;
  box-shadow: var(--shadow);
  animation: slideIn .3s ease;
  pointer-events: none;
}
.toast.error { border-left-color: var(--danger); }
.toast.warn  { border-left-color: var(--warn); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } }

/* ---- Loading ---- */
.loading-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; height: 200px; color: var(--muted); }
.spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Chart placeholder ---- */
.chart-area { width: 100%; height: 160px; position: relative; }
canvas.mini-chart { width: 100% !important; }

/* ---- Tabs ---- */
.tabs { display: flex; gap: 2px; background: var(--surface); border-radius: 10px; padding: 3px; margin-bottom: 18px; border: 1px solid var(--border); }
.tab-btn {
  flex: 1;
  padding: 7px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
  text-align: center;
}
.tab-btn.active { background: var(--accent); color: #000; }

/* ---- Invoice Print ---- */
@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area { position: fixed; inset: 0; }
}

/* ---- Payment History ---- */
.pay-history { margin-top: 16px; }
.pay-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.pay-row:last-child { border-bottom: none; }
.pay-date { font-family: var(--mono); font-size: 11px; color: var(--muted); min-width: 80px; }
.pay-desc { flex: 1; }
.pay-amount { font-family: var(--mono); font-weight: 600; color: var(--success); }
.pay-thumb { width: 32px; height: 32px; object-fit: cover; border-radius: 4px; cursor: pointer; border: 1px solid var(--border2); }

/* ---- Section title ---- */
.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 12px;
  margin-top: 24px;
}
.section-title:first-child { margin-top: 0; }

/* ---- Item table in order form ---- */
.order-items-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size:12px; }
.order-items-table th, .order-items-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.order-items-table th { color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; white-space:nowrap; }
.order-items-table input, .order-items-table select { background: var(--surface); border: 1px solid var(--border2); border-radius: 6px; color: var(--text); font-size: 12px; padding: 5px 8px; font-family: var(--font); width: 100%; }
.order-items-table input:focus, .order-items-table select:focus { outline: none; border-color: var(--accent); }
.remove-row-btn { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 16px; }

/* ---- Aging buckets ---- */
.aging-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 20px; }
.aging-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; text-align: center; }
.aging-label { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.aging-value { font-family: var(--mono); font-size: 18px; font-weight: 700; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .menu-btn { display: flex; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .aging-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: 0 12px; }
  .page-content { padding: 14px; }
}
