/* GQWORK operate-mode refresh: task scanning and state recognition first. */
:root {
  --work-navy: #11223f;
  --work-navy-2: #172e55;
  --work-blue: #2e68d7;
  --work-blue-soft: #eaf1ff;
  --work-ink: #15233b;
  --work-muted: #73829a;
  --work-line: #dfe7f1;
  --work-canvas: #f2f5fa;
  --work-surface: #ffffff;
}

body { color: var(--work-ink); background: var(--work-canvas); }
.app { grid-template-columns: 252px minmax(0, 1fr); }

aside {
  padding: 25px 14px 19px;
  background: var(--work-navy);
  box-shadow: 12px 0 28px rgba(16, 34, 63, .12);
}
.logo { padding: 4px 11px 27px; }
.logo strong { font-size: 18px; letter-spacing: .02em; }
.logo small { margin-top: 4px; color: #91a3c3; font-size: 11px; letter-spacing: .05em; }
.brand-mark.small { gap: 5px; }
.brand-mark.small span { width: 10px; height: 10px; }
.nav-group-label { margin: 19px 11px 7px; color: #7690bb; font-size: 11px; font-weight: 700; letter-spacing: .08em; }
nav { gap: 3px; }
nav button {
  display: flex; align-items: center; gap: 11px; min-height: 42px;
  border-radius: 8px; padding: 10px 12px; color: #b7c5dc; font-weight: 600;
}
nav button::before { display: none; }
nav button svg { width: 17px; height: 17px; flex: 0 0 17px; color: #90a6ce; }
nav button:hover { color: #fff; background: #1c3966; box-shadow: none; }
nav button.active { color: #fff; background: var(--work-blue); box-shadow: 0 8px 18px rgba(0, 0, 0, .18); }
nav button.active svg { color: #fff; }
.aside-bottom { margin: 18px 7px 0; padding: 16px 4px 0; border-top-color: rgba(174, 195, 229, .20); }
.aside-bottom button { color: #bbcae1; }

main { padding: 34px 42px 48px; overflow: visible; }
main::before, main::after { display: none; }
.workbench-header {
  align-items: flex-end; min-height: 94px; margin: 0 0 26px;
  border-bottom: 1px solid var(--work-line); padding: 0 0 21px;
}
header h1 { color: var(--work-ink); margin-bottom: 8px; font-size: 32px; font-weight: 800; letter-spacing: -.035em; }
header p { color: var(--work-muted); font-size: 14px; font-weight: 600; }
.primary {
  border: 1px solid transparent; border-radius: 8px; padding: 11px 18px;
  background: var(--work-blue); box-shadow: 0 8px 16px rgba(46, 104, 215, .22);
}
.primary:not(:disabled):hover { background: #235ac5; box-shadow: 0 10px 19px rgba(35, 90, 197, .26); }

.stats { grid-template-columns: 1.38fr repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 27px; }
.stats article {
  min-height: 132px; border: 1px solid var(--work-line); border-radius: 12px;
  padding: 20px; background: var(--work-surface); box-shadow: 0 8px 20px rgba(23, 43, 76, .06);
}
.stats article::before { right: 20px; left: 20px; height: 3px; background: #b9c8df; }
.stats article:nth-child(2)::before { background: #d69b2d; }
.stats article:nth-child(3)::before { background: #1f9a70; }
.stats article:nth-child(4)::before { background: #d65b67; }
.stats span { color: #62748f; font-size: 13px; font-weight: 700; }
.stats strong { margin-top: 14px; color: var(--work-ink); font-size: 38px; font-weight: 800; letter-spacing: -.04em; }
.stats i { display: none; }
.stats .primary-stat { border-color: var(--work-navy); background: var(--work-navy); box-shadow: 0 14px 28px rgba(17, 34, 63, .24); }
.stats .primary-stat::before { background: #76a3ff; }
.stats .primary-stat span { color: #b7c9e8; }
.stats .primary-stat strong { color: #fff; font-size: 42px; }

.panel { border: 1px solid var(--work-line); border-radius: 12px; background: var(--work-surface); box-shadow: 0 10px 25px rgba(23, 43, 76, .07); }
.task-panel { overflow: hidden; }
.panel-heading { display: flex; align-items: center; min-height: 82px; padding: 17px 21px; border-bottom: 1px solid var(--work-line); background: #fbfcff; }
.panel-heading h2 { margin: 0 0 5px; color: var(--work-ink); font-size: 18px; line-height: 1.2; letter-spacing: -.02em; }
.panel-heading p { margin: 0; color: var(--work-muted); font-size: 13px; }
.toolbar { padding: 13px 17px; border-bottom-color: var(--work-line); background: #fff; }
.filters { gap: 4px; }
.filters button { border-radius: 7px; padding: 8px 12px; color: #667791; font-weight: 700; }
.filters button.active { color: #1f58c6; background: var(--work-blue-soft); box-shadow: inset 0 0 0 1px #d3e1ff; }
.filters button:not(.active):hover { color: #1f58c6; background: #f0f4fb; }
.search { width: 298px; border-color: #d5e0ee; border-radius: 7px; padding: 10px 13px; background: #fbfcfe; }
.search:focus { border-color: #6691eb; box-shadow: 0 0 0 3px rgba(46, 104, 215, .12); }

th { padding: 14px 19px; color: #667791; background: #f4f7fb; font-size: 11px; font-weight: 800; letter-spacing: .05em; }
td { padding: 17px 19px; border-top-color: #e8eef5; }
tbody tr { transition: background .16s ease; }
tbody tr:hover { background: #f5f8fe; }
th, td, .stats strong { font-variant-numeric: tabular-nums; }
.badge { border-radius: 6px; padding: 6px 9px; font-weight: 800; letter-spacing: .01em; }
.more { border-color: #d5e0ee; border-radius: 7px; padding: 7px 11px; color: #405572; font-weight: 700; }
.more:hover { border-color: #9ab7ed; color: #1f58c6; background: #f5f8fe; box-shadow: none; }
#taskRows tr.row-in-progress td { background: #f1faf6; border-top-color: #dcefe6; }
#taskRows tr.row-in-progress:hover td { background: #e9f7f0; }
#taskRows tr.row-partially-shipped td { background: #fff9eb; border-top-color: #f2e7c7; }
#taskRows tr.row-partially-shipped:hover td { background: #fff4d9; }
#taskRows tr.row-shipped-complete td { background: #fafbfc; }

::selection { color: #fff; background: var(--work-blue); }
*:focus-visible { outline: 3px solid rgba(46, 104, 215, .35); outline-offset: 2px; }

@media (max-width: 1120px) {
  .app { grid-template-columns: 226px minmax(0, 1fr); }
  main { padding: 30px 26px 40px; }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stats .primary-stat strong { font-size: 38px; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  aside { padding: 14px 16px; }
  main { padding: 24px 16px 34px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .workbench-header { min-height: 0; align-items: flex-start; padding-bottom: 17px; }
  header h1 { font-size: 26px; }
  .stats article { min-height: 108px; padding: 16px; }
  .stats strong, .stats .primary-stat strong { font-size: 31px; }
  .panel-heading { min-height: 72px; padding: 15px; }
  .toolbar { align-items: stretch; padding: 12px; }
  .search { width: 100%; }
}

/* Phone layout: keep navigation thumb-friendly and turn the task list into cards. */
@media (max-width: 680px) {
  aside {
    display: block;
    position: sticky;
    height: auto;
    min-height: 0;
    padding: max(10px, env(safe-area-inset-top)) 12px 8px;
    background: var(--work-navy);
  }
  .logo { min-height: 42px; padding: 2px 82px 2px 4px; }
  .logo strong { font-size: 17px; }
  .logo small { display: none; }
  .nav-group-label { display: none; }
  nav {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 54px;
    margin: 7px -12px -8px;
    padding: 6px 12px 8px;
    border-top: 1px solid rgba(174, 195, 229, .18);
    border-bottom: 0;
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }
  nav button { flex: 0 0 auto; min-height: 40px; padding: 9px 11px; }
  nav button svg { width: 16px; height: 16px; }
  .aside-bottom {
    position: absolute;
    top: max(10px, env(safe-area-inset-top));
    right: 12px;
    display: block;
    margin: 0;
    padding: 0;
    border: 0;
  }
  .aside-bottom span { display: none; }
  .aside-bottom button { min-height: 38px; padding: 7px 4px; }

  main { min-height: calc(100dvh - 108px); padding: 16px 12px max(30px, env(safe-area-inset-bottom)); }
  .workbench-header { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 0; margin-bottom: 16px; padding-bottom: 14px; }
  .workbench-header > div { min-width: 0; }
  header h1 { margin-bottom: 5px; font-size: 23px; line-height: 1.2; }
  header p { font-size: 12px; }
  header .primary { width: auto; min-height: 42px; padding: 9px 12px; white-space: nowrap; }

  .stats { gap: 9px; margin-bottom: 16px; }
  .stats article, .stats .primary-stat { grid-column: auto; min-height: 94px; padding: 14px; border-radius: 10px; }
  .stats strong, .stats .primary-stat strong { margin-top: 8px; font-size: 29px; }

  .panel { border-radius: 10px; }
  .panel-heading { min-height: 74px; padding: 15px; }
  .panel-heading h2 { font-size: 17px; }
  .panel-heading p { line-height: 1.45; }
  .toolbar { flex-direction: column; align-items: stretch; gap: 11px; padding: 11px; }
  .filters { width: 100%; padding-bottom: 2px; }
  .filters button { min-height: 42px; padding: 9px 12px; }
  .search { width: 100%; min-height: 46px; }

  .task-panel .table-wrap { overflow: visible; }
  .task-panel .table-wrap::after { display: none; }
  .task-panel table { display: block; min-width: 0; }
  .task-panel thead { display: none; }
  .task-panel tbody { display: grid; gap: 10px; padding: 10px; }
  .task-panel tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0 12px;
    overflow: hidden;
    border: 1px solid var(--work-line);
    border-radius: 9px;
    background: #fff;
  }
  .task-panel tbody tr:hover { background: #fff; }
  .task-panel td { display: none; border: 0; padding: 0; }
  .task-panel td:nth-child(1), .task-panel td:nth-child(2), .task-panel td:nth-child(3),
  .task-panel td:nth-child(4), .task-panel td:nth-child(6), .task-panel td:nth-child(8) { display: block; }
  .task-panel td:nth-child(1) {
    grid-column: 1 / -1;
    padding: 13px 13px 4px;
    color: var(--work-ink);
    font-size: 14px;
    font-weight: 800;
  }
  .task-panel td:nth-child(2) { grid-column: 1 / -1; padding: 2px 13px 10px; }
  .task-panel td:nth-child(3), .task-panel td:nth-child(4) {
    padding: 10px 13px;
    border-top: 1px solid #edf1f6;
    color: #53657f;
    font-size: 12px;
  }
  .task-panel td:nth-child(3)::before { content: "数量 "; color: #8492a7; }
  .task-panel td:nth-child(4)::before { content: "交期 "; color: #8492a7; }
  .task-panel td:nth-child(6) { align-self: center; padding: 10px 0 10px 13px; border-top: 1px solid #edf1f6; }
  .task-panel td:nth-child(8) { padding: 8px 13px 8px 0; border-top: 1px solid #edf1f6; }
  .task-panel .task-actions { justify-content: flex-end; }
  .task-panel .more { min-height: 40px; padding: 7px 12px; }
  #taskRows tr.row-in-progress td, #taskRows tr.row-partially-shipped td, #taskRows tr.row-shipped-complete td { background: transparent; }
  #taskRows tr.row-in-progress { border-color: #cce9da; background: #f2faf6; }
  #taskRows tr.row-partially-shipped { border-color: #f0dfb4; background: #fff9eb; }

  .dialog-actions { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}

@media (max-width: 380px) {
  .task-panel td:nth-child(3), .task-panel td:nth-child(4) { font-size: 11px; padding-right: 9px; padding-left: 9px; }
  .task-panel td:nth-child(6) { padding-left: 9px; }
  .task-panel td:nth-child(8) { padding-right: 9px; }
}

@media (pointer: coarse) {
  .more, .filters button, nav button { -webkit-tap-highlight-color: transparent; }
  .more:active, .filters button:active, nav button:active { filter: brightness(.94); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
