:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #1d2433;
  --muted: #667085;
  --line: #d9e0ea;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --accent: #0f766e;
  --danger: #b42318;
  --warning: #b54708;
  --ok: #047857;
  --shadow: 0 18px 50px rgba(29, 36, 51, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
a {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  min-height: 42px;
  padding: 0 16px;
}

button:hover {
  background: var(--primary-strong);
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  padding: 8px 10px;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 0.9rem;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.muted,
.hint {
  color: var(--muted);
}

.hint {
  font-size: 0.85rem;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
}

.login-panel {
  display: grid;
  gap: 26px;
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 30px;
}

.login-panel h1 {
  margin-top: 4px;
  font-size: 2.6rem;
}

.login-form {
  display: grid;
  gap: 15px;
}

.form-error {
  color: var(--danger);
  min-height: 20px;
  font-weight: 700;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  border-right: 1px solid var(--line);
  background: #ffffff;
  padding: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: #e0f2fe;
  color: #075985;
  font-weight: 900;
}

.brand div {
  display: grid;
  gap: 2px;
}

.brand span:last-child {
  color: var(--muted);
  font-size: 0.8rem;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-link,
.logout,
.secondary-button,
.icon-button {
  background: transparent;
  color: var(--ink);
}

.nav-link {
  justify-content: flex-start;
  text-align: left;
}

.nav-link:hover,
.nav-link.active {
  background: #eef4ff;
  color: var(--primary-strong);
}

.logout {
  margin-top: auto;
  border: 1px solid var(--line);
}

.logout:hover,
.secondary-button:hover,
.icon-button:hover {
  background: #eef2f7;
}

.workspace {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  padding: 20px 28px;
}

.topbar h2 {
  margin-top: 2px;
  font-size: 1.8rem;
}

.user-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  color: #475467;
  padding: 8px 12px;
  white-space: nowrap;
}

.view {
  display: none;
  padding: 24px 28px;
}

.active-view {
  display: grid;
  gap: 18px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.metric span {
  color: var(--muted);
  font-weight: 700;
}

.metric strong {
  font-size: 2rem;
}

.panel {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel-header h3 {
  font-size: 1.15rem;
}

.list {
  display: grid;
  gap: 10px;
}

.list-item,
.employee-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 14px;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.list-item strong,
.employee-card strong {
  display: block;
}

.secondary-button {
  border: 1px solid var(--line);
  color: #344054;
}

.secondary-link {
  display: inline-grid;
  min-height: 42px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #344054;
  font-weight: 700;
  padding: 0 14px;
  text-decoration: none;
  white-space: nowrap;
}

.secondary-link:hover {
  background: #eef2f7;
}

.module-frame {
  width: 100%;
  height: min(760px, calc(100vh - 190px));
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: #475467;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 5px 9px;
}

.status.pending {
  background: #fff7ed;
  color: var(--warning);
}

.status.sent,
.status.ok {
  background: #ecfdf3;
  color: var(--ok);
}

.status.draft {
  background: #eff6ff;
  color: var(--primary-strong);
}

.payment-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  align-items: end;
}

.payment-form .wide {
  grid-column: span 3;
}

.compact-tool {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.compact-tool > summary {
  align-items: center;
  background: #f8fafc;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  list-style: none;
  min-height: 58px;
  padding: 10px 14px;
}

.compact-tool > summary::-webkit-details-marker {
  display: none;
}

.compact-tool > summary:hover {
  background: #f1f5f9;
}

.compact-tool > summary > span:first-child {
  display: grid;
  gap: 2px;
}

.compact-tool summary small {
  color: var(--muted);
  font-size: 0.82rem;
}

.compact-tool-action {
  color: var(--primary-strong);
  font-size: 0.82rem;
  font-weight: 800;
}

.compact-tool .tool-open,
.compact-tool[open] .tool-closed {
  display: none;
}

.compact-tool[open] .tool-open {
  display: inline;
}

.compact-tool-body {
  border-top: 1px solid var(--line);
  padding: 14px;
}

.panel-actions {
  display: flex;
  justify-content: flex-end;
}

.payroll-import-panel {
  border-left: 4px solid var(--accent);
}

.payments-workspace {
  gap: 10px;
}

.payments-workspace > .compact-tool,
.payments-workspace > .batch-item {
  margin: 0;
  width: 100%;
}

.batch-config {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.batch-list {
  display: grid;
  gap: 10px;
}

.print-range {
  display: grid;
  grid-template-columns: 1fr minmax(130px, 0.35fr) minmax(130px, 0.35fr);
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.print-range > div {
  display: grid;
  gap: 3px;
}

.print-range > div span {
  color: var(--muted);
  font-size: 0.82rem;
}

.batch-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  overflow: hidden;
}

.batch-item-summary {
  display: grid;
  grid-template-columns: minmax(220px, 1.7fr) repeat(3, minmax(110px, 0.7fr)) minmax(92px, auto);
  gap: 14px;
  align-items: center;
  padding: 14px;
  cursor: pointer;
  list-style: none;
}

.utility-item-summary {
  align-items: center;
  background: #f8fafc;
  cursor: pointer;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(220px, 1fr) auto;
  list-style: none;
  min-height: 58px;
  padding: 14px;
}

.utility-item-summary::-webkit-details-marker {
  display: none;
}

.utility-item-summary:hover {
  background: #f4f7fb;
}

.manual-payment-panel,
.utility-panel {
  padding: 0;
}

.manual-payment-panel > .batch-item,
.utility-panel > .batch-item {
  border: 0;
}

.manual-payment-detail {
  display: grid;
  gap: 16px;
}

.utility-item .panel-actions {
  margin-bottom: 12px;
}

.batch-item-summary::-webkit-details-marker {
  display: none;
}

.batch-item-summary:hover {
  background: #f4f7fb;
}

.batch-disclosure {
  color: var(--primary);
  font-size: 0.84rem;
  font-weight: 800;
  text-align: right;
}

.detail-open,
.batch-item[open] .detail-closed {
  display: none;
}

.batch-item[open] .detail-open {
  display: inline;
}

.batch-detail {
  border-top: 1px solid var(--line);
  background: white;
  padding: 14px;
}

.batch-detail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.batch-detail-heading > div:first-child {
  display: grid;
  gap: 3px;
}

.batch-detail-heading span,
.empty-table {
  color: var(--muted);
}

.batch-detail-table table {
  min-width: 760px;
}

.batch-item-meta {
  display: grid;
  gap: 3px;
}

.batch-item-meta span,
.batch-stat span {
  color: var(--muted);
  font-size: 0.78rem;
}

.batch-stat {
  display: grid;
  gap: 3px;
}

.batch-actions {
  display: flex;
  gap: 8px;
}

.file-drop {
  position: relative;
  min-height: 112px;
  place-content: center;
  border: 1px dashed #98a2b3;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--ink);
  cursor: pointer;
  padding: 20px;
  text-align: center;
}

.file-drop:hover {
  border-color: var(--primary);
  background: #f4f7ff;
}

.file-drop span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 500;
}

.file-drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.import-message {
  min-height: 20px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.import-actions {
  display: flex;
  justify-content: flex-end;
}

.import-message.ok {
  color: var(--ok);
}

.import-message.error {
  color: var(--danger);
}

.import-message.working {
  color: var(--primary-strong);
}

.batch-summary {
  display: grid;
  grid-template-columns: 1.5fr repeat(4, minmax(120px, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.batch-summary > div {
  display: grid;
  gap: 4px;
  padding: 14px 12px;
}

.batch-summary span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.batch-summary strong {
  overflow-wrap: anywhere;
}

.payroll-table {
  min-width: 880px;
}

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

.employee-card {
  display: grid;
  gap: 10px;
}

.employee-card span {
  color: var(--muted);
}

.letters-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.8fr) minmax(520px, 1.2fr);
  gap: 18px;
  align-items: start;
}

.letter-form {
  position: sticky;
  top: 18px;
}

.letter-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.letter-fields .wide {
  grid-column: 1 / -1;
}

.letter-fields [hidden] {
  display: none;
}

.letter-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.letter-preview-panel {
  overflow: auto;
}

.letter-sheet {
  width: min(100%, 700px);
  aspect-ratio: 8.5 / 11;
  margin: 0 auto;
  padding: 42px 48px 36px;
  border: 1px solid #cfd6df;
  background: white;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
  color: #111827;
  font-family: Arial, sans-serif;
  font-size: 0.92rem;
  line-height: 1.45;
}

.letter-logo {
  display: block;
  width: 185px;
  max-height: 125px;
  object-fit: contain;
  margin: 0 auto 34px;
}

.letter-sheet h4 {
  margin: 0 0 38px;
  text-align: center;
  font-size: 1rem;
}

.letter-copy {
  display: grid;
  gap: 14px;
  text-align: justify;
}

.letter-copy p {
  margin: 0;
}

.letter-signature {
  margin-top: 62px;
  line-height: 1.35;
}

@media (max-width: 1120px) {
  .letters-layout {
    grid-template-columns: 1fr;
  }

  .letter-form {
    position: static;
  }
}

.save-note {
  min-height: 18px;
  font-size: 0.84rem;
  font-weight: 700;
}

.save-note.ok {
  color: var(--ok);
}

.save-note.error {
  color: var(--danger);
}

.receipt-dialog {
  width: min(880px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.receipt-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.receipt-dialog form {
  display: grid;
  gap: 16px;
}

.icon-button {
  width: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 1.5rem;
}

.receipt-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  overflow: hidden;
}

.receipt-heading {
  display: grid;
  gap: 5px;
  border-bottom: 2px solid var(--ink);
  padding: 18px;
  text-align: center;
}

.receipt-heading strong {
  font-size: 1.2rem;
}

.receipt-heading span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.receipt-meta {
  display: grid;
  grid-template-columns: 1.4fr 0.65fr 0.65fr 1.4fr;
  border-bottom: 1px solid var(--line);
}

.receipt-meta > div {
  display: grid;
  gap: 3px;
  border-right: 1px solid var(--line);
  padding: 12px 14px;
}

.receipt-meta > div:last-child {
  border-right: 0;
}

.receipt-meta span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.receipt-meta strong {
  overflow-wrap: anywhere;
}

.receipt-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.receipt-columns section:first-child {
  border-right: 1px solid var(--line);
}

.receipt-columns h4 {
  margin: 0;
  border-bottom: 1px solid var(--line);
  background: #f2f4f7;
  color: #344054;
  font-size: 0.8rem;
  padding: 9px 12px;
  text-align: center;
  text-transform: uppercase;
}

.receipt-line,
.receipt-total,
.receipt-net {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 12px;
}

.receipt-line {
  min-height: 39px;
  border-bottom: 1px solid #eaecf0;
  font-size: 0.84rem;
}

.receipt-line strong,
.receipt-total strong,
.receipt-net strong {
  white-space: nowrap;
}

.receipt-total {
  background: #f8fafc;
  font-size: 0.88rem;
}

.receipt-net {
  border-top: 2px solid var(--ink);
  background: #ecfdf3;
  color: #065f46;
  font-size: 1.02rem;
  padding: 14px 16px;
}

.dialog-note {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .logout {
    margin-top: 0;
  }

  .metrics-grid,
  .payment-form,
  .batch-config,
  .print-range {
    grid-template-columns: 1fr;
  }

  .batch-item {
    display: block;
  }

  .batch-item-summary {
    grid-template-columns: 1fr 1fr;
  }

  .utility-item-summary {
    grid-template-columns: 1fr auto;
  }

  .batch-item-meta,
  .batch-actions,
  .batch-disclosure {
    grid-column: 1 / -1;
  }

  .batch-disclosure {
    text-align: left;
  }

  .batch-detail-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .batch-summary,
  .receipt-meta,
  .receipt-columns {
    grid-template-columns: 1fr;
  }

  .batch-summary > div,
  .receipt-meta > div,
  .receipt-columns section:first-child {
    border-right: 0;
  }

  .dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .payment-form .wide {
    grid-column: auto;
  }

  .letter-fields {
    grid-template-columns: 1fr;
  }

  .letter-fields .wide {
    grid-column: auto;
  }

  .letter-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .letter-sheet {
    min-width: 520px;
  }

  .compact-tool > summary {
    align-items: flex-start;
    gap: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .receipt-dialog .panel-header {
    align-items: center;
    flex-direction: row;
  }
}
