:root {
  color-scheme: light;
  --navy: #10243d;
  --navy-2: #17395f;
  --blue: #1f5eff;
  --teal: #0f8b7e;
  --red: #b91c1c;
  --amber: #b45309;
  --ink: #122033;
  --muted: #64748b;
  --line: #afc0d4;
  --line-soft: #dbe4ee;
  --paper: #ffffff;
  --canvas: #f4f7fb;
  --soft: #f8fafc;
  --shadow: none;
  --grid-line: #e8eef5;
  --header-bg: #f3f7fc;
  --header-fg: #435166;
  font-family: "Microsoft YaHei UI", "Noto Sans CJK SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
h1, h2, h3, p { margin-top: 0; }

/* === Shell === */
.admin-shell { width: 100%; margin: 0 auto; padding: 0; }

/* === Header — 对齐桌面版MainWindow内嵌标题 === */
.admin-header {
  min-height: 64px;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  border-top: none;
  box-shadow: none;
}
.admin-header h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: 0; color: var(--ink); }
.eyebrow { margin-bottom: 2px; color: var(--teal); font-size: 11px; font-weight: 700; letter-spacing: .12em; }
.subtle, .muted { color: var(--muted); }
.header-status { min-width: 320px; text-align: right; display: grid; justify-items: end; gap: 6px; }
.version-chip, .badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e9f1ff;
  color: #2458a8;
  border: 1px solid #c7dcf8;
  font-size: 11px;
  font-weight: 600;
}

