/* =============================================
   RESET & BASE
   ============================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  font-size: 0.75rem;
  background: #f1f5f9;
  color: #1e293b;
  min-height: 100vh;
}

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

/* =============================================
   HEADER
   ============================================= */
.app-header {
  background: linear-gradient(135deg, #1e3a5f 0%, #1a3352 100%);
  color: #fff;
  padding: 0;
  margin: 0;
  width: 100%;
  box-shadow: 0 2px 12px rgba(0,0,0,0.22);
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}
.app-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px 6px;
}
.app-title {
  font-size: 0.9rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.app-title-sub {
  font-size: 0.72rem;
  font-weight: 600;
  color: #93c5fd;
  letter-spacing: 0.04em;
}
.header-badge {
  display: flex;
  align-items: center;
  gap: 8px;
}
.badge-online {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(34,197,94,0.15);
  border: 1px solid rgba(34,197,94,0.3);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.68rem;
  font-weight: 700;
  color: #86efac;
  letter-spacing: 0.05em;
}
.badge-dot {
  width: 6px;
  height: 6px;
  background: #22c55e;
  border-radius: 50%;
  animation: pulse-dot 2s infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}
.header-time {
  font-size: 0.75rem;
  color: #93c5fd;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

/* =============================================
   TAB NAVIGATION
   ============================================= */
.tab-row {
  display: flex;
  gap: 0;
  align-items: flex-end;
  padding: 0 14px;
}
.tab-btn {
  flex: 0 0 auto;
  padding: 6px 20px;
  height: 34px;
  box-sizing: border-box;
  border-radius: 0;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  border-bottom: 3px solid transparent;
  transition: all 0.15s;
  color: #93c5fd;
  background: transparent;
  letter-spacing: 0.06em;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-transform: uppercase;
}
.tab-btn.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-bottom: 3px solid #38bdf8;
}
.tab-btn:not(.active):hover {
  background: rgba(255,255,255,0.08);
  color: #e0f2fe;
}

.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.06);
  padding: 8px 14px;
  position: sticky;
  top: 67px;
  z-index: 90;
}
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  max-width: 100%;
  margin: 0;
}
.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.toolbar-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #475569;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.toolbar-select {
  border: 1.5px solid #cbd5e1;
  border-radius: 7px;
  padding: 5px 10px;
  font-size: 0.72rem;
  color: #1e3a5f;
  background: #fff;
  cursor: pointer;
  transition: border 0.15s, box-shadow 0.15s;
  min-width: 0;
}
.toolbar-select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.toolbar-input {
  border: 1.5px solid #cbd5e1;
  border-radius: 7px;
  padding: 5px 10px;
  font-size: 0.72rem;
  color: #1e3a5f;
  transition: border 0.15s, box-shadow 0.15s;
  background: #fff;
}
.toolbar-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.toolbar-info {
  font-size: 0.72rem;
  color: #94a3b8;
  margin-left: auto;
  font-style: italic;
}

/* =============================================
   BUTTONS
   ============================================= */
