:root {
  --nav: #0f3558;
  --nav-deep: #0a2946;
  --nav-active: #1d5f99;
  --topbar: #eaf4ff;
  --bg: #f3f6fa;
  --panel: #ffffff;
  --panel-soft: #f8fbff;
  --line: #d8e2ee;
  --line-strong: #c7d5e5;
  --text: #172331;
  --muted: #637387;
  --primary: #1f6fbf;
  --primary-dark: #155896;
  --danger: #c83636;
  --warning: #b96b0c;
  --success: #16815a;
  --green-soft: #e9f7f0;
  --blue-soft: #e8f2ff;
  --orange-soft: #fff2df;
  --red-soft: #fff0ef;
  --gray-soft: #f1f4f8;
  --shadow: 0 8px 22px rgba(16, 38, 63, 0.08);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", Arial, sans-serif;
  font-size: 14px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(180deg, rgba(234, 244, 255, 0.85), rgba(243, 246, 250, 0.95)),
    repeating-linear-gradient(90deg, rgba(15, 53, 88, 0.05) 0, rgba(15, 53, 88, 0.05) 1px, transparent 1px, transparent 64px);
}

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 34px;
}

.login-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin-bottom: 18px;
  border-radius: 8px;
  background: var(--nav);
  color: #fff;
  font-weight: 800;
  letter-spacing: 1px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 25px;
  letter-spacing: 0;
}

.login-card p {
  margin: 0 0 26px;
  color: var(--muted);
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
}

.field label,
.label {
  color: #324457;
  font-weight: 600;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.textarea {
  min-height: 76px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 111, 191, 0.12);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.btn:hover {
  box-shadow: 0 2px 8px rgba(16, 38, 63, 0.08);
}

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn.primary:hover {
  background: var(--primary-dark);
}

.btn.secondary {
  border-color: var(--line-strong);
  background: #f8fbff;
  color: #23415f;
}

.btn.ghost {
  background: transparent;
  color: #214767;
}

.btn.danger {
  border-color: #ffd2d0;
  background: #fff7f6;
  color: var(--danger);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  box-shadow: none;
}

.btn.text-danger {
  padding: 4px 6px;
  min-height: 28px;
  background: transparent;
  color: var(--danger);
}

.btn.small {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}

.btn.full {
  width: 100%;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  padding: 0;
  font-weight: 700;
}

.shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  z-index: 30;
  top: 0;
  left: 0;
  bottom: 0;
  width: 226px;
  background: var(--nav);
  color: #dceaf8;
  display: flex;
  flex-direction: column;
}

