/* PayGoSG stylesheet. No framework. Plain modern CSS. */

:root {
  --bg: #0b1020;
  --fg: #f5f7fb;
  --muted: #aab3c5;
  --accent: #4f8cff;
  --accent-strong: #2c6ef0;
  --card-bg: #141a2e;
  --card-border: #232b45;
  --danger: #ff6b6b;
  --ok: #4cd07d;
  --warn: #ffd166;
  --radius: 10px;
  --maxw: 720px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.55;
}

main {
  max-width: var(--maxw);
  margin: 5vh auto;
  padding: 40px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
}

h1 {
  margin: 0 0 12px;
  font-size: 32px;
  letter-spacing: -0.02em;
}

.tagline {
  color: var(--muted);
  font-size: 19px;
  margin: 0 0 28px;
}

form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 24px 0;
}

label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

input[type="email"],
input[type="file"] {
  width: 100%;
  padding: 12px 14px;
  background: #0e1424;
  color: var(--fg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  font-size: 16px;
}

input[type="email"]:focus,
input[type="file"]:focus {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
}

button {
  appearance: none;
  cursor: pointer;
  padding: 14px 20px;
  background: var(--accent-strong);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 16px;
  transition: background .15s ease, transform .05s ease;
}

button:hover { background: var(--accent); }
button:active { transform: translateY(1px); }

.fineprint {
  color: var(--muted);
  font-size: 13px;
  margin-top: 18px;
}

.error {
  background: rgba(255, 107, 107, 0.08);
  border: 1px solid rgba(255, 107, 107, 0.4);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 6px;
  margin: 16px 0;
}

.save-banner {
  background: rgba(255, 209, 102, 0.08);
  border: 1px solid rgba(255, 209, 102, 0.4);
  color: var(--warn);
  padding: 12px 14px;
  border-radius: 6px;
  margin-bottom: 24px;
}

.prep-banner {
  border-left: 3px solid var(--accent);
  background: rgba(79, 140, 255, .08);
  padding: 16px 18px;
  border-radius: 8px;
  margin: 0 0 24px;
  color: var(--fg);
  font-size: 15px;
}

.prep-banner strong {
  display: block;
  margin-bottom: 6px;
  color: var(--accent);
}

.prep-banner ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.prep-banner li {
  margin: 4px 0;
}

.prep-banner a {
  color: var(--accent);
  text-decoration: underline;
}

.prep-banner code {
  background: rgba(79, 140, 255, .15);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 13px;
}

.dev-banner {
  background: rgba(255, 107, 107, 0.08);
  border: 1px dashed rgba(255, 107, 107, 0.5);
  color: var(--danger);
  padding: 12px 14px;
  border-radius: 6px;
  margin-bottom: 24px;
  font-size: 14px;
}

.usage {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 20px;
}

.success .url {
  background: #0e1424;
  border: 1px solid var(--card-border);
  padding: 14px;
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  word-break: break-all;
  user-select: all;
}

a {
  color: var(--accent);
}

a:hover {
  color: var(--accent-strong);
}

@media (max-width: 600px) {
  main { margin: 0; padding: 24px; border-radius: 0; min-height: 100vh; }
  h1 { font-size: 26px; }
}

/* Journey bar — connected bubble stepper, shared across every page.
   Past steps get a filled bubble with checkmark, current step pulses
   with an accent ring, future steps are ghost outlines. A horizontal
   track behind the bubbles fills as the user advances. The track fill
   width is driven by the --current custom property set inline on the
   <ol> (1..4) by the journey template. */
.journey {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 0;
  margin: 32px auto 32px;
  max-width: var(--maxw);
  position: relative;
}

.journey::before {
  content: "";
  position: absolute;
  top: 23px;
  left: 12.5%;
  right: 12.5%;
  height: 2px;
  background: var(--card-border);
  border-radius: 1px;
  z-index: 0;
}

.journey::after {
  content: "";
  position: absolute;
  top: 23px;
  left: 12.5%;
  width: calc((var(--current, 1) - 1) * 25%);
  height: 2px;
  background: linear-gradient(90deg, var(--accent-strong), var(--accent));
  border-radius: 1px;
  transition: width .3s ease;
  z-index: 0;
}

.journey .step {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  z-index: 1;
}

.journey .bubble {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #0e1424;
  border: 2px solid var(--card-border);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, "Cascadia Code", monospace;
  font-weight: 600;
  font-size: 14px;
  transition: background .25s ease, border-color .25s ease, color .25s ease, box-shadow .25s ease;
}

.journey .label {
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.journey .step.done .bubble {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: white;
  font-size: 18px;
}

.journey .step.current .bubble {
  background: #0e1424;
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 6px rgba(79, 140, 255, 0.15);
  animation: journey-pulse 2s ease-in-out infinite;
}

.journey .step.current .label {
  color: var(--fg);
  font-weight: 600;
}

@keyframes journey-pulse {
  0%, 100% { box-shadow: 0 0 0 6px rgba(79, 140, 255, 0.15); }
  50%      { box-shadow: 0 0 0 12px rgba(79, 140, 255, 0.05); }
}

@media (prefers-reduced-motion: reduce) {
  .journey .step.current .bubble { animation: none; }
  .journey::after { transition: none; }
}

@media (max-width: 600px) {
  .journey { margin: 0 0 24px; }
  .journey .bubble { width: 38px; height: 38px; font-size: 13px; }
  .journey .step.done .bubble { font-size: 16px; }
  .journey .label { font-size: 11px; margin-top: 10px; letter-spacing: 0.02em; }
  .journey::before, .journey::after { top: 19px; }
}

/* Confirm page table */
.summary {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 24px;
  font-size: 15px;
}

.summary th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  padding: 8px 12px 8px 0;
  border-bottom: 1px solid var(--card-border);
  white-space: nowrap;
}

.summary td {
  padding: 8px 0;
  border-bottom: 1px solid var(--card-border);
  word-break: break-all;
}

/* The .confirm wrapper is itself the <form> so the per-row CPF
   checkboxes (nested inside <details>) are submitted with the POST. */
.confirm form,
form.confirm {
  gap: 12px;
}

.confirm .confirm-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin: 24px 0 0;
}

