:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --line: #d7dee8;
  --text: #14202d;
  --muted: #5d6c7d;
  --primary: #0d6efd;
  --primary-2: #0b5ed7;
  --ok: #146c43;
  --heading: #0f1d2c;
  --table-head: #f2f6fc;
}
body[data-theme="dark"] {
  --bg: #0f141b;
  --surface: #151d27;
  --line: #2a394b;
  --text: #e7edf6;
  --muted: #9fb0c5;
  --primary: #4d9dff;
  --primary-2: #2f7fe0;
  --ok: #4ec48b;
  --heading: #f3f8ff;
  --table-head: #1c2a3a;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
[id] { scroll-margin-top: 90px; }

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  background: linear-gradient(180deg, #eef2f8, var(--bg));
  color: var(--text);
}
body[data-theme="dark"] {
  background: linear-gradient(180deg, #0a1016, var(--bg));
}

.wrap {
  max-width: min(1720px, 98vw);
  margin: 14px auto;
  padding: 0 12px 20px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  margin-bottom: 10px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
}
.topbar-menu {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.topbar-item {
  position: relative;
}
.topbar-item::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  height: 10px;
}
.topbar-trigger {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.topbar-item:nth-of-type(1) .topbar-trigger::before { content: "◫"; font-size: 11px; opacity: .75; }
.topbar-item:nth-of-type(2) .topbar-trigger::before { content: "◎"; font-size: 11px; opacity: .75; }
.topbar-item:nth-of-type(3) .topbar-trigger::before { content: "◉"; font-size: 11px; opacity: .75; }
.topbar-item:nth-of-type(4) .topbar-trigger::before { content: "◌"; font-size: 11px; opacity: .75; }
.topbar-item:nth-of-type(5) .topbar-trigger::before { content: "◍"; font-size: 11px; opacity: .75; }
#openApproverBtn::before { content: "⟁"; font-size: 11px; opacity: .75; }
#logoutBtn::before { content: "⤴"; font-size: 11px; opacity: .75; }
#themeToggleBtn::before { content: "◐"; font-size: 11px; opacity: .75; }
.topbar-dropdown a::before {
  content: "•";
  display: inline-block;
  margin-right: 6px;
  opacity: 0.45;
}
.topbar-trigger:hover,
.topbar-trigger:focus-visible {
  border-color: #9ab5db;
  outline: none;
}
.topbar-item.is-current > .topbar-trigger {
  border-color: #8fb1e4;
  background: #eef4ff;
  box-shadow: inset 0 0 0 1px #d7e6ff;
}
.topbar-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 210px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 22px rgba(26, 41, 61, 0.14);
  padding: 8px;
}
.topbar-item:hover .topbar-dropdown,
.topbar-item:focus-within .topbar-dropdown {
  display: block;
}
.topbar-dropdown a {
  display: block;
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
  border-radius: 8px;
  padding: 8px 10px;
}
.topbar-dropdown a.is-active {
  background: #e9f2ff;
  border: 1px solid #c8dcff;
}
.topbar-dropdown a:hover,
.topbar-dropdown a:focus-visible {
  background: #eff5ff;
  outline: none;
}

[data-page] {
  display: none;
}
[data-page].page-active {
  display: block;
}
.grid[data-page].page-active {
  display: grid;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 10px;
}

h1, h2 {
  margin: 0 0 8px;
  line-height: 1.2;
  color: var(--heading);
}
h1 { font-size: 1.45rem; font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 1.08rem; font-weight: 750; letter-spacing: -0.005em; }
h3 { margin: 0 0 8px; font-size: 0.95rem; font-weight: 700; color: var(--heading); }
ul { margin: 0; padding-left: 18px; }
li { margin: 4px 0; }

.phase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}
.phase {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fafcff;
}
.phase-active {
  border-color: #76a7ff;
  box-shadow: inset 0 0 0 1px #c7dcff;
}

.muted {
  color: var(--muted);
  margin: 0;
  font-size: 12px;
}
.small { font-size: 11px; margin-top: 8px; }

.form {
  display: grid;
  gap: 8px;
}
.form.two {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
}
.inline-check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text);
}

