:root {
  --bg: #eef1f4;
  --panel: #ffffff;
  --line: #d8dde2;
  --line-strong: #c6cdd4;
  --text: #465260;
  --muted: #7e8a96;
  --green: #35b72a;
  --green-dark: #22951f;
  --blue: #08abd5;
  --dark-blue: #25384d;
  --orange: #f47b20;
  --red: #ef4438;
  --yellow: #f4df6b;
  --lime: #cfe983;
  --holiday: #ffebec;
  --weekend: #f1f2f4;
  --focus: #0a95c4;
  font-family: "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at 100% 0%, #f9fafb 0, #eef1f4 310px);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

.app-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 12px 18px 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 72px;
}

.brand-lockup {
  align-items: center;
  display: flex;
  gap: 14px;
  min-width: 0;
}

.brand-logo {
  height: 58px;
  max-width: 150px;
  object-fit: contain;
}

.brand-kicker {
  color: var(--green);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.1;
}

.topbar h1 {
  margin: 0;
  font-size: 25px;
  font-weight: 700;
  color: #27313d;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

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

.today-chip {
  padding: 9px 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 4px;
  font-weight: 650;
  color: var(--dark-blue);
  white-space: nowrap;
}

.topbar-logout {
  padding: 7px 12px;
}

.tabbar {
  display: flex;
  gap: 10px;
  border-bottom: 2px solid var(--green);
  margin-bottom: 20px;
}

.tab {
  border: 0;
  background: transparent;
  padding: 15px 20px;
  color: #34465b;
  font-weight: 650;
}

.tab.active {
  background: var(--panel);
  border-radius: 3px 3px 0 0;
  box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.03), 1px 0 0 rgba(0, 0, 0, 0.04), -1px 0 0 rgba(0, 0, 0, 0.04);
}

.main-panel {
  min-height: calc(100vh - 132px);
}

.legal-footer {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 12px;
  gap: 8px;
  justify-content: center;
  padding: 18px 0 4px;
}

.legal-footer a {
  color: var(--muted);
  text-decoration: none;
}

.legal-footer a:hover,
.legal-footer a:focus {
  color: var(--dark-blue);
  text-decoration: underline;
}

.rfid-legal-footer {
  padding-bottom: 18px;
}

.legal-page {
  background: #eef1f4;
}

.legal-shell {
  margin: 0 auto;
  max-width: 940px;
  padding: 18px;
}

.legal-document {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 10px 24px rgba(37, 56, 77, 0.08);
}

.legal-document .panel-body {
  display: grid;
  gap: 18px;
}

.legal-heading {
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.legal-heading h1 {
  color: #27313d;
  font-size: 28px;
  margin: 4px 0 0;
}

.legal-section {
  display: grid;
  gap: 8px;
}

.legal-section h2 {
  color: #27313d;
  font-size: 18px;
  margin: 0;
}

.legal-section p,
.legal-section li {
  line-height: 1.55;
}

.legal-section p,
.legal-section ul {
  margin: 0;
}

.legal-section ul {
  padding-left: 20px;
}

.legal-address {
  line-height: 1.55;
}

.layout-two {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 30px;
}

.full-width-flow {
  width: 100%;
}

.profile-page {
  display: flex;
  justify-content: center;
  padding: 24px 0;
}

.profile-page aside {
  width: min(430px, 100%);
}

.section-title {
  margin: 0 0 12px;
  padding-left: 4px;
  font-size: 16px;
  font-weight: 650;
  color: #536170;
}

.panel {
  background: var(--panel);
  border-top: 2px solid var(--green);
  box-shadow: 0 0 0 1px rgba(198, 205, 212, 0.65);
  margin-bottom: 20px;
}

.panel-body {
  padding: 22px 26px;
}

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

.compact-form {
  gap: 10px;
}

.admin-subsection {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
}

.print-title {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.time-month-table tfoot th {
  background: #f3f6f8;
  border-top: 2px solid var(--line-strong);
}

.subsection-title {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--dark-blue);
}

.time-hero {
  align-items: center;
  display: flex;
  gap: 18px;
  justify-content: space-between;
}

.time-toggle {
  background: var(--green);
  border: 0;
  border-radius: 6px;
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  min-height: 96px;
  min-width: 260px;
  padding: 24px 30px;
}

.time-toggle.running {
  background: var(--red);
}

.time-toggle:disabled {
  background: var(--line-strong);
  cursor: not-allowed;
}

.form-row {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.form-row label,
.compact-label {
  font-weight: 700;
  color: #5a6470;
}

.field,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 4px;
  min-height: 40px;
  padding: 8px 11px;
  color: #4f5964;
  background: #fff;
}

.chip-field {
  display: grid;
  gap: 6px;
}

.chip-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.rfid-terminal-page {
  background: #eef1f4;
}

.rfid-terminal-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 22px;
}

