:root {
  color-scheme: light;
  --ink: #202124;
  --muted: #68717d;
  --line: #dde3ea;
  --panel: #ffffff;
  --page: #f4f6f8;
  --brand-red: #c43b3b;
  --brand-red-strong: #9f252c;
  --brand-charcoal: #1e2228;
  --brand-slate: #353b44;
  --brand-gold: #d09219;
  --brand-blue: #24445c;
  --ok: #168454;
  --warn: #b55b16;
  --danger: #a82a1f;
  --shadow: 0 18px 50px rgba(31, 36, 43, 0.14);
  --soft-shadow: 0 10px 28px rgba(31, 36, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page);
  overflow-x: hidden;
}

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

button {
  border: 0;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background-color 140ms ease, color 140ms ease, border-color 140ms ease;
  will-change: transform;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button:not(:disabled):active,
.link-button:active {
  transform: translateY(1px) scale(0.985);
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(196, 59, 59, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(30, 34, 40, 0.08), transparent 38%),
    var(--page);
}

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

.company-logo {
  display: block;
  object-fit: contain;
  max-width: 100%;
}

.login-logo {
  width: min(260px, 78vw);
  height: auto;
}

.sidebar-logo {
  width: 170px;
  height: auto;
}

.login-panel {
  width: min(680px, 100%);
  display: grid;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 32px;
  border: 1px solid var(--line);
  border-top: 5px solid var(--brand-red);
  border-radius: 8px;
  padding: 50px;
  background: var(--panel);
  box-shadow: var(--soft-shadow);
  text-align: center;
}

.login-card-wrap {
  display: grid;
  justify-items: center;
  gap: 26px;
}

.login-card {
  width: 100%;
}

.login-card label {
  text-align: left;
}

.login-card h3 {
  margin: 0 0 18px;
  font-size: 1.35rem;
}

.login-brand-block {
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 18px;
}

.login-brand {
  display: grid;
  justify-items: center;
  gap: 12px;
}

.portal-pill {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #f0cfd1;
  border-radius: 999px;
  padding: 0 16px;
  color: var(--brand-red);
  background: #fff6f5;
  font-weight: 900;
}

.portal-pill-large {
  min-height: 54px;
  border-radius: 999px;
  padding: 0 30px;
  font-size: 1.45rem;
  box-shadow: 0 14px 28px rgba(196, 59, 59, 0.14);
}

.login-heading {
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
}

.login-heading h2 {
  margin: 8px 0 0;
  font-size: 2.15rem;
}

.eyebrow {
  color: var(--brand-red);
  font-weight: 900;
  text-transform: uppercase;
  font-size: 0.74rem;
  letter-spacing: 0.08em;
}

h1,
h2,
h3 {
  letter-spacing: 0;
}

h2 {
  margin: 10px 0 18px;
  font-size: 2rem;
}

h3 {
  margin: 0;
  font-size: 1.05rem;
}

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

.form-grid {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #343940;
  font-weight: 800;
  font-size: 0.92rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px 13px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.login-card input {
  min-height: 50px;
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 92px;
}

.password-toggle {
  position: absolute;
  right: 7px;
  top: 7px;
  min-height: 36px;
  border-radius: 5px;
  padding: 0 12px;
  color: var(--brand-red);
  background: #faeeee;
  font-weight: 900;
}

.login-lock-notice.blocked {
  display: grid !important;
  gap: 4px;
  border-left: 5px solid var(--danger);
  text-align: left;
}

.login-lock-notice.blocked strong,
.login-lock-notice.blocked span {
  display: block;
  font-weight: 700;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand-red);
  box-shadow: 0 0 0 3px rgba(169, 22, 58, 0.14);
}

.primary,
.secondary,
.danger,
.icon-button,
.link-button {
  min-height: 42px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  font-weight: 900;
  transition: transform 140ms ease, box-shadow 140ms ease, background-color 140ms ease, color 140ms ease;
}

.primary {
  color: white;
  background: var(--brand-red);
  box-shadow: 0 8px 18px rgba(196, 59, 59, 0.2);
}

.primary:hover {
  background: var(--brand-red-strong);
}

.secondary {
  color: var(--brand-red);
  background: #faeeee;
}

.muted-action {
  color: var(--brand-slate);
  background: #eef1f4;
}

.danger {
  color: #fff;
  background: var(--danger);
}

.icon-button {
  width: 42px;
  padding: 0;
  color: var(--ink);
  background: #eef1f4;
}

.app-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
}

