:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #687386;
  --line: #dfe4eb;
  --line-strong: #cbd3df;
  --canvas: #f1f5fa;
  --surface: #ffffff;
  --nav: #111b2b;
  --nav-soft: #1a273a;
  --blue: #1268b9;
  --blue-dark: #0e528f;
  --blue-soft: #eaf2ff;
  --green: #17745a;
  --green-soft: #e7f6f0;
  --amber: #9a5c00;
  --amber-soft: #fff4db;
  --red: #b4233c;
  --red-soft: #fdecef;
  --shadow: 0 20px 60px rgba(14, 39, 69, 0.12);
  font-family: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  letter-spacing: 0;
}

button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background: radial-gradient(circle at 15% 15%, #dfeeff 0, transparent 38%),
              linear-gradient(140deg, #edf3f9, #f8fafc 65%);
}

.login-panel {
  width: min(820px, 100%);
  min-height: 430px;
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(360px, 1.2fr);
  background: var(--surface);
  border: 1px solid #d8dee8;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.login-brand {
  padding: 48px 38px;
  display: flex;
  align-items: flex-start;
  gap: 18px;
  color: #fff;
  background: linear-gradient(150deg, #0e2746, #132f58 70%, #0d4e83);
}

.login-brand strong, .topbar-brand strong {
  display: block;
  font-size: 19px;
  line-height: 1.2;
  letter-spacing: 0;
}

.login-brand span:not(.brand-mark), .topbar-brand span:not(.brand-mark) {
  display: block;
  margin-top: 7px;
  color: #9eabc0;
  font-size: 12px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: inline-grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #1153a0, #149bd1);
  border-radius: 13px;
  box-shadow: 0 8px 22px rgba(0, 95, 168, 0.25);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
}

.brand-mark.small {
  width: 36px;
  height: 36px;
  flex-basis: 36px;
  font-size: 14px;
}

.login-form {
  padding: 54px 58px 42px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 20px;
}

.login-form header { margin-bottom: 6px; }
.login-form h1 { margin: 5px 0 0; font-size: 27px; font-weight: 650; }

.eyebrow, .section-kicker {
  margin: 0;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

label { display: flex; flex-direction: column; gap: 7px; color: #3f4a5d; font-weight: 600; }
label > span { font-size: 12px; }

input, select, textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31, 95, 191, 0.12); }

.button {
  min-height: 40px;
  padding: 9px 17px;
  border: 1px solid transparent;
  border-radius: 5px;
  font-weight: 650;
  white-space: nowrap;
}

.button:disabled { cursor: not-allowed; opacity: 0.55; }
.button.primary { color: #fff; background: var(--blue); border-color: var(--blue); }
.button.primary:hover:not(:disabled) { background: var(--blue-dark); }
.button.secondary { color: #26344a; background: #fff; border-color: var(--line-strong); }
.button.secondary:hover:not(:disabled), .button.ghost:hover:not(:disabled) { background: #f4f6f9; }
.button.ghost { color: #46536a; background: transparent; border-color: transparent; }
.button.neutral { color: #fff; background: #30445f; border-color: #30445f; }
.button.danger-outline { color: var(--red); background: #fff; border-color: #e7aab5; }
.button.danger-outline:hover:not(:disabled) { background: var(--red-soft); }
.button.wide { width: 100%; }
.button.compact { min-height: 34px; padding: 6px 11px; font-size: 12px; }
.button.action { min-width: 128px; min-height: 46px; }

.login-meta { display: flex; align-items: center; justify-content: space-between; gap: 14px; color: var(--muted); font-size: 12px; }
.connection-status { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; font-size: 12px; font-weight: 650; }
.connection-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.connection-status.online { color: var(--green); }
.connection-status.offline { color: var(--red); }

.app-shell { min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  color: #fff;
  background: var(--nav);
  border-bottom: 1px solid #26344a;
}

.topbar-brand { display: flex; align-items: center; gap: 12px; min-width: 245px; }
.topbar-brand strong { font-size: 15px; }
.topbar-brand span:not(.brand-mark) { margin-top: 3px; font-size: 11px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar .connection-status { color: #86dec2; margin-right: 6px; }
.topbar time { min-width: 146px; color: #b9c4d4; font-variant-numeric: tabular-nums; font-size: 12px; }
.topbar .button.ghost { color: #d8e0ea; }
.topbar .button.ghost:hover { background: var(--nav-soft); }
.topbar .button.secondary { color: #fff; background: #25354b; border-color: #3b4b61; }
.identity { min-width: 90px; padding-left: 10px; border-left: 1px solid #39465a; }
.identity strong, .identity span { display: block; }
.identity strong { font-size: 13px; }
.identity span { margin-top: 2px; color: #9eabc0; font-size: 11px; }

.workspace { min-height: calc(100vh - 64px); display: grid; grid-template-columns: 216px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: #182437;
  border-right: 1px solid #26344a;
}

.sidebar nav { display: flex; flex-direction: column; gap: 5px; }
.nav-item {
  min-height: 46px;
  padding: 9px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #bdc8d8;
  background: transparent;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 3px;
  text-align: left;
}
.nav-item:hover { color: #fff; background: #202e43; }
.nav-item.active { color: #fff; background: #24364f; border-left-color: #4e8fe8; }
.nav-item span { font-weight: 650; }
.nav-item small { color: #8291a7; font-size: 11px; }
.nav-item.active small { color: #bdd7fb; }
.sidebar-foot { padding: 14px 12px 4px; color: #8896aa; border-top: 1px solid #2b394d; }
.sidebar-foot span, .sidebar-foot small { display: block; }
.sidebar-foot small { margin-top: 4px; }

.main-content { min-width: 0; padding: 28px 30px 46px; }
.page-heading { min-height: 58px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.page-heading h2 { margin: 5px 0 0; font-size: 23px; font-weight: 650; }
.page-actions { display: flex; align-items: center; gap: 8px; }
.page { display: none; }
.page.active { display: block; }

.metric-grid { display: grid; grid-template-columns: repeat(6, minmax(118px, 1fr)); gap: 10px; margin: 6px 0 16px; }
.metric {
  min-height: 92px;
  padding: 15px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.metric span { display: block; color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 9px; font-size: 25px; font-weight: 650; font-variant-numeric: tabular-nums; }
.metric.attention strong { color: var(--red); }
.metric.good strong { color: var(--green); }

.status-board { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.status-board[hidden] { display: none; }
.status-card { min-height: 112px; padding: 16px 17px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid #597595; border-radius: 12px; box-shadow: 0 6px 24px rgba(20, 49, 80, 0.04); }
.status-card.working { border-left-color: #2d9d68; }
.status-card.resting { border-left-color: #6484c5; }
.status-card.warning { border-left-color: #e9a33b; }
.status-card.overtime { border-left-color: #945bc7; }
.status-card-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 650; }
.status-card-heading strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.status-people { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.status-people span { padding: 3px 7px; background: #f0f4f8; border-radius: 4px; font-size: 12px; }
.status-people small { color: var(--muted); }

.surface { margin-bottom: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 6px 24px rgba(20, 49, 80, 0.04); }
.attendance-actions { min-height: 112px; padding: 20px 22px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.attendance-actions h3 { margin: 5px 0 6px; font-size: 18px; }
.muted { margin: 0; color: var(--muted); }
.action-buttons { display: flex; align-items: center; gap: 10px; }
.section-header { min-height: 66px; padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.section-header h3 { margin: 4px 0 0; font-size: 16px; }

.toolbar, .filter-bar {
  margin: 6px 0 14px;
  padding: 12px 14px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.toolbar { align-items: center; justify-content: space-between; }
.toolbar > div:last-child { display: flex; gap: 8px; }
.toolbar-copy strong, .toolbar-copy span { display: block; }
.toolbar-copy span { margin-top: 4px; color: var(--muted); font-size: 12px; }
.filter-bar label { min-width: 150px; }
.filter-bar input, .filter-bar select { min-height: 38px; }

.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { min-height: 46px; padding: 12px 14px; border-bottom: 1px solid #e7ebf0; text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; z-index: 1; color: #5c687a; background: #f7f8fa; font-size: 12px; font-weight: 700; }
td { color: #303b4c; font-size: 13px; }
tbody tr:hover { background: #f8faff; }
tbody tr:last-child td { border-bottom: 0; }
.empty-row td { padding: 36px 18px; color: var(--muted); text-align: center; }
.cell-main, .cell-sub { display: block; }
.cell-main { font-weight: 650; color: var(--ink); }
.cell-sub { margin-top: 3px; color: var(--muted); font-size: 11px; }
.table-actions { display: flex; gap: 6px; }
.inline-select { min-width: 110px; min-height: 32px; padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: 7px; background: #f8fbff; color: var(--ink); }
.inline-select:focus { outline: 2px solid #80bbeb; outline-offset: 1px; }

.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.badge.normal, .badge.approved { color: var(--green); background: var(--green-soft); }
.badge.late, .badge.pending { color: var(--amber); background: var(--amber-soft); }
.badge.error, .badge.rejected { color: var(--red); background: var(--red-soft); }
.badge.neutral { color: #4d5b70; background: #edf0f4; }

.modal {
  width: min(660px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  box-shadow: 0 22px 64px rgba(13, 25, 44, 0.22);
}
.modal.wide-modal { width: min(790px, calc(100vw - 32px)); }
.modal.small-modal { width: min(480px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(13, 25, 44, 0.48); }
.modal form { max-height: calc(100vh - 42px); display: flex; flex-direction: column; }
.modal header { min-height: 70px; padding: 15px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.modal header h3 { margin: 4px 0 0; font-size: 18px; }
.modal footer { padding: 14px 20px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); }
.form-grid { padding: 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; overflow-y: auto; }
.form-grid .full { grid-column: 1 / -1; }
.form-stack { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.checkbox-field { min-height: 40px; flex-direction: row; align-items: center; gap: 9px; }
.checkbox-field input { width: 17px; min-height: 17px; height: 17px; }
.checkbox-field span { font-size: 13px; }
.icon-close { width: 34px; height: 34px; padding: 0; color: #667286; background: transparent; border: 0; border-radius: 4px; font-size: 24px; line-height: 1; }
.icon-close:hover { color: var(--ink); background: #f0f2f5; }
.field-note { margin: -6px 0 0; color: var(--muted); font-size: 12px; }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 100;
  min-width: 260px;
  max-width: min(440px, calc(100vw - 44px));
  padding: 13px 16px;
  color: #fff;
  background: #223149;
  border-left: 4px solid #5b9bf2;
  border-radius: 5px;
  box-shadow: var(--shadow);
}
.toast.error { border-left-color: #ff6b7f; background: #4a1f28; }
.toast.success { border-left-color: #4bc59f; background: #153f34; }

@media (max-width: 1120px) {
  .metric-grid { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
  .status-board { grid-template-columns: repeat(2, minmax(150px, 1fr)); }
  .topbar time, .topbar .connection-status { display: none; }
}

@media (max-width: 860px) {
  .login-panel { grid-template-columns: 1fr; }
  .login-brand { padding: 24px; }
  .login-form { padding: 34px 28px; }
  .topbar { height: auto; min-height: 64px; flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .topbar-brand { min-width: 210px; }
  .workspace { display: block; }
  .sidebar { position: sticky; top: 0; z-index: 15; width: 100%; height: auto; padding: 6px; overflow-x: auto; }
  .sidebar nav { min-width: max-content; flex-direction: row; }
  .nav-item { min-width: 120px; border-left: 0; border-bottom: 3px solid transparent; }
  .nav-item.active { border-bottom-color: #4e8fe8; }
  .sidebar-foot { display: none; }
  .main-content { padding: 22px 16px 38px; }
  .attendance-actions { align-items: flex-start; flex-direction: column; }
  .action-buttons { width: 100%; }
  .button.action { flex: 1; min-width: 0; }
  .filter-bar { align-items: stretch; flex-wrap: wrap; }
  .filter-bar label { flex: 1 1 160px; }
}

@media (max-width: 560px) {
  .login-view { padding: 14px; }
  .login-meta { align-items: flex-start; flex-direction: column; }
  .topbar-brand span:not(.brand-mark), .topbar .button.ghost, .identity { display: none; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .status-board { grid-template-columns: 1fr; }
  .metric { min-height: 82px; }
  .action-buttons { flex-direction: column; }
  .button.action { width: 100%; }
  .toolbar { align-items: flex-start; flex-direction: column; }
  .toolbar > div:last-child { width: 100%; flex-wrap: wrap; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .page-heading { min-height: 52px; }
}

/* ICP filing number, required on every public page */
.icp-footer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; padding: 6px 0; text-align: center; font-size: 12px; pointer-events: none; }
.icp-footer a { color: #98a2b3; text-decoration: none; pointer-events: auto; }
.icp-footer a:hover { text-decoration: underline; }