.rfid-terminal {
  width: min(760px, 100%);
}

.rfid-terminal-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.rfid-terminal-head h1 {
  color: #27313d;
  font-size: 30px;
  margin: 4px 0 0;
}

.rfid-terminal-status {
  align-items: center;
  background: #f3f6f8;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--dark-blue);
  display: flex;
  font-size: 32px;
  font-weight: 750;
  justify-content: center;
  min-height: 132px;
  padding: 22px;
  text-align: center;
}

.rfid-terminal-status.good {
  background: #eaf7e8;
  border-color: #b7dfb4;
  color: var(--green-dark);
}

.rfid-terminal-status.bad {
  background: #fff0ef;
  border-color: #f1b4af;
  color: var(--red);
}

.rfid-terminal-message {
  color: var(--muted);
  font-size: 17px;
  font-weight: 650;
  margin: 14px 0 22px;
  text-align: center;
}

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

.rfid-terminal-actions {
  justify-content: center;
  margin-top: 22px;
}

.textarea {
  min-height: 86px;
  resize: vertical;
}

.inline-options {
  display: flex;
  align-items: center;
  gap: 52px;
  min-height: 38px;
}

.radio {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.radio input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.person-line {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
}

.person-line + .person-line {
  margin-top: 10px;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #d9edf8, #fff);
  border: 1px solid var(--line);
  color: #2b4b66;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  flex: 0 0 auto;
}

.avatar.large {
  width: 84px;
  height: 84px;
  font-size: 28px;
}

.person-name {
  font-weight: 750;
  color: #425064;
}

.person-role {
  font-size: 14px;
  color: #6f7a86;
}

.summary-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid var(--line);
  background: #f7f8fa;
}

.summary-item {
  text-align: center;
  padding: 16px 10px;
  border-right: 1px solid #e4e8ec;
}

.summary-item:last-child {
  border-right: 0;
}

.summary-label {
  display: block;
  font-size: 11px;
  color: #9aa3ad;
  text-transform: uppercase;
}

.summary-value {
  display: block;
  margin-top: 4px;
  font-weight: 800;
  color: #536170;
}

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

.actions.right {
  justify-content: flex-end;
}

.btn {
  border: 0;
  border-radius: 3px;
  padding: 9px 13px;
  color: #fff;
  min-height: 38px;
  font-weight: 700;
}

.btn.green {
  background: var(--green);
}

.btn.green:hover {
  background: var(--green-dark);
}

.btn.blue {
  background: var(--blue);
}

.btn.dark {
  background: var(--dark-blue);
}

.btn.orange {
  background: var(--orange);
}

.btn.red {
  background: var(--red);
}

.btn.gray {
  background: #c9cdd2;
  color: #25313f;
}

.btn.ghost {
  color: #40505f;
  background: #fff;
  border: 1px solid var(--line);
}

.message {
  margin: 0 0 16px;
  padding: 16px 18px;
  background: #dff1fa;
  color: #256082;
  font-weight: 650;
}

.message.warning {
  background: #fff3cd;
  color: #805b08;
}

.profile-card {
  background: var(--panel);
  border-top: 2px solid var(--green);
  box-shadow: 0 0 0 1px rgba(198, 205, 212, 0.65);
  min-height: 590px;
  padding: 26px 28px;
}

.compact-person {
  min-height: 44px;
}

.profile-top {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  margin-bottom: 22px;
}

.pie {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: conic-gradient(var(--blue) 0 18%, var(--lime) 18% 56%, #cfcfcf 56% 100%);
  border: 4px solid #fff;
  box-shadow: 0 0 0 1px #e1e5e9;
}

.profile-name {
  text-align: center;
  font-size: 25px;
  color: #727982;
  margin: 0 0 8px;
  font-weight: 300;
}

.profile-sub {
  text-align: center;
  color: #65707b;
  margin: 3px 0;
}

.profile-action {
  text-align: center;
  margin: 8px 0 22px;
}

.metric-list {
  display: grid;
  gap: 9px;
  margin-top: 18px;
}

.metric {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  font-size: 14px;
}

.metric strong {
  color: #52606c;
}

.metric .value {
  font-weight: 800;
  color: #536170;
  white-space: nowrap;
}

.metric .good {
  color: #18b414;
}

.metric .bad {
  color: #ff6b00;
}

.profile-buttons {
  display: flex;
  justify-content: space-between;
  margin-top: 26px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  background: #fff;
}

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

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

th {
  background: #f3f6f8;
  color: #536170;
  font-weight: 800;
}

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 12px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
}