.confirm .cancel {
  font-size: 14px;
}

/* Collapsible per-employee breakdown. Native <details>/summary> gives
   us keyboard and screen-reader support for free; CSS adds the visual
   chrome (card-style container, custom disclosure triangle, hover row
   tint). */
.confirm .employee-breakdown {
  margin: 24px 0;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  background: #0e1424;
  overflow: hidden;
}

.confirm .employee-breakdown > summary {
  cursor: pointer;
  padding: 14px 18px;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  user-select: none;
  font-weight: 600;
  font-size: 15px;
  transition: color .15s ease, background .15s ease;
}

.confirm .employee-breakdown > summary::-webkit-details-marker {
  display: none;
}

.confirm .employee-breakdown > summary::before {
  content: "▸";
  margin-right: 10px;
  color: var(--accent);
  transition: transform .2s ease;
  display: inline-block;
}

.confirm .employee-breakdown[open] > summary::before {
  transform: rotate(90deg);
}

.confirm .employee-breakdown > summary:hover {
  color: var(--accent);
  background: rgba(79, 140, 255, 0.04);
}

.confirm .employee-breakdown .summary-hint {
  font-weight: 400;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.confirm .employee-breakdown .breakdown-hint {
  padding: 0 18px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.confirm .employee-breakdown .breakdown-hint {
  padding: 0 18px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.confirm .employee-breakdown .employee-cards {
  list-style: none;
  margin: 0;
  padding: 0 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* One card per employee. Vertical key-value layout keeps each
   employee's numbers scannable without horizontal scrolling. */
.confirm .employee-card {
  background: #0e1424;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 14px 16px;
}

.confirm .employee-card h4 {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.confirm .employee-card .kv {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.confirm .employee-card .kv-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding: 5px 8px;
  margin: 0 -8px;
  border-radius: 4px;
  font-size: 14px;
}

.confirm .employee-card .kv-row .k {
  color: var(--muted);
  font-size: 13px;
}

.confirm .employee-card .kv-row .v {
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-weight: 500;
}

.confirm .employee-card .kv-row .v.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, "Cascadia Code", monospace;
  font-size: 13px;
  font-weight: 400;
}

/* Highlighted bottom-line rows: Net pay, Total CPF, Total cost.
   These are the three values the employer is verifying — what hits
   the employee's bank, what gets remitted to CPF Board, and the
   combined cash outlay. Accent tint + bolder weight makes them jump
   out within each card. */
.confirm .employee-card .kv-row.highlight {
  background: rgba(79, 140, 255, 0.10);
  font-weight: 700;
}

.confirm .employee-card .kv-row.highlight .k {
  color: var(--fg);
}

.confirm .employee-card .kv-row.highlight .v {
  color: var(--fg);
  font-weight: 700;
}

@media (max-width: 600px) {
  .confirm .employee-breakdown > summary { padding: 12px 14px; font-size: 14px; }
  .confirm .employee-breakdown .breakdown-hint,
  .confirm .employee-breakdown .employee-cards { padding-left: 14px; padding-right: 14px; }
  .confirm .employee-card { padding: 12px 14px; }
}

/* CPF comparison table — two-column submitted vs calculated layout
   nested inside each employee card. Compact header and tabular-aligned
   amounts so the two columns line up visually. */
.confirm .cpf-comparison {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 13px;
}

.confirm .cpf-comparison th,
.confirm .cpf-comparison td {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid var(--card-border);
  vertical-align: top;
}

.confirm .cpf-comparison th {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.confirm .cpf-comparison td:nth-child(2),
.confirm .cpf-comparison td:nth-child(3) {
  font-variant-numeric: tabular-nums;
}

.confirm .cpf-comparison details {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.confirm .cpf-comparison details summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 500;
}

.confirm .cpf-comparison em {
  color: var(--muted);
  font-style: italic;
  font-size: 12px;
}

/* Per-row toggle for choosing the calculated CPF over the submitted
   value. Block layout so the checkbox sits on its own line beneath the
   comparison table. */
.confirm .use-calculated-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.confirm .use-calculated-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Output page */
.output .downloads {
  list-style: none;
  padding: 0;
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.output .downloads li {
  padding: 12px 14px;
  background: #0e1424;
  border: 1px solid var(--card-border);
  border-radius: 8px;
}

.output .downloads a {
  font-weight: 600;
}

/* ===== /build — Spreadsheet Builder ===== */

.build fieldset.build-section {
  border: 1px solid var(--card-border);
  background: #0e1424;
  border-radius: 8px;
  padding: 18px;
  margin: 20px 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.build fieldset.build-section legend {
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
  padding: 0 8px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.build label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

.build input[type="text"],
.build input[type="date"],
.build input[type="number"],
.build select {
  width: 100%;
  padding: 10px 12px;
  background: #0b1020;
  color: var(--fg);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  font-size: 15px;
  font-family: inherit;
}

.build input:focus,
.build select:focus {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
}

.build .add-employee {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
}

.build .add-employee:hover {
  background: rgba(79, 140, 255, 0.1);
}

.build .employee-card {
  grid-column: 1 / -1;
  background: #0b1020;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.build .employees-list {
  grid-column: 1 / -1;
}

.build .employee-card h4 {
  grid-column: 1 / -1;
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--fg);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.build .remove-employee {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  width: 22px;
  height: 22px;
  padding: 0;
  font-size: 14px;
  line-height: 1;
  border-radius: 4px;
  cursor: pointer;
}

.build .cpf-toggle {
  grid-column: 1 / -1;
  border-top: 1px dashed var(--card-border);
  padding-top: 10px;
  margin-top: 6px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  align-items: center;
}

.build .cpf-preview {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.build .cpf-preview .cpf-emp,
.build .cpf-preview .cpf-er {
  color: var(--accent);
  font-weight: 600;
}

.build .cpf-manual {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.build .validation-errors {
  background: rgba(255, 107, 107, 0.08);
  border: 1px solid rgba(255, 107, 107, 0.4);
  border-radius: 6px;
  padding: 12px 16px;
  margin: 16px 0;
}

.build .validation-errors h2 {
  margin: 0 0 8px;
  font-size: 15px;
  color: var(--danger);
}

.build .validation-errors ul {
  margin: 0;
  padding-left: 20px;
  color: var(--fg);
  font-size: 14px;
}

@media (max-width: 600px) {
  .build fieldset.build-section,
  .build .employee-card {
    grid-template-columns: 1fr;
  }
}

/* ===== /build summary ===== */

.build-summary .summary-card {
  background: #0e1424;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 18px 22px;
  margin: 20px 0;
}

.build-summary .summary-card h2 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.build-summary .summary {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.build-summary .summary th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  padding: 8px 12px 8px 0;
  width: 50%;
}

.build-summary .summary td {
  padding: 8px 0;
  font-variant-numeric: tabular-nums;
}

.build-summary .summary .muted {
  color: var(--muted);
  font-size: 13px;
}

.build-summary .summary-actions {
  display: flex;
  align-items: center;
  gap: 20px;
  margin: 24px 0;
}

.build-summary .summary-actions .button {
  display: inline-block;
  padding: 14px 20px;
  background: var(--accent-strong);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 16px;
  text-decoration: none;
  cursor: pointer;
}

.build-summary .summary-actions .button:hover {
  background: var(--accent);
}

.build-summary .summary-actions .link {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
}
