/* ==== Reset & base ==== */
:root {
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: #17352e;
  background: #f5f8f6;
  font-size: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
a { color: #12674c; text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }

/* ==== Buttons ==== */
button, .button {
  border: 0;
  border-radius: 10px;
  background: #117958;
  color: #fff;
  padding: 11px 17px;
  font-weight: 650;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-decoration: none;
}
button:hover, .button:hover { background: #0b6549; text-decoration: none; }
button:disabled { opacity: .45; cursor: not-allowed; }
.secondary { background: #e0f2e9; color: #176447; }
.secondary:hover { background: #c8e8d8; }
.ghost { background: #fff; color: #285c49; border: 1px solid #dce9e2; }
.ghost:hover { background: #f2f9f5; }

/* ==== Sidebar ==== */
.sidebar {
  width: 242px;
  position: fixed;
  inset: 0 auto 0 0;
  padding: 28px 18px;
  background: linear-gradient(160deg, #0c3028, #153d35 65%, #1b4c3c);
  color: #d9efe4;
  display: flex;
  flex-direction: column;
  z-index: 5;
}
.brand { display: flex; align-items: center; gap: 11px; color: #fff; font-size: 20px; font-weight: 800; letter-spacing: .04em; padding: 4px 8px; }
.brand:hover { text-decoration: none; }
.brand small { display: block; font-size: 10px; font-weight: 500; letter-spacing: .12em; color: #a9ceb9; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 13px; background: #4bc387; color: #073b27; font-size: 25px; }
.side-label { color: #8bb9a1; font-size: 10px; letter-spacing: .18em; margin: 26px 12px 10px; }
.side-label:first-of-type { margin-top: 30px; }
.side-nav { display: grid; gap: 5px; }
.side-nav a { color: #c7e5d6; padding: 12px 13px; border-radius: 10px; display: flex; gap: 12px; align-items: center; font-weight: 550; }
.side-nav a:hover { background: #ffffff19; text-decoration: none; color: white; }
.side-nav a.active { background: #ffffff26; color: white; }
.sidebar-foot { margin-top: auto; padding: 17px 12px 4px; border-top: 1px solid #ffffff23; overflow-wrap: anywhere; }
.sidebar-foot strong { font-size: 12px; }
.sidebar-foot small { display: block; color: #94c0a8; margin-top: 12px; font-size: 10px; }
.link-button { background: none; color: #a8d8b9; padding: 7px 0; font-size: 12px; }
.link-button:hover { background: none; color: white; }

/* ==== App shell / topbar ==== */
.app-shell { margin-left: 242px; min-height: 100vh; }
.topbar { height: 65px; background: #fff; border-bottom: 1px solid #e3ede6; display: flex; justify-content: space-between; align-items: center; padding: 0 34px; }
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.back-button { background: #eef5f1; color: #245641; padding: 8px 12px; font-size: 12px; }
.back-button:hover { background: #e0ede4; }
.home-link { font-size: 12px; font-weight: 600; white-space: nowrap; }
.crumb { color: #a8b8ad; }
.topbar-pill { color: #4f8067; border: 1px solid #d9e9de; border-radius: 30px; padding: 7px 11px; letter-spacing: .09em; font-size: 10px; font-weight: 700; }
.content { max-width: 1500px; margin: auto; padding: 36px 42px 80px; }

/* ==== Headings ==== */
.eyebrow { color: #26845d; font-size: 11px; font-weight: 800; letter-spacing: .14em; margin-bottom: 10px; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
h1 { font-size: 30px; letter-spacing: -.04em; margin: 0 0 8px; }
h2 { font-size: 19px; letter-spacing: -.02em; margin: 0 0 7px; }
h3 { font-size: 22px; letter-spacing: -.03em; margin: 12px 0 8px; }
p { color: #657a6e; line-height: 1.65; margin: 5px 0 13px; }
.page-heading p { margin: 0; }
.hero-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 22px 0; }

/* ==== Panels / cards ==== */
.panel, .card, .process-card { background: #fff; border: 1px solid #e1ebe4; border-radius: 16px; box-shadow: 0 8px 30px #153d2c08; }
.panel { padding: 24px; margin: 23px 0; }
.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 16px; }
.section-head p { margin: 0; }
.counter { border-radius: 30px; background: #e9f4ec; color: #336f4d; padding: 8px 12px; font-weight: 700; font-size: 12px; white-space: nowrap; }
.info-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: #dce9df; border-radius: 14px; overflow: hidden; margin: 27px 0; }
.info-strip div { padding: 17px; background: #f0f8f3; }
.info-strip strong, .info-strip span { display: block; }
.info-strip strong { font-size: 12px; color: #176847; }
.info-strip span { font-size: 11px; color: #718679; margin-top: 5px; }
.tablelinks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; }
.table-tile { border: 1px solid #e1ebe4; border-radius: 12px; padding: 15px; display: flex; flex-direction: column; justify-content: space-between; gap: 14px; min-width: 0; }
.table-tile strong { display: block; overflow-wrap: anywhere; }
.table-tile small { color: #829589; display: block; margin-top: 5px; }
.tile-actions { display: flex; gap: 14px; font-size: 12px; font-weight: 700; }

/* ==== Status chips ==== */
.status-chip { display: inline-flex; align-items: center; border-radius: 30px; padding: 7px 11px; background: #e8efea; color: #456a50; font-size: 11px; font-weight: 800; letter-spacing: .05em; white-space: nowrap; }
.status-draft { background: #e7f2ee; color: #287154; }
.status-running, .status-calculating, .status-queued { background: #dff0ff; color: #2767a0; }
.status-failed, .status-rejected { background: #ffe7e2; color: #a43a30; }
.status-succeeded, .status-approved, .status-closed { background: #dcf5e4; color: #217746; }
.status-warning { background: #fff2d6; color: #9c6a16; }

/* ==== Notices / messages ==== */
.notice { border-left: 4px solid #d2a344; background: #fff7e6; padding: 15px 18px; border-radius: 9px; color: #765c28; line-height: 1.6; margin: 16px 0; }
.message { background: #e2f4e8; color: #245a39; padding: 15px 18px; border-radius: 10px; margin: 0 0 18px; }
.message.error, .errorlist { background: #ffe9e4; color: #943b30; }
.message ul { margin-bottom: 0; }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; margin: 20px 0; }
.card { padding: 20px; min-width: 0; }
.card small { color: #778e7e; font-weight: 700; }
.card h3 { overflow-wrap: anywhere; }
.card span { color: #7f9688; font-size: 12px; }

/* ==== Tables ==== */
.scroll { overflow: auto; max-height: 670px; }
table { border-collapse: separate; border-spacing: 0; width: 100%; white-space: nowrap; font-size: 12px; }
th { text-align: left; background: #f0f7f2; color: #3b6650; padding: 12px; position: sticky; top: 0; z-index: 1; }
td { padding: 12px; border-bottom: 1px solid #edf1ed; max-width: 450px; overflow: hidden; text-overflow: ellipsis; }
tr:hover td { background: #fafdfa; }
.inline-search { display: flex; gap: 8px; }

/* Sticky identity column(s) for wide tables (Employee_Master, reports) */
.sticky-col { position: sticky; left: 0; z-index: 2; background: #fff; box-shadow: 2px 0 0 #edf1ed; }
th.sticky-col { z-index: 3; background: #f0f7f2; }
tr:hover td.sticky-col { background: #fafdfa; }

/* Grouped report header (Payroll_Summary rincian lengkap - dua tingkat) */
.group-header { text-align: center; background: #dcefe3; color: #175a3c; border-left: 1px solid #fff; border-bottom: 2px solid #b7dcc3; text-transform: uppercase; font-size: 10px; letter-spacing: .06em; z-index: 3; }
.sub-header th { top: auto; }

/* Numeric / currency columns */
.amount-col, td.amount-col { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot .amount-col, tfoot td { font-weight: 700; }
tfoot td { background: #f0f7f2; border-top: 2px solid #dce9df; }

/* ==== Forms ==== */
input, select, textarea { padding: 10px 12px; border: 1px solid #d2e2d6; border-radius: 9px; background: #fff; color: #183e2b; max-width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9edab8; }
label { display: block; margin: 14px 0 8px; font-weight: 650; }
label input, label textarea, label select { display: block; width: 100%; margin-top: 6px; }
textarea { min-height: 88px; }
.formgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 22px; }
.field small { display: block; color: #879b8b; margin-top: 5px; }
.login { max-width: 530px; margin: 45px auto; }

/* Directory / filter bar (Master Karyawan) */
.directory-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin: 18px 0; }
.directory-filters label { margin: 0; font-size: 11px; font-weight: 700; color: #4a685a; }
.directory-filters select, .directory-filters input { margin-top: 5px; min-width: 160px; }
.directory-filters .field-inline { display: flex; flex-direction: column; }

/* Grid edit mode (Variable_Input spreadsheet-style entry) */
.grid-save-bar { display: flex; align-items: flex-end; gap: 14px; margin: 14px 0; flex-wrap: wrap; }
.grid-save-bar .field-inline { flex: 1; min-width: 260px; display: flex; flex-direction: column; }
.grid-save-bar .field-inline span { font-size: 11px; font-weight: 700; color: #4a685a; margin-bottom: 5px; }
.grid-table input[type="text"], .grid-table input[type="number"] { padding: 6px 8px; font-size: 12px; width: 100%; min-width: 90px; }
.grid-table td { padding: 6px 8px; }

/* Employee detail grouped fields */
.employee-detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: #e4ede6; border: 1px solid #e4ede6; border-radius: 11px; overflow: hidden; margin: 14px 0; }
.employee-detail-grid div { padding: 14px 16px; background: #fff; min-width: 0; }
.employee-detail-grid span { display: block; color: #819286; font-size: 11px; }
.employee-detail-grid strong { display: block; margin-top: 5px; overflow-wrap: anywhere; }

/* ==== Process grid (Calculation Engine) ==== */
.process-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: stretch; }
.process-card { padding: 24px; display: flex; flex-direction: column; position: relative; }
.process-card p { flex: 1; }
.process-card.featured { border-color: #8cc7a1; background: linear-gradient(160deg, #fff, #f3fbf5); }
.process-icon { display: grid; place-items: center; width: 42px; height: 42px; background: #e1f2e9; color: #1d7650; border-radius: 13px; font-size: 20px; margin-bottom: 17px; }
.process-card button { width: 100%; margin-top: 10px; }
.process-step { position: absolute; top: 18px; right: 20px; width: 24px; height: 24px; border-radius: 50%; background: #eef5f1; color: #4a685a; font-size: 12px; font-weight: 800; display: grid; place-items: center; }
.featured .process-step { background: #d9f0e2; color: #1d7650; }
.disabled-reason { display: block; margin-top: 8px; color: #a43a30; font-size: 11px; }

/* ==== Upload ==== */
.field-list { display: flex; flex-wrap: wrap; gap: 8px; }
.field-list span { background: #f3f7f3; border-radius: 8px; padding: 8px 10px; font-size: 11px; }
.field-list small { color: #839487; }
.upload-form { max-width: 620px; }

/* ==== Approval summary grid ==== */
.approval-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: #e4ede6; border: 1px solid #e4ede6; border-radius: 11px; overflow: hidden; }
.approval-grid div { padding: 16px; background: #fff; min-width: 0; }
.approval-grid span, .approval-grid strong { display: block; }
.approval-grid span { color: #819286; font-size: 12px; }
.approval-grid strong { font-size: 16px; margin-top: 7px; overflow-wrap: anywhere; }
.small-note { font-size: 12px; color: #8a9b8e; }

/* ==== Report run list ==== */
.report-group { margin-top: 25px; }
.report-group h3 { margin: 0 0 12px; font-size: 14px; }
.report-catalog-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.report-catalog-card { display: flex; flex-direction: column; min-height: 146px; padding: 15px; border: 1px solid #e2ebe5; border-radius: 12px; background: #fbfdfa; color: inherit; text-decoration: none; transition: border-color .16s, transform .16s, box-shadow .16s; }
.report-catalog-card:hover, .report-catalog-card:focus-visible { border-color: #62ad7d; box-shadow: 0 6px 18px #1f724218; transform: translateY(-2px); }
.report-catalog-icon { font-size: 18px; color: #198456; }
.report-catalog-card strong { margin-top: 8px; font-size: 13px; }
.report-catalog-card small { color: #738879; margin-top: 3px; overflow-wrap: anywhere; }
.report-catalog-foot { display: flex; justify-content: space-between; gap: 7px; margin-top: auto; padding-top: 10px; color: #24704a; font-size: 11px; font-weight: 700; }
.report-schema + .report-schema { border-top: 1px solid #e5eee8; margin-top: 24px; padding-top: 20px; }
.report-column-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.report-column-list span { display: flex; align-items: flex-start; gap: 7px; padding: 9px 11px; border-radius: 8px; background: #f3f8f4; font-size: 12px; overflow-wrap: anywhere; }
.report-column-list b { color: #218356; min-width: 19px; }
.report-run { border-top: 1px solid #e5eee8; padding: 17px 0; }
.report-run > div:first-child { display: flex; gap: 10px; align-items: center; }
.report-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.report-links a { display: inline-flex; padding: 9px 12px; border-radius: 8px; background: #f0f7f2; font-weight: 650; font-size: 12px; }
.empty-state { text-align: center; padding: 35px 15px; }
.empty-state strong { font-size: 17px; }

/* ==== Live run panel ==== */
.live-panel { border-color: #a8d4b8; }
.live-head { display: flex; align-items: center; gap: 18px; }
.live-orb { width: 45px; height: 45px; border-radius: 50%; background: #40ae75; box-shadow: 0 0 0 0 #40ae7566; animation: pulse 1.7s infinite; }
.live-head p { margin: 0; }
.step-track { display: flex; gap: 8px; margin-top: 24px; }
.step { flex: 1; background: #eff4f0; color: #91a093; padding: 11px; text-align: center; border-radius: 8px; font-size: 11px; font-weight: 700; }
.step.active { background: #dff2e7; color: #18764c; animation: glow 2s infinite; }

/* ==== Loading overlay ==== */
.loading-overlay { position: fixed; inset: 0; background: #102e28b8; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 17px; color: white; font-weight: 700; z-index: 99; }
.spinner { width: 46px; height: 46px; border: 4px solid #ffffff55; border-top-color: #69d797; border-radius: 50%; animation: spin .85s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { box-shadow: 0 0 0 15px #40ae7500; } }
@keyframes glow { 50% { background: #c7ead7; } }

/* ==== Responsive ==== */
@media (max-width: 1050px) {
  .tablelinks, .process-grid, .report-catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .info-strip { grid-template-columns: repeat(2, 1fr); }
  .approval-grid, .employee-detail-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .sidebar { position: relative; width: auto; padding: 17px; }
  .side-label, .sidebar-foot { display: none; }
  .side-nav { display: flex; overflow: auto; margin-top: 13px; }
  .side-nav a { white-space: nowrap; font-size: 12px; }
  .app-shell { margin-left: 0; }
  .topbar { padding: 0 17px; }
  .topbar-pill { display: none; }
  .content { padding: 25px 17px 70px; }
  .page-heading { display: block; }
  .page-heading .status-chip { margin-top: 14px; }
  .tablelinks, .process-grid, .cards, .approval-grid, .employee-detail-grid, .report-catalog-grid, .report-column-list { grid-template-columns: 1fr; }
  .info-strip { grid-template-columns: repeat(2, 1fr); }
  .formgrid { grid-template-columns: 1fr; }
  .home-link { display: none; }
  .directory-filters select, .directory-filters input { min-width: 0; width: 100%; }
}

/* ==== Print ==== */
@media print {
  .sidebar, .topbar, .hero-actions, .back-button, .side-nav { display: none; }
  .app-shell { margin: 0; }
  .content { padding: 0; }
  .panel { box-shadow: none; border: 0; }
  .scroll { max-height: none; overflow: visible; }
  table { white-space: normal; font-size: 9px; }
  th { position: static; }
  .sticky-col { position: static; box-shadow: none; }
}