.brand {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  background: var(--nav-deep);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-badge {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #ffffff;
  color: var(--nav);
  font-weight: 900;
}

.brand-title {
  min-width: 0;
}

.brand-title strong {
  display: block;
  color: #fff;
  font-size: 15px;
  white-space: nowrap;
}

.brand-title span {
  display: block;
  color: #aecaE8;
  font-size: 12px;
  margin-top: 2px;
}

.side-menu {
  display: grid;
  gap: 4px;
  padding: 14px 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  background: transparent;
  color: #dceaf8;
  text-align: left;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.nav-item.active {
  background: var(--nav-active);
  color: #fff;
  box-shadow: inset 3px 0 0 #7cc4ff;
}

.nav-icon {
  width: 20px;
  text-align: center;
  font-size: 15px;
}

.sidebar-foot {
  margin-top: auto;
  padding: 14px 16px 18px;
  color: #b9cee2;
  font-size: 12px;
  line-height: 1.6;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.topbar {
  position: fixed;
  z-index: 25;
  left: 226px;
  right: 0;
  top: 0;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 22px;
  background: var(--topbar);
  border-bottom: 1px solid #cfe0f0;
}

.topbar h2 {
  margin: 0;
  font-size: 19px;
  letter-spacing: 0;
}

.topbar-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid #cbddeb;
  background: rgba(255, 255, 255, 0.65);
  color: #24445f;
  font-weight: 700;
}

.content {
  margin-left: 226px;
  padding: 84px 20px 28px;
}

.page {
  display: grid;
  gap: 16px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.section-head h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.section-head p {
  margin: 0;
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.panel.pad {
  padding: 16px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-title h3,
.panel-title h4 {
  margin: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-left,
.toolbar-right,
.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 12px;
}

.filters.four {
  grid-template-columns: repeat(4, minmax(140px, 1fr));
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat-card {
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stat-card span {
  color: var(--muted);
  font-size: 12px;
}

.stat-card strong {
  display: block;
  margin-top: 5px;
  font-size: 22px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
  gap: 16px;
}

.donut-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  overflow: hidden;
  padding: 18px 10px 12px;
}

.donut {
  width: min(210px, 100%);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--success) calc(var(--done) * 1%), #f0ad4e 0 calc((var(--done) + var(--doing)) * 1%), #e05850 0 calc((var(--done) + var(--doing) + var(--issue)) * 1%), #d8e2ee 0);
  position: relative;
}

.donut::after {
  content: "";
  width: 64%;
  height: 64%;
  position: absolute;
  border-radius: 50%;
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--line);
}

.donut-content {
  position: relative;
  z-index: 1;
  text-align: center;
}

.donut-content strong {
  display: block;
  font-size: 32px;
}

.legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin-top: 14px;
  width: min(260px, 100%);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  background: var(--muted);
}

.dot.done {
  background: var(--success);
}

.dot.doing {
  background: #f0ad4e;
}

.dot.issue {
  background: #e05850;
}

.dot.wait {
  background: #b8c3d0;
}

.progress-list {
  display: grid;
  gap: 12px;
}

.dept-progress {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) 54px;
  align-items: center;
  gap: 12px;
}

.track {
  height: 10px;
  min-width: 0;
  overflow: hidden;
  border-radius: 99px;
  background: #e6edf5;
}

.track span {
  display: block;
  height: 100%;
  width: var(--value);
  background: var(--primary);
  border-radius: inherit;
}

.table-scroll {
  width: 100%;
  overflow: auto;
}

.table-scroll.tall {
  max-height: calc(100vh - 240px);
}

.data-table {
  width: 100%;
  min-width: 960px;
  border-collapse: separate;
  border-spacing: 0;
}

.data-table th,
.data-table td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #edf5fd;
  color: #24445f;
  font-weight: 800;
  white-space: nowrap;
}

.data-table tbody tr:hover td {
  background: #f7fbff;
}

.data-table td {
  background: #fff;
}

.data-table .nested-cell {
  padding: 0;
  background: #f8fbff;
}

.details-box {
  padding: 14px;
  background: #f8fbff;
  border-top: 1px solid var(--line);
}

.subtle {
  color: var(--muted);
}

.strong {
  font-weight: 800;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 5px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-badge.pending,
.status-select.pending {
  background: var(--gray-soft);
  color: #526070;
  border-color: #d9e1ea;
}

.status-badge.doing,
.status-select.doing {
  background: var(--blue-soft);
  color: #1d5f99;
  border-color: #bdd7f1;
}

.status-badge.done,
.status-select.done {
  background: var(--green-soft);
  color: var(--success);
  border-color: #bce2d2;
}

.status-badge.issue,
.status-select.issue {
  background: var(--red-soft);
  color: var(--danger);
  border-color: #ffc9c4;
}

.status-badge.rework,
.status-select.rework,
.status-badge.pause,
.status-select.pause,
.status-badge.risk {
  background: var(--orange-soft);
  color: var(--warning);
  border-color: #f4d1a2;
}

.status-badge.none,
.status-select.none {
  background: #f7f7f7;
  color: #8b949e;
  border-color: #e3e6ea;
}

.status-select {
  min-width: 86px;
  min-height: 30px;
  border-radius: 5px;
  padding: 4px 7px;
  border: 1px solid var(--line-strong);
  font-weight: 700;
}

.status-select:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.thumb {
  width: 56px;
  height: 42px;
  object-fit: cover;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: #f6f8fb;
}

.image-thumb-button {
  display: inline-flex;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
}

.image-thumb-button:hover .thumb {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 111, 191, 0.12);
}

.empty {
  padding: 30px 16px;
  color: var(--muted);
  text-align: center;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.flow-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.flow-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fbff;
  font-weight: 700;
}

.perm-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.modal-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(10, 25, 43, 0.45);
}