.sidebar {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 18px;
  padding: 22px 18px;
  color: white;
  background: linear-gradient(180deg, #2b2225, var(--brand-charcoal));
}

.brand {
  flex-direction: column;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.brand .company-logo {
  padding: 8px;
  border-radius: 6px;
  background: white;
}

.brand span {
  display: block;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.86rem;
  font-weight: 900;
}

.portal-cover {
  min-height: auto;
  align-items: flex-start;
  justify-content: start;
  text-align: left;
  padding: 18px;
  background:
    linear-gradient(145deg, rgba(196, 59, 59, 0.2), transparent 58%),
    rgba(255, 255, 255, 0.08);
}

.portal-cover span {
  color: rgba(255, 255, 255, 0.58);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.portal-cover strong {
  display: block;
  color: white;
  font-size: 1.18rem;
  line-height: 1.15;
}

.nav {
  display: grid;
  align-content: start;
  gap: 7px;
}

.nav button {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  border-radius: 6px;
  padding: 0 14px;
  text-align: left;
  color: rgba(255, 255, 255, 0.76);
  background: transparent;
  font-weight: 900;
}

.nav button.active,
.nav button:hover {
  color: white;
  background: rgba(255, 255, 255, 0.13);
  box-shadow: inset 3px 0 0 var(--brand-red);
}

.side-note {
  align-self: end;
  display: grid;
  gap: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  padding-top: 18px;
}

.side-note span {
  color: rgba(255, 255, 255, 0.66);
  font-size: 0.86rem;
}

.content {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 22px;
  padding: 30px;
}

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

.topbar h1 {
  margin: 4px 0 0;
  font-size: 1.9rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.topbar-brand {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  background: white;
}

.topbar-brand span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}

.topbar-logo {
  width: 150px;
  height: auto;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: white;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--brand-red);
  font-weight: 900;
}

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

.stat,
.panel,
.table-wrap,
.audit-preview,
.secure-panel,
.security-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 0 rgba(31, 36, 43, 0.04);
}

.panel,
.table-wrap {
  box-shadow: var(--soft-shadow);
}

.stat {
  min-height: 92px;
  display: grid;
  align-content: center;
  justify-items: start;
  padding: 18px;
  border-top: 0;
  border-left: 4px solid var(--brand-slate);
  text-align: left;
}

.stat.accent {
  border-left-color: var(--brand-red);
}

.stat span {
  color: var(--muted);
  font-weight: 800;
}

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 1.8rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 18px;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
}

.users-layout {
  display: grid;
  gap: 18px;
}

.user-create .form-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  align-items: end;
  margin-top: 14px;
}

.panel,
.secure-panel,
.audit-preview {
  padding: 18px;
}

.table-wrap {
  overflow: auto;
}

.section-head {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
}

.section-head.compact {
  min-height: auto;
  align-items: flex-start;
  padding: 0;
  margin-bottom: 16px;
}

.section-head.compact p {
  margin: 6px 0 0;
  max-width: 780px;
}

.user-search-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.user-search-tools input {
  width: min(320px, 42vw);
  min-height: 38px;
}

.is-hidden {
  display: none;
}

.search-toggle {
  min-height: 38px;
}