.status.pending {
  background: #fff1c2;
  color: #8a6410;
}

.status.approved {
  background: #ddf4cf;
  color: #24791e;
}

.status.rejected {
  background: #ffe0dc;
  color: #af2f25;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr)) auto;
  gap: 14px;
  align-items: end;
  margin-bottom: 18px;
}

.request-year-toolbar {
  grid-template-columns: minmax(180px, 260px);
}

.calendar-panel {
  background: #fff;
  border-top: 2px solid var(--green);
  box-shadow: 0 0 0 1px rgba(198, 205, 212, 0.65);
}

.calendar-toolbar {
  padding: 16px 26px;
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr auto;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  align-items: end;
}

.calendar-scroller {
  overflow: auto;
  max-height: calc(100vh - 270px);
}

.calendar-legend {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  padding: 14px 26px 16px;
  border-top: 1px solid var(--line);
  color: #596675;
  font-size: 13px;
}

.calendar-legend span {
  align-items: center;
  display: inline-flex;
  gap: 7px;
}

.legend-box {
  border: 1px solid var(--line-strong);
  display: inline-block;
  height: 14px;
  width: 24px;
}

.year-table {
  table-layout: fixed;
  min-width: 9800px;
  font-size: 13px;
}

.year-table th,
.year-table td {
  padding: 0;
  text-align: center;
  height: 32px;
  min-width: 26px;
}

.year-table .sticky-name,
.year-table .sticky-balance {
  position: sticky;
  left: 0;
  z-index: 3;
  background: #fff;
}

.year-table .sticky-name {
  width: 170px;
  min-width: 170px;
  text-align: left;
  padding: 6px 10px;
}

.year-table .sticky-balance {
  left: 170px;
  width: 92px;
  min-width: 92px;
  background: #fff;
  font-size: 12px;
  color: #67737e;
}

.year-table thead .sticky-name,
.year-table thead .sticky-balance {
  z-index: 5;
  background: #f3f6f8;
}

.day-cell {
  color: #34404d;
}

.day-cell.weekend {
  background: var(--weekend);
}

.day-cell.holiday {
  background: var(--holiday);
  color: #d71920;
  font-weight: 800;
}

.day-cell.school-holiday {
  background: #eef8ed;
  box-shadow: inset 0 0 0 999px rgba(53, 183, 42, 0.08);
}

.day-cell.employee-free {
  background: #f7f8fa;
  color: #a5aeb7;
}

.day-cell.leave-approved {
  background: var(--lime);
  color: #1e2f13;
  font-weight: 900;
  text-decoration: underline;
}

.day-cell.leave-training {
  background: var(--blue);
  color: #fff;
  font-weight: 900;
}

.day-cell.leave-pending {
  background: var(--yellow);
  color: #4b3a03;
  font-weight: 900;
}

