:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --ink: #172033;
  --muted: #677489;
  --line: #d9e2ef;
  --brand: #0b2d5c;
  --brand-2: #c69a2f;
  --brand-3: #123f78;
  --ok: #1f8f56;
  --warn: #ba6b12;
  --bad: #b83f3f;
  --shadow: 0 18px 45px rgba(15, 34, 61, 0.1);
  --shadow-soft: 0 10px 28px rgba(15, 34, 61, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body.locked .app {
  display: none;
}

.login-screen {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 32px;
  background:
    radial-gradient(circle at 14% 18%, rgba(198, 154, 47, 0.16), transparent 28%),
    linear-gradient(135deg, #061a36 0%, #0b2d5c 48%, #f4f7fb 48%, #ffffff 100%);
}

.login-screen.hidden {
  display: none;
}

.login-shell {
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(320px, 0.75fr);
  width: min(100%, 1040px);
  min-height: 620px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 24px;
  box-shadow: 0 26px 80px rgba(4, 18, 40, 0.28);
  overflow: hidden;
}

.login-brand-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 48px;
  background:
    linear-gradient(145deg, rgba(11, 45, 92, 0.96), rgba(6, 26, 54, 0.98)),
    var(--brand);
  color: #ffffff;
}

.login-logo {
  width: min(320px, 82%);
  height: auto;
  align-self: center;
  margin-bottom: 16px;
  object-fit: contain;
  filter: drop-shadow(0 18px 34px rgba(0, 0, 0, 0.28));
}

.login-brand-panel h1 {
  max-width: 430px;
  margin: 0;
  font-size: clamp(34px, 4vw, 54px);
  line-height: 1.03;
  letter-spacing: 0;
  text-align: center;
}

.login-brand-panel h1 sup {
  font-size: 0.36em;
  line-height: 0;
  vertical-align: super;
}

.product-title span {
  display: block;
  margin-top: 8px;
  font-size: 0.42em;
  font-weight: 800;
  line-height: 1.2;
}

.login-kicker {
  margin: 0 0 12px;
  color: var(--brand-2);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.login-welcome {
  max-width: 420px;
  margin: 20px 0 0;
  color: #d8e3f2;
  font-size: 16px;
  line-height: 1.7;
}

.login-brand-panel footer {
  color: #b9c7dc;
  font-size: 13px;
  text-align: center;
}

.login-card {
  display: grid;
  align-content: center;
  gap: 18px;
  width: 100%;
  background: var(--surface);
  padding: 54px;
}

.login-form-head {
  margin-bottom: 10px;
}

.login-form-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 32px;
}

.login-form-head span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.login-help,
.login-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.login-help {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.login-note {
  margin: -8px 0 0;
  text-align: center;
}

.login-secondary-action {
  width: 100%;
}

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

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
  background: var(--bg);
}

.sidebar {
  background: linear-gradient(180deg, #071a33 0%, #0b2d5c 100%);
  color: #f8fbfb;
  padding: 28px 20px;
  box-shadow: 10px 0 32px rgba(7, 26, 51, 0.13);
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 34px;
}

.brand-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  flex: 0 0 auto;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  padding: 4px;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
}

.brand p,
.eyebrow,
.panel p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.sidebar .brand p {
  color: #b6c4c8;
}

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

.nav-item {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #dbe6f5;
  text-align: left;
  padding: 0 14px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.nav-item::before {
  content: attr(data-icon);
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-right: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--brand-2);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  transform: translateX(2px);
}

.content {
  padding: 28px 30px;
  overflow-x: hidden;
}

.topbar,
.panel-head,
.attendance-toolbar,
.top-actions,
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar {
  margin-bottom: 24px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
}

.live-clock {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

h2,
h3 {
  margin: 0;
}

h2 {
  font-size: 28px;
}

h3 {
  font-size: 17px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.metric,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 22px;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.metric:hover,
.panel:hover {
  border-color: rgba(198, 154, 47, 0.34);
}

.metric:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 46px rgba(15, 34, 61, 0.13);
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin-top: 8px;
  color: var(--brand);
  font-size: 30px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 18px;
}

.portal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.portal-controls {
  display: grid;
  grid-template-columns: 220px 170px;
  gap: 12px;
}

.portal-metrics {
  margin-bottom: 18px;
}

.portal-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.portal-menu {
  display: grid;
  gap: 8px;
  position: sticky;
  top: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 12px;
}

.portal-menu-item {
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0 12px;
  text-align: left;
  transition: background 0.18s ease, color 0.18s ease;
}

.portal-menu-item:hover,
.portal-menu-item.active {
  background: var(--surface-2);
  color: var(--ink);
}

.portal-section {
  display: none;
}

.portal-section.active {
  display: block;
}

.panel {
  padding: 22px;
}

.split-layout,
.hr-grid {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.hr-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 18px;
}

.hr-bottom {
  margin-top: 18px;
}

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

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

.salary-breakdown div {
  display: grid;
  gap: 4px;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 10px 12px;
}

.salary-breakdown span {
  color: var(--muted);
  font-size: 12px;
}

.salary-breakdown strong {
  font-size: 14px;
}

.policy-list {
  display: grid;
  gap: 22px;
}

.policy-group h4 {
  margin: 0 0 12px;
  color: var(--brand);
  font-size: 18px;
}

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

.policy-card {
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 16px;
  box-shadow: 0 12px 30px rgba(15, 35, 63, 0.06);
}

.policy-card h5 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 15px;
}

.policy-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 13px;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input,
select {
  height: 42px;
}

textarea {
  min-height: 130px;
  padding: 11px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  outline: 3px solid rgba(11, 45, 92, 0.13);
}

.primary-button,
.ghost-button,
.small-button,
.file-button {
  display: inline-grid;
  place-items: center;
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 0 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.primary-button {
  background: linear-gradient(135deg, var(--brand), var(--brand-3));
  color: #ffffff;
  box-shadow: 0 12px 24px rgba(11, 45, 92, 0.18);
}

.primary-button:hover,
.ghost-button:hover,
.small-button:hover,
.file-button:hover {
  transform: translateY(-1px);
}

.ghost-button,
.file-button {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

.small-button {
  min-height: 34px;
  background: #fff7e4;
  border-color: rgba(198, 154, 47, 0.34);
  color: #6e5010;
}

.file-button input {
  display: none;
}

.today-list,
.attendance-list,
.payroll-preview,
.profile-card,
.portal-payslip {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.person-row,
.preview-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 54px;
  padding: 11px 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.person-row:hover,
.preview-row:hover {
  border-color: rgba(11, 45, 92, 0.2);
  background: #fbfcff;
}

.badge {
  display: inline-grid;
  place-items: center;
  min-height: 28px;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
}

.badge.approved,
.badge.active {
  background: rgba(31, 143, 86, 0.12);
  color: var(--ok);
}

.badge.pending,
.badge.on-notice {
  background: rgba(186, 107, 18, 0.12);
  color: var(--warn);
}

.badge.rejected,
.badge.inactive,
.badge.open {
  background: rgba(184, 63, 63, 0.12);
  color: var(--bad);
}

.badge.resolved {
  background: rgba(31, 143, 86, 0.12);
  color: var(--ok);
}

.table-textarea {
  min-width: 220px;
  min-height: 74px;
}

.person-main strong,
.preview-row strong {
  display: block;
}

.person-main span,
.preview-row span {
  color: var(--muted);
  font-size: 12px;
}

.profile-row,
.payslip-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 42px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 8px;
}

.profile-row span,
.payslip-row span {
  color: var(--muted);
  font-size: 13px;
}

.payslip-row.total {
  background: rgba(22, 117, 111, 0.12);
  color: var(--brand);
}

.portal-payslip .payslip-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.status-group {
  display: grid;
  grid-template-columns: repeat(4, 92px);
  gap: 8px;
}

.status-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
}

.status-button.active[data-status="present"] {
  border-color: var(--ok);
  background: rgba(31, 143, 86, 0.12);
  color: var(--ok);
}

.status-button.active[data-status="leave"] {
  border-color: var(--warn);
  background: rgba(186, 107, 18, 0.12);
  color: var(--warn);
}

.status-button.active[data-status="absent"] {
  border-color: var(--bad);
  background: rgba(184, 63, 63, 0.12);
  color: var(--bad);
}

.status-button.active[data-status="late"] {
  border-color: var(--brand-2);
  background: rgba(212, 91, 50, 0.12);
  color: var(--brand-2);
}

.table-wrap {
  margin-top: 14px;
  overflow-x: auto;
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-right: 6px;
}

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

.legend-dot.leave {
  background: #2f74c0;
}

.legend-dot.comp-off {
  background: #d6a21d;
}

.legend-dot.lop {
  background: var(--bad);
}

.legend-dot.off {
  background: var(--muted);
}

.monthly-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.calendar-head,
.calendar-day {
  min-height: 58px;
  border-radius: 8px;
  padding: 8px;
}

.calendar-head {
  display: grid;
  place-items: center;
  min-height: 34px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.calendar-day {
  display: grid;
  align-content: space-between;
  border: 1px solid var(--line);
  background: #ffffff;
}

.calendar-day span {
  color: var(--muted);
  font-size: 12px;
}

.calendar-day strong {
  font-size: 15px;
}

.calendar-day em {
  color: var(--text);
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  line-height: 1.25;
}

.calendar-day.present {
  border-color: var(--ok);
  background: rgba(31, 143, 86, 0.14);
  color: var(--ok);
}

.calendar-day.leave {
  border-color: #2f74c0;
  background: rgba(47, 116, 192, 0.14);
  color: #2f74c0;
}

.calendar-day.comp-off {
  border-color: #d6a21d;
  background: rgba(214, 162, 29, 0.18);
  color: #8b6508;
}

.calendar-day.lop {
  border-color: var(--bad);
  background: rgba(184, 63, 63, 0.14);
  color: var(--bad);
}

.calendar-day.off {
  border-color: var(--muted);
  background: var(--surface-2);
  color: var(--muted);
}

.calendar-day.muted {
  background: transparent;
  border-color: transparent;
}

.checkbox-group {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.checkbox-group legend {
  padding: 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.checkbox-group label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.icon-button {
  min-width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  cursor: pointer;
}

.payroll-table td:last-child,
.payroll-table th:last-child {
  font-weight: 800;
}

.settings-grid {
  max-width: 560px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  background: #172326;
  color: #ffffff;
  border-radius: 8px;
  padding: 12px 14px;
  transition: 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.empty {
  color: var(--muted);
  padding: 20px;
  background: var(--surface-2);
  border-radius: 8px;
  text-align: center;
}

@media (max-width: 980px) {
  .login-screen {
    padding: 20px;
    background: linear-gradient(180deg, #061a36 0%, #0b2d5c 42%, #f4f7fb 42%, #ffffff 100%);
  }

  .login-shell {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .login-brand-panel {
    min-height: 320px;
    padding: 34px;
  }

  .login-card {
    padding: 34px;
  }

  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 16px;
  }

  .brand {
    margin-bottom: 14px;
  }

  .nav {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    overflow-x: auto;
  }

  .nav-item {
    text-align: center;
  }

  .nav-item::before {
    margin-right: 0;
    margin-bottom: 6px;
  }

  .metrics-grid,
  .dashboard-grid,
  .split-layout,
  .hr-grid {
    grid-template-columns: 1fr;
  }

  .portal-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .portal-controls {
    grid-template-columns: 1fr;
  }

  .portal-shell {
    grid-template-columns: 1fr;
  }

  .portal-menu {
    position: static;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .portal-menu-item {
    text-align: center;
  }
}

@media (max-width: 680px) {
  .login-screen {
    padding: 14px;
  }

  .login-shell {
    border-radius: 18px;
  }

  .login-brand-panel {
    min-height: 260px;
    padding: 26px;
  }

  .login-brand-panel h1 {
    font-size: 32px;
  }

  .login-welcome {
    font-size: 14px;
  }

  .login-card {
    padding: 26px;
  }

  .content {
    padding: 18px;
  }

  .topbar,
  .panel-head,
  .attendance-toolbar,
  .top-actions,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

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

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

  .two-columns {
    grid-template-columns: 1fr;
  }

  .salary-breakdown {
    grid-template-columns: 1fr;
  }

  .person-row {
    grid-template-columns: 1fr;
  }

  .profile-row,
  .payslip-row {
    grid-template-columns: 1fr;
  }

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

@media print {
  .sidebar,
  .topbar,
  .nav,
  #printPayroll,
  #downloadPortalPayslip {
    display: none;
  }

  .app {
    display: block;
  }

  .content {
    padding: 0;
  }

  .panel {
    box-shadow: none;
    border: 0;
  }
}