.search-symbol {
  width: 16px;
  height: 16px;
  position: relative;
  display: inline-block;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.search-symbol::after {
  content: "";
  width: 7px;
  height: 2px;
  position: absolute;
  right: -6px;
  bottom: -3px;
  border-radius: 2px;
  background: currentColor;
  transform: rotate(45deg);
}

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

th,
td {
  padding: 13px 16px;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  background: #eceff2;
  color: #3c4651;
  font-size: 0.8rem;
  font-weight: 900;
}

.badge.admin {
  color: #6e3a00;
  background: #fff0c7;
}

.ok-badge {
  color: #12623e;
  background: #e3f6ee;
}

.status-dot {
  width: 9px;
  height: 9px;
  display: inline-block;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.status-dot.ok {
  background: var(--ok);
}

.status-dot.off {
  background: var(--danger);
}

.actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.edit-user-button {
  color: var(--brand-blue);
  background: #eaf1f6;
}

.notice {
  display: none;
  margin-top: 14px;
  border-radius: 6px;
  padding: 12px 14px;
  background: #ecf8f2;
  color: #135f3c;
  font-weight: 800;
}

.notice.error {
  background: #ffe7e1;
  color: #8c241a;
}

#payslipNotice.notice {
  max-width: 720px;
  margin: 16px auto 0;
  text-align: center;
}

.empty {
  padding: 34px;
  text-align: center;
  color: var(--muted);
}

.employee-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 340px);
  align-items: center;
  gap: 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand-red);
  border-radius: 8px;
  padding: 20px 22px;
  background: white;
  text-align: left;
  box-shadow: 0 1px 0 rgba(31, 36, 43, 0.04);
}

.employee-hero h2,
.employee-hero p {
  margin: 0;
}

.employee-hero h2 {
  margin-top: 7px;
}

.employee-hero p {
  margin-top: 8px;
  color: var(--muted);
}

.employee-search {
  font-size: 0.86rem;
}

.employee-search input {
  min-height: 46px;
  margin-top: 4px;
}

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

.document-groups {
  display: grid;
  gap: 18px;
}

.document-month {
  display: grid;
  gap: 12px;
}

.document-month header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.document-month header span {
  color: var(--muted);
  font-weight: 900;
}

.document-card {
  min-height: 154px;
  display: grid;
  align-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand-red);
  border-radius: 8px;
  padding: 15px;
  background: white;
  box-shadow: 0 1px 0 rgba(31, 36, 43, 0.04);
  text-align: left;
}

.document-card.viewed {
  border-left-color: var(--ok);
}

.document-status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 900;
}

.document-status.pending {
  color: #8a4511;
  background: #fff0df;
}

.document-status.seen {
  color: #12623e;
  background: #e3f6ee;
}

.document-card h3 {
  margin-top: 8px;
  font-size: 1.12rem;
}

.document-card p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.document-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.document-card .link-button {
  width: auto;
  justify-self: start;
}

.upload-layout {
  align-items: start;
}

.upload-shell {
  display: grid;
  gap: 18px;
}

.upload-header {
  border: 1px solid var(--line);
  border-top: 4px solid var(--brand-red);
  border-radius: 8px;
  padding: 22px 24px;
  background: white;
  box-shadow: var(--soft-shadow);
  text-align: center;
}

.upload-header h2,
.upload-header p {
  margin: 0;
}

.upload-header h2 {
  margin-top: 6px;
}

.upload-header p {
  max-width: 720px;
  margin: 8px auto 0;
  color: var(--muted);
  line-height: 1.6;
}

.upload-form {
  max-width: 980px;
  width: 100%;
  justify-self: center;
}

.upload-form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(220px, 0.65fr);
  gap: 16px;
  align-items: end;
}

.upload-form-grid label:nth-child(3),
.upload-form-grid label:nth-child(4),
.upload-form-grid .primary {
  grid-column: 1 / -1;
}

.upload-assurance {
  max-width: 980px;
  width: 100%;
  justify-self: center;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.upload-assurance article {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: white;
  box-shadow: var(--soft-shadow);
}

.upload-assurance strong {
  display: block;
  color: var(--brand-charcoal);
}

.upload-assurance span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.45;
}

.payslip-account-panel {
  max-width: 980px;
  width: 100%;
  justify-self: center;
}

.account-filter-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.55fr);
  gap: 14px;
  align-items: end;
}

.account-payslip-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #f7f9fb;
}

.account-payslip-summary span {
  color: var(--muted);
  font-weight: 800;
}

