/* ─── FONTS ─────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: #1a1a1a;
  background: #f0f2f5;
  overflow: hidden;
  user-select: none;
}

/* ─── LAYOUT ─────────────────────────────────────────────────────────────── */
.app { display: flex; height: 100vh; }

/* ─── SIDEBAR ────────────────────────────────────────────────────────────── */
.sidebar {
  width: 210px;
  min-width: 210px;
  background: #1a2744;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo-img { width: 36px; height: 36px; object-fit: contain; border-radius: 6px; }

.sidebar-title { display: block; font-size: 14px; font-weight: 600; color: #fff; }
.sidebar-sub { display: block; font-size: 10px; color: rgba(255,255,255,0.45); margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 8px 0; }

.nav-section {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,0.3);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 10px 14px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  color: rgba(255,255,255,0.65);
  border-radius: 0;
  transition: background 0.12s, color 0.12s;
  border-left: 3px solid transparent;
}

.nav-item i { font-size: 16px; min-width: 18px; }
.nav-item:hover { background: rgba(255,255,255,0.07); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.1); color: #fff; border-left-color: #4ade80; font-weight: 500; }

.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.db-badge {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 500;
}
.db-offline { background: rgba(74,222,128,0.15); color: #4ade80; }
.db-online  { background: rgba(96,165,250,0.15); color: #60a5fa; }

/* ─── MAIN ───────────────────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: #f0f2f5;
}

/* ─── PAGE HEADER ────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}
.page-title { font-size: 20px; font-weight: 600; color: #1a2744; }

/* ─── CARDS ──────────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.stat-label { font-size: 11px; color: #6b7280; margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 600; color: #1a2744; }
.stat-sub   { font-size: 11px; color: #9ca3af; margin-top: 2px; }

/* ─── BUTTONS ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  color: #374151;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s;
}
.btn:hover { background: #f9fafb; border-color: #d1d5db; }
.btn-primary { background: #1a2744; color: #fff; border-color: #1a2744; }
.btn-primary:hover { background: #243461; }
.btn-green { background: #059669; color: #fff; border-color: #059669; }
.btn-green:hover { background: #047857; }
.btn-danger { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { background: none; border: none; cursor: pointer; color: #6b7280; padding: 4px; border-radius: 6px; display: inline-flex; align-items: center; }
.btn-icon:hover { background: #f3f4f6; color: #374151; }

/* ─── TABLE ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  padding: 8px 12px;
  color: #6b7280;
  font-weight: 500;
  border-bottom: 1px solid #f3f4f6;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
  background: #fafafa;
}
td { padding: 9px 12px; border-bottom: 1px solid #f9fafb; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }
.td-actions { display: flex; gap: 4px; }
.tr-total td { font-weight: 600; background: #f9fafb !important; border-top: 2px solid #e5e7eb; }
.tr-section td { font-weight: 600; font-size: 11px; text-transform: uppercase; color: #6b7280; background: #f9fafb; padding: 6px 12px; letter-spacing: 0.4px; }

/* ─── BADGES ─────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-gray    { background: #f3f4f6; color: #4b5563; }

/* ─── FORM ───────────────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-full { grid-column: 1 / -1; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 12px; font-weight: 500; color: #374151; }

input, select, textarea {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  background: #fff;
  color: #1a1a1a;
  width: 100%;
  transition: border-color 0.12s;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #1a2744;
  box-shadow: 0 0 0 3px rgba(26,39,68,0.08);
}

.filter-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.filter-row .form-group { min-width: 120px; }
.filter-row input { width: 90px; }

/* ─── TABS ───────────────────────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 2px solid #e5e7eb; margin-bottom: 16px; gap: 0; }
.tab {
  padding: 8px 16px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.12s;
}
.tab:hover { color: #1a2744; }
.tab.active { color: #1a2744; border-bottom-color: #1a2744; }

/* ─── MODAL ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 12px;
  padding: 22px;
  width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-wide { width: 720px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-title { font-size: 16px; font-weight: 600; color: #1a2744; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid #f3f4f6; }

/* ─── INFO BOX ───────────────────────────────────────────────────────────── */
.info-box {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  color: #1e40af;
  margin-bottom: 14px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

/* ─── PROGRESS BAR ───────────────────────────────────────────────────────── */
.progress-bar { height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; margin-top: 6px; }
.progress-fill { height: 100%; background: #059669; border-radius: 4px; transition: width 0.3s; }
.progress-fill.warning { background: #f59e0b; }
.progress-fill.danger  { background: #dc2626; }

/* ─── CREDIT CARD ────────────────────────────────────────────────────────── */
.credit-card {
  background: #fff;
  border-radius: 10px;
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  border-left: 4px solid #1a2744;
}
.credit-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 8px; }
.credit-name { font-size: 15px; font-weight: 600; color: #1a2744; }
.credit-meta { font-size: 11px; color: #9ca3af; margin-top: 3px; }

/* ─── EMPTY STATE ────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: #9ca3af; }
.empty-state i { font-size: 48px; display: block; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ─── TOAST ──────────────────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1a2744;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: toastIn 0.2s ease;
  max-width: 300px;
}
.toast.success { background: #059669; }
.toast.error   { background: #dc2626; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ─── INVOICE PRINT STYLES ───────────────────────────────────────────────── */
.invoice-doc {
  background: #fff;
  color: #000;
  font-family: 'Times New Roman', Times, serif;
  font-size: 12pt;
  line-height: 1.5;
  padding: 28px 32px;
  max-width: 720px;
}
.invoice-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 2px solid #1a2744;
}
.invoice-logo { height: 56px; object-fit: contain; }
.invoice-title-block { text-align: right; }
.invoice-title-block h2 { font-family: 'Times New Roman', Times, serif; font-size: 16pt; font-weight: 700; color: #1a2744; }
.invoice-title-block p  { font-family: 'Times New Roman', Times, serif; font-size: 11pt; color: #555; }
.invoice-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 14px; }
.invoice-party h4 { font-family: 'Times New Roman', Times, serif; font-size: 10pt; font-weight: 700; text-transform: uppercase; color: #1a2744; margin-bottom: 5px; border-bottom: 1px solid #e0e0e0; padding-bottom: 3px; }
.invoice-party p  { font-family: 'Times New Roman', Times, serif; font-size: 11pt; line-height: 1.7; }
.invoice-contract { font-family: 'Times New Roman', Times, serif; font-size: 11pt; font-style: italic; color: #555; margin-bottom: 12px; }
.invoice-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.invoice-table th { background: #1a2744; color: #fff; padding: 7px 9px; text-align: center; font-family: 'Times New Roman', Times, serif; font-size: 10pt; font-weight: 600; }
.invoice-table td { border: 1px solid #ccc; padding: 6px 9px; font-family: 'Times New Roman', Times, serif; font-size: 11pt; }
.invoice-table .tc { text-align: center; }
.invoice-table .tr { text-align: right; font-weight: 600; }
.invoice-bank { background: #f0f4f8; border-left: 3px solid #1a2744; padding: 8px 12px; font-family: 'Times New Roman', Times, serif; font-size: 11pt; margin-bottom: 18px; }
.invoice-sign-area { display: flex; align-items: flex-end; gap: 0; }
.invoice-sign-left { flex: 1; }
.invoice-sign-label { font-family: 'Times New Roman', Times, serif; font-size: 11pt; color: #555; margin-bottom: 4px; }
.invoice-sig-row { display: flex; align-items: flex-end; gap: 10px; }
.invoice-sig-img { height: 48px; object-fit: contain; max-width: 180px; }
.invoice-sig-name { font-family: 'Times New Roman', Times, serif; font-size: 12pt; font-weight: 600; }
.invoice-stamp { width: 120px; height: 120px; object-fit: contain; margin-bottom: -10px; }
.invoice-words { font-family: 'Times New Roman', Times, serif; font-size: 11pt; }
.invoice-count { font-family: 'Times New Roman', Times, serif; font-size: 11pt; }

/* ─── ELEC INVOICE ───────────────────────────────────────────────────────── */
.elec-doc { background: #1a1a2e; color: #fff; font-family: Arial, sans-serif; border-radius: 8px; overflow: hidden; max-width: 400px; }
.elec-header { background: #c0392b; text-align: center; padding: 14px 20px; }
.elec-header h3 { font-size: 17px; font-weight: 700; letter-spacing: 2px; }
.elec-header p  { font-size: 11px; color: #ffcccc; margin-top: 3px; }
.elec-body { padding: 16px 20px; }
.elec-tenant { border: 1px solid #444; padding: 10px; text-align: center; margin-bottom: 14px; border-radius: 4px; }
.elec-tenant h4 { font-size: 15px; font-weight: 700; }
.elec-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid #333; font-size: 13px; }
.elec-footer-total { background: #c0392b; padding: 14px 20px; text-align: center; }
.elec-footer-total p { font-size: 11px; letter-spacing: 1px; opacity: 0.8; margin-bottom: 4px; }
.elec-footer-total h2 { font-size: 26px; font-weight: 700; }
.elec-footer-org { padding: 8px 20px; text-align: center; font-size: 10px; color: #888; background: #1a1a2e; }

/* ─── STATKOM ────────────────────────────────────────────────────────────── */
.statkom-section { margin-bottom: 20px; }
.statkom-section h3 { font-size: 14px; font-weight: 600; color: #1a2744; margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid #e5e7eb; }
.statkom-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid #f9fafb; }
.statkom-code { font-size: 11px; color: #9ca3af; min-width: 40px; font-weight: 600; }
.statkom-label { flex: 1; font-size: 12px; color: #374151; }
.statkom-val { font-weight: 600; font-size: 13px; min-width: 80px; text-align: right; }
.statkom-input { width: 110px; text-align: right; }
