/* =====================================================================
   HCMS Design System - satu sistem desain dipakai di seluruh halaman.
   Palet terinspirasi identitas korporat MIGAS internasional: navy/hijau
   tua gelap + aksen emas/amber, tipografi bersih, kontras tinggi.
   ===================================================================== */

:root {
  --primary: #0f5c3f;
  --primary-dark: #0a3f2b;
  --primary-light: #167a54;
  --navy: #0b1f2e;
  --navy-light: #142f45;
  --accent: #c9982f;
  --accent-light: #e4b750;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #e2e6ea;
  --text: #1c2530;
  --text-muted: #64748b;
  --success: #1a8754;
  --danger: #d33636;
  --warning: #c9982f;
  --info: #2569a8;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(15, 30, 45, .08), 0 1px 2px rgba(15,30,45,.06);
  --shadow-lg: 0 10px 30px rgba(11,31,46,.12);
  --sidebar-width: 260px;
  --topbar-height: 64px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4,h5 { margin: 0 0 .5em; font-weight: 600; color: var(--navy); }
p { margin: 0 0 1em; }
table { border-collapse: collapse; width: 100%; }
img { max-width: 100%; }

/* ---------- App Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-light) 100%);
  color: #dbe6ee;
  flex-shrink: 0;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  overflow-y: auto;
  z-index: 40;
  transition: transform .25s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand img { height: 34px; width: 34px; object-fit: contain; border-radius: 6px; background: #fff; }
.sidebar-brand .logo-fallback {
  height: 34px; width: 34px; border-radius: 6px; background: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: #1a1a1a;
}
.sidebar-brand .title { font-weight: 700; font-size: 15px; color: #fff; line-height: 1.2; }
.sidebar-brand .subtitle { font-size: 11px; color: #93a7b8; }

.sidebar-nav { padding: 12px 10px 40px; }
.sidebar-section { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #6b8299; padding: 14px 12px 6px; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: #c4d3e0; font-size: 13.5px; font-weight: 500;
  margin-bottom: 2px;
}
.sidebar-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sidebar-link.active { background: var(--primary); color: #fff; }
.sidebar-link .icon { width: 18px; text-align: center; opacity: .9; }

.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px;
  position: sticky; top: 0; z-index: 30;
}
.topbar-title { font-weight: 600; font-size: 16px; color: var(--navy); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.menu-toggle { display: none; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--navy); }

.content { padding: 24px; flex: 1; }

.page-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.page-header h1 { font-size: 20px; margin: 0; }
.page-header .subtitle { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--border); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.card-header h2, .card-header h3 { margin: 0; font-size: 15px; }
.card-body { padding: 20px; }
.card + .card { margin-top: 18px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); border: 1px solid var(--border); border-left: 4px solid var(--primary); }
.stat-card .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-card .value { font-size: 24px; font-weight: 700; color: var(--navy); margin-top: 4px; }
.stat-card.accent { border-left-color: var(--accent); }
.stat-card.info { border-left-color: var(--info); }
.stat-card.danger { border-left-color: var(--danger); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; background: var(--surface); color: var(--text);
  transition: all .15s ease; line-height: 1.2;
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-accent { background: var(--accent); color: #1a1a1a; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-outline { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-icon { padding: 8px; width: 34px; height: 34px; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--navy); margin-bottom: 6px; }
label .req { color: var(--danger); }
.form-control, select.form-control, textarea.form-control {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  font-size: 13.5px; background: #fff; color: var(--text); font-family: inherit;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,92,63,.12); }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; font-weight: 600; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.form-check { display: flex; align-items: center; gap: 8px; }
.form-check input { width: 16px; height: 16px; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
legend { font-weight: 700; color: var(--navy); font-size: 13px; padding: 0 8px; }
.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group-addon { padding: 9px 12px; background: #eef1f4; border: 1px solid var(--border); border-left: none; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 13px; color: var(--text-muted); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; font-size: 13px; }
table.data-table th {
  text-align: left; padding: 10px 14px; background: #f0f3f5; color: var(--navy);
  font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
  border-bottom: 2px solid var(--border); white-space: nowrap;
}
table.data-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tbody tr:hover { background: #f8fafb; }
table.data-table tfoot td { font-weight: 700; background: #f8fafb; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.badge-success { background: #e5f6ec; color: var(--success); }
.badge-danger { background: #fbe8e8; color: var(--danger); }
.badge-warning { background: #fbf1de; color: #9c7112; }
.badge-info { background: #e6f0fa; color: var(--info); }
.badge-gray { background: #eef1f4; color: var(--text-muted); }

/* ---------- Alerts ---------- */
.alert { padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13.5px; border: 1px solid transparent; display: flex; align-items: flex-start; gap: 10px; }
.alert-success { background: #e5f6ec; border-color: #bfe6cd; color: #0f5c3f; }
.alert-danger { background: #fbe8e8; border-color: #f2c1c1; color: #9c1f1f; }
.alert-warning { background: #fbf1de; border-color: #ecd8a4; color: #7a5a0c; }
.alert-info { background: #e6f0fa; border-color: #bcd6ef; color: #1c4a75; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 6px; list-style: none; padding: 0; margin: 16px 0 0; flex-wrap: wrap; }
.pagination a, .pagination span { display: inline-flex; padding: 6px 11px; border-radius: var(--radius-sm); border: 1px solid var(--border); font-size: 12.5px; color: var(--text); }
.pagination a:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.pagination .active span { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .disabled span { color: #b7c0c9; }

/* ---------- Empty / loading states ---------- */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 40px; margin-bottom: 10px; opacity: .5; }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Modal / confirm dialog ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(11,31,46,.55); display: none; align-items: center; justify-content: center; z-index: 100; }
.modal-backdrop.open { display: flex; }
.modal-box { background: #fff; border-radius: var(--radius); max-width: 440px; width: 92%; box-shadow: var(--shadow-lg); }
.modal-box .modal-header { padding: 18px 20px; border-bottom: 1px solid var(--border); font-weight: 700; }
.modal-box .modal-body { padding: 20px; font-size: 13.5px; color: var(--text-muted); }
.modal-box .modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Checklist grid (salary components) ---------- */
.component-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.component-row { display: grid; grid-template-columns: auto 1fr 200px; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.component-row.checked { border-color: var(--primary); background: #f4faf7; }
.component-row .name { font-weight: 600; font-size: 13px; }
.component-row .meta { font-size: 11.5px; color: var(--text-muted); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tab-link { padding: 10px 16px; font-size: 13px; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab-link.active { color: var(--primary); border-color: var(--primary); }
.tab-link:hover { text-decoration: none; color: var(--primary); }

/* ---------- Utility ---------- */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-0{margin-top:0} .mt-8{margin-top:8px} .mt-16{margin-top:16px} .mt-24{margin-top:24px}
.mb-0{margin-bottom:0} .mb-8{margin-bottom:8px} .mb-16{margin-bottom:16px}
.text-muted { color: var(--text-muted); }
.font-bold { font-weight: 700; }
.small { font-size: 12px; }
.avatar-sm { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: #eef1f4; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ---------- Photo upload ---------- */
.photo-upload { display: flex; align-items: center; gap: 16px; }
.photo-preview { width: 96px; height: 96px; border-radius: var(--radius); object-fit: cover; background: #eef1f4; border: 1px solid var(--border); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .content { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .component-row { grid-template-columns: auto 1fr; }
  .component-row .amount-col { grid-column: 1 / -1; }
  table.data-table th, table.data-table td { padding: 8px 10px; }
}

/* ---------- Login / Install screens ---------- */
.auth-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--navy) 0%, var(--primary-dark) 100%); padding: 20px; }
.auth-card { background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 420px; padding: 36px 32px; }
.auth-logo { text-align: center; margin-bottom: 22px; }
.auth-logo .badge-circle { width: 56px; height: 56px; border-radius: 14px; background: var(--primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 22px; }
.install-shell { min-height: 100vh; background: var(--bg); padding: 30px 16px; }
.install-container { max-width: 760px; margin: 0 auto; }
.install-steps { display: flex; gap: 8px; margin-bottom: 24px; }
.install-steps .step { flex: 1; text-align: center; padding: 10px; border-radius: var(--radius-sm); background: #fff; border: 1px solid var(--border); font-size: 12px; font-weight: 700; color: var(--text-muted); }
.install-steps .step.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.install-steps .step.done { background: #e5f6ec; color: var(--success); border-color: #bfe6cd; }
.check-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.check-item:last-child { border-bottom: none; }
.check-item .status { width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.check-item .status.pass { background: #e5f6ec; color: var(--success); }
.check-item .status.fail { background: #fbe8e8; color: var(--danger); }

/* ---------- Print styles ---------- */
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
}
.print-page { max-width: 210mm; margin: 0 auto; background: #fff; padding: 14mm; }
.print-page.letter { max-width: 216mm; }
.print-toolbar { max-width: 210mm; margin: 12px auto; display: flex; justify-content: flex-end; gap: 8px; }
@page { margin: 12mm; }
