:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --sidebar: #202733;
  --sidebar-soft: #2c3545;
  --surface: #ffffff;
  --ink: #202733;
  --muted: #667085;
  --line: #d9dee7;
  --blue: #2764d8;
  --green: #167b57;
  --amber: #b35c00;
  --red: #c93434;
  --violet: #6945b8;
  --shadow: 0 18px 45px rgba(32, 39, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 26px 18px;
  background: var(--sidebar);
  color: white;
}

.brand h1,
.module-header h2,
.section-heading h3,
p {
  margin-top: 0;
}

.brand h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.12;
}

.eyebrow {
  margin: 0 0 8px;
  color: #8eb7ff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.module-nav {
  display: grid;
  gap: 10px;
}

.nav-group {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  width: 100%;
  min-height: 74px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: transparent;
  color: white;
  text-align: left;
}

.sub-nav {
  display: none;
  gap: 6px;
  padding-left: 54px;
}

.nav-group.expanded .sub-nav {
  display: grid;
}

.sub-nav-item {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.82);
  text-align: left;
}

.sub-nav-item.active,
.sub-nav-item:hover {
  color: white;
  border-color: rgba(142, 183, 255, 0.55);
  background: rgba(142, 183, 255, 0.18);
}

.nav-item.active,
.nav-item:hover {
  background: var(--sidebar-soft);
  border-color: rgba(142, 183, 255, 0.55);
}

.nav-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  color: #bcd4ff;
  font-weight: 800;
}

.nav-item strong,
.nav-item small {
  display: block;
}

.nav-item strong {
  margin-bottom: 4px;
}

.nav-item small {
  color: rgba(255, 255, 255, 0.68);
  line-height: 1.35;
}

.sidebar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: auto;
}

.sync-status {
  min-height: 34px;
  padding: 8px 10px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.08);
  font-size: 12px;
  line-height: 1.5;
}

.sync-status.is-saved {
  color: #c9f7df;
  background: rgba(22, 123, 87, 0.22);
}

.sync-status.is-error {
  color: #ffd2d2;
  background: rgba(201, 52, 52, 0.22);
}

.content {
  min-width: 0;
  padding: 28px;
}

.module {
  display: none;
}

.module.active {
  display: grid;
  gap: 18px;
}

#setupModule.active {
  grid-template-columns: minmax(0, 980px) minmax(280px, 360px);
  align-items: start;
  justify-content: center;
}

#setupModule .module-header {
  grid-column: 1 / -1;
  width: min(1360px, 100%);
}

#setupModule .form-panel {
  width: min(980px, 100%);
}

#setupModule .pending-panel {
  width: 100%;
  max-height: calc(100vh - 140px);
  overflow: auto;
}

.module-header,
.section-heading,
.form-row,
.filter-bar,
.card-title,
.detail-meta,
.stat-header {
  display: flex;
  align-items: center;
}

.module-header {
  justify-content: space-between;
  gap: 18px;
}

.module-header h2 {
  margin-bottom: 0;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.12;
}

.module-note {
  max-width: 420px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

.panel,
.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.form-panel,
.panel {
  padding: 18px;
}

.form-panel {
  display: grid;
  gap: 14px;
  max-width: 980px;
}

.compact-form {
  max-width: none;
}

.section-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-heading h3 {
  margin-bottom: 0;
  font-size: 18px;
}

label,
fieldset {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  padding: 0 0 7px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: white;
  color: var(--ink);
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(39, 100, 216, 0.14);
}

.form-row,
.filter-bar {
  gap: 12px;
}

.form-row > label {
  flex: 1;
}

.member-manager,
.member-picker,
.sku-grid {
  display: grid;
  gap: 10px;
}

.member-manager {
  grid-template-columns: minmax(0, 1fr) 120px;
}

.member-picker,
.sku-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.member-picker label {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fbfcfe;
}

.member-picker span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-picker input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.member-delete {
  min-width: 30px;
  min-height: 30px;
  border: 0;
  border-radius: 8px;
  color: var(--red);
  background: #fff0f0;
}

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

.metric {
  min-height: 116px;
  padding: 18px;
  text-align: left;
  position: relative;
  overflow: hidden;
}

.metric.clickable:hover {
  border-color: var(--blue);
  transform: translateY(-1px);
  transition: transform 0.16s ease, border-color 0.16s ease;
}

#dashboardModule .metric::after {
  content: "";
  position: absolute;
  right: -24px;
  bottom: -28px;
  width: 88px;
  height: 88px;
  border-radius: 999px;
  background: rgba(39, 100, 216, 0.08);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.metric strong {
  color: var(--ink);
  font-size: 34px;
}

.dashboard-grid {
  display: block;
}

.dashboard-stack,
.detail-panel {
  margin-top: 18px;
}

.dashboard-panel {
  border-color: #ccd7e8;
  background: linear-gradient(180deg, #ffffff, #f9fbfe);
}

#dashboardModule .section-heading {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

#dashboardModule .stats-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

#dashboardModule .owner-stat {
  min-height: 150px;
  border-color: #d7e2f2;
  background: linear-gradient(135deg, #ffffff, #f8fbff);
  box-shadow: 0 10px 28px rgba(32, 39, 51, 0.06);
}

#dashboardModule .owner-stat .stat-header {
  align-items: flex-start;
}

#dashboardModule .owner-stat .stat-header span:first-child {
  font-size: 18px;
}