.modal {
  width: min(760px, 100%);
  max-height: calc(100vh - 44px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(10, 25, 43, 0.28);
}

.modal.small {
  width: min(440px, 100%);
}

.modal.wide {
  width: min(980px, 100%);
}

.modal.image-modal {
  width: min(980px, 100%);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #f8fbff;
}

.modal-head h3 {
  margin: 0;
  font-size: 17px;
}

.modal-body {
  padding: 16px;
  overflow: auto;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: #fafcff;
}

.close-x {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  font-size: 22px;
  color: #5a6775;
}

.close-x:hover {
  background: #eef4fb;
}

.image-preview {
  display: grid;
  gap: 12px;
}

.image-preview img {
  width: 100%;
  max-height: 68vh;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f6f8fb;
}

.image-preview div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.confirm-copy {
  display: grid;
  gap: 8px;
}

.confirm-copy strong {
  font-size: 16px;
}

.confirm-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.import-dropzone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 178px;
  padding: 20px;
  border: 1px dashed #9eb9d3;
  border-radius: 8px;
  background: #f8fbff;
  color: #30506d;
  text-align: center;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.import-dropzone:hover,
.import-dropzone.dragging {
  border-color: var(--primary);
  background: #eef6ff;
  box-shadow: inset 0 0 0 2px rgba(31, 111, 191, 0.08);
}

.import-dropzone.loading {
  cursor: progress;
  border-color: var(--primary);
  background: #eef6ff;
}

.import-plus {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
}

.import-dropzone span {
  color: var(--muted);
}

.import-errors {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #ffc9c4;
  border-radius: 6px;
  background: var(--red-soft);
  color: var(--danger);
  font-weight: 700;
}

.import-preview-table {
  margin-top: 14px;
  max-height: 300px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 150;
  min-width: 240px;
  padding: 12px 14px;
  border-radius: 7px;
  background: #143959;
  color: #fff;
  box-shadow: 0 12px 30px rgba(10, 25, 43, 0.22);
}

.mobile-bottom-nav,
.more-sheet {
  display: none;
}

@media (max-width: 1100px) {
  .filters,
  .filters.four {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  body {
    font-size: 13px;
  }

  .sidebar {
    display: none;
  }

  .topbar {
    left: 0;
    height: 58px;
    padding: 0 12px;
  }

  .topbar h2 {
    font-size: 16px;
  }

  .topbar-sub {
    display: none;
  }

  .topbar-actions {
    gap: 6px;
  }

  .topbar-actions .btn.secondary {
    display: none;
  }

  .user-pill {
    min-height: 30px;
    padding: 0 8px;
  }

  .content {
    margin-left: 0;
    padding: 74px 10px 78px;
  }

  .section-head,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-title {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-left,
  .toolbar-right,
  .row-actions {
    width: 100%;
  }

  .toolbar-left .btn,
  .toolbar-right .btn {
    flex: 1;
  }

  .filters,
  .filters.four,
  .form-grid,
  .flow-grid,
  .perm-grid,
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-grid {
    gap: 12px;
  }

  .donut-wrap {
    padding: 12px 0 8px;
  }

  .donut {
    width: min(176px, 72vw);
    max-width: 100%;
    margin-inline: auto;
  }

  .donut-content strong {
    font-size: 26px;
  }

  .legend {
    grid-template-columns: repeat(2, max-content);
    justify-content: center;
    column-gap: 14px;
    row-gap: 8px;
    width: 100%;
    font-size: 12px;
  }

  .dept-progress {
    grid-template-columns: 68px minmax(0, 1fr) 42px;
    gap: 8px;
    font-size: 12px;
  }

  .track {
    height: 8px;
  }

  .panel.pad {
    padding: 12px;
  }

  .data-table {
    min-width: 900px;
  }

  .btn,
  .input,
  .select,
  .status-select {
    min-height: 40px;
  }

  .mobile-bottom-nav {
    position: fixed;
    z-index: 60;
    left: 0;
    right: 0;
    bottom: 0;
    height: 62px;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    border-top: 1px solid var(--line);
    background: #fff;
    box-shadow: 0 -8px 22px rgba(16, 38, 63, 0.08);
  }

  .mobile-nav-btn {
    border: 0;
    background: transparent;
    color: #42556a;
    font-size: 12px;
    font-weight: 700;
  }

  .mobile-nav-btn.active {
    color: var(--primary);
    background: #eef6ff;
  }

  .more-sheet {
    position: fixed;
    z-index: 90;
    left: 10px;
    right: 10px;
    bottom: 74px;
    display: none;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 16px 48px rgba(10, 25, 43, 0.22);
  }

  .more-sheet.open {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .modal-backdrop {
    z-index: 120;
    align-items: flex-end;
    padding: 10px;
  }

  .modal {
    max-height: calc(100vh - 26px);
  }

  .toast {
    left: 10px;
    right: 10px;
    bottom: 74px;
  }
}
