:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(31, 41, 55, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #3b82f6;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --accent-gold: #f59e0b;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-purple: #8b5cf6;
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
  padding-bottom: 4rem;
}

/* Header & Nav */
.header-bar {
  background: rgba(17, 24, 39, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.025em;
}

.brand-badge {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #fff;
  font-size: 0.7rem;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-weight: 600;
  text-transform: uppercase;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.period-badge {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.45rem 0.85rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}
.btn-success:hover {
  background: linear-gradient(135deg, #059669, #047857);
  transform: translateY(-1px);
}

.btn-warning {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}
.btn-warning:hover {
  background: linear-gradient(135deg, #d97706, #b45309);
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #fff;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  transform: translateY(-1px);
}

/* Flexible Period Banner */
.period-control-banner {
  background: rgba(17, 24, 39, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.75rem;
  padding: 0.85rem 1.25rem;
  margin-bottom: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.period-info-box {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.period-badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
}
.badge-teknisi {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: #93c5fd;
}
.badge-keuangan {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
}
.badge-status-closed {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}
.badge-status-open {
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #34d399;
}

/* Container & Excel Layout Grid */
.main-container {
  max-width: 1750px;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
}

/* Two-tier layout: Tier 1 (Setoran 1 & Setoran 2 berdampingan lebar), Tier 2 (Pemasukan Bruto, Pengeluaran, Bulan Lalu) */
.middle-grid-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.bottom-grid-layout {
  display: grid;
  grid-template-columns: minmax(380px, 1.2fr) minmax(350px, 1fr) minmax(300px, 0.8fr);
  gap: 1.5rem;
  align-items: start;
}

.table-large {
  font-size: 0.875rem;
  width: 100%;
}

.table-large th {
  padding: 0.65rem 0.75rem;
}

.table-large td {
  padding: 0.5rem 0.65rem;
}

.table-large input.editable-cell {
  font-size: 0.875rem;
  padding: 0.3rem 0.5rem;
}

@media (max-width: 1200px) {
  .middle-grid-layout {
    grid-template-columns: 1fr;
  }
  .bottom-grid-layout {
    grid-template-columns: 1fr;
  }
}


/* Excel Sheet Cards */
.sheet-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  margin-bottom: 1.25rem;
}

.sheet-header-gold {
  background: linear-gradient(90deg, #d97706, #b45309);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.6rem 0.85rem;
  text-align: center;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sheet-header-gray {
  background: #374151;
  color: #f3f4f6;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 0.6rem 0.85rem;
  text-align: center;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sheet-total-bar {
  background: #fef3c7;
  color: #92400e;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.5rem 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

/* Spreadsheet Tables */
.excel-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.825rem;
}

.excel-table th {
  background: rgba(31, 41, 55, 0.9);
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.5rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  border-right: 1px solid rgba(255, 255, 255, 0.04);
  white-space: nowrap;
}

.excel-table th.center, .excel-table td.center {
  text-align: center;
}

.excel-table th.right, .excel-table td.right {
  text-align: right;
}

.excel-table td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  border-right: 1px solid rgba(255, 255, 255, 0.03);
  color: var(--text-main);
}

.excel-table tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* Editable Inputs & Selects */
.editable-cell {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #f3f4f6;
  padding: 0.25rem 0.4rem;
  border-radius: 0.3rem;
  width: 100%;
  font-family: inherit;
  font-size: 0.825rem;
  transition: all 0.15s;
}

select,
select.editable-cell,
select.form-input,
.period-badge,
input[type="date"],
input[type="month"] {
  background-color: #1f2937 !important;
  color: #ffffff !important;
  color-scheme: dark;
}

select option,
select optgroup,
select.editable-cell option,
select.form-input option {
  background-color: #111827 !important;
  color: #ffffff !important;
  padding: 8px 12px;
}

.editable-cell:focus,
select:focus,
select.editable-cell:focus,
select.form-input:focus {
  background-color: #111827 !important;
  border-color: var(--border-focus);
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4);
  color: #ffffff !important;
}

.editable-cell.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.editable-cell.highlight-kasbon {
  color: #f87171;
}

.editable-cell.highlight-total {
  color: #60a5fa;
  font-weight: 700;
}

/* Profit Share & Clean Summary Cards */
.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.85rem;
}

.summary-row.total {
  background: rgba(245, 158, 11, 0.1);
  font-weight: 700;
  border-top: 2px solid var(--accent-gold);
}

.summary-row.clean {
  background: rgba(16, 185, 129, 0.15);
  font-weight: 700;
  font-size: 0.95rem;
  color: #34d399;
}

/* Modal Dialog Styling */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.75rem;
  width: 90%;
  max-width: 650px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.02);
}

.modal-header h3 {
  font-size: 1.1rem;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: rgba(255, 255, 255, 0.02);
}

.btn-close-modal {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
}
.btn-close-modal:hover {
  color: #fff;
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}
.btn-success:hover {
  background: linear-gradient(135deg, #059669, #047857);
  transform: translateY(-1px);
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1rem;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 0.6rem;
  transition: all 0.2s;
}
.history-item:hover {
  background: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.3);
}

.history-item.active {
  background: rgba(59, 130, 246, 0.2);
  border-color: #3b82f6;
}

.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}
.form-input {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 0.4rem;
  color: #fff;
  font-size: 0.9rem;
}
.form-input:focus {
  border-color: var(--primary);
  outline: none;
}

/* Loading & Toast notification */
.toast-msg {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #1e293b;
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 0.5rem;
  border-left: 4px solid var(--primary);
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  gap: 0.75rem;
  z-index: 999;
}
