* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #eef2f5;
  color: #33475b;
}

/* ---------- Top bar ---------- */
.topbar {
  background: #1c3a5e;
  color: #fff;
  display: flex;
  align-items: center;
  height: 44px;
  padding: 0 16px;
}

.topbar-left {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.topbar-sub {
  font-weight: 700;
}

.tabs {
  display: flex;
  margin-left: 32px;
  flex: 1;
  height: 100%;
  gap: 4px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: #9fb3c8;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 0 18px;
  min-width: 155px;
  text-align: center;
  height: 100%;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  color: #e3ecf5;
}

.tab-btn.active {
  color: #fff;
  border-bottom-color: #3ea1f0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  color: #9fb3c8;
  font-size: 14px;
}

.topbar-filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: #9fb3c8;
  white-space: nowrap;
}

.topbar-filter-item label {
  white-space: nowrap;
}

.topbar-filter-item input[type="date"] {
  border: 1px solid #35507a;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  color: #fff;
  background: #24466f;
  outline: none;
  color-scheme: dark;
}

.topbar-filter-item input[type="date"]:focus {
  border-color: #3ea1f0;
}

/* ---------- Filter bar ---------- */
.filter-bar {
  background: #fff;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 10px 20px;
  border-bottom: 1px solid #e3e8ec;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #7d8b99;
}

.filter-item label {
  white-space: nowrap;
}

.filter-item select,
.filter-item input[type="date"] {
  border: 1px solid #d6dde3;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12.5px;
  color: #33475b;
  background: #fff;
  outline: none;
}

.filter-item select {
  min-width: 190px;
}

.filter-item select:focus,
.filter-item input:focus {
  border-color: #3ea1f0;
}

/* ---------- Main content ---------- */
.main-content {
  padding: 24px;
  display: flex;
  justify-content: center;
}

.report-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(30, 60, 90, 0.08);
  width: 100%;
  max-width: 620px;
  padding: 24px 28px 20px;
}

.report-card.wide {
  max-width: 95vw;
  width: 95vw;
}

.report-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.report-title {
  font-size: 15px;
  font-weight: 700;
  color: #1c3a5e;
  line-height: 1.4;
  margin: 0;
  text-transform: uppercase;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #e5f7ec;
  color: #24a148;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  margin-bottom: 0;
}

.status-badge.hidden {
  display: none;
}

.status-badge i {
  font-size: 10px;
}

/* ---------- Form ---------- */
.form-row {
  display: flex;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid #f0f2f4;
  font-size: 13px;
}

.form-row:last-of-type {
  border-bottom: none;
}

.form-label {
  width: 150px;
  min-width: 150px;
  color: #33475b;
  flex-shrink: 0;
}

.form-colon {
  width: 14px;
  color: #b0b9c2;
  flex-shrink: 0;
}

.form-value {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-value input[type="text"],
.form-value input[type="number"],
.form-value input[type="time"],
.form-value textarea {
  flex: 1;
  border: 1px solid #d6dde3;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  color: #33475b;
  outline: none;
  min-width: 0;
  font-family: inherit;
}

.form-value input:focus,
.form-value textarea:focus {
  border-color: #3ea1f0;
}

.form-value input:disabled {
  background: #f7f8f9;
  color: #a6b0ba;
}

.form-value input:read-only {
  background: #f7f8f9;
  color: #33475b;
  cursor: default;
}

.unit-suffix {
  font-size: 12px;
  color: #8a97a3;
  min-width: 22px;
}

/* Samakan lebar input di form Opname Harian dengan lebar kolom kWh Produksi
   (yang memiliki unit-suffix + tombol Galeri), agar semua field sejajar. */
#form-operasional .form-value input[type="text"],
#form-operasional .form-value input[type="number"] {
  flex: none;
  width: 276px;
}

@media (max-width: 640px) {
  /* Input mengisi sisa ruang, tidak overflow */
  #form-operasional .form-value input[type="text"],
  #form-operasional .form-value input[type="number"] {
    flex: 1 1 0;
    width: 0;
    min-width: 0;
    font-size: 11px;
    padding: 5px 5px;
  }

  /* Tetap 1 baris, tidak wrap */
  #form-operasional .form-value {
    flex-wrap: nowrap;
    gap: 4px;
    overflow: hidden;
  }

  /* Unit suffix: lebar fixed agar input semua field sama lebar */
  #form-operasional .unit-suffix {
    font-size: 10px;
    width: 22px;
    min-width: 22px;
    max-width: 22px;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-align: left;
  }

  /* Galeri tetap di baris sama, ukuran kecil */
  #form-operasional .btn-galeri-inline {
    flex-shrink: 0;
    font-size: 10px;
    padding: 5px 7px;
    white-space: nowrap;
  }
}

.oli-inactive-text {
  flex: 1;
  font-style: italic;
  color: #a6b0ba;
  font-size: 13px;
}

.oli-toggle {
  background: transparent;
  border: none;
  color: #8a97a3;
  cursor: pointer;
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 4px;
}

.oli-toggle:hover {
  color: #3ea1f0;
  background: #f0f6fb;
}

/* ---------- Upload ---------- */
.upload-row {
  padding: 14px 0 6px;
}

.upload-label {
  font-size: 13px;
  color: #33475b;
  margin-bottom: 10px;
}

.upload-label .req {
  color: #e0483e;
}

.upload-label .hint {
  color: #a6b0ba;
  font-weight: 400;
  font-size: 12px;
  margin-left: 4px;
}

.upload-buttons {
  display: flex;
  gap: 10px;
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid #d6dde3;
  color: #5a6b7a;
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
}

