/* WP06 Employee Payroll Portal — professional, light, card-based. Local fonts only (no external assets). */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #4b5563;
  --line: #d7dde5;
  --brand: #1d3c6e;
  --brand-ink: #ffffff;
  --accent-bg: #eef3fa;
  --ok-bg: #e6f4ea;
  --ok-ink: #14532d;
  --warn-bg: #fff7e0;
  --warn-ink: #6b4a00;
  --err-bg: #fdecec;
  --err-ink: #8a1c1c;
  --focus: #1d4ed8;
  --radius: 10px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* the hidden attribute always wins over component display rules */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans Thai", "Leelawadee UI", "Sarabun", "Tahoma", system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
}
.wrap { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 16px; }
h1 { font-size: clamp(1.4rem, 1.1rem + 1.4vw, 1.9rem); margin: 24px 0 4px; line-height: 1.3; }
h2 { font-size: 1.15rem; margin: 0 0 8px; }
h3 { margin: 0; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
main:focus { outline: none; }

.skip-link { position: absolute; left: -9999px; top: 0; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip-link:focus { left: 8px; top: 8px; }

.dev-banner {
  background: var(--warn-bg); color: var(--warn-ink); border-bottom: 1px solid #e8cf86;
  padding: 6px 16px; font-size: 0.875rem; text-align: center;
}
.site-header { background: var(--brand); color: var(--brand-ink); }
.header-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.brand { font-weight: 700; letter-spacing: 0.08em; font-size: 1.1rem; }
.brand-sub { opacity: 0.9; font-size: 0.9rem; }
.site-footer { color: var(--muted); font-size: 0.85rem; padding: 24px 0 32px; }

.employee-line { color: var(--muted); margin: 0 0 16px; }
.hint { color: var(--muted); margin: 0 0 12px; font-size: 0.925rem; }

/* states */
.state { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin: 16px 0; }
.state-loading { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.state-empty { border-left: 5px solid var(--brand); }
.state-error { border-left: 5px solid var(--err-ink); background: var(--err-bg); }
.state-title { margin: 0 0 6px; font-size: 1.1rem; }
.state-text { margin: 0 0 12px; color: var(--muted); }
.state-error .state-text { color: var(--err-ink); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand); animation: spin 0.9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 18px; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover { background: #163059; }
.btn-secondary { background: var(--surface); color: var(--brand); border-color: var(--brand); }
.btn-link { background: transparent; color: var(--brand); padding-left: 0; padding-right: 0; }
.btn[disabled], .btn.is-busy { opacity: 0.6; cursor: progress; }

/* history — WP10D: one row per pay period (scannable list instead of a ragged card grid) */
.history-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr; gap: 10px; max-width: 760px; }
.history-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: nowrap;
}
.history-info { min-width: 0; display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 16px; }
.history-title { font-size: 1.05rem; }
.history-period { margin: 0; color: var(--muted); }
.badge { display: inline-block; font-size: 0.8rem; padding: 2px 10px; border-radius: 999px; font-weight: 600; }
.badge-ready { background: var(--ok-bg); color: var(--ok-ink); }
.badge-ready::before { content: "✓ "; }

/* payslip */
.actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin: 16px 0 4px; }
.slip { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin: 12px 0 32px; overflow: hidden; }
.slip-header {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap;
  padding: 20px; border-bottom: 3px solid var(--brand); background: var(--accent-bg);
}
.slip-brand { margin: 0; font-weight: 700; letter-spacing: 0.08em; color: var(--brand); }
.slip-header h1 { margin: 0; }
/* WP11-H1 legal employer header (from the payload only) */
.slip-employer { flex: 1 1 320px; min-width: 0; }
.employer-name { margin: 0; font-weight: 700; font-size: 1.05rem; line-height: 1.45; color: var(--brand); overflow-wrap: anywhere; }
.employer-name-en { margin: 0; font-weight: 600; font-size: 0.9rem; line-height: 1.4; overflow-wrap: anywhere; }
.employer-address, .employer-phone { margin: 0; font-size: 0.85rem; line-height: 1.45; color: var(--muted); overflow-wrap: anywhere; }
.employer-note { margin: 4px 0 0; font-size: 0.85rem; font-weight: 600; line-height: 1.45; color: var(--muted); overflow-wrap: anywhere; }
.employer-note.is-integrity { color: var(--danger, #9b1c1c); border-left: 4px solid currentColor; padding-left: 8px; }   /* H1R2 */
.slip-employer h1, .slip-employer .slip-title-h { margin: 10px 0 0; }
.slip-period { display: flex; gap: 20px; margin: 0; flex-wrap: wrap; }
.slip-period dt, .kv dt { color: var(--muted); font-size: 0.85rem; }
.slip-period dd, .kv dd { margin: 0; font-weight: 600; }
.slip-section { padding: 16px 20px; border-bottom: 1px solid var(--line); min-width: 0; }
.section-title { font-size: 1rem; color: var(--brand); margin-bottom: 8px; }
.kv { display: flex; gap: 32px; margin: 0; flex-wrap: wrap; }
.kv > div { min-width: 0; }
.kv dd { overflow-wrap: anywhere; }
.slip-columns { display: grid; grid-template-columns: 1fr 1fr; }
.slip-columns .slip-section + .slip-section { border-left: 1px solid var(--line); }
.lines { list-style: none; margin: 0; padding: 0; }
.line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.line:last-child { border-bottom: 0; }
.line-label { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.line-amount, .totals dd { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; flex: none; }
.line-empty { color: var(--muted); }
.totals { margin: 0; }
.total-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 6px 0; flex-wrap: wrap; }
.total-row dt { font-weight: 600; }
.total-row dd { margin: 0; font-weight: 600; margin-left: auto; }
.total-row.net { margin-top: 8px; padding: 12px 14px; background: var(--accent-bg); border-left: 5px solid var(--brand); border-radius: 6px; }
.total-row.net dt { font-size: 1.1rem; }
.total-row.net dd { font-size: clamp(1.3rem, 1.1rem + 1vw, 1.6rem); color: var(--brand); font-weight: 700; }
.is-unavailable { color: var(--muted); font-weight: 400 !important; }
.payment { margin: 0; }
.slip-footer { padding: 14px 20px; color: var(--muted); font-size: 0.85rem; }
.slip-footer p { margin: 0 0 4px; }
.print-only { display: none; }

@media (max-width: 640px) {
  .slip-columns { grid-template-columns: 1fr; }
  .slip-columns .slip-section + .slip-section { border-left: 0; }
  .slip-header, .slip-section, .slip-footer { padding-left: 16px; padding-right: 16px; }
  .history-card { flex-wrap: wrap; }
  .history-card .btn { width: 100%; }
  .kv { gap: 12px 24px; }
}

/* WP11-B / D02 — synthetic / non-production document marker. Removed by the server only in a PRODUCTION environment. */
.env-marker { display: block; margin: 0 0 16px; padding: 10px 14px; border: 2px solid #b45309; border-radius: 8px;
  background: #fff7ed; color: #7c2d12; font-weight: 700; text-align: center; line-height: 1.5; overflow-wrap: anywhere; }
.slip > .env-marker { margin: 0; border-width: 0 0 2px; border-radius: 0; }

/* WP11 DR-01A — slip header: WARITHEP group wordmark top-left (the legal employer below it still comes from data only)
   and the WP11-B synthetic marker moved to the top-right corner of the slip. Presentation only. */
.slip { position: relative; }
.slip-header .slip-brand { flex: 1 0 100%; margin: 0; padding-right: 15.5rem; font-size: clamp(1.6rem, 1.3rem + 1.2vw, 2.1rem);
  font-weight: 800; line-height: 1.1; letter-spacing: 0.14em; color: var(--brand); }
.slip > .env-marker { position: absolute; top: 10px; right: 12px; z-index: 1; max-width: 14.5rem; margin: 0; padding: 3px 10px;
  border: 2px solid #b45309; border-radius: 6px; font-size: 0.8rem; line-height: 1.35; text-align: right; }
@media (max-width: 640px) {
  .slip > .env-marker { position: static; width: fit-content; max-width: calc(100% - 24px); margin: 8px 12px 0 auto; }
  .slip-header .slip-brand { padding-right: 0; }
}

/* WP11-I8 — DR-01B provenance label (presentation only) */
.slip-provenance { font-weight: 700; }