.table-scroll {
  overflow: auto;
}

.compact-table {
  min-width: 760px;
}

.upload-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 460px);
  align-items: end;
  gap: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: white;
  box-shadow: var(--soft-shadow);
}

.upload-intro h2,
.upload-intro p {
  margin: 0;
}

.upload-intro h2 {
  margin-top: 6px;
}

.upload-intro p,
.upload-rules p {
  color: var(--muted);
  line-height: 1.6;
}

.upload-layout-modern {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(300px, 0.65fr);
  gap: 18px;
  align-items: start;
}

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

.upload-form label:nth-child(3),
.upload-form label:nth-child(4),
.upload-form .primary {
  grid-column: 1 / -1;
}

.upload-side {
  display: grid;
  gap: 14px;
}

.upload-rules {
  border-left: 5px solid var(--brand-red);
}

.secure-panel {
  min-height: 280px;
  color: white;
  background: linear-gradient(135deg, var(--brand-charcoal), var(--brand-blue));
}

.secure-panel p {
  color: rgba(255, 255, 255, 0.76);
  line-height: 1.6;
}

.secure-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.secure-list span {
  border-left: 3px solid var(--brand-gold);
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 800;
}

.audit-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.audit-search-panel {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(160px, 0.22fr) minmax(160px, 0.22fr) auto;
  gap: 12px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: white;
  box-shadow: var(--soft-shadow);
}

.audit-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.audit-toolbar button {
  min-height: 38px;
  border-radius: 999px;
  padding: 0 13px;
  color: var(--brand-slate);
  background: #e8ebef;
  font-weight: 900;
}

.audit-toolbar button.active {
  color: white;
  background: var(--brand-red);
}

.audit-timeline,
.audit-preview {
  display: grid;
  gap: 12px;
}

.audit-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--brand-slate);
  border-radius: 8px;
  padding: 14px;
  background: white;
}

.audit-card.security {
  border-left-color: var(--brand-red);
}

.audit-card.warning {
  border-left-color: var(--warn);
}

.audit-card.critical {
  border-left-color: var(--danger);
  background: #fff8f6;
}

.audit-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: white;
  background: var(--brand-charcoal);
  font-weight: 900;
}

.audit-card.security .audit-icon {
  background: var(--brand-red);
}

.audit-card.warning .audit-icon {
  background: var(--warn);
}

.audit-card.critical .audit-icon {
  background: var(--danger);
}

.audit-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.audit-title-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.audit-title span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.audit-delete-button {
  width: 34px;
  min-height: 34px;
  color: var(--danger);
  background: #fff0ed;
}

.trash-symbol {
  width: 15px;
  height: 17px;
  position: relative;
  display: inline-block;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 0 0 3px 3px;
}

.trash-symbol::before {
  content: "";
  width: 19px;
  height: 2px;
  position: absolute;
  left: -4px;
  top: -5px;
  border-radius: 2px;
  background: currentColor;
}

.trash-symbol::after {
  content: "";
  width: 7px;
  height: 2px;
  position: absolute;
  left: 2px;
  top: -9px;
  border-radius: 2px 2px 0 0;
  background: currentColor;
}

.audit-card p {
  margin: 6px 0 10px;
  color: #3f454d;
}

.audit-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.audit-meta span,
.audit-meta time {
  border-radius: 999px;
  padding: 4px 8px;
  background: #eef1f4;
}

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

.security-card {
  min-height: 118px;
  padding: 18px;
  border-top: 4px solid var(--brand-red);
}

.security-card span {
  color: var(--muted);
  font-weight: 900;
}

.security-card strong {
  display: block;
  margin-top: 10px;
  line-height: 1.35;
}

.security-overview {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: white;
  box-shadow: var(--soft-shadow);
  text-align: center;
}

.security-overview h2,
.security-overview p {
  margin: 0;
}

.security-overview h2 {
  margin-top: 6px;
}

.security-overview p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

.security-counter {
  min-height: 118px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  padding: 16px;
  color: white;
  background: var(--brand-charcoal);
  text-align: center;
}

