/* =============================================
   RESET & BASE
   ============================================= */
*, *::before, *::after { box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  min-height: 100vh;
}

/* Tailwind replacements */
.bg-slate-100  { background-color: #f1f5f9; }
.min-h-screen  { min-height: 100vh; }
.hidden        { display: none !important; }
.flex          { display: flex; }
.inline-flex   { display: inline-flex; }
.block         { display: block; }

/* =============================================
   HEADER
   ============================================= */
.app-header {
  background: #1e3a5f;
  color: #fff;
  padding: 8px 16px 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header-body { display: flex; flex-direction: column; }
.app-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding-bottom: 4px;
}
.app-name-accent { color: #ffffff; }
.app-header-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tab-row { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.header-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; margin-left: auto; }

/* =============================================
   TAB BUTTONS
   ============================================= */
.tab-btn {
  flex: 0 0 auto;
  width: 12.5%;
  text-align: center;
  padding: 6px 8px;
  height: 32px;
  box-sizing: border-box;
  border-radius: 6px 6px 0 0;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  border-bottom: 3px solid transparent;
  transition: all 0.18s;
  color: #93c5fd;
  background: rgba(255,255,255,0.08);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.tab-btn.active { background: rgba(255,255,255,0.18); color: #fff; border-bottom: 3px solid #38bdf8; }
.tab-btn:not(.active):hover { background: rgba(255,255,255,0.13); color: #e0f2fe; }

/* =============================================
   TAB CONTENT
   ============================================= */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* =============================================
   TOOLBAR
   ============================================= */
.toolbar-wrap {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  padding: 10px 14px;
  position: sticky;
  top: 48px;   /* tinggi header ~48px */
  z-index: 90;
}
.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.toolbar-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: #475569;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
}
.toolbar-select {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 0.82rem;
  color: #1e3a5f;
  background: #fff;
  cursor: pointer;
  transition: border 0.15s;
  min-width: 0;
  flex: 1;
  max-width: 220px;
}
.toolbar-select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px #bfdbfe;
}
.toolbar-select:disabled {
  background: #f1f5f9;
  color: #94a3b8;
  cursor: not-allowed;
}
.toolbar-input {
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 0.82rem;
  color: #1e3a5f;
  transition: border 0.15s;
}
.toolbar-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px #bfdbfe;
}
.toolbar-info {
  font-size: 0.7rem;
  color: #94a3b8;
  margin-left: auto;
}

/* =============================================
   DATA SUB-TAB BUTTONS
   ============================================= */
.data-subtab-row {
  display: flex;
  gap: 6px;
  padding: 0;
  align-items: center;
}
.data-subtab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 8px;
  min-width: 110px;
  height: 32px;
  box-sizing: border-box;
  border-radius: 6px 6px 0 0;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  border: 1.5px solid #e2e8f0;
  border-bottom: none;
  background: #f8fafc;
  color: #64748b;
  letter-spacing: 0.03em;
  transition: all 0.15s;
}
.data-subtab-btn.active {
  background: #1e3a5f;
  color: #fff;
  border-color: #1e3a5f;
}
.data-subtab-btn:not(.active):hover {
  background: #e2e8f0;
  color: #1e3a5f;
}

/* =============================================
   BUTTONS
   ============================================= */
.btn {
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
  white-space: nowrap;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary   { background: #1e3a5f; color: #fff; }
.btn-primary:hover:not(:disabled)  { background: #1e4976; }
.btn-success   { background: #16a34a; color: #fff; }
.btn-success:hover:not(:disabled)  { background: #15803d; }
.btn-danger    { background: #dc2626; color: #fff; }
.btn-danger:hover:not(:disabled)   { background: #b91c1c; }
.btn-info      { background: #2563eb; color: #fff; }
.btn-info:hover:not(:disabled)     { background: #1d4ed8; }
.btn-warning   { background: #d97706; color: #fff; }
.btn-warning:hover:not(:disabled)  { background: #b45309; }
.btn-outline   { background: #fff; color: #1e3a5f; border: 1px solid #1e3a5f; }
.btn-outline:hover:not(:disabled)  { background: #eff6ff; }
.btn-sm { padding: 5px 10px; font-size: 0.73rem; }

/* =============================================
   TABLE
   ============================================= */
.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 220px);
  border-radius: 0.5rem;
  border: 1px solid #e5e7eb;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  -webkit-overflow-scrolling: touch;
}
table {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
  font-size: 0.75rem;
  background: #fff;
}
/* Sticky header */
thead th {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #1e3a5f;
  color: #fff;
  font-size: 0.57rem;
  font-weight: 600;
  white-space: nowrap;
  padding: 9px 8px;
  border-right: 1px solid #2d5382;
  text-align: center;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
thead th.left  { text-align: left; }
thead th.right { text-align: right; }
/* Sticky first col header */
thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 30;
  background: #152d4a;
  min-width: 170px;
  max-width: 220px;
  text-align: left;
}
/* Sticky first col body */
tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 10;
  background: #fff;
  font-weight: 600;
  font-size: 0.75rem;
  color: #374151;
  padding: 7px 10px;
  border-right: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  min-width: 170px;
  max-width: 220px;
}
tbody tr:hover td:first-child { background: #f0f7ff; }
tbody td {
  padding: 3px 4px;
  border-right: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  text-align: center;
  font-size: 0.75rem;
  background: #fff;
  vertical-align: middle;
}
tbody tr:hover td { background: #f0f7ff; }
tbody tr:last-child td { border-bottom: none; }
tbody td.center { text-align: center; }
tbody td.right  { text-align: right; }
tbody td.left   { text-align: left; }
table tbody tr.row-alt  td { background: #f8fafc; }
table tbody tr.row-alt:hover td { background: #f0f7ff; }
table tbody tr.row-alt td:first-child { background: #f8fafc; }
table tbody tr.row-alt:hover td:first-child { background: #f0f7ff; }

/* =============================================
   STATUS BADGES
   ============================================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef9c3; color: #854d0e; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-neutral { background: #f1f5f9; color: #475569; }
.badge-purple  { background: #ede9fe; color: #5b21b6; }
.badge-dot::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* =============================================
   CARDS
   ============================================= */
.card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  padding: 16px 18px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 8px;
}
.card-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: #1e3a5f;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.card-subtitle {
  font-size: 0.72rem;
  color: #94a3b8;
  margin-top: 2px;
}

/* =============================================
   STAT CARDS
   ============================================= */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.stat-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  padding: 14px 16px;
  border-left: 4px solid #93c5fd;
  transition: box-shadow 0.15s, transform 0.15s;
}
.stat-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); transform: translateY(-1px); }
.stat-card.blue   { border-left-color: #3b82f6; }
.stat-card.green  { border-left-color: #22c55e; }
.stat-card.red    { border-left-color: #ef4444; }
.stat-card.yellow { border-left-color: #f59e0b; }
.stat-card.purple { border-left-color: #a855f7; }
.stat-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.1;
}
.stat-unit {
  font-size: 0.7rem;
  color: #64748b;
  font-weight: 600;
  margin-top: 2px;
}
.stat-change {
  font-size: 0.7rem;
  margin-top: 4px;
  font-weight: 600;
}
.stat-change.up   { color: #16a34a; }
.stat-change.down { color: #dc2626; }

/* =============================================
   FORM
   ============================================= */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}
.form-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 4px;
}
.form-input,
.form-select,
.form-textarea {
  border: 1.5px solid #e2e8f0;
  border-radius: 7px;
  padding: 9px 12px;
  font-size: 0.88rem;
  color: #1e3a5f;
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
  box-sizing: border-box;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* =============================================
   MODAL
   ============================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 12px;
  backdrop-filter: blur(2px);
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.22);
  padding: 20px;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.18s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e3a5f;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #f1f5f9;
}

/* =============================================
   TOAST
   ============================================= */
#toast {
  position: fixed;
  bottom: 20px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: calc(100vw - 32px);
}
.toast-item {
  padding: 9px 14px;
  border-radius: 8px;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 200px;
  max-width: 340px;
}
.toast-item.success { background: #16a34a; }
.toast-item.error   { background: #dc2626; }
.toast-item.warning { background: #d97706; }
.toast-item.info    { background: #2563eb; }
@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* =============================================
   SPINNER
   ============================================= */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 3px solid #bfdbfe;
  border-top: 3px solid #2563eb;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =============================================
   EMPTY STATE
   ============================================= */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: #94a3b8;
  text-align: center;
  gap: 10px;
}
.empty-state p {
  font-size: 0.82rem;
  font-weight: 500;
}
.empty-state span {
  font-size: 0.75rem;
  color: #cbd5e1;
}

/* =============================================
   SECTION CONTENT
   ============================================= */
.section-pad { padding: 10px 12px; }

/* =============================================
   DIVIDER
   ============================================= */
.divider {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: 12px 0;
}

/* =============================================
   PROGRESS BAR
   ============================================= */
.progress-wrap {
  background: #f1f5f9;
  border-radius: 100px;
  height: 8px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: 100px;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  transition: width 0.4s ease;
}
.progress-bar.green  { background: linear-gradient(90deg, #16a34a, #4ade80); }
.progress-bar.red    { background: linear-gradient(90deg, #dc2626, #f87171); }
.progress-bar.yellow { background: linear-gradient(90deg, #d97706, #fbbf24); }

/* =============================================
   CHIP / TAG
   ============================================= */
.chip {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: #e2e8f0;
  color: #475569;
}

/* =============================================
   SCROLLBAR
   ============================================= */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* =============================================
   RESPONSIVE — MOBILE ≤ 640px
   ============================================= */
@media (max-width: 640px) {
  .app-header { padding: 6px 10px 0; }
  .app-name { font-size: 0.7rem; padding-bottom: 3px; }
  .tab-btn { flex: 1; padding: 5px 4px; font-size: 0.65rem; height: 28px; }
  .toolbar-wrap { padding: 6px 8px; top: 43px; }
  .toolbar { gap: 5px; }
  .toolbar-select { font-size: 0.75rem; padding: 5px 6px; }
  .toolbar-input  { font-size: 0.75rem; padding: 5px 6px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .section-pad { padding: 8px; }
  .table-wrap { max-height: calc(100vh - 190px); }
  .modal-overlay { padding: 8px; align-items: flex-end; }
  .modal-box { border-radius: 12px 12px 0 0; max-width: 100%; }
}
@media (max-width: 400px) {
  .stat-grid { grid-template-columns: 1fr; }
}