/* === Navigation — 对齐桌面版侧边栏Tab按钮 === */
.primary-nav {
  margin: 0;
  padding: 8px 14px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.primary-nav button, .subnav button {
  min-height: 34px;
  padding: 0 14px;
  color: var(--ink);
  background: #eef4fc;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-weight: 600;
  white-space: nowrap;
}
.primary-nav button:hover, .subnav button:hover { filter: brightness(.96); }
.primary-nav button.active, .subnav button.active {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

/* === Page area === */
.page-root { min-height: calc(100vh - 110px); margin-top: 0; padding: 10px; }
.page { display: grid; gap: 10px; min-height: calc(100vh - 130px); }
.page-titlebar {
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.page-titlebar h2 { margin-bottom: 4px; font-size: 22px; font-weight: 600; }
.page-actions, .toolbar, .button-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* === Cards / Panels — 对齐桌面版Border样式 === */
.panel, .card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: none;
}

/* === Buttons — 对齐桌面版Button Style === */
.button, button.action {
  min-height: 34px;
  padding: 0 12px;
  color: var(--ink);
  background: #eef4fc;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-weight: 600;
  cursor: pointer;
}
.button.primary, button.primary { color: #fff; background: var(--blue); border-color: var(--blue); }
.button.success, button.success { color: #fff; background: var(--teal); border-color: var(--teal); }
.button.danger, button.danger { color: #fff; background: var(--red); border-color: var(--red); }
.button.ghost { background: transparent; }
.button:hover, button.action:hover { filter: brightness(.96); }

/* === Inputs — 对齐桌面版TextBox Style === */
.input, input, select, textarea {
  min-height: 34px;
  width: 100%;
  padding: 5px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  vertical-align: middle;
}
label { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--header-fg); }
label small { font-weight: 400; color: var(--muted); }

/* === Employee page layout === */
.employee-layout { grid-template-columns: 405px minmax(0, 1fr); align-items: stretch; }
.employee-layout > .sidebar { min-height: calc(100vh - 130px); display: grid; grid-template-rows: auto minmax(300px, 1fr) 230px; gap: 10px; }
.sidebar-head, .sidebar-status, .table-card, .form-card, .preview-card, .review-card, .work-card { padding: 14px 16px; }
.sidebar-head h2 { font-size: 26px; font-weight: 600; }
.sidebar-head .button-row { margin-top: 10px; }
.employee-main { display: grid; min-width: 0; gap: 10px; grid-template-columns: minmax(560px, 1fr) minmax(420px, 480px); }
.wide-row { grid-column: 1 / -1; }
.employee-center { display: grid; gap: 10px; grid-template-rows: minmax(260px, 38vh) minmax(380px, 1fr); min-width: 0; }
.review-card { display: grid; min-height: 0; grid-template-rows: auto minmax(0, 1fr) auto minmax(220px, 36vh) auto; }
.review-fields { overflow: auto; display: grid; gap: 8px; align-content: start; }
.review-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.ocr-box { min-height: 220px; font-size: 14px; }

/* === Tables — 对齐桌面版DataGrid样式 === */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
thead tr { background: var(--header-bg); }
th {
  color: var(--header-fg);
  font-weight: 600;
  text-align: left;
  padding: 0 8px;
  height: 34px;
  border-bottom: 1px solid var(--line);
}
td {
  padding: 0 8px;
  height: 25px;
  border-bottom: 1px solid var(--grid-line);
}
tbody tr { background: #fff; }
tbody tr:nth-child(even) { background: var(--soft); }
tbody tr:hover { background: #f4f8ff; }
tbody tr.selected { background: #e9f1ff; }
tbody tr.expired { color: #dc2626; font-weight: 700; }
.empty-cell { height: 90px; text-align: center; color: var(--muted); }

/* === Section headers === */
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.section-head h3 { margin: 0; font-size: 17px; font-weight: 600; }
.status-strip { padding: 8px 10px; border: 1px solid var(--line-soft); border-radius: 5px; background: var(--soft); color: var(--muted); font-size: 12px; }
.warning { color: var(--amber); }
.danger-text { color: var(--red); }
.success-text { color: var(--teal); }

/* === Preview === */
.preview-surface {
  position: relative;
  min-height: 320px;
  height: 100%;
  overflow: auto;
  border: 1px solid var(--line-soft);
  background: var(--soft);
  display: grid;
  place-items: center;
}
.preview-surface img { max-width: 100%; max-height: 100%; transform-origin: center; }
.preview-surface iframe { width: 100%; height: 100%; min-height: 420px; border: 0; background: #fff; }
.preview-placeholder { max-width: 420px; padding: 24px; text-align: center; color: var(--muted); }

/* === Forms === */
.dense-form { display: grid; grid-template-columns: repeat(6, minmax(130px, 1fr)); gap: 8px 10px; }
.dense-form .wide { grid-column: span 3; }
.dense-form .double { grid-column: span 2; }
.create-workspace { display: grid; grid-template-columns: 65fr 35fr; gap: 12px; min-height: 500px; }
.create-preview { display: grid; grid-template-rows: auto auto minmax(360px,1fr); }
.create-certificates { display: grid; grid-template-rows: auto minmax(360px,1fr); }

.split-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.split-left { display: grid; grid-template-columns: minmax(430px, 1fr) minmax(620px, 1.5fr); gap: 12px; }
.stack { display: grid; gap: 10px; align-content: start; }
.form-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 9px; }
.subnav { padding: 8px; display: flex; gap: 6px; overflow-x: auto; background: var(--paper); border-bottom: 1px solid var(--line); }
.tab-page { display: none; }
.tab-page.active { display: grid; gap: 10px; min-height: 520px; }

/* === Attendance === */
.attendance-layout { display: grid; grid-template-columns: 390px minmax(700px,1fr); gap: 12px; min-height: 620px; }
.location-pane { display: grid; grid-template-rows: auto minmax(320px,1fr); gap: 10px; }
.attendance-pane { display: grid; grid-template-rows: auto minmax(480px,1fr); gap: 10px; }
.whatsapp-header { display: grid; grid-template-columns: minmax(0,1fr) 360px auto; gap: 12px; align-items: start; }
.whatsapp-pages { min-width: 1280px; }
.reconcile-layout { display: grid; grid-template-columns: minmax(780px,1fr) 420px; gap: 8px; min-height: 540px; }
.manual-grid { display: grid; grid-template-columns: 140px 140px 150px 150px minmax(260px,1fr) 120px; gap: 8px; }
.audit-layout { display: grid; grid-template-columns: 1.35fr 1fr; gap: 10px; min-height: 500px; }
.whitelist-info { display: grid; grid-template-columns: 1fr 1fr 360px; gap: 14px; }

/* === Contracts === */
.contracts-layout { display: grid; grid-template-columns: 430px minmax(700px,1fr); gap: 12px; min-height: 700px; }
.contracts-editor { overflow: auto; max-height: calc(100vh - 200px); }
.contracts-list { display: grid; grid-template-rows: auto minmax(360px,1fr) auto; }
.approval-dock { display: grid; grid-template-columns: minmax(0,1fr) 430px; gap: 14px; }

/* === Workbench === */
.workbench-grid { display: grid; grid-template-columns: 1.1fr .9fr; grid-template-rows: auto minmax(420px,1fr); gap: 12px; }
.readonly-chip { color: #0c7c4c; background: #e6f7ef; border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600; }

/* === Crop === */
.crop-workspace { display: grid; grid-template-columns: minmax(600px, 1fr) 300px; gap: 10px; }
.crop-canvas { min-height: 520px; border: 1px solid var(--line); background: #111827; position: relative; overflow: hidden; }
.crop-canvas img { width: 100%; height: 100%; object-fit: contain; transform-origin: center; }
.crop-box { position: absolute; border: 3px solid #22c55e; background: rgba(34,197,94,.15); inset: 22% 18%; cursor: move; }

/* === Dialogs === */
.confirm-dialog, .preview-dialog { border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 24px 80px rgba(15,23,42,.32); }
.confirm-dialog { width: min(520px, 90vw); }
.confirm-dialog form { display: grid; gap: 12px; }
.dialog-actions, .dialog-head { display: flex; justify-content: flex-end; gap: 8px; }
.dialog-head { justify-content: space-between; align-items: center; }
.preview-dialog { width: min(1500px, 95vw); height: 92vh; padding: 12px; }
.preview-dialog::backdrop, .confirm-dialog::backdrop { background: rgba(15,23,42,.78); }
.preview-dialog iframe { width: 100%; height: calc(100% - 52px); border: 1px solid var(--line); }

/* === Responsive === */
@media (max-width: 1280px) {
  .employee-layout, .employee-main, .contracts-layout, .attendance-layout { grid-template-columns: 1fr; }
  .employee-layout > .sidebar { min-height: auto; grid-template-rows: auto 420px auto; }
  .dense-form { grid-template-columns: repeat(3, minmax(150px,1fr)); }
  .whatsapp-header { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .admin-shell { padding: 0; }
  .admin-header, .page-titlebar { align-items: flex-start; flex-direction: column; }
  .header-status { min-width: 0; text-align: left; justify-items: start; }
  .dense-form, .form-grid-2, .form-grid-3, .split-2, .create-workspace, .workbench-grid, .whitelist-info, .approval-dock { grid-template-columns: 1fr; }
  .dense-form .wide, .dense-form .double { grid-column: span 1; }
}
