:root {
  --bg: #edf1f4;
  --surface: #ffffff;
  --surface-soft: #f7f9fb;
  --ink: #17202a;
  --muted: #64717f;
  --line: #cfd8e3;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --amber: #b45309;
  --blue: #1d4ed8;
  --danger: #b91c1c;
  --shadow: 0 14px 36px rgba(24, 34, 48, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid transparent;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.side-nav {
  background: #17202a;
  color: #eef5f6;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: #0f766e;
  color: #fff;
  font-weight: 700;
  border-radius: 6px;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.brand p,
.side-meta,
.panel-head p,
#viewSubTitle,
.phone-status,
.empty {
  color: var(--muted);
}

.brand p {
  margin: 4px 0 0;
  color: #aac1c7;
  font-size: 13px;
}

.side-nav nav {
  display: grid;
  gap: 8px;
}

.nav-button {
  width: 100%;
  padding: 11px 12px;
  background: transparent;
  color: #d9e4e8;
  border-color: rgba(255, 255, 255, 0.12);
  text-align: left;
  border-radius: 6px;
}

.nav-button.active,
.nav-button:hover {
  background: #233241;
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.22);
}

.side-meta {
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: #b7c7cc;
  font-size: 13px;
  line-height: 1.7;
}

.workspace {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.topbar h2,
.panel h3 {
  margin: 0;
}

.topbar h2 {
  font-size: 24px;
}

#viewSubTitle,
.panel-head p {
  margin: 5px 0 0;
  font-size: 13px;
}

.top-actions,
.submit-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ai-drawer {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 50;
  width: min(420px, calc(100vw - 24px));
  height: min(720px, calc(100vh - 36px));
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 24px 70px rgba(20, 30, 42, 0.22);
  overflow: hidden;
}

.ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  background: #17202a;
  color: #fff;
}

.ai-head h3 {
  margin: 0;
}

.ai-head p {
  margin: 4px 0 0;
  color: #b7c7cc;
  font-size: 12px;
}

.ai-messages {
  overflow: auto;
  padding: 14px;
  background: #f4f7fa;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-message {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 8px;
  line-height: 1.55;
  white-space: pre-wrap;
  font-size: 14px;
}

.ai-message.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
}

.ai-message.assistant {
  align-self: flex-start;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.ai-message.pending {
  color: var(--muted);
  font-style: italic;
}

.ai-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.ai-input-row textarea {
  min-height: 64px;
  max-height: 140px;
}

.primary,
.secondary,
.tiny {
  min-height: 36px;
  padding: 8px 13px;
  border-radius: 6px;
}

.primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.primary:disabled,
.secondary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.secondary {
  background: #ffffff;
  color: var(--ink);
  border-color: var(--line);
}

.tiny {
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 16px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
}

.metric strong {
  display: block;
  font-size: 28px;
  line-height: 1;
  margin-bottom: 8px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-head.inline {
  margin: 16px 0 10px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.form-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 5px;
  color: #3d4b58;
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  border-radius: 6px;
  padding: 9px 10px;
  outline: none;
}

textarea {
  min-height: 76px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  vertical-align: top;
  text-align: left;
}

th {
  background: #eef5f6;
  color: #26323d;
  font-weight: 700;
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e6f3f1;
  color: #0f5f58;
  font-size: 12px;
  white-space: nowrap;
}

.tag.warn {
  background: #fff3e1;
  color: var(--amber);
}

.tag.blue {
  background: #e8f0ff;
  color: var(--blue);
}

.mobile-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
}

.phone-frame {
  background: #101820;
  border-radius: 28px;
  padding: 16px;
  min-height: 720px;
  box-shadow: var(--shadow);
}

.phone-status {
  display: flex;
  justify-content: space-between;
  color: #b9c8cf;
  padding: 4px 4px 12px;
}

.task-list {
  display: grid;
  gap: 10px;
}

.task-card {
  background: #f8fafc;
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.task-card.active {
  border-color: #27a79d;
}

.task-card h4 {
  margin: 0;
  font-size: 15px;
}

.task-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.mobile-detail {
  min-width: 0;
}

.hidden {
  display: none !important;
}

.mode-switch {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  margin-bottom: 14px;
  background: #edf3f6;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.mode-button {
  min-height: 34px;
  padding: 7px 13px;
  background: transparent;
  color: var(--ink);
  border-radius: 6px;
}

.mode-button.active {
  background: var(--accent);
  color: #fff;
}

.point-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.point-tab {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 6px;
  padding: 7px 10px;
}

.point-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.point-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-soft);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 8px;
  font-size: 12px;
  line-height: 1.35;
}

.check-item input {
  width: auto;
  margin-top: 2px;
}

.requirements-block {
  margin-top: 16px;
}

.requirement-list {
  display: grid;
  gap: 8px;
}

.requirement {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fff;
}

.requirement h4 {
  margin: 0 0 6px;
}

.requirement p {
  margin: 4px 0;
  color: #3d4b58;
  font-size: 13px;
}

.empty {
  padding: 24px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.sheet-edit-panel {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f2f4f7;
  padding: 12px;
}

.sheet-edit-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.editable-sheet {
  min-width: 1280px;
  padding: 18px;
  background: #fff;
  border: 1px solid #111;
  font-family: "SimSun", "Microsoft YaHei", serif;
}

.editable-sheet h2 {
  margin: 0 0 12px;
  text-align: center;
  font-size: 22px;
}

.editable-sheet-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid #111;
  border-left: 1px solid #111;
}

.editable-sheet-grid label {
  gap: 4px;
  min-height: 56px;
  padding: 6px;
  border-right: 1px solid #111;
  border-bottom: 1px solid #111;
  color: #111;
}

.editable-sheet-grid label.wide {
  grid-column: span 2;
}

.editable-sheet-grid.sign-grid {
  margin-top: 12px;
  grid-template-columns: 2fr 1fr 1fr;
}

.editable-sheet-grid span {
  font-weight: 700;
}

.editable-sheet input,
.editable-sheet select,
.editable-sheet textarea {
  border-color: #8da4b7;
  border-radius: 3px;
  padding: 6px 7px;
  font-size: 13px;
}

.editable-sheet-table-wrap {
  overflow: auto;
  margin-top: 12px;
}

.editable-sheet-table {
  min-width: 1600px;
  table-layout: fixed;
  font-size: 12px;
}

.editable-sheet-table th,
.editable-sheet-table td {
  border: 1px solid #111;
  padding: 5px;
  color: #111;
}

.editable-sheet-table th {
  background: #eef5f6;
  text-align: center;
}

.editable-sheet-table td:nth-child(1),
.editable-sheet-table td:nth-child(2) {
  width: 150px;
}

.editable-sheet-table td:nth-child(6) {
  width: 300px;
}

.editable-sheet-table textarea {
  min-height: 64px;
  margin-top: 5px;
  resize: vertical;
}

.editable-sheet-table tr.active-row td {
  background: #f0fdfa;
}

.print-document {
  background: #fff;
  color: #111;
  overflow: auto;
}

.live-preview-document {
  max-height: 620px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f2f4f7;
  padding: 12px;
}

.live-preview-document .record-sheet {
  transform: scale(0.72);
  transform-origin: top left;
  margin: 0 0 -140px;
}

.record-sheet {
  width: 1120px;
  margin: 0 auto 18px;
  padding: 18px;
  border: 1px solid #111;
  background: #fff;
  font-family: "SimSun", "Microsoft YaHei", serif;
}

.record-sheet h2 {
  margin: 0 0 12px;
  text-align: center;
  font-size: 22px;
}

.sheet-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid #111;
  border-left: 1px solid #111;
}

