:root {
  color-scheme: light;
  --ink: #14212a;
  --muted: #66727d;
  --line: #d8dee3;
  --soft: #f4f6f7;
  --paper: #ffffff;
  --canvas: #eef1f3;
  --brand: #0b6270;
  --brand-dark: #074953;
  --brand-soft: #e1eff0;
  --positive: #177158;
  --negative: #ae382b;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background: var(--canvas);
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .62; }

:focus-visible {
  outline: 3px solid rgba(11, 98, 112, .32);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

.skip-link {
  position: fixed;
  left: 16px;
  top: -60px;
  z-index: 20;
  padding: 10px 14px;
  color: #fff;
  background: var(--brand-dark);
  border-radius: 5px;
}
.skip-link:focus { top: 12px; }

.portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 66px;
  padding: 9px max(22px, calc((100vw - 1240px) / 2));
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 750;
  text-decoration: none;
}
.brand img { width: 44px; height: 44px; border-radius: 5px; object-fit: cover; }

.header-actions, .language-control { display: flex; align-items: center; gap: 6px; }
.language-control {
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
}
.language-control button,
.text-button {
  min-height: 32px;
  padding: 5px 9px;
  border: 0;
  border-radius: 4px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 700;
}
.language-control button.is-selected { color: var(--ink); background: var(--paper); box-shadow: 0 1px 2px rgba(20, 33, 42, .12); }
.text-button:hover { color: var(--brand-dark); background: var(--brand-soft); }

main { width: min(1240px, calc(100% - 36px)); margin: 0 auto; }
.eyebrow { margin: 0 0 6px; color: var(--brand); font-size: 12px; font-weight: 800; text-transform: uppercase; }

.auth-view {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(360px, 430px);
  align-items: center;
  gap: clamp(38px, 8vw, 120px);
  min-height: calc(100vh - 142px);
  padding: 54px max(18px, 6vw);
}
.auth-intro { max-width: 520px; }
.auth-intro h1 { margin: 0 0 14px; font-size: clamp(34px, 5vw, 58px); line-height: 1.02; }
.auth-intro > p:last-child { margin: 0; color: var(--muted); font-size: 18px; line-height: 1.55; }
.auth-panel {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  box-shadow: 0 14px 34px rgba(20, 33, 42, .08);
}
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.auth-tabs button {
  min-height: 42px;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  background: transparent;
  font-weight: 750;
}
.auth-tabs button.is-selected { color: var(--brand-dark); border-bottom-color: var(--brand); }
.field { margin-bottom: 15px; }
.field label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 750; }
.field input {
  width: 100%;
  min-height: 43px;
  padding: 9px 11px;
  border: 1px solid #bfc8ce;
  border-radius: 5px;
  color: var(--ink);
  background: var(--paper);
}
.field input:focus { border-color: var(--brand); }
.field small { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.password-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 43px;
}
.password-input input { border-radius: 5px 0 0 5px; }
.password-toggle {
  display: grid;
  width: 43px;
  min-height: 43px;
  place-items: center;
  padding: 0;
  border: 1px solid #bfc8ce;
  border-left: 0;
  border-radius: 0 5px 5px 0;
  background: var(--soft);
}
.password-toggle:hover { background: var(--brand-soft); }
.password-toggle img { width: 18px; height: 18px; }
.field-error {
  display: block;
  min-height: 16px;
  margin-top: 4px;
  color: var(--negative);
  font-size: 12px;
  line-height: 1.3;
}
.field input[aria-invalid="true"] { border-color: var(--negative); }
.primary-button, .secondary-button {
  min-height: 38px;
  border-radius: 5px;
  font-weight: 750;
}
.primary-button { width: 100%; padding: 8px 14px; border: 1px solid var(--brand); color: #fff; background: var(--brand); }
.primary-button:hover { background: var(--brand-dark); }
.secondary-button { padding: 7px 11px; border: 1px solid #aeb9c0; color: var(--ink); background: var(--paper); }
.secondary-button:hover { border-color: var(--brand); color: var(--brand-dark); background: var(--brand-soft); }
.form-note { margin: 14px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; text-align: center; }

.payroll-view { padding: 28px 0 42px; }
.payroll-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.payroll-toolbar h1 { margin: 0; font-size: 26px; }
.period-selector {
  display: grid;
  grid-template-columns: repeat(2, minmax(176px, 230px));
  gap: 8px;
}
.period-button {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--paper);
  text-align: left;
}
.period-button.is-selected { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand); }
.period-button__date { font-size: 14px; font-weight: 800; white-space: nowrap; }
.period-button__amount { color: var(--muted); font-size: 13px; font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }

#payroll-content {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  box-shadow: 0 12px 30px rgba(20, 33, 42, .06);
}
.period-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 22px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line);
}
.period-title { margin: 0; font-size: 30px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.period-total { display: grid; justify-items: end; gap: 2px; }
.period-total__label { color: var(--muted); font-size: 12px; font-weight: 700; }
.period-total__value { font-size: 30px; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 282px;
  align-items: start;
  gap: 20px;
  padding: 20px 24px 24px;
}
.platform-list { min-width: 0; }
.platform-section + .platform-section { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.platform-band { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 10px; }
.platform-title { margin: 0; font-size: 20px; }
.payment-status { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.earning-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; }
.earning-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.earning-table th, .earning-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.earning-table th { color: var(--muted); background: var(--soft); font-size: 12px; font-weight: 800; }
.earning-table th:nth-child(1) { width: 16%; }
.earning-table th:nth-child(2) { width: 34%; }
.earning-table th:nth-child(n+3) { width: 16.66%; text-align: right; }
.earning-table td { font-size: 14px; }
.earning-table td:nth-child(n+3) { text-align: right; font-variant-numeric: tabular-nums; }
.earning-table tbody tr:last-child td { border-bottom: 0; }
.strong { font-weight: 800; }
.section-title { margin: 15px 0 8px; font-size: 15px; }
.deduction-list { min-width: 0; }
.deduction-row {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) auto minmax(0, auto);
  align-items: center;
  gap: 14px;
  min-height: 48px;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
}
.deduction-row__details { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.deduction-row__type { flex: 0 0 auto; }
.deduction-row__tracking { overflow: hidden; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.deduction-row__amount { color: var(--negative); }
.deduction-row__actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 6px; }
.evidence-thumbnail {
  position: relative;
  width: 112px;
  height: 72px;
  overflow: hidden;
  padding: 0;
  border: 1px solid #aeb9c0;
  border-radius: 5px;
  color: var(--muted);
  background: var(--soft);
}
.evidence-thumbnail:not(:disabled):hover { border-color: var(--brand); }
.evidence-thumbnail__image {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--soft);
}
.evidence-thumbnail__loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 6px;
  font-size: 11px;
  line-height: 1.25;
}
.evidence-unavailable { color: var(--muted); font-size: 12px; }
.muted-line { margin: 0; padding: 10px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }

.pay-summary {
  position: sticky;
  top: 18px;
  padding: 16px;
  border-left: 3px solid var(--brand);
  background: var(--soft);
}
.summary-title { margin: 0 0 10px; font-size: 16px; }
.summary-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: 14px; }
.summary-row.positive strong { color: var(--positive); }
.summary-row.negative strong { color: var(--negative); }
.summary-row.total { margin-top: 7px; padding-top: 13px; border-top: 1px solid #bfc8ce; font-size: 17px; }

.empty-state { margin: 0; padding: 48px 24px; color: var(--muted); text-align: center; }
.portal-status { min-height: 20px; margin: 0 auto 12px; padding: 0 18px; color: var(--brand-dark); font-size: 13px; text-align: center; }
.portal-status.is-error { color: var(--negative); }
footer { min-height: 40px; padding: 8px 18px 18px; text-align: center; }
footer a { color: var(--muted); font-size: 12px; }

@media (max-width: 900px) {
  .auth-view { grid-template-columns: 1fr; gap: 28px; min-height: auto; padding: 42px 0; }
  .auth-intro { max-width: 650px; }
  .workspace-grid { grid-template-columns: 1fr; }
  .pay-summary { position: static; grid-row: 1; border-left: 0; border-top: 3px solid var(--brand); }
  .platform-list { grid-row: 2; }
}

@media (max-width: 680px) {
  .portal-header { align-items: flex-start; min-height: 60px; padding: 8px 14px; }
  .brand span { display: none; }
  .brand img { width: 40px; height: 40px; }
  .header-actions { align-items: flex-end; flex-direction: column; }
  .language-control button { min-height: 28px; padding: 3px 7px; }
  main { width: min(100% - 20px, 1240px); }
  .auth-view { padding: 26px 0 34px; }
  .auth-intro h1 { font-size: 34px; }
  .auth-intro > p:last-child { font-size: 16px; }
  .auth-panel { padding: 16px; }
  .payroll-view { padding-top: 18px; }
  .payroll-toolbar { align-items: stretch; flex-direction: column; gap: 12px; }
  .period-selector { grid-template-columns: 1fr 1fr; gap: 6px; }
  .period-button { grid-template-columns: 1fr; gap: 2px; min-width: 0; min-height: 58px; }
  .period-button__date { font-size: 13px; }
  .period-heading { align-items: flex-start; padding: 17px 15px 14px; }
  .period-title, .period-total__value { font-size: 22px; }
  .workspace-grid { gap: 16px; padding: 14px; }
  .platform-band { align-items: flex-start; }
  .secondary-button { max-width: 148px; font-size: 12px; }
  .earning-table-wrap { overflow: visible; border: 0; }
  .earning-table, .earning-table tbody { display: block; }
  .earning-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .earning-table tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 18px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; }
  .earning-table tr + tr { margin-top: 7px; }
  .earning-table td { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; min-width: 0; padding: 5px 0; border: 0; text-align: right; overflow-wrap: anywhere; }
  .earning-table td::before { content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 700; text-align: left; }
  .earning-table td:nth-child(1), .earning-table td:nth-child(2) { grid-column: span 1; text-align: right; }
  .earning-table td:nth-child(n+3) { grid-column: span 2; }
  .deduction-row { grid-template-columns: 1fr auto; gap: 7px 10px; padding: 10px 0; }
  .deduction-row__details { align-items: flex-start; flex-direction: column; gap: 3px; }
  .deduction-row__tracking { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
  .deduction-row__actions { grid-column: 1 / -1; justify-content: flex-start; }
}

@media (max-width: 420px) {
  .earning-table tr { grid-template-columns: minmax(0, 1fr); column-gap: 16px; }
  .earning-table td:nth-child(1),
  .earning-table td:nth-child(2),
  .earning-table td:nth-child(n+3) { grid-column: 1; }
  .evidence-thumbnail { width: 96px; height: 64px; }
}