.security-counter strong {
  font-size: 2.45rem;
  line-height: 1;
}

.security-counter span {
  color: rgba(255, 255, 255, 0.76);
  font-weight: 800;
}

.security-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.security-section,
.security-next {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: white;
  box-shadow: var(--soft-shadow);
}

.security-section header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.security-section h3,
.security-section p {
  margin: 0;
}

.security-section p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.55;
}

.security-list-table {
  display: grid;
}

.security-row {
  display: grid;
  grid-template-columns: minmax(120px, 0.35fr) minmax(0, 0.65fr);
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}

.security-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.security-row span {
  color: var(--muted);
  font-weight: 900;
}

.security-row strong {
  line-height: 1.35;
}

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

.security-summary-card {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: white;
  box-shadow: var(--soft-shadow);
}

.security-summary-card h3,
.security-summary-card p {
  margin: 0;
}

.security-summary-card p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.55;
}

.security-command {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  background: white;
  box-shadow: var(--soft-shadow);
}

.security-command h2,
.security-command p {
  margin: 0;
}

.security-command h2 {
  margin-top: 6px;
}

.security-command p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.6;
}

.security-command strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 112px;
  border-radius: 999px;
  padding: 10px 16px;
  color: #0f6640;
  background: #e8f7ef;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

.security-control {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  border: 1px solid var(--line);
  border-top: 3px solid var(--brand-red);
  border-radius: 8px;
  padding: 18px;
  background: white;
  box-shadow: var(--soft-shadow);
}

.security-control-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: var(--brand-red);
  background: #fff0f0;
  font-weight: 950;
}

.security-control h3,
.security-control p,
.security-procedure h3,
.security-procedure p {
  margin: 0;
}

.security-control p,
.security-procedure p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.55;
}

.security-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(260px, 0.85fr);
  gap: 14px;
}

.security-procedure {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: white;
  box-shadow: var(--soft-shadow);
}

.security-procedure.muted-panel {
  background: #f7f8fa;
}

.security-checklist {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.security-checklist span {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px 11px 36px;
  background: #fbfcfd;
  color: #303741;
  font-weight: 800;
}

.security-checklist span::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 50%;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--brand-red);
  transform: translateY(-50%);
}

.legal-note p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.65;
}

.legal-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  justify-content: center;
}

.legal-footer button {
  padding: 0;
  color: var(--brand-red);
  background: transparent;
  font-weight: 900;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 18, 24, 0.58);
}

.legal-modal,
.confirm-modal,
.password-modal {
  width: min(720px, 100%);
  max-height: min(82vh, 760px);
  overflow: auto;
  border-radius: 8px;
  padding: 24px;
  background: white;
  box-shadow: var(--shadow);
}

.confirm-modal {
  width: min(480px, 100%);
}

.password-modal {
  width: min(560px, 100%);
}

.user-edit-modal {
  width: min(680px, 100%);
}

.legal-modal header,
.password-modal header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.legal-modal p {
  color: #3f454d;
  line-height: 1.7;
}

.confirm-modal p {
  color: #3f454d;
  line-height: 1.6;
}

.password-modal h2 {
  margin-bottom: 0;
}

.password-modal form {
  margin-top: 18px;
}

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

.edit-details label:nth-child(6),
.edit-details .modal-actions,
.edit-details .notice {
  grid-column: 1 / -1;
}

.check-row {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #f8fafc;
  font-weight: 900;
}

.check-row input {
  width: auto;
  min-height: auto;
  margin: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1040px) {
  .app-layout,
  .dashboard-grid,
  .grid-2,
  .upload-intro,
  .upload-layout-modern,
  .upload-form-grid,
  .upload-assurance,
  .account-filter-grid,
  .audit-search-panel,
  .security-overview,
  .security-command,
  .security-sections,
  .security-summary-grid,
  .security-control-grid,
  .security-workspace,
  .user-create .form-grid,
  .stats,
  .security-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    grid-template-rows: auto auto;
  }

  .brand {
    align-items: center;
  }

  .portal-cover {
    align-items: flex-start;
    justify-content: start;
    text-align: left;
  }

  .side-note {
    display: none;
  }

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

  .nav button {
    justify-content: center;
    text-align: center;
  }
}