.btn {
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.18s;
  white-space: nowrap;
  letter-spacing: 0.03em;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: #1e3a5f; color: #fff; }
.btn-primary:hover { background: #2563eb; }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: #d97706; color: #fff; }
.btn-warning:hover { background: #b45309; }
.btn-info { background: #0891b2; color: #fff; }
.btn-info:hover { background: #0e7490; }
.btn-outline {
  background: #fff;
  color: #1e3a5f;
  border: 1.5px solid #1e3a5f;
}
.btn-outline:hover { background: #eff6ff; }
.btn-sm { padding: 4px 10px; font-size: 0.7rem; }

/* =============================================
   MAIN CONTENT AREA
   ============================================= */
.content-wrap {
  padding: 14px 16px;
  max-width: 1600px;
  margin: 0 auto;
}

/* =============================================
   STAT CARDS
   ============================================= */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.stat-card {
  background: #fff;
  border-radius: 10px;
  padding: 12px 14px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: box-shadow 0.2s, transform 0.2s;
  cursor: default;
}
.stat-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
  transform: translateY(-1px);
}
.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stat-card-title {
  font-size: 0.68rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stat-card-icon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}
.icon-blue { background: #eff6ff; color: #2563eb; }
.icon-green { background: #f0fdf4; color: #16a34a; }
.icon-yellow { background: #fffbeb; color: #d97706; }
.icon-red { background: #fef2f2; color: #dc2626; }
.icon-purple { background: #faf5ff; color: #7c3aed; }
.icon-cyan { background: #ecfeff; color: #0891b2; }
.icon-orange { background: #fff7ed; color: #ea580c; }
.stat-card-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: #1e293b;
  line-height: 1;
}
.stat-card-value span {
  font-size: 0.7rem;
  font-weight: 600;
  color: #94a3b8;
  margin-left: 4px;
}
.stat-card-footer {
  font-size: 0.68rem;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 4px;
}
.stat-trend-up { color: #16a34a; font-weight: 700; }
.stat-trend-down { color: #dc2626; font-weight: 700; }
.stat-trend-neutral { color: #64748b; font-weight: 700; }

/* =============================================
   SECTION HEADER
   ============================================= */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 6px;
}
.section-title {
  font-size: 0.78rem;
  font-weight: 800;
  color: #1e3a5f;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.section-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 16px;
  background: #3b82f6;
  border-radius: 2px;
}
.section-badge {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 0.68rem;
  font-weight: 700;
}

/* =============================================
   TABLE
   ============================================= */
.table-outer {
  margin-bottom: 14px;
}
.table-wrap {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  background: #fff;
}
table {
  border-collapse: collapse;
  width: 100%;
}
thead th {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #1e3a5f;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
  padding: 9px 10px;
  border-right: 1px solid #2d5382;
  text-align: center;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 30;
  background: #152d4a;
  min-width: 200px;
  text-align: left;
}
thead th.th-sticky2 {
  position: sticky;
  left: 200px;
  z-index: 25;
  background: #1e3a5f;
}
tbody td {
  padding: 6px 10px;
  border-right: 1px solid #e8ecf0;
  border-bottom: 1px solid #e8ecf0;
  text-align: center;
  font-size: 0.72rem;
  background: #fff;
  color: #374151;
  white-space: nowrap;
}
tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 10;
  background: #fff;
  font-weight: 600;
  font-size: 0.72rem;
  color: #1e3a5f;
  padding: 7px 12px;
  border-right: 2px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  min-width: 200px;
  text-align: left;
}
tbody td.td-sticky2 {
  position: sticky;
  left: 200px;
  z-index: 9;
  background: #fff;
  border-right: 1px solid #e2e8f0;
}
tbody tr:hover td { background: #f8fafc !important; }
tbody tr:hover td:first-child { background: #eff6ff !important; }
tbody tr:nth-child(even) td { background: #f9fafb; }
tbody tr:nth-child(even) td:first-child { background: #f9fafb; }
tbody tr:nth-child(even):hover td { background: #f0f9ff !important; }

/* Row group header */
.row-group-header td {
  background: #f0f7ff !important;
  font-weight: 800 !important;
  color: #1e3a5f !important;
  font-size: 0.72rem !important;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid #bfdbfe !important;
}

/* Table footer / total row */
.row-total td {
  background: #1e3a5f !important;
  color: #fff !important;
  font-weight: 700 !important;
  font-size: 0.72rem !important;
  border-color: #2d5382 !important;
}
.row-total td:first-child { background: #152d4a !important; color: #fff !important; }

/* =============================================
   BADGE / PILL CELLS
   ============================================= */
.badge-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-green  { background: #dcfce7; color: #166534; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-gray   { background: #f1f5f9; color: #475569; }
.badge-orange { background: #ffedd5; color: #9a3412; }
.badge-normal { background: #dcfce7; color: #166534; }
.badge-siaga  { background: #fef9c3; color: #92400e; }

/* =============================================
   TABEL BEBAN PUNCAK
   ============================================= */
.tbl-beban { table-layout: auto; }
.tbl-beban thead th { white-space: nowrap; }
.tbl-beban thead th:first-child { min-width: unset; position: static; }
.tbl-beban tbody td:first-child { min-width: unset; position: static; width: 1%; white-space: nowrap; }
.th-unit  { width: 360px; min-width: 360px; max-width: 360px; text-align: center !important; }
.td-unit  { width: 360px; min-width: 360px; max-width: 360px; text-align: left !important; font-weight: 600; color: #1e3a5f; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.th-no    { width: 36px; min-width: 36px; max-width: 36px; text-align: center !important; }
.td-no    { width: 36px; min-width: 36px; max-width: 36px; text-align: center !important; color: #64748b; font-size: 0.68rem; }
.th-stat  { width: 80px; min-width: 80px; max-width: 80px; text-align: center !important; }
.td-num   { width: 80px; min-width: 80px; max-width: 80px; text-align: right !important; font-variant-numeric: tabular-nums; padding: 6px 8px !important; }
.td-avg   { color: #0891b2; font-weight: 700; }
.th-day   {
  width: 26px; min-width: 26px; max-width: 26px;
  padding: 9px 4px !important;
  font-size: 0.65rem;
}

/* ── DAILY STATUS CELLS ── */
.day-cell {
  width: 26px; min-width: 26px; max-width: 26px;
  padding: 0 !important;
  height: 32px;
  vertical-align: middle;
  text-align: center;
}
.day-empty { background: #f8fafc; }

/* positive/negative diff */
.diff-pos { color: #16a34a; font-weight: 700; }
.diff-neg { color: #dc2626; font-weight: 700; }
.diff-zero { color: #94a3b8; font-weight: 600; }

/* =============================================
   EMPTY / LOADING STATE
   ============================================= */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: #94a3b8;
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state-title { font-size: 0.85rem; font-weight: 700; color: #64748b; margin-bottom: 6px; }
.empty-state-desc { font-size: 0.75rem; color: #94a3b8; }

.loading-spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =============================================
   TOAST NOTIFICATIONS
   ============================================= */
.toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  animation: toast-in 0.25s ease;
  min-width: 240px;
  max-width: 360px;
}
@keyframes toast-in {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
.toast-success { background: #16a34a; color: #fff; }
.toast-error   { background: #dc2626; color: #fff; }
.toast-info    { background: #0891b2; color: #fff; }
.toast-warning { background: #d97706; color: #fff; }

/* =============================================
   SUBTAB (inner tabs)
   ============================================= */
.subtab-row {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.subtab-btn {
  padding: 5px 14px;
  height: 30px;
  border-radius: 6px 6px 0 0;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  border: 1.5px solid #e2e8f0;
  border-bottom: none;
  background: #f8fafc;
  color: #64748b;
  letter-spacing: 0.04em;
  transition: all 0.15s;
  white-space: nowrap;
}
.subtab-btn.active {
  background: #1e3a5f;
  color: #fff;
  border-color: #1e3a5f;
}
.subtab-btn:not(.active):hover {
  background: #e2e8f0;
  color: #1e3a5f;
}

/* =============================================
   ALERT BOXES
   ============================================= */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.75rem;
  margin-bottom: 12px;
}
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }
.alert-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-danger  { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-icon    { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.alert-content { flex: 1; }
.alert-title   { font-weight: 700; margin-bottom: 2px; }

/* =============================================
   GRID LAYOUTS
   ============================================= */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* =============================================
   CARD PANEL
   ============================================= */
.panel {
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  overflow: hidden;
  margin-bottom: 14px;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}
.panel-title {
  font-size: 0.75rem;
  font-weight: 800;
  color: #1e3a5f;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.panel-body { padding: 14px; }

/* =============================================
   MODAL CEKLIST
   ============================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(2px);
  animation: modal-fade-in 0.18s ease;
}
@keyframes modal-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.modal-box {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.22);
  width: 100%;
  max-width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modal-slide-in 0.18s ease;
}
@keyframes modal-slide-in {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 18px 12px;
  border-bottom: 1px solid #e2e8f0;
}
.modal-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: #1e3a5f;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.modal-subtitle {
  font-size: 0.72rem;
  color: #64748b;
  margin-top: 3px;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1rem;
  color: #94a3b8;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: #f1f5f9; color: #1e293b; }
.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ceklist-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ceklist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  user-select: none;
}
.ceklist-item:hover { background: #eff6ff; border-color: #bfdbfe; }
.ceklist-item.checked { background: #f0fdf4; border-color: #86efac; }
.ceklist-item input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: #16a34a;
  flex-shrink: 0;
  cursor: pointer;
}
.ceklist-item-text {
  font-size: 0.75rem;
  color: #374151;
  flex: 1;
  line-height: 1.4;
}
.ceklist-item.checked .ceklist-item-text {
  color: #166534;
  text-decoration: line-through;
  text-decoration-color: #86efac;
}
.ceklist-catatan { display: flex; flex-direction: column; gap: 5px; }
.ceklist-catatan-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ceklist-catatan-input {
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.75rem;
  color: #1e293b;
  resize: vertical;
  font-family: inherit;
  transition: border 0.15s;
}
.ceklist-catatan-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px 14px;
  border-top: 1px solid #e2e8f0;
  gap: 10px;
}
.modal-status {
  font-size: 0.7rem;
  color: #64748b;
  font-style: italic;
}
.day-cell.has-ceklist { outline: 2px solid #16a34a; outline-offset: -2px; }
.day-cell-clickable { cursor: pointer; }
.day-cell-clickable:hover { filter: brightness(0.92); }

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 768px) {
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .toolbar { gap: 8px; }
  .tab-btn { padding: 6px 12px; font-size: 0.65rem; }
  .content-wrap { padding: 10px; }
  .stat-card-value { font-size: 1.1rem; }
}
@media (max-width: 480px) {
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .header-time { display: none; }
}