.sheet-grid div {
  min-height: 38px;
  padding: 8px;
  border-right: 1px solid #111;
  border-bottom: 1px solid #111;
}

.sheet-grid .wide {
  grid-column: span 2;
}

.sheet-grid .full {
  grid-column: 1 / -1;
}

.sheet-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 12px;
}

.sheet-table th,
.sheet-table td {
  border: 1px solid #111;
  padding: 6px;
  color: #111;
}

.sheet-foot {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 14px;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-nav {
    position: sticky;
    top: 0;
    z-index: 10;
  }

  .side-nav,
  .side-nav nav {
    display: flex;
    flex-direction: row;
    align-items: center;
  }

  .side-meta {
    display: none;
  }

  .metric-grid,
  .form-grid,
  .form-grid.compact,
  .checkbox-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mobile-layout {
    grid-template-columns: 1fr;
  }

  .phone-frame {
    min-height: auto;
    border-radius: 14px;
  }
}

@media (max-width: 680px) {
  .workspace {
    padding: 12px;
  }

  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .submit-row {
    justify-content: stretch;
  }

  .primary,
  .secondary {
    width: 100%;
  }

  .metric-grid,
  .form-grid,
  .form-grid.compact,
  .checkbox-grid {
    grid-template-columns: 1fr;
  }

  .brand h1 {
    font-size: 16px;
  }

  .side-nav {
    overflow-x: auto;
  }
}

@media print {
  body {
    background: #fff;
  }

  .side-nav,
  .topbar,
  #adminView,
  #mobileView,
  .panel-head,
  .top-actions {
    display: none !important;
  }

  .app-shell,
  .workspace,
  #printView,
  .panel,
  .view.active {
    display: block;
    padding: 0;
    margin: 0;
    border: 0;
    box-shadow: none;
  }

  .record-sheet {
    width: 100%;
    page-break-after: always;
    border: 0;
  }
}