@media (max-width: 640px) {
  html {
    -webkit-text-size-adjust: 100%;
  }

  body {
    background: #f6f7f9;
  }

  input,
  select,
  textarea {
    min-height: 46px;
    border-radius: 8px;
    font-size: 16px;
  }

  .primary,
  .secondary,
  .danger,
  .link-button {
    min-height: 46px;
  }

  .login-screen {
    min-height: 100dvh;
    align-items: start;
    justify-items: center;
    padding: 12px;
  }

  .login-panel {
    width: 100%;
    min-height: calc(100dvh - 24px);
    gap: 22px;
    border-radius: 10px;
    padding: 24px 18px 18px;
  }

  .login-logo {
    width: min(220px, 74vw);
  }

  .portal-pill-large {
    min-height: 44px;
    padding: 0 20px;
    font-size: 1.05rem;
  }

  .login-heading {
    gap: 8px;
  }

  .login-heading h2 {
    font-size: 1.75rem;
    line-height: 1.15;
  }

  .login-card h3 {
    font-size: 1.12rem;
  }

  .login-lock-notice.blocked {
    gap: 6px;
    padding: 13px;
  }

  .app-layout {
    display: block;
    min-height: 100dvh;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 15;
    min-height: auto;
    display: grid;
    grid-template-rows: auto auto;
    gap: 10px;
    padding: 10px 10px 12px;
    box-shadow: 0 12px 26px rgba(18, 22, 28, 0.2);
  }

  .brand.portal-cover {
    min-height: 48px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    border-radius: 8px;
    padding: 10px 12px;
  }

  .portal-cover span {
    font-size: 0.68rem;
  }

  .portal-cover strong {
    font-size: 1rem;
    line-height: 1.1;
    text-align: right;
  }

  .nav {
    display: flex;
    grid-template-columns: none;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  .nav button {
    min-width: 112px;
    min-height: 42px;
    flex: 0 0 auto;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0 13px;
    text-align: center;
    white-space: nowrap;
    scroll-snap-align: start;
  }

  .nav button.active,
  .nav button:hover {
    box-shadow: inset 0 -3px 0 var(--brand-red);
  }

  .content {
    gap: 16px;
    padding: 14px 14px calc(18px + env(safe-area-inset-bottom));
  }

  .topbar {
    display: grid;
    align-items: stretch;
    gap: 12px;
  }

  .topbar h1 {
    margin-top: 5px;
    font-size: 1.5rem;
    line-height: 1.15;
  }

  .topbar-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-brand {
    display: none;
  }

  .user-chip {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    border-radius: 8px;
    padding: 10px;
  }

  .user-chip .secondary {
    min-width: 74px;
    padding: 0 12px;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .stat {
    min-height: 84px;
    padding: 14px;
    border-left-width: 3px;
  }

  .stat span {
    font-size: 0.78rem;
  }

  .stat strong {
    font-size: 1.45rem;
  }

  h2 {
    font-size: 1.45rem;
  }

  .panel,
  .secure-panel,
  .audit-preview,
  .security-card,
  .security-section,
  .security-next {
    border-radius: 8px;
    padding: 14px;
  }

  .section-head {
    min-height: auto;
    align-items: stretch;
    flex-direction: column;
    padding: 14px;
    gap: 10px;
  }

  .section-head.compact {
    padding: 0;
    margin-bottom: 12px;
  }

  .user-search-tools {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .user-search-tools input {
    width: 100%;
  }

  .search-toggle {
    width: 100%;
  }

  .dashboard-grid,
  .grid-2,
  .upload-intro,
  .upload-layout-modern,
  .audit-search-panel,
  .document-grid,
  .employee-hero,
  .upload-form .form-grid,
  .upload-form-grid,
  .upload-assurance,
  .account-filter-grid,
  .edit-details,
  .security-row,
  .security-summary-grid,
  .security-command,
  .security-control-grid,
  .security-workspace,
  .security-grid {
    grid-template-columns: 1fr;
  }

  .security-command {
    align-items: stretch;
    padding: 18px;
  }

  .security-command strong {
    min-width: 0;
  }

  .table-wrap,
  .table-scroll {
    overflow: visible;
  }

  table,
  .compact-table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0 10px;
  }

  thead {
    display: none;
  }

  tbody,
  tr,
  td {
    display: block;
  }

  tr {
    display: grid;
    gap: 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    background: white;
    box-shadow: 0 1px 0 rgba(31, 36, 43, 0.04);
  }

  td {
    min-height: 28px;
    display: grid;
    grid-template-columns: minmax(92px, 0.36fr) minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    border: 0;
    padding: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }

  td[colspan] {
    display: block;
  }

  td[colspan]::before,
  td.actions::before {
    display: none;
  }

  td.actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    align-items: stretch;
  }

  td.actions button {
    width: 100%;
  }

  .employee-hero {
    align-items: start;
    gap: 14px;
    border-left-width: 0;
    border-top: 4px solid var(--brand-red);
    padding: 16px;
    text-align: left;
  }

  .employee-hero h2 {
    font-size: 1.35rem;
  }

  .employee-hero p {
    line-height: 1.45;
  }

  .employee-search {
    text-align: left;
  }

  .document-month {
    gap: 10px;
  }

  .document-month header {
    align-items: flex-start;
    flex-direction: row;
    padding-bottom: 8px;
  }

  .document-card {
    min-height: auto;
    gap: 14px;
    border-radius: 8px;
    padding: 14px;
  }

  .document-card .link-button {
    width: 100%;
    justify-self: stretch;
  }

  .upload-header,
  .upload-intro,
  .security-overview {
    padding: 16px;
    text-align: left;
  }

  .upload-header p,
  .upload-intro p,
  .security-overview p {
    line-height: 1.5;
  }

  .upload-form,
  .payslip-account-panel,
  .upload-assurance {
    max-width: none;
  }

  .upload-assurance article {
    min-height: auto;
    padding: 14px;
  }

  .account-payslip-summary {
    align-items: stretch;
    flex-direction: column;
    padding: 12px;
  }

  .audit-search-panel {
    gap: 10px;
    padding: 12px;
  }

  .audit-actions,
  .audit-title {
    align-items: stretch;
    flex-direction: column;
  }

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

  .audit-toolbar button {
    width: 100%;
    padding: 0 10px;
  }

  .audit-card {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
  }

  .audit-icon {
    width: 32px;
    height: 32px;
  }

  .audit-title-actions {
    width: 100%;
    justify-content: space-between;
  }

  .audit-meta {
    gap: 6px;
  }

  .security-summary-card {
    grid-template-columns: 16px minmax(0, 1fr);
    gap: 10px;
    padding: 14px;
  }

  .security-row {
    gap: 6px;
    padding: 12px 0;
  }

  .legal-footer {
    justify-content: center;
    gap: 8px 12px;
    font-size: 0.8rem;
    line-height: 1.45;
    text-align: center;
  }

  .empty {
    padding: 22px 14px;
  }

  .modal-backdrop {
    place-items: end center;
    padding: 0;
  }

  .legal-modal,
  .confirm-modal,
  .password-modal,
  .user-edit-modal {
    width: 100%;
    max-height: 92dvh;
    border-radius: 14px 14px 0 0;
    padding: 18px;
  }

  .legal-modal header,
  .password-modal header {
    align-items: flex-start;
  }

  .modal-actions {
    flex-direction: column-reverse;
    gap: 8px;
    margin-top: 16px;
  }

  .modal-actions button {
    width: 100%;
  }
}

@media (max-width: 380px) {
  .stats,
  .audit-toolbar {
    grid-template-columns: 1fr;
  }

  .user-chip {
    grid-template-columns: 40px minmax(0, 1fr);
  }

  .user-chip .secondary {
    grid-column: 1 / -1;
    width: 100%;
  }
}