#dashboardModule .detail-list {
  grid-template-columns: 1fr;
}

#dashboardModule .detail-card {
  min-height: 0;
  grid-template-columns: minmax(220px, 1fr) minmax(0, 2fr) 42px;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
}

#dashboardModule .detail-card .card-title {
  margin: 0;
}

#dashboardModule .detail-card .detail-meta {
  align-items: center;
  gap: 6px;
}

#dashboardModule .dashboard-card-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.sku-after-time {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-left: auto;
  justify-content: flex-end;
}

.sku-card-right {
  flex: 1 1 360px;
  min-width: 280px;
}

#dashboardModule .detail-card p {
  display: none;
}

#dashboardModule .detail-card > .detail-meta:last-child {
  justify-content: flex-end;
}

.title-with-edit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

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

.kanban-column {
  min-width: 0;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.column-title,
.stat-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-weight: 800;
}

.project-card,
.detail-card,
.owner-stat {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.detail-card {
  position: relative;
  overflow: hidden;
  border-left-width: 6px;
}

.detail-card.state-todo {
  border-left-color: var(--violet);
  background: linear-gradient(90deg, rgba(105, 69, 184, 0.1), #ffffff 34%);
}

.detail-card.state-doing {
  border-left-color: var(--blue);
  background: linear-gradient(90deg, rgba(39, 100, 216, 0.11), #ffffff 34%);
}

.detail-card.state-overdue {
  border-left-color: var(--red);
  background: linear-gradient(90deg, rgba(201, 52, 52, 0.12), #ffffff 34%);
  box-shadow: 0 14px 34px rgba(201, 52, 52, 0.12);
}

.detail-card.state-done {
  border-left-color: var(--green);
  background: linear-gradient(90deg, rgba(22, 123, 87, 0.1), #ffffff 34%);
}

.project-card {
  margin-bottom: 10px;
}

.pending-list {
  display: grid;
  gap: 10px;
}

.pending-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--violet);
  border-radius: 8px;
  background: white;
}

.assign-owner-control {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.assign-owner-control select {
  width: 100%;
}

.click-card {
  width: 100%;
  text-align: left;
}

.click-card:hover,
.owner-stat:hover {
  border-color: var(--blue);
}

.card-title {
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  font-weight: 800;
}

.overdue-star {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-right: 7px;
  border-radius: 999px;
  color: white;
  background: var(--red);
  font-size: 18px;
  line-height: 1;
  vertical-align: middle;
}

.collab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-right: 7px;
  border-radius: 999px;
  color: white;
  background: var(--blue);
  font-size: 12px;
  font-weight: 900;
  vertical-align: middle;
}

.detail-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.assistant-picker {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.assistant-picker select {
  min-height: 30px;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 12px;
}

.assistant-list {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.assistant-chip {
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid #cfe0ff;
  border-radius: 999px;
  color: #0f4ba8;
  background: #e8f1ff;
  font-size: 12px;
  font-weight: 800;
}

.assistant-chip:hover {
  color: var(--red);
  border-color: #ffc9c9;
  background: #fff0f0;
}

.action-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  color: white;
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(32, 39, 51, 0.14);
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

.action-pill span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  font-size: 12px;
}

.action-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(32, 39, 51, 0.18);
  filter: saturate(1.08);
}

.start-button {
  background: linear-gradient(135deg, #2764d8, #1f7ae0);
}

.complete-button {
  background: linear-gradient(135deg, #167b57, #1f9b6f);
}

.card-meta,
.detail-meta {
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.date-range {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--ink);
  background: #eef2f7;
  font-size: 15px;
  font-weight: 800;
}

.finish-time {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 600;
}

.count-pill,
.priority,
.status-pill,
.sku-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.count-pill {
  color: var(--muted);
  background: white;
  border: 1px solid var(--line);
}

.priority.high {
  color: white;
  background: var(--red);
}

.priority.medium {
  color: #5f3600;
  background: #ffe0ad;
}

.priority.low {
  color: white;
  background: var(--green);
}

.status-pill.todo {
  color: var(--violet);
  background: #eee9ff;
}

.status-pill.doing {
  color: #0f4ba8;
  background: #e3efff;
}

.status-pill.done {
  color: var(--green);
  background: #dff5ec;
}

.sku-pill {
  color: #0f4ba8;
  background: #e8f1ff;
}

.sku-label-editor {
  gap: 6px;
  padding: 3px 5px 3px 8px;
}

.sku-label-editor input {
  width: clamp(72px, 10vw, 132px);
  height: 22px;
  min-height: 0;
  padding: 0 6px;
  border: 1px solid rgba(15, 75, 168, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: #0f4ba8;
  font-size: 12px;
  font-weight: 800;
}

.sku-label-editor span {
  min-width: 18px;
  text-align: center;
}

.sku-quantity-editor {
  gap: 6px;
  padding-right: 5px;
}

.sku-quantity-editor input {
  width: 58px;
  height: 22px;
  min-height: 0;
  padding: 0 6px;
  border: 1px solid rgba(15, 75, 168, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: #0f4ba8;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.sku-quantity-editor .sku-other-label-input {
  width: clamp(72px, 9vw, 124px);
  text-align: left;
}

.sku-edit-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 2px;
}

.sku-readonly-row {
  opacity: 0.92;
}

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

.sku-stat-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff, #f7fbff);
}

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

.sku-stat-item {
  min-height: 70px;
  padding: 10px;
  border: 1px solid #dbe8fb;
  border-radius: 8px;
  background: white;
}

.sku-stat-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 7px;
}

.sku-stat-item strong {
  color: var(--ink);
  font-size: 24px;
}

.sku-inline {
  display: inline-grid;
  grid-template-columns: auto 64px;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 4px 7px 4px 10px;
  border: 1px solid #cfe0ff;
  border-radius: 999px;
  color: #0f4ba8;
  background: #e8f1ff;
  font-size: 12px;
  font-weight: 800;
}

.sku-inline-custom {
  grid-template-columns: minmax(92px, 140px) 64px;
}

.sku-inline input {
  height: 26px;
  min-height: 0;
  padding: 0 6px;
  border-color: #b8cdf5;
  border-radius: 999px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.sku-inline .sku-name-input {
  width: 100%;
  text-align: left;
}

.stats-list,
.detail-list {
  display: grid;
  gap: 12px;
}

.project-group {
  display: grid;
  gap: 10px;
}

.project-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 36px;
  padding: 0 4px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
}

.month-group {
  display: grid;
  gap: 10px;
  padding: 8px 0 2px;
}

.month-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 32px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.stat-numbers,
.sku-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.stat-numbers strong,
.sku-summary strong {
  display: block;
  color: var(--ink);
  font-size: 16px;
}

.detail-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.empty-state {
  padding: 18px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: white;
  text-align: center;
}

.ghost-button,
.text-button,
.primary-button {
  border: 0;
  border-radius: 8px;
  min-height: 40px;
}

.ghost-button {
  padding: 0 14px;
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
}

.ghost-button.danger {
  color: var(--red);
}

.text-button {
  padding: 0 8px;
  background: transparent;
  color: var(--blue);
}

.compact-edit-button {
  justify-self: end;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid #cfe0ff;
  border-radius: 8px;
  color: var(--blue);
  background: #eef5ff;
  font-size: 12px;
  font-weight: 800;
}

.compact-edit-button:hover {
  border-color: var(--blue);
  background: #e2efff;
}

.icon-delete-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: end;
  width: 32px;
  height: 32px;
  border: 1px solid #ffc9c9;
  border-radius: 8px;
  color: var(--red);
  background: #fff4f4;
}

.icon-delete-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-delete-button:hover {
  color: white;
  border-color: var(--red);
  background: var(--red);
}

.primary-button {
  width: 100%;
  padding: 0 18px;
  color: white;
  background: var(--blue);
  font-weight: 800;
}

.hidden {
  display: none;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 250px minmax(0, 1fr);
  }

  #setupModule.active {
    grid-template-columns: 1fr;
  }

  #setupModule .pending-panel {
    max-height: none;
  }

  .summary-grid,
  .dashboard-grid,
  #dashboardModule .stats-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 820px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .content {
    padding: 18px 12px;
  }

  .module-header,
  .section-heading,
  .form-row,
  .filter-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .summary-grid,
  .kanban,
  .member-manager,
  .member-picker,
  .sku-grid,
  .sku-stats-board,
  .sku-stat-grid,
  #dashboardModule .stats-list,
  #dashboardModule .detail-list,
  .stat-numbers,
  .sku-summary {
    grid-template-columns: 1fr;
  }

  #dashboardModule .detail-card {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  #dashboardModule .icon-delete-button {
    justify-self: end;
  }
}