.day-cell.auto-half {
  background: linear-gradient(135deg, var(--lime) 0 50%, #fff 50% 100%);
  color: #1e2f13;
  font-weight: 900;
}

.day-cell.today {
  outline: 3px solid var(--blue);
  outline-offset: -3px;
  background-image: linear-gradient(135deg, rgba(8, 171, 213, 0.22), rgba(8, 171, 213, 0));
}

.legend-box.leave-approved {
  background: var(--lime);
}

.legend-box.leave-pending {
  background: var(--yellow);
}

.legend-box.leave-training {
  background: var(--blue);
}

.legend-box.school-holiday {
  background: #ddf4dc;
}

.legend-box.holiday {
  background: var(--holiday);
}

.legend-box.auto-half {
  background: linear-gradient(135deg, var(--lime) 0 50%, #fff 50% 100%);
}

.legend-box.today {
  background: linear-gradient(135deg, rgba(8, 171, 213, 0.26), #fff);
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}

.month-head {
  height: 34px;
  background: #eef6fb;
  color: #178bb0;
}

.weekday-head {
  color: #009ddb;
}

.weekday-head.sun,
.weekday-head.holiday {
  color: #ff0000;
}

.calendar-summary td {
  background: #e8f6fb;
  font-weight: 750;
}

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

.admin-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.admin-full {
  width: 100%;
}

.admin-section-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.employee-list {
  display: grid;
  gap: 12px;
}

.employee-summary-card {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(240px, 1.1fr) minmax(0, 2fr) auto;
  gap: 16px;
  padding: 14px 0;
}

.employee-summary-card.archived {
  opacity: 0.78;
}

.employee-summary-card:first-child {
  padding-top: 0;
}

.employee-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.employee-summary-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.employee-form-panel {
  margin-bottom: 18px;
}

.employee-form {
  display: grid;
  gap: 18px;
}

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

.employee-form-block {
  display: grid;
  gap: 8px;
}

.request-card,
.employee-editor {
  border-bottom: 1px solid var(--line);
  padding: 15px 0;
}

.request-card:first-child,
.employee-editor:first-child {
  padding-top: 0;
}

.sort-control {
  display: block;
  max-width: 320px;
  margin: 0 0 14px;
}

.workday-editor {
  margin-top: 12px;
}

.weekday-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 6px;
}

.weekday-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.weekday-toggle span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
  color: #55616e;
  font-weight: 750;
}

.weekday-toggle input:checked + span {
  border-color: var(--green);
  background: #e6f7e4;
  color: #1f8120;
}

.request-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
}

.admin-time-layout {
  align-items: start;
  display: grid;
  grid-template-columns: minmax(520px, 0.9fr) minmax(320px, 0.55fr);
  gap: 18px;
}

.admin-time-side {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.admin-time-side .admin-subsection {
  margin-top: 0;
}

.admin-time-side .request-card .mini-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.time-month-table {
  table-layout: fixed;
}

.print-overall-summary {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 12px;
}

.print-overall-summary .good {
  color: #18b414;
  font-weight: 800;
}

.print-overall-summary .bad {
  color: #ff6b00;
  font-weight: 800;
}

.time-month-table th:nth-child(1),
.time-month-table td:nth-child(1) {
  width: 18%;
}

.time-month-table th:nth-child(2),
.time-month-table td:nth-child(2) {
  width: 22%;
}

.time-month-table th:nth-child(3),
.time-month-table td:nth-child(3) {
  width: 15%;
}

.time-month-table th:nth-child(4),
.time-month-table td:nth-child(4) {
  width: 15%;
}

.compact-list {
  margin-top: 12px;
}

.login-box {
  max-width: 460px;
  margin: 56px auto;
}

.empty {
  padding: 18px;
  color: #7b8792;
  background: #f8fafb;
  border: 1px dashed var(--line-strong);
}

.small {
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 980px) {
  .layout-two,
  .admin-grid,
  .admin-time-layout,
  .rfid-terminal-grid {
    grid-template-columns: 1fr;
  }

  .profile-card {
    min-height: auto;
  }

  .toolbar,
  .calendar-toolbar {
    grid-template-columns: 1fr 1fr;
  }

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

@media (max-width: 680px) {
  .app-shell {
    padding: 8px;
  }

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

  .brand-logo {
    height: 48px;
    max-width: 120px;
  }

  .tabbar {
    overflow-x: auto;
  }

  .tab {
    white-space: nowrap;
    padding: 13px 14px;
  }

  .panel-body {
    padding: 18px 14px;
  }

  .toolbar,
  .calendar-toolbar,
    .mini-grid,
    .side-mini-grid,
    .employee-form-grid,
    .employee-summary-card,
  .employee-summary-metrics,
  .summary-bar {
    grid-template-columns: 1fr;
  }

  .admin-tabs,
  .admin-section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .time-hero {
    align-items: stretch;
    flex-direction: column;
  }

  .time-toggle {
    min-width: 0;
    width: 100%;
  }

  .inline-options {
    gap: 18px;
    flex-wrap: wrap;
  }

  .chip-input-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .rfid-terminal-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .rfid-terminal-status {
    font-size: 24px;
    min-height: 112px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .tabbar,
  .no-print,
  .admin-tabs,
  .admin-subsection:not(.print-area) {
    display: none !important;
  }

  .app-shell {
    max-width: none;
    padding: 0;
  }

  .main-panel,
  .panel,
  .panel-body {
    box-shadow: none;
    border: 0;
    padding: 0;
  }

  .print-area {
    border: 0;
    margin: 0;
    padding: 0;
  }

  table {
    page-break-inside: auto;
  }
}
