:root {
  --ink: #172938;
  --muted: #697c89;
  --paper: #eef3f7;
  --surface: #ffffff;
  --line: #d7e0e7;
  --navy: #102f4b;
  --navy-deep: #0a2439;
  --blue: #2d6faa;
  --blue-soft: #e9f2fb;
  --green: #2d8064;
  --amber: #b66b15;
  --red: #b33b35;
  --purple: #735697;
  --teal: #2b7d83;
  --shadow: 0 14px 36px rgba(18, 47, 72, 0.08);
  color-scheme: light;
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--paper); }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
.authPending .appSidebar,
.authPending .appCanvas,
.authPending .drawerBackdrop { visibility: hidden; }

.appSidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  width: 248px;
  flex-direction: column;
  color: #ecf4f8;
  background: var(--navy-deep);
  box-shadow: 12px 0 34px rgba(8, 35, 55, 0.16);
}

.brand { display: grid; gap: 5px; padding: 31px 29px 28px; border-bottom: 1px solid rgba(255,255,255,.12); text-decoration: none; }
.brand strong { font-family: "Songti SC", SimSun, serif; font-size: 26px; letter-spacing: .18em; }
.brand span { color: #aebfca; font-size: 12px; letter-spacing: .27em; }
.appSidebar nav { display: grid; gap: 7px; padding: 26px 15px; }
.appSidebar nav a { display: flex; align-items: center; gap: 13px; padding: 13px 14px; color: #b9c8d1; border: 1px solid transparent; border-radius: 7px; font-size: 14px; text-decoration: none; }
.appSidebar nav a span { width: 20px; color: #718da0; font-family: Georgia, serif; font-size: 10px; }
.appSidebar nav a:hover { color: #fff; background: rgba(255,255,255,.06); }
.appSidebar nav a.active { color: #fff; border-color: rgba(121,174,219,.28); background: #1e5c91; }
.appSidebar nav a.active span { color: #b9dcf7; }
.sidebarNotice { display: grid; gap: 6px; margin: auto 20px 22px; padding: 15px; border: 1px solid rgba(255,255,255,.13); background: rgba(255,255,255,.045); }
.sidebarNotice b { font-size: 12px; font-weight: 600; }
.sidebarNotice span { color: #92a8b6; font-size: 10px; line-height: 1.6; }

.appCanvas { min-height: 100vh; margin-left: 248px; }
.topbar { display: flex; min-height: 108px; align-items: center; justify-content: space-between; gap: 30px; padding: 22px clamp(24px, 4vw, 54px); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.92); }
.eyebrow { margin: 0 0 6px; color: var(--blue); font-family: Georgia, serif; font-size: 10px; letter-spacing: .2em; }
.topbar h1 { margin: 0; font-family: "Songti SC", SimSun, serif; font-size: 27px; font-weight: 600; letter-spacing: .05em; }
.subhead { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.topbarMeta { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.topbarMeta a { padding-left: 16px; color: var(--ink); border-left: 1px solid var(--line); text-decoration: none; }
.previewBadge { padding: 4px 9px; color: #77500e; border: 1px solid #e2c78d; border-radius: 999px; background: #fff6df; font-size: 10px; font-weight: 700; letter-spacing: .08em; }

.mainContent { width: min(1540px, 100%); margin: 0 auto; padding: 26px clamp(22px, 3.6vw, 48px) 40px; }
.overviewBand { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 36px; align-items: center; padding: 28px 32px; color: #f4f8fb; background: var(--navy); box-shadow: var(--shadow); }
.overviewBand .eyebrow { color: #86b9df; }
.overviewBand h2 { margin: 0 0 9px; font-family: "Songti SC", SimSun, serif; font-size: clamp(23px, 2.2vw, 32px); font-weight: 600; letter-spacing: .04em; }
.overviewBand p:last-child { max-width: 820px; margin: 0; color: #b9cbd6; font-size: 12px; line-height: 1.8; }
.overviewRule { display: grid; gap: 7px; padding: 16px 0 16px 22px; border-left: 1px solid rgba(255,255,255,.16); }
.overviewRule b { font-size: 11px; font-weight: 500; }
.overviewRule span { color: #f3b553; font-family: Georgia, "Songti SC", serif; font-size: 22px; }
.overviewRule small { color: #9fb4c1; font-size: 10px; line-height: 1.5; }

.metricGrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: solid var(--line); border-width: 0 1px 1px 0; background: var(--surface); box-shadow: var(--shadow); }
.metricGrid article { position: relative; display: grid; min-height: 118px; align-content: center; gap: 7px; padding: 20px 23px; border: solid var(--line); border-width: 1px 0 0 1px; }
.metricGrid article::before { position: absolute; top: -1px; left: 22px; width: 38px; height: 3px; content: ""; background: var(--blue); }
.metricGrid article:nth-child(2)::before { background: var(--teal); }
.metricGrid article:nth-child(3)::before { background: var(--amber); }
.metricGrid article:nth-child(4)::before { background: var(--green); }
.metricGrid span { color: var(--muted); font-size: 11px; }
.metricGrid strong { font-family: Georgia, "Songti SC", serif; font-size: 27px; font-weight: 500; }
.metricGrid small { color: #93a1aa; font-size: 10px; }
.metricGrid article.inspectionMetric { background: linear-gradient(180deg, #fff 0%, #f8fbfd 100%); }
.metricGrid article.inspectionMetric strong { color: var(--navy); }

.workbenchTabs { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 20px; padding: 7px; border: 1px solid var(--line); background: var(--surface); }
.workbenchTabs button { min-height: 38px; padding: 8px 14px; color: var(--muted); border: 0; border-radius: 4px; background: transparent; font-size: 11px; font-weight: 600; }
.workbenchTabs button.active { color: #fff; background: var(--navy); }
.closureWorkbench { margin-top: 14px; }
.closurePane { padding: 22px; border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.closurePane > header { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin-bottom: 15px; }
.closurePane h2 { margin: 0; font-family: "Songti SC", SimSun, serif; font-size: 22px; }
.workCardList { display: grid; gap: 10px; }
.workCard { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px; border: 1px solid var(--line); border-left: 4px solid var(--blue); background: #fff; }
.workCard > div { min-width: 0; }
.workCard h3 { margin: 5px 0; font-size: 14px; }
.workCard p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.65; }
.workCard .primaryButton { flex: 0 0 auto; }
.rectificationEvidence { display: grid; gap: 7px; min-width: 220px; max-width: 360px; border-left: 3px solid #3f8067; background: #f1f8f5; padding: 9px 11px; }
.rectificationEvidence strong { color: #275f4c; font-size: 11px; }
.rectificationEvidence p { color: #365f51; }
.rectificationEvidence .quietButton { min-height: 32px; padding: 6px 9px; font-size: 10px; }
.statusText { display: inline-block; color: var(--navy); font-size: 10px; font-weight: 700; }
.emptyWorkCard { margin: 0; padding: 25px; color: var(--muted); border: 1px dashed #c7d5df; background: #f7fafc; text-align: center; font-size: 11px; }
.closureDrawer #closureForm { display: grid; gap: 16px; padding-top: 20px; }
.closureDrawer #closureFormFields { display: grid; gap: 14px; }
.closureDrawer fieldset { display: flex; flex-wrap: wrap; gap: 12px; margin: 0; padding: 12px; border: 1px solid var(--line); }
.closureDrawer legend { padding: 0 5px; color: var(--muted); font-size: 10px; }
.closureDrawer fieldset label, .closureDrawer #closureFormFields > label { display: grid; gap: 6px; color: var(--ink); font-size: 11px; }
.closureDrawer fieldset label { display: flex; align-items: center; }
.closureDrawer .identityHint { margin: 0; padding: 11px; color: #24475f; border: 1px solid #c9d8e4; background: #f1f7fb; font-size: 10px; line-height: 1.6; }
.closureDrawer footer { display: flex; justify-content: flex-end; gap: 9px; padding-top: 16px; border-top: 1px solid var(--line); }

.filterBar { display: flex; align-items: end; gap: 12px; margin-top: 20px; padding: 16px; border: 1px solid var(--line); background: var(--surface); }
.filterBar label { display: grid; min-width: 160px; gap: 6px; }
.filterBar label span, .formGrid label span, .overrideReason > span { color: var(--muted); font-size: 10px; }
select, input, textarea { min-height: 40px; padding: 9px 11px; color: var(--ink); border: 1px solid #cdd9e2; border-radius: 5px; background: #fff; outline: none; }
select:focus, input:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(45,111,170,.12); }
.quietButton, .primaryButton, .fileButton, .importControls button { min-height: 40px; padding: 9px 15px; border: 1px solid #c9d6df; border-radius: 5px; background: #fff; color: var(--ink); font-weight: 600; }
.quietButton:hover { border-color: #8ea8ba; }
.filterBar .quietButton { margin-left: auto; }
.primaryButton { color: #fff; border-color: var(--blue); background: var(--blue); }
.primaryButton:hover { background: #255f92; }

.workspaceGrid { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 18px; margin-top: 18px; }
.schedulePanel, .insightRail section, .importPanel { border: 1px solid var(--line); background: var(--surface); box-shadow: 0 10px 28px rgba(18,47,72,.055); }
.schedulePanel { min-width: 0; }
.scheduleToolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 17px; border-bottom: 1px solid var(--line); }
.viewTabs { display: flex; gap: 5px; padding: 4px; background: #eef3f7; }
.viewTabs button { padding: 8px 12px; color: var(--muted); border: 0; border-radius: 4px; background: transparent; font-size: 11px; }
.viewTabs button.active { color: #fff; background: var(--navy); }
.periodNavigator { display: flex; align-items: center; gap: 7px; margin-left: auto; }
.periodNavigator button { min-height: 34px; padding: 6px 9px; color: var(--muted); border: 1px solid #cbd8e1; border-radius: 4px; background: #fff; font-size: 9px; }
.periodNavigator strong { min-width: 128px; font-family: Georgia, "Songti SC", serif; font-size: 10px; font-weight: 500; text-align: center; }
.periodNavigator label { display: grid; gap: 2px; }
.periodNavigator label span { color: var(--muted); font-size: 8px; }
.periodNavigator input { width: 126px; min-height: 34px; padding: 5px 7px; font-size: 9px; }
.conflictSummary { display: none; margin: 0; padding: 10px 17px; color: #8b2e2a; border-bottom: 1px solid #e5b6b2; background: #fff1f0; font-size: 10px; font-weight: 600; }
.conflictSummary.visible { display: block; }
.typeLegend { display: flex; flex-wrap: wrap; gap: 12px 18px; padding: 12px 17px; border-bottom: 1px solid var(--line); background: #fbfcfd; }
.typeLegend span { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }
.typeLegend i { width: 8px; height: 8px; border-radius: 2px; background: var(--task-color); }

.timelineView { overflow-x: auto; min-height: 520px; }
.timelineGrid { min-width: 900px; }
.timelineHeader, .timelineRow { display: grid; grid-template-columns: 132px minmax(760px, 1fr); }
.timelineName { position: sticky; left: 0; z-index: 4; display: grid; align-content: center; min-height: 57px; padding: 10px 14px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fff; }
.timelineName strong { font-size: 11px; }
.timelineName small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.timelineHeader .timelineName { z-index: 6; min-height: 48px; color: var(--muted); background: #f5f8fa; font-size: 10px; font-weight: 600; }
.timelineDays { position: relative; display: grid; grid-template-columns: repeat(var(--days), minmax(54px, 1fr)); min-height: 57px; border-bottom: 1px solid var(--line); }
.timelineDay { display: grid; place-content: center; color: #7a8c98; border-right: 1px solid #e6edf1; font-size: 9px; }
.timelineDay b { margin-bottom: 2px; color: var(--ink); font-family: Georgia, serif; font-size: 12px; font-weight: 500; }
.timelineDay.weekend { background: #f7f9fb; }
.timelineDay.today { background: #edf6fe; }
.taskBar { position: absolute; top: 12px; left: calc((var(--start) * 100% / var(--days)) + 4px); z-index: 2; width: calc((var(--span) * 100% / var(--days)) - 8px); min-width: 32px; height: 32px; overflow: hidden; padding: 7px 8px; color: var(--task-text, #fff); border-left: 3px solid rgba(0,0,0,.16); border-radius: 4px; background: var(--task-color); font-size: 9px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; box-shadow: 0 4px 12px rgba(17,49,74,.12); }
.taskBar.conflictTask { top: 8px; height: 40px; padding-top: 16px; outline: 3px solid #cc3029; outline-offset: -2px; }
.taskBar .conflictFlag { position: absolute; inset: 2px 4px auto; color: #fff; font-size: 8px; line-height: 1; text-align: right; }
.emptyTimeline { display: grid; min-height: 360px; place-items: center; color: var(--muted); font-size: 12px; }

.monthView { padding: 17px; }
.monthHeading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.monthHeading h3 { margin: 0; font-family: "Songti SC", SimSun, serif; font-size: 18px; }
.calendarGrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: solid var(--line); border-width: 1px 0 0 1px; }
.weekday, .calendarDay { min-height: 94px; padding: 9px; border: solid var(--line); border-width: 0 1px 1px 0; }
.weekday { min-height: auto; color: var(--muted); background: #f4f7f9; font-size: 10px; text-align: center; }
.calendarDay.muted { color: #afbac1; background: #fafbfc; }
.calendarDay.today { background: #edf6fe; }
.calendarDay > b { font-family: Georgia, serif; font-size: 11px; font-weight: 500; }
.calendarTasks { display: grid; gap: 3px; margin-top: 6px; }
.calendarTasks span { overflow: hidden; padding: 3px 5px; color: #fff; border-radius: 3px; background: var(--task-color); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.calendarTasks span.conflictCalendar { outline: 2px solid #c92f28; outline-offset: -1px; }
.calendarTasks small { color: var(--muted); font-size: 8px; }

.taskListView { overflow-x: auto; }
.taskTable { width: 100%; border-collapse: collapse; font-size: 10px; }
.taskTable th, .taskTable td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.taskTable th { color: var(--muted); background: #f4f7f9; font-weight: 500; white-space: nowrap; }
.typePill { display: inline-block; padding: 3px 7px; color: #fff; border-radius: 999px; background: var(--task-color); font-size: 9px; white-space: nowrap; }
.taskTable tr.conflictRow td { background: #fff2f1; }
.conflictText { display: block; margin-top: 5px; color: #a52d28; font-size: 9px; font-weight: 700; }

.insightRail { display: grid; align-content: start; gap: 18px; }
.insightRail section { overflow: hidden; }
.insightRail header { display: flex; align-items: center; justify-content: space-between; padding: 17px 18px 13px; border-bottom: 1px solid var(--line); }
.insightRail header div { display: grid; gap: 3px; }
.insightRail header span { color: var(--blue); font-size: 9px; letter-spacing: .08em; }
.insightRail header h2 { margin: 0; font-family: "Songti SC", SimSun, serif; font-size: 17px; }
.insightRail header > b { color: var(--blue); font-family: Georgia, serif; font-size: 24px; font-weight: 500; }
.upcomingList { display: grid; max-height: 384px; overflow-y: auto; }
.upcomingItem { display: grid; grid-template-columns: 8px 1fr; gap: 10px; padding: 13px 17px; border-bottom: 1px solid #e8eef2; }
.upcomingItem:last-child { border-bottom: 0; }
.upcomingItem i { width: 7px; height: 7px; margin-top: 4px; border-radius: 50%; background: var(--task-color); }
.upcomingItem div { display: grid; gap: 4px; min-width: 0; }
.upcomingItem b { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.upcomingItem span { color: var(--muted); font-size: 9px; line-height: 1.5; }
.achievementSummary { display: grid; grid-template-columns: repeat(3, 1fr); padding: 18px; }
.achievementSummary p { display: grid; gap: 5px; margin: 0; text-align: center; border-right: 1px solid var(--line); }
.achievementSummary p:last-child { border-right: 0; }
.achievementSummary strong { color: var(--green); font-family: Georgia, serif; font-size: 21px; font-weight: 500; }
.achievementSummary span { color: var(--muted); font-size: 9px; }
.auditHint { margin: 0; padding: 10px 17px; color: var(--muted); border-bottom: 1px solid var(--line); background: #f7f9fb; font-size: 9px; }
.auditTrail { display: grid; max-height: 260px; overflow-y: auto; }
.auditEntry { display: grid; gap: 5px; padding: 13px 17px; border-bottom: 1px solid #e8eef2; }
.auditEntry:last-child { border-bottom: 0; }
.auditEntry b { font-size: 10px; }
.auditEntry p { margin: 0; color: #8f3833; font-size: 9px; line-height: 1.55; }
.auditEntry time { color: var(--muted); font-size: 8px; }

.importPanel { display: grid; grid-template-columns: minmax(280px, 1fr) auto; gap: 22px 34px; align-items: center; margin-top: 18px; padding: 22px 24px; }
.importPanel h2 { margin: 0 0 7px; font-family: "Songti SC", SimSun, serif; font-size: 19px; }
.importPanel p:last-child { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.6; }
.importControls { display: flex; align-items: center; gap: 8px; }
#dutyWorkbook { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.fileButton { display: inline-grid; place-items: center; cursor: pointer; }
.importControls button { color: #fff; border-color: var(--teal); background: var(--teal); }
.importControls button:disabled { cursor: not-allowed; opacity: .45; }
.importPreview { grid-column: 1 / -1; padding: 12px 14px; color: var(--muted); border: 1px dashed #c7d5df; background: #f7fafc; font-size: 10px; }
.importPreview.success { color: #25654f; border-color: #a8d0bf; background: #edf8f3; }
.importPreview.error { color: #90332e; border-color: #e0aaa6; background: #fff1f0; }

.drawerBackdrop { position: fixed; inset: 0; z-index: 80; display: grid; justify-items: end; background: rgba(8,30,47,.5); }
.assignmentDrawer { width: min(540px, 100%); height: 100%; overflow-y: auto; padding: 25px; background: #fff; box-shadow: -16px 0 42px rgba(8,30,47,.2); }
.assignmentDrawer > header { display: flex; align-items: flex-start; justify-content: space-between; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.assignmentDrawer h2 { margin: 0; font-family: "Songti SC", SimSun, serif; font-size: 22px; }
.assignmentDrawer > header button { color: var(--muted); border: 0; background: transparent; font-size: 11px; }
#assignmentForm { display: grid; gap: 17px; padding-top: 20px; }
.formGrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.formGrid label, .overrideReason { display: grid; gap: 6px; }
.formGrid .wide { grid-column: 1 / -1; }
textarea { resize: vertical; }
.conflictPanel { padding: 14px 16px; border: 1px solid #c9d8e4; background: #f1f7fb; }
.conflictPanel b { font-size: 11px; }
.conflictPanel p, .conflictPanel ul { margin: 7px 0 0; color: var(--muted); font-size: 10px; line-height: 1.6; }
.conflictPanel.blocked { border-color: #e0a7a3; background: #fff0ef; }
.conflictPanel.clear { border-color: #acd4c3; background: #edf8f3; }
.overrideRow { display: flex; align-items: center; gap: 8px; color: var(--red); font-size: 11px; }
.overrideRow input { width: 16px; min-height: 16px; }
.formMessage { min-height: 16px; margin: 0; color: var(--red); font-size: 10px; }
#assignmentForm footer { display: flex; justify-content: flex-end; gap: 9px; padding-top: 16px; border-top: 1px solid var(--line); }

@media (max-width: 1180px) {
  .workspaceGrid { grid-template-columns: 1fr; }
  .insightRail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metricGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .appSidebar { position: static; width: auto; }
  .brand { padding: 20px 24px; }
  .appSidebar nav { display: flex; overflow-x: auto; padding: 10px 15px 14px; }
  .appSidebar nav a { flex: 0 0 auto; padding: 10px 12px; }
  .sidebarNotice { display: none; }
  .appCanvas { margin-left: 0; }
  .overviewBand { grid-template-columns: 1fr; }
  .overviewRule { padding: 16px 0 0; border-top: 1px solid rgba(255,255,255,.16); border-left: 0; }
}

@media (max-width: 680px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbarMeta { flex-wrap: wrap; }
  .mainContent { padding-inline: 14px; }
  .metricGrid { grid-template-columns: 1fr; }
  .filterBar { align-items: stretch; flex-direction: column; }
  .filterBar label { width: 100%; }
  .filterBar .quietButton { margin-left: 0; }
  .scheduleToolbar { align-items: stretch; flex-direction: column; }
  .viewTabs { overflow-x: auto; }
  .viewTabs button { flex: 0 0 auto; }
  .periodNavigator { flex-wrap: wrap; margin-left: 0; }
  .insightRail { grid-template-columns: 1fr; }
  .importPanel { grid-template-columns: 1fr; }
  .importControls { align-items: stretch; flex-direction: column; }
  .importPreview { grid-column: auto; }
  .formGrid { grid-template-columns: 1fr; }
  .formGrid .wide { grid-column: auto; }
  .workbenchTabs { flex-wrap: nowrap; overflow-x: auto; }
  .workbenchTabs button { flex: 0 0 auto; }
  .closurePane { padding: 15px; }
  .workCard { display: grid; gap: 12px; padding: 14px; }
  .workCard .primaryButton { width: 100%; }
  .closureDrawer fieldset { display: grid; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