.btn-outline:hover {
  background: #f5f7f9;
}

.btn-outline.green {
  border-color: #24a148;
  color: #24a148;
}

.btn-outline.green:hover {
  background: #e5f7ec;
}

.file-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 12.5px;
  color: #5a6b7a;
  background: #f5f7f9;
  border-radius: 6px;
  padding: 8px 10px;
}

.file-preview i {
  color: #24a148;
}

.file-preview.hidden {
  display: none;
}

.btn-galeri-inline {
  flex-shrink: 0;
  padding: 7px 14px;
  font-size: 12px;
  white-space: nowrap;
}

.file-preview-inline {
  margin: -4px 0 9px 164px;
}

@media (max-width: 640px) {
  .file-preview-inline { margin-left: 0; }
  .file-list-preview    { margin-left: 0; }
}

/* Multi-dokumen file list */
.file-list-preview {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: -4px 0 9px 164px;
}

@media (max-width: 640px) {
  .file-list-preview { margin-left: 0; }
}

.file-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: #5a6b7a;
  background: #f5f7f9;
  border-radius: 6px;
  padding: 6px 10px;
}

.file-item i {
  flex-shrink: 0;
}

.file-item-saved i { color: #24a148; }
.file-item-new   i { color: #0077cc; }

.doc-link {
  color: #0077cc;
  text-decoration: none;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-link:hover { text-decoration: underline; }

.file-badge {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 600;
  background: #e3f5ea;
  color: #24a148;
  border-radius: 4px;
  padding: 1px 6px;
}

.file-badge-new {
  background: #e0f0ff;
  color: #0077cc;
}

/* Tombol hapus dokumen — kecil, merah, di ujung kanan setiap file-item */
.btn-hapus-dok {
  margin-left: auto;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: #c0392b;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 11px;
  opacity: 0.6;
  transition: opacity 0.15s, background 0.15s;
}
.btn-hapus-dok:hover { opacity: 1; background: #fdecea; }
.btn-hapus-dok:disabled { opacity: 0.3; cursor: not-allowed; }

/* Jika ada badge sebelum tombol hapus, badge jangan margin-left auto lagi */
.file-item .file-badge + .btn-hapus-dok,
.file-item .file-badge {
  margin-left: auto;
}
.file-item .file-badge + .btn-hapus-dok {
  margin-left: 4px;
}

/* file-preview (Penerimaan & Beban Puncak) juga flex agar tombol hapus rata kanan */
.file-preview {
  display: flex;
  align-items: center;
  gap: 7px;
}

/* ---------- Save button ---------- */
.save-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.btn-save {
  background: #24a148;
  color: #fff;
  border: none;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 26px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-save:hover {
  background: #1e8a3d;
}

.btn-save:disabled {
  background: #9fd4b1;
  cursor: not-allowed;
}

/* ---------- Data table ---------- */
.data-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.data-toolbar select,
.data-toolbar input {
  border: 1px solid #d6dde3;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 12.5px;
  color: #33475b;
  outline: none;
}

.data-table-wrap {
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  table-layout: auto;
}

table.data-table th {
  background: #f5f7f9;
  color: #5a6b7a;
  font-weight: 700;
  text-align: left;
  padding: 7px 7px;
  white-space: nowrap;
  border-bottom: 2px solid #e3e8ec;
  font-size: 10.5px;
}

table.data-table td {
  padding: 7px 7px;
  border-bottom: 1px solid #f0f2f4;
  white-space: nowrap;
  color: #33475b;
  font-size: 11px;
}

table.data-table tr:hover td {
  background: #f9fbfc;
}

.badge-mini {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #e5f7ec;
  color: #24a148;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}

.link-dok {
  color: #3ea1f0;
  text-decoration: none;
}

.link-dok:hover {
  text-decoration: underline;
}

.empty-state {
  text-align: center;
  color: #a6b0ba;
  padding: 40px 0;
  font-size: 13px;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1c3a5e;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.25s ease;
  pointer-events: none;
  z-index: 999;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: #c0392b;
}

@media (max-width: 640px) {
  /* Topbar jadi 2 baris: baris 1 = judul+tanggal, baris 2 = tabs */
  .topbar {
    flex-wrap: wrap;
    height: auto;
    padding: 0 12px;
  }

  /* Baris 1: judul kiri, tanggal+lock kanan */
  .topbar-left {
    font-size: 11px;
    flex: 1;
    padding: 10px 0;
  }

  .topbar-right {
    padding: 10px 0;
    gap: 10px;
  }

  /* Baris 2: tabs full lebar, di bawah */
  .tabs {
    order: 3;           /* pindah ke bawah */
    flex-basis: 100%;   /* full lebar */
    margin-left: 0;
    height: 38px;
    gap: 0;
    border-top: 1px solid #253f5e;
  }

  .tab-btn {
    flex: 1;            /* bagi rata */
    padding: 0 4px;
    font-size: 9.5px;
    min-width: 0;
    letter-spacing: 0;
  }

  .filter-bar { flex-wrap: wrap; gap: 12px; }
  .form-label { width: 115px; min-width: 115px; }
  .main-content { padding: 14px; }
  .report-card { padding: 18px 16px; }

  /* Form Opname Harian: label fixed + truncate agar input semua baris lebar sama */
  #form-operasional .form-label {
    width: 90px;
    min-width: 90px;
    max-width: 90px;
    font-size: 11px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  #form-operasional .form-colon {
    width: 8px;
    min-width: 8px;
    flex-shrink: 0;
  }
  #form-operasional .form-row {
    padding: 7px 0;
    font-size: 11px;
  }
}