input:not([type="checkbox"]):not([type="radio"]), select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  color: var(--text);
  background: #fff;
  min-height: 34px;
  font-size: 13px;
  font-weight: 500;
}
input[type="checkbox"],
input[type="radio"] {
  width: 14px;
  height: 14px;
  min-height: 14px;
  padding: 0;
  margin: 0 6px 0 0;
  vertical-align: middle;
}
.file-input-themed {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 5px 8px;
  background: #fff;
  color: var(--text);
}
.file-input-themed::file-selector-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 7px 12px;
  margin-right: 10px;
  font-weight: 700;
  cursor: pointer;
}

.btn {
  border: 1px solid var(--primary-2);
  background: linear-gradient(180deg, var(--primary), var(--primary-2));
  color: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 34px;
  height: 34px;
  line-height: 1;
  font-size: 12px;
  box-sizing: border-box;
}
.btn-subtle {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}
.icon-svg {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 16px;
}
.icon-svg svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.row-btn {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.row-btn .btn {
  min-height: 34px;
  height: 34px;
}
.emp-photo-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.emp-photo-left {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 0 0 140px;
}
.emp-photo-right {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 260px;
}
.emp-photo-dropzone {
  width: 130px;
  height: 130px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #f7f9fc;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}
.emp-photo-dropzone.is-dragover {
  border-color: #8fb1e4;
  background: #edf4ff;
  box-shadow: inset 0 0 0 1px #d2e4ff;
}
.emp-photo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}
.emp-photo-placeholder {
  text-align: center;
  padding: 6px;
  margin: 0;
  pointer-events: none;
}
.custom-list {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}
.custom-row {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  display: grid;
  grid-template-columns: 1.3fr 0.8fr auto;
  gap: 8px;
  align-items: center;
}
.custom-row .mini {
  font-size: 12px;
  color: var(--muted);
}

.result {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfdff;
}

.result table {
  width: 100%;
  border-collapse: collapse;
}
.result td .linklike {
  text-decoration: underline;
  color: var(--primary-2);
  cursor: pointer;
}
.batch-table tbody tr {
  cursor: pointer;
}
.batch-table tbody tr:hover {
  background: #f2f7ff;
}

.payroll-dashboard {
  padding: 14px;
}
.dash-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.dash-head-right {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.kpi-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 10px;
}
.kpi-card-status {
  background: linear-gradient(180deg, rgba(63, 139, 194, 0.08), transparent);
}
.kpi-label {
  margin: 0;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.kpi-value {
  margin: 6px 0 4px;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--heading);
}
.kpi-meta,
.kpi-trend {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
}
.dash-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 10px;
}
.dash-panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 10px;
}
.dash-panel-wide {
  grid-column: 1 / -1;
}
.dash-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 600;
}
.pill-warn {
  background: #fff3cd;
  color: #7a5600;
}
.dash-scroll {
  max-height: 220px;
  overflow: auto;
}
.qa-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 8px;
}
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 2px solid var(--line);
}
.timeline li {
  position: relative;
  margin: 0 0 10px 12px;
  padding-left: 12px;
}
.timeline-dot {
  position: absolute;
  left: -19px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #3f8bc2;
}
.timeline-title {
  margin: 0;
  font-weight: 600;
}
.timeline-meta {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.result th,
.result td {
  border-bottom: 1px solid var(--line);
  padding: 6px;
  text-align: left;
  font-size: 12px;
}
.result th {
  background: var(--table-head);
  color: var(--heading);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.result th:last-child,
.result td:last-child {
  text-align: right;
}

.net {
  font-weight: 800;
  color: var(--ok);
}

.payslip {
  border: 1.5px solid #222;
  background: #fff;
  color: #000;
  max-width: 720px;
  margin: 8px auto 0;
  font-family: "Arial Narrow", Arial, sans-serif;
}
.ps-head {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 8px;
  border-bottom: 1px solid #222;
  padding: 8px;
}
.ps-brand {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
}
.ps-logo {
  width: 58px;
  height: 58px;
  border: 1px solid #222;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  overflow: hidden;
  background: #fff;
}
.ps-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.ps-company {
  font-size: 13px;
  line-height: 1.2;
}
.ps-company-name {
  font-size: 16px;
}
.ps-company-line {
  font-size: 12px;
}
.ps-period {
  border: 1px solid #222;
  padding: 6px 8px 5px;
  font-size: 13px;
  text-align: center;
  min-width: 170px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  background: #f4f4f4;
}
.ps-period-label {
  font-weight: 700;
}
.ps-period-value {
  font-size: 15px;
  font-weight: 700;
}
.ps-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 8px 10px;
  border-bottom: 1px solid #222;
  font-size: 12px;
}
.ps-meta-row {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 8px;
}
.ps-meta-row-sub {
  opacity: 0.9;
}
.ps-meta-label {
  font-weight: 700;
}
.ps-meta-value {
  font-weight: 700;
  letter-spacing: 0.01em;
}
.ps-band {
  background: #d4d4d4;
  border-top: 1px solid #222;
  border-bottom: 1px solid #222;
  font-weight: 700;
  padding: 4px 8px 3px;
  letter-spacing: 0.03em;
}
.ps-table {
  width: 100%;
  border-collapse: collapse;
}
.ps-table th,
.ps-table td {
  padding: 2px 8px;
  border-bottom: 0;
  font-size: 12px;
}
.ps-table th:last-child,
.ps-table td:last-child {
  text-align: right;
}
.ps-table thead th {
  font-size: 14px;
  border-bottom: 1px solid #222;
  padding-top: 6px;
  padding-bottom: 4px;
}
.ps-particular {
  font-weight: 700;
}
.ps-amount {
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ps-deductions td {
  padding-top: 3px;
  padding-bottom: 3px;
}
.ps-d-label {
  font-weight: 700;
}
.ps-d-amount {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.ps-total {
  font-weight: 700;
  border-top: 1px solid #222;
}
.ps-net {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px;
  border-top: 1px solid #222;
  background: #efefef;
}
.ps-net-label {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.ps-net-value {
  min-width: 220px;
  text-align: right;
  font-size: 34px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.batch-print-page {
  page-break-after: always;
  break-after: page;
  margin-bottom: 18px;
}

.company-logo-field {
  grid-column: 1 / -1;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 8px;
}
.company-logo-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.company-logo-preview {
  margin-top: 8px;
  width: 88px;
  height: 88px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f7f8fa;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  padding: 6px;
}
.company-logo-preview.has-logo {
  background: #fff;
}
.company-logo-preview-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.company-logo-preview-empty {
  line-height: 1.2;
}

body[data-theme="dark"] .topbar {
  background: rgba(20, 29, 39, 0.92);
}
body[data-theme="dark"] .topbar-trigger,
body[data-theme="dark"] .topbar-dropdown {
  background: #1a2533;
}
body[data-theme="dark"] .topbar-dropdown a:hover,
body[data-theme="dark"] .topbar-dropdown a:focus-visible {
  background: #223246;
}
body[data-theme="dark"] .topbar-dropdown a.is-active {
  background: #243853;
  border-color: #3f608a;
}
body[data-theme="dark"] .phase {
  background: #182230;
}
body[data-theme="dark"] input,
body[data-theme="dark"] select {
  background: #111822;
}
body[data-theme="dark"] .file-input-themed,
body[data-theme="dark"] .file-input-themed::file-selector-button {
  background: #1a2533;
  color: var(--text);
}
body[data-theme="dark"] .btn-subtle {
  background: #1a2533;
}
body[data-theme="dark"] .emp-photo-dropzone {
  background: #132031;
}
body[data-theme="dark"] .emp-photo-dropzone.is-dragover {
  border-color: #5b89c7;
  background: #19304a;
  box-shadow: inset 0 0 0 1px #31557d;
}
body[data-theme="dark"] .result {
  background: #192432;
}
body[data-theme="dark"] .batch-table tbody tr:hover {
  background: #223143;
}

@media (max-width: 1080px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }
  .dash-grid {
    grid-template-columns: 1fr;
  }
  .emp-photo-row {
    flex-direction: column;
  }
  .emp-photo-right {
    min-width: 0;
    width: 100%;
  }
}
@media (max-width: 640px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .qa-grid {
    grid-template-columns: 1fr;
  }
}
