:root {
  --bg: #f6f7f9;
  --panel: #fff;
  --text: #1f2933;
  --muted: #687385;
  --line: #d9dee7;
  --primary: #1769aa;
  --success: #1f8a4c;
  --warning: #b98200;
  --danger: #b42318;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--primary); text-decoration: none; }
h1 { margin: 0 0 18px; font-size: 26px; }
h2 { margin: 24px 0 12px; font-size: 18px; }
.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand { font-weight: 700; color: var(--text); }
.topbar-actions { display: flex; gap: 14px; align-items: center; }
.language { display: flex; gap: 8px; font-size: 14px; }
.user { color: var(--muted); font-size: 14px; }
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 58px); }
.auth-shell { min-height: calc(100vh - 58px); }
.sidebar {
  background: #243142;
  padding: 18px 12px;
}
.sidebar a, .nav-section {
  display: block;
  padding: 10px 12px;
  color: #eef3f8;
  border-radius: 6px;
  margin-bottom: 4px;
}
.sidebar a:hover { background: rgba(255,255,255,.1); }
.nav-section { color: #9fb1c5; font-size: 12px; text-transform: uppercase; margin-top: 16px; }
.main { padding: 24px; max-width: 1280px; width: 100%; }
.login-panel {
  max-width: 420px;
  margin: 80px auto;
  background: var(--panel);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.form { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px; }
.form.narrow { border: 0; padding: 0; }
.stacked-form { display: grid; gap: 16px; }
.form-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
.form-card h2 { margin-top: 0; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(160px, 1fr)); gap: 14px; }
label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  font: inherit;
  color: var(--text);
  background: #fff;
}
textarea { min-height: 110px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; }
.check input { width: auto; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}
.button.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.button.success { background: var(--success); color: #fff; border-color: var(--success); }
.button.warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.button.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.button.ghost { background: transparent; }
.toolbar { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.admin-toolbar { margin-bottom: 14px; }
.hint { margin: 10px 0; color: var(--muted); font-size: 13px; }
.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.metric span { display: block; color: var(--muted); font-size: 13px; min-height: 32px; }
.metric strong { display: block; font-size: 28px; margin-top: 8px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.table-scroll { overflow-x: auto; }
.admin-table { min-width: 1320px; }
.users-table { min-width: 1460px; }
.admin-table th { white-space: nowrap; }
.admin-table td { font-size: 13px; }
.number-cell { text-align: right; font-variant-numeric: tabular-nums; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 10px 12px; vertical-align: top; }
th { background: #eef2f6; color: #3c4655; font-size: 13px; }
.actions-col { min-width: 190px; }
.table-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.table-actions form { margin: 0; }
.table-actions .button { padding: 6px 10px; min-height: 32px; white-space: nowrap; }
.status {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.4;
  background: #e5e7eb;
}
.status.pending { background: #fff3cd; color: #7a5a00; }
.status.approved { background: #d1fadf; color: #05603a; }
.status.rejected { background: #fee4e2; color: #912018; }
.status.returned { background: #ffead5; color: #93370d; }
.status.cancelled { background: #e5e7eb; color: #374151; }
.status.ok { background: #d1fadf; color: #05603a; }
.status.too_far { background: #fee4e2; color: #912018; }
.status.manual_review { background: #ffead5; color: #93370d; }
.status.blocked { background: #e5e7eb; color: #374151; }
.flash {
  margin: 0 0 16px;
  padding: 11px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #eef2f6;
}
.flash.success { background: #d1fadf; border-color: #a6f4c5; }
.flash.warning { background: #fff3cd; border-color: #f6d365; }
.flash.error { background: #fee4e2; border-color: #fda29b; }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.detail-grid div { display: grid; gap: 6px; }
.detail-grid strong { color: var(--muted); font-size: 13px; }
.inline-form { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-bottom: 14px; }
.inline-form input, .inline-form select { width: 150px; }
.approval-actions { display: grid; gap: 8px; }
.approval-actions form { display: flex; gap: 8px; }
.attendance-mobile-page {
  max-width: 720px;
  width: 100%;
  display: grid;
  gap: 14px;
  overflow-x: hidden;
}
.attendance-clock-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  display: grid;
  gap: 12px;
  min-width: 0;
}
.attendance-person { color: var(--muted); font-size: 14px; }
.attendance-date { font-weight: 700; }
.attendance-time {
  font-size: 42px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.attendance-location-status {
  border: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--muted);
}
.attendance-reminder-card {
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  padding: 14px;
  background: #f8fafc;
  box-shadow: 0 10px 24px rgba(31, 41, 51, .08);
  min-width: 0;
}
.attendance-reminder-card h2 {
  margin: 0 0 8px;
  font-size: 16px;
}
.attendance-reminder-card dl {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 6px;
  margin: 0;
}
.attendance-reminder-card p {
  margin: 0 0 8px;
  font-weight: 700;
  overflow-wrap: anywhere;
}
.attendance-payroll-card {
  border: 1px solid #bbf7d0;
  border-left: 4px solid var(--success);
  border-radius: 8px;
  padding: 14px;
  background: #f0fdf4;
  box-shadow: 0 10px 24px rgba(20, 83, 45, .08);
}
.attendance-payroll-card h2 {
  margin: 0 0 8px;
  font-size: 16px;
}
.attendance-payroll-card dl {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 6px;
  margin: 0;
}
.attendance-payroll-card dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}
.reminder-info { border-left-color: var(--primary); background: #eff8ff; }
.reminder-warning { border-left-color: var(--warning); background: #fff8e6; }
.reminder-danger { border-left-color: var(--danger); background: #fff1f0; }
.reminder-success { border-left-color: var(--success); background: #ecfdf3; }
.attendance-distance { font-size: 16px; }
.attendance-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.clock-button {
  min-height: 54px;
  font-size: 17px;
  font-weight: 700;
}
.clock-button-alert {
  box-shadow: 0 0 0 4px rgba(180, 35, 24, .22), 0 10px 22px rgba(180, 35, 24, .18);
  border-color: var(--danger);
  transform: translateY(-1px);
}
.attendance-log-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.page-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.overtime-form {
  max-width: 980px;
}
.overtime-form .time-input-field input[type="time"] {
  min-width: 150px;
}
.approval-button {
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(20, 83, 45, .16);
}
.warning-text {
  color: var(--danger);
  font-weight: 700;
  margin: 0;
}
.truncate-cell {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.payroll-summary .metric strong {
  font-variant-numeric: tabular-nums;
}
.attendance-settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 12px;
}
.ai-card {
  margin-top: 14px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  padding: 14px;
  white-space: pre-wrap;
}
.ai-card.low { border-left-color: var(--success); }
.ai-card.medium { border-left-color: #d4a106; }
.ai-card.high { border-left-color: var(--warning); }
.ai-card.blocked { border-left-color: var(--danger); }
.hidden { display: none; }
.calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: start;
  margin-bottom: 22px;
}
.calendar-panel, .day-detail {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.calendar-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}
.calendar-toolbar h2 { margin: 0; }
.calendar-filter {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.calendar-filter select { width: auto; min-width: 86px; }
.weekday-row, .month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}
.weekday-row div {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  padding: 6px;
}
.calendar-day {
  min-height: 128px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  overflow: hidden;
}
.calendar-day:hover { background: #eef7ff; }
.calendar-day.selected { outline: 3px solid #89c2ff; }
.calendar-day.today { border: 2px solid var(--primary); }
.calendar-day.weekend { background: #f1f3f5; }
.calendar-day.holiday { background: #fff4e5; border-color: #f7c56b; }
.calendar-day.adjusted_workday { background: #ecfdf3; border-color: #8ee0ad; }
.calendar-day.empty {
  background: transparent;
  border: 0;
  pointer-events: none;
}
.day-number { font-weight: 700; font-size: 16px; }
.holiday-name { color: var(--danger); font-size: 12px; font-weight: 700; }
.calendar-count, .calendar-users, .calendar-types {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.25;
}
.leave-pill {
  display: inline-flex;
  align-self: flex-start;
  background: #fff3cd;
  color: #7a5a00;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 12px;
}
.merged-calendar-layout {
  grid-template-columns: minmax(0, 1fr) 340px;
}
.merged-calendar {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}
.merged-calendar-day {
  min-height: 148px;
  gap: 3px;
  padding: 7px;
  font-size: 11px;
  line-height: 1.25;
  border-radius: 7px;
}
.merged-calendar-day.cn-weekend.de-weekend {
  background: #f5f6f8;
}
.merged-calendar-day.cn-holiday,
.merged-calendar-day.cn-adjusted_workday,
.merged-calendar-day.de-holiday,
.merged-calendar-day.de-adjusted_workday {
  background: #fffdf7;
}
.region-line {
  display: flex;
  gap: 5px;
  align-items: center;
  min-width: 0;
}
.region-line span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.region-badge {
  flex: 0 0 auto;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  font-weight: 700;
}
.region-badge-cn {
  color: #7a271a;
  background: #fee4e2;
}
.region-badge-de {
  color: #1849a9;
  background: #dbeafe;
}
.region-holiday {
  color: #912018;
  font-weight: 700;
}
.region-workday {
  color: #344054;
}
.staff-line,
.leave-line {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}
.leave-line {
  color: #7a5a00;
}
.day-detail-region {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-top: 10px;
}
.day-detail-region h3 {
  margin: 0 0 8px;
  font-size: 15px;
}
body[data-portal="employee"] .calendar-layout {
  grid-template-columns: minmax(0, 1fr) 300px;
}
body[data-portal="employee"] .calendar-day {
  min-height: 88px;
  gap: 3px;
  padding: 6px;
  font-size: 12px;
  border-radius: 6px;
}
body[data-portal="employee"] .day-number {
  font-size: 14px;
}
body[data-portal="employee"] .holiday-name {
  font-size: 11px;
}
body[data-portal="employee"] .calendar-count,
body[data-portal="employee"] .calendar-users,
body[data-portal="employee"] .calendar-types {
  font-size: 11px;
  line-height: 1.25;
}
body[data-portal="employee"] .leave-pill {
  font-size: 11px;
  padding: 1px 6px;
}
body[data-portal="employee"] .merged-calendar-layout {
  grid-template-columns: minmax(0, 1fr) 320px;
}
body[data-portal="employee"] .merged-calendar-day {
  min-height: 136px;
  font-size: 11px;
}
.day-detail dl {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 8px;
  margin: 0;
}
.day-detail dt { color: var(--muted); }
.day-detail dd { margin: 0; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: flex; overflow-x: auto; }
  .sidebar a, .nav-section { white-space: nowrap; }
  .form-grid, .metric-grid, .two-col, .detail-grid, .calendar-layout { grid-template-columns: 1fr; }
  .month-grid, .weekday-row { grid-template-columns: repeat(7, minmax(44px, 1fr)); overflow-x: auto; }
  .calendar-day { min-height: 112px; padding: 6px; }
  .attendance-mobile-page { max-width: none; }
  .attendance-clock-card { padding: 14px; border-radius: 7px; }
  .attendance-time { font-size: 42px; }
  .attendance-reminder-card { padding: 16px; font-size: 15px; }
  .attendance-reminder-card h2 { font-size: 18px; }
  .attendance-payroll-card { padding: 16px; font-size: 15px; }
  .attendance-payroll-card h2 { font-size: 18px; }
  .attendance-payroll-card dl { grid-template-columns: 1fr; }
  .attendance-actions { grid-template-columns: 1fr; }
  .clock-button { min-height: 58px; width: 100%; }
  .attendance-log-card { grid-template-columns: 1fr; }
  .overtime-form .form-grid { grid-template-columns: 1fr; }
  .overtime-form .time-input-field input[type="time"] { width: 100%; min-width: 0; }
  .page-title-row { align-items: stretch; }
  .page-title-row .button { width: 100%; text-align: center; }
  .attendance-settings-grid { grid-template-columns: 1fr; }
  .topbar { height: auto; padding: 12px; align-items: flex-start; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
}
