
/* ===== 原版复刻界面样式 ===== */

/* 整体外壳 */
.legacy-shell {
  min-height: 100vh;
  background: #b6b6b6;
  color: #000;
  font-family: 'SimSun','Microsoft YaHei',Arial,sans-serif;
  font-size: 12px;
}

/* 顶部程序栏 */
.legacy-programbar {
  height: 22px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
  background: linear-gradient(#eaf4ff, #b8d6ee);
  border-bottom: 1px solid #7f9db9;
}
.legacy-logo {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

/* 顶部菜单栏 */
.legacy-menu {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  height: 24px;
  background: #eee;
  border-bottom: 1px solid #a0a0a0;
  overflow: visible;
}
.menu-root {
  position: relative;
  display: inline-block;
}
.legacy-menu button {
  min-height: 22px;
  height: 22px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0 8px;
  font-size: 12px;
  cursor: pointer;
}
.legacy-menu button:hover {
  background: #dceaf7;
  outline: 1px solid #7f9db9;
}

/* 子菜单默认隐藏 */
.submenu {
  display: none;
  position: absolute;
  left: 0;
  top: 100%;
  min-width: 150px;
  background: #f2f2f2;
  border: 1px solid #808080;
  box-shadow: 2px 2px 4px rgba(0,0,0,0.25);
  padding: 2px 0;
  z-index: 1000;
}
.menu-root:hover > .submenu,
.menu-root:focus-within > .submenu {
  display: block;
}
.submenu-item {
  position: relative;
  display: block;
}
.submenu-item > button {
  width: 100%;
  text-align: left;
  white-space: nowrap;
}
.submenu.nested {
  left: 100%;
  top: 0;
}
.submenu-item:hover > .submenu.nested,
.submenu-item:focus-within > .submenu.nested {
  display: block;
}

/* 公司名 */
.legacy-company {
  height: 48px;
  padding: 10px 10px 0;
  color: #000;
  font-family: 'KaiTi','STKaiti','SimSun',serif;
  font-size: 28px;
  font-style: italic;
  font-weight: 700;
  background: #eee;
  border-bottom: 1px solid #8a8a8a;
}

/* 工作区 */
.legacy-workspace {
  position: relative;
  min-height: calc(100vh - 94px);
  padding: 0;
  background: #b6b6b6;
  overflow: hidden;
}

/* 桌面窗口 */
.mdi-window {
  position: absolute;
  left: 4px;
  top: 4px;
  right: 4px;
  bottom: 4px;
  background: #fff;
  border: 1px solid #8a8a8a;
  overflow: auto;
}
.desktop-window {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 12px;
  padding: 16px;
}
.desktop-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.desktop-grid button {
  width: 80px;
  height: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid #ccc;
  background: #fafafa;
  cursor: pointer;
  font-size: 11px;
  color: #000;
}
.desktop-grid button:hover {
  background: #dceaf7;
  border-color: #7f9db9;
}

/* 登录窗口 */
.login-shell {
  background: #b6b6b6;
  min-height: 100vh;
}
.legacy-login-dialog {
  position: absolute;
  left: 8px;
  top: 12px;
  width: 395px;
  background: #efefef;
  border: 1px solid #7f9db9;
  box-shadow: 1px 1px 0 #777;
}
.dialog-title {
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(#d6ebff, #a9c9e6);
  border-bottom: 1px solid #7f9db9;
  padding: 0 8px;
}
.dialog-body {
  margin: 32px 28px 24px;
  padding: 24px 34px 12px;
  border: 1px solid #bcbcbc;
  background: #f4f4f4;
}
.login-field {
  display: grid;
  grid-template-columns: 70px 136px auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.login-field label {
  display: block;
  color: #000;
  text-align: right;
}
.login-field input {
  width: 136px;
  min-height: 21px;
  height: 21px;
  border: 1px solid #7f9db9;
  border-radius: 0;
  padding: 1px 4px;
}
.login-field button {
  min-height: 24px;
  height: 24px;
  padding: 0 14px;
}
.legacy-login-hint {
  font-size: 11px;
  color: #666;
  text-align: center;
  margin-top: 8px;
}

/* 经典窗口 */
.classic-window {
  background: #fff;
  border: 1px solid #8a8a8a;
}
.classic-titlebar {
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(#d6ebff, #a9c9e6);
  padding: 0 8px;
  border-bottom: 1px solid #7f9db9;
}

:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #eef2ef;
  --line: #cfd7d2;
  --ink: #16211d;
  --muted: #65736d;
  --primary: #12634d;
  --primary-2: #0d4d3d;
  --danger: #a2352f;
  --focus: #2a6f9e;
  --warn: #b07722;
  --shadow: 0 12px 30px rgba(21, 34, 30, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

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

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

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  min-height: 34px;
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  border-color: var(--primary);
}

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

button.primary:hover {
  background: var(--primary-2);
}

button.danger {
  border-color: #d8b3af;
  color: var(--danger);
}

button.ghost {
  background: transparent;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  min-height: 34px;
  padding: 6px 9px;
}

input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus {
  outline: 2px solid color-mix(in srgb, var(--focus) 25%, transparent);
  outline-offset: 1px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 700;
}

h2 {
  font-size: 16px;
}

.hidden {
  display: none !important;
}

.eyebrow {
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hint {
  color: var(--muted);
  font-size: 12px;
}

.error-line {
  color: var(--danger);
  min-height: 18px;
}

.login-screen {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(18, 99, 77, 0.08), transparent 45%),
    var(--bg);
}

.login-box {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.app {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  gap: 18px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand-block {
  display: grid;
  gap: 2px;
}

.brand-company {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.1;
  color: #0f5a45;
}

.brand-subtitle {
  font-size: 13px;
  color: var(--muted);
}

.tabs {
  display: inline-flex;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px;
}

.tabs button {
  min-width: 76px;
  border-color: transparent;
  background: transparent;
}

.tabs button.active {
  background: var(--surface);
  border-color: var(--line);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.user-area {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

main {
  padding: 18px 20px 28px;
}

.toolbar,
.order-list,
.order-editor,
.directory-form,
.settings-form,
.backup-panel,
.directory-layout > div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: end;
  padding: 14px;
  margin-bottom: 14px;
}

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

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.orders-layout {
  display: grid;
  grid-template-columns: minmax(420px, 0.72fr) minmax(720px, 1.28fr);
  gap: 14px;
  align-items: start;
}

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

.section-head span {
  color: var(--muted);
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid #e7ece8;
  padding: 8px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  color: #41514a;
  background: #f1f4f2;
  font-size: 12px;
  font-weight: 700;
}

tr.selected {
  background: #e8f4ef;
}

tr.clickable {
  cursor: pointer;
}

.compact-list {
  max-height: calc(100vh - 236px);
}

.order-editor {
  padding-bottom: 14px;
}

.order-editor > .form-grid,
.order-editor > .wide-label {
  margin: 14px;
}

.wide-label {
  display: grid;
  gap: 6px;
}

.item-head {
  border-top: 1px solid var(--line);
}

.item-table {
  margin: 0 14px;
  width: calc(100% - 28px);
  border: 1px solid var(--line);
  border-radius: 7px;
  max-height: 44vh;
}

.item-table table {
  min-width: 1540px;
}

.item-table input,
.item-table select {
  min-width: 80px;
  border-color: #dde4df;
  min-height: 30px;
  padding: 4px 6px;
}

.item-table select {
  appearance: auto;
  -webkit-appearance: menulist;
  pointer-events: auto;
  cursor: pointer;
  position: relative;
  z-index: 2;
  background: #fff;
}

.item-table textarea {
  min-width: 150px;
  min-height: 30px;
}

.item-table .small {
  min-width: 56px;
}

.item-table .style-input {
  min-width: 150px;
}

.row-actions {
  display: flex;
  gap: 4px;
}

.image-chip {
  display: grid;
  grid-template-columns: 44px 88px;
  gap: 5px;
  align-items: center;
}

.thumb {
  width: 44px;
  height: 34px;
  border: 1px solid var(--line);
  object-fit: cover;
  background: #f6f6f6;
}

.totals {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 18px;
  padding: 12px 14px 0;
  color: var(--muted);
}

.totals strong {
  color: var(--ink);
}

.directory-layout {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) 420px;
  gap: 14px;
  align-items: start;
}

.directory-form {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.directory-form .form-grid,
.settings-form .form-grid {
  grid-template-columns: repeat(2, minmax(160px, 1fr));
}

.settings-layout {
  display: grid;
  grid-template-columns: minmax(640px, 1fr) 360px;
  gap: 14px;
  align-items: start;
}

.settings-form {
  padding-bottom: 14px;
}

.settings-form .form-grid {
  padding: 14px;
}

.backup-panel {
  padding: 14px;
  display: grid;
  gap: 14px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #1f2e29;
  color: #fff;
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
  z-index: 100;
}

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

@media (max-width: 1200px) {
  .app-header,
  .toolbar,
  .orders-layout,
  .directory-layout,
  .settings-layout {
    grid-template-columns: 1fr;
  }

  .tabs,
  .user-area {
    justify-self: start;
  }

  .filter-grid,
  .form-grid {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }
}

@media (max-width: 680px) {
  main,
  .app-header {
    padding-left: 12px;
    padding-right: 12px;
  }

  .brand-company {
    font-size: 24px;
  }

  .filter-grid,
  .form-grid,
  .directory-form .form-grid,
  .settings-form .form-grid {
    grid-template-columns: 1fr;
  }

  .tabs {
    width: 100%;
    overflow-x: auto;
  }
}

/* Classic order-entry surface modeled after the original desktop program. */
body {
  background: #b6b6b6;
  font-family: "SimSun", "Microsoft YaHei", Arial, sans-serif;
  font-size: 12px;
}

button,
input,
select,
textarea {
  border-radius: 0;
}

.app-header {
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  padding: 3px 8px 0;
  border-bottom: 1px solid #7f9db9;
  background: linear-gradient(#f8fbff, #d8e8f6);
}

.brand-company {
  color: #000;
  font-family: "STKaiti", "KaiTi", "SimSun", serif;
  font-size: 28px;
  font-style: italic;
  font-weight: 700;
}

.brand-subtitle {
  display: none;
}

.tabs {
  border: 0;
  border-radius: 0;
  background: transparent;
  gap: 0;
  padding: 0;
}

.tabs button {
  min-width: auto;
  min-height: 24px;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  padding: 0 8px;
}

.tabs button.active,
.tabs button:hover {
  border-color: #7f9db9;
  background: #eef5fb;
  box-shadow: none;
}

.user-area {
  color: #1d1d1d;
}

main {
  padding: 0;
}

.classic-window {
  background: #efefef;
  border-top: 1px solid #91b4d8;
  min-height: calc(100vh - 42px);
}

.classic-titlebar {
  height: 28px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 7px;
  background: linear-gradient(#d6ebff, #a9c9e6);
  border-bottom: 1px solid #7f9db9;
  color: #000;
  font-size: 13px;
  font-weight: 700;
}

.classic-titlebar::before {
  content: none;
  display: none;
}

#classicStats {
  font-weight: 400;
}

.classic-toolbar {
  height: 26px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px;
  border-bottom: 1px solid #c5c5c5;
  background: #f4f4f4;
  overflow-x: auto;
}

.classic-toolbar button {
  min-height: 21px;
  border: 0;
  background: transparent;
  padding: 0 6px;
  color: #111;
}

.classic-toolbar button:hover {
  background: #dceaf7;
  outline: 1px solid #7f9db9;
}

.classic-toolbar button::first-letter {
  color: #044bc0;
  font-weight: 700;
}

.classic-top {
  display: grid;
  grid-template-columns: 420px minmax(620px, 1fr);
  gap: 6px;
  padding: 6px;
  border-bottom: 1px solid #a5a5a5;
}

.classic-form-panel,
.classic-list-panel {
  border: 1px solid #9f9f9f;
  background: #f2f2f2;
}

.classic-form-panel {
  padding: 18px 12px 12px;
}

.classic-form-row {
  display: grid;
  grid-template-columns: 58px minmax(96px, 1fr) 58px minmax(96px, 1fr);
  align-items: center;
  gap: 7px 8px;
  margin-bottom: 8px;
}

.classic-form-row label {
  display: block;
  color: #111;
  font-size: 12px;
  text-align: right;
}

.classic-note-row {
  grid-template-columns: 58px 1fr;
}

.classic-note-row textarea {
  grid-column: 2 / -1;
  height: 66px;
}

.classic-form-panel input,
.classic-form-panel select,
.classic-form-panel textarea,
.classic-filter-row input,
.classic-filter-row select {
  min-height: 20px;
  height: 22px;
  border: 1px solid #7f9db9;
  background: #fff;
  padding: 1px 4px;
  font-size: 12px;
}

.classic-form-panel textarea {
  height: auto;
}

.classic-attach {
  display: block;
  width: 122px;
  min-height: 22px;
  margin: 4px 0 0 58px;
  border: 1px solid #9f9f9f;
  background: linear-gradient(#fbfbfb, #dfdfdf);
  color: #555;
}

.classic-list-panel {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-width: 0;
}

.classic-filter-row {
  display: grid;
  grid-template-columns: auto 106px 106px auto minmax(96px, 150px) minmax(96px, 150px) 66px 52px 88px;
  gap: 4px;
  align-items: center;
  padding: 5px;
  white-space: nowrap;
}

.classic-filter-row span {
  color: #111;
}

.classic-filter-row button,
.classic-list-total {
  min-height: 22px;
  border: 1px solid #aaa;
  background: linear-gradient(#fafafa, #e0e0e0);
  padding: 1px 9px;
}

.classic-list-table {
  height: 198px;
  background: #fff;
}

.classic-list-table table,
.classic-item-table table {
  table-layout: auto;
}

.classic-list-table th,
.classic-list-table td,
.classic-item-table th,
.classic-item-table td {
  border: 1px solid #dedede;
  padding: 2px 4px;
  height: 19px;
  color: #111;
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
}

.classic-list-table th,
.classic-item-table th {
  border-color: #808080;
  background: #efefef;
  text-align: center;
}

.classic-list-table tr.selected,
.classic-item-table tr.selected {
  background: #e6f0ff;
}

.classic-list-total {
  border-width: 1px 0 0;
  background: #f2f2f2;
}

.classic-detail {
  padding: 5px 6px 8px;
}

.classic-item-table {
  margin: 0;
  width: 100%;
  max-height: calc(100vh - 344px);
  min-height: 380px;
  border: 1px solid #8a8a8a;
  border-radius: 0;
  background: #fff;
}

.classic-item-table table {
  min-width: 1800px;
}

.classic-item-table td:first-child {
  background: #f3f3f3;
  text-align: center;
}

.classic-item-table input,
.classic-item-table select,
.classic-item-table textarea {
  width: 100%;
  min-width: 0;
  min-height: 20px;
  height: 20px;
  border: 0;
  background: transparent;
  padding: 1px 3px;
  font-size: 12px;
}

.classic-item-table textarea {
  height: 20px;
  resize: none;
}

.classic-item-table .small {
  min-width: 52px;
}

.classic-item-table .style-input,
.classic-item-table .item-code-input,
.classic-item-table .customer-order-input {
  min-width: 116px;
}

.classic-item-table .image-chip {
  grid-template-columns: 34px 78px;
}

.classic-item-table .thumb {
  width: 32px;
  height: 22px;
}

.classic-item-table button[data-action="remove"] {
  min-height: 18px;
  padding: 0 5px;
  border: 1px solid #aaa;
  background: #eee;
}

.classic-totals {
  justify-content: flex-start;
  gap: 18px;
  padding: 4px 2px 0;
  color: #111;
}

.toast {
  border-radius: 0;
}

@media (max-width: 1100px) {
  .classic-top {
    grid-template-columns: 1fr;
  }

  .classic-filter-row {
    grid-template-columns: repeat(4, minmax(80px, 1fr));
  }

  .classic-item-table {
    max-height: 52vh;
  }
}

/* Legacy desktop shell rescue styles.
   Keep this block focused on the original-program shell only; business and print
   pages use the classic-* rules above. */
.legacy-shell {
  min-height: 100vh;
  background: #b6b6b6;
  color: #000;
  font-family: "SimSun", "Microsoft YaHei", Arial, sans-serif;
  font-size: 12px;
}

.legacy-shell.app {
  display: block;
}

.legacy-programbar {
  height: 22px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
  background: linear-gradient(#eaf4ff, #b8d6ee);
  border-bottom: 1px solid #7f9db9;
  color: #000;
  line-height: 22px;
}

.legacy-logo {
  width: 18px;
  height: 18px;
  object-fit: contain;
  flex: 0 0 18px;
}

.legacy-menu {
  position: relative;
  z-index: 50;
  display: flex;
  align-items: center;
  height: 24px;
  gap: 0;
  overflow: visible;
  background: #eeeeee;
  border: 0;
  border-bottom: 1px solid #a0a0a0;
  border-radius: 0;
  padding: 0;
}

.legacy-menu button {
  min-width: auto;
  min-height: 22px;
  height: 22px;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #000;
  padding: 0 8px;
  font-size: 12px;
  line-height: 20px;
  white-space: nowrap;
  box-shadow: none;
}

.legacy-menu button:hover,
.legacy-menu button:focus {
  border-color: #7f9db9;
  background: #dceaf7;
  outline: 0;
}

.menu-root,
.submenu-item {
  position: relative;
  display: block;
}

.menu-root {
  display: inline-block;
}

.submenu {
  display: none;
  position: absolute;
  left: 0;
  top: 100%;
  min-width: 152px;
  padding: 2px 0;
  background: #f2f2f2;
  border: 1px solid #808080;
  box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.25);
  z-index: 1000;
}

.menu-root:hover > .submenu,
.menu-root:focus-within > .submenu {
  display: block;
}

.submenu-item > button {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
}

.submenu.nested {
  left: 100%;
  top: 0;
}

.submenu-item:hover > .submenu.nested,
.submenu-item:focus-within > .submenu.nested {
  display: block;
}

.submenu-item.menu-block-start {
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px solid #8a8a8a;
}

.submenu-item.menu-block-end {
  margin-bottom: 6px;
  padding-bottom: 5px;
  border-bottom: 1px solid #8a8a8a;
}

.submenu-item.menu-block-start > button,
.submenu-item.menu-block-start + .submenu-item > button,
.submenu-item.menu-block-start + .submenu-item + .submenu-item > button,
.submenu-item.menu-block-end > button {
  background: #f8f8f8;
}

.submenu-item.menu-block-start > button:hover,
.submenu-item.menu-block-start + .submenu-item > button:hover,
.submenu-item.menu-block-start + .submenu-item + .submenu-item > button:hover,
.submenu-item.menu-block-end > button:hover {
  background: #dceaf7;
}

.legacy-user {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 24px;
  padding-right: 6px;
  white-space: nowrap;
}

.legacy-company {
  height: 50px;
  padding: 10px 10px 0;
  color: #000;
  background: #eeeeee;
  border-bottom: 1px solid #8a8a8a;
  font-family: "KaiTi", "STKaiti", "SimSun", serif;
  font-size: 28px;
  font-style: italic;
  font-weight: 700;
  line-height: 32px;
}

.legacy-workspace {
  position: relative;
  min-height: calc(100vh - 96px);
  padding: 0;
  overflow: hidden;
  background: #b6b6b6;
}

.mdi-window {
  position: relative;
  background: #fff;
  border: 1px solid #7f9db9;
  box-shadow: 1px 1px 0 #777;
}

.desktop-window {
  position: absolute;
  left: 2px;
  top: 0;
  width: 704px;
  height: 545px;
}

.mdi-caption {
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 7px;
  background: linear-gradient(#d6ebff, #a9c9e6);
  border-bottom: 1px solid #7f9db9;
}

.mdi-caption button,
.dialog-title button {
  width: 28px;
  min-width: 28px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  border: 1px solid #9aa9b8;
  background: #e8eef5;
  line-height: 16px;
}

.desktop-grid {
  position: relative;
  width: 100%;
  height: calc(100% - 28px);
  background:
    linear-gradient(135deg, transparent 58%, rgba(190, 220, 235, 0.18) 58%),
    #fff;
}

.module-icon {
  position: absolute;
  left: var(--x);
  top: var(--y);
  transform: translate(-50%, -50%);
  width: 82px;
  min-height: 72px;
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #000;
  font-size: 12px;
}

.module-icon:hover,
.module-icon.selected {
  border: 0;
  background: transparent;
  color: #004fd0;
}

.module-icon img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.legacy-login-dialog {
  position: absolute;
  left: 8px;
  top: 12px;
  width: 395px;
  min-height: 236px;
  margin: 0;
  background: #efefef;
  border: 1px solid #7f9db9;
  box-shadow: 1px 1px 0 #777;
}

.dialog-title {
  height: 28px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(#d6ebff, #a9c9e6);
  border-bottom: 1px solid #7f9db9;
  padding: 0 8px;
}

.dialog-title > span {
  flex: 1;
}

.dialog-title > div {
  display: flex;
  gap: 4px;
}

.dialog-body {
  margin: 32px 12px 24px;
  padding: 24px 34px 12px;
  border: 1px solid #bcbcbc;
  background: #f4f4f4;
}

.login-field {
  display: grid;
  grid-template-columns: 70px 136px auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.login-field label {
  display: block;
  color: #000;
  text-align: right;
  font-size: 12px;
}

.login-field input {
  width: 136px;
  min-height: 21px;
  height: 21px;
  border: 1px solid #7f9db9;
  border-radius: 0;
  padding: 1px 4px;
}

.login-field button {
  min-width: 58px;
  min-height: 24px;
  height: 24px;
  padding: 0 14px;
  border: 1px solid #999;
  background: #efefef;
}

.legacy-login-hint {
  color: #0000cc;
  font-size: 12px;
  text-align: center;
}

/* Legacy data windows: repair Hermes layout drift on finished/inventory/history pages. */
.legacy-data-window {
  min-height: calc(100vh - 98px);
  background: #b6b6b6;
  border: 0;
  border-top: 1px solid #91b4d8;
  color: #000;
  font-size: 12px;
}

.legacy-data-window .classic-titlebar {
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 0 7px;
  background: linear-gradient(#d6ebff, #a9c9e6);
  border-bottom: 1px solid #7f9db9;
  color: #000;
  font-size: 13px;
  font-weight: 700;
}

.legacy-data-window .classic-titlebar::before {
  content: "";
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  background: url("/assets/dl-logo.png") center / contain no-repeat;
  color: transparent;
  font-size: 0;
}

.legacy-finished-filter,
.legacy-bottom-form,
.legacy-window-footer,
.legacy-invoice-lower {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 31px;
  padding: 4px 5px;
  background: #eeeeee;
  border-bottom: 1px solid #a5a5a5;
  color: #000;
  white-space: nowrap;
}

.legacy-finished-filter span,
.legacy-bottom-form span,
.legacy-window-footer span {
  color: #000;
  font-size: 12px;
}

.legacy-section-title {
  height: 26px;
  line-height: 26px;
  padding: 0 8px;
  background: #eeeeee;
  border-top: 1px solid #a5a5a5;
  border-bottom: 1px solid #a5a5a5;
  color: #000;
  font-size: 12px;
  font-weight: 700;
}

.legacy-finished-filter label,
.legacy-bottom-form label,
.legacy-invoice-lower label {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: #000;
  font-size: 12px;
}

.legacy-finished-filter input,
.legacy-finished-filter select,
.legacy-bottom-form input,
.legacy-bottom-form select,
.legacy-invoice-lower input,
.legacy-invoice-lower select,
.legacy-invoice-lower textarea {
  width: auto;
  min-width: 0;
  min-height: 22px;
  height: 22px;
  padding: 1px 4px;
  border: 1px solid #7f9db9;
  border-radius: 0;
  background: #fff;
  color: #000;
  font-size: 12px;
}

.legacy-finished-filter input[type="date"] {
  width: 108px;
}

.legacy-finished-filter select {
  width: 88px;
}

.legacy-finished-filter input[data-filter-keyword] {
  width: 150px;
}

.legacy-finished-filter input[type="checkbox"],
.legacy-bottom-form input[type="checkbox"],
.legacy-grid input[type="checkbox"] {
  width: 13px;
  min-width: 13px;
  height: 13px;
  min-height: 13px;
  padding: 0;
}

.legacy-finished-filter button,
.legacy-bottom-form button,
.legacy-invoice-lower button,
.legacy-window-footer button {
  min-width: 52px;
  min-height: 23px;
  height: 23px;
  padding: 1px 9px;
  border: 1px solid #aaa;
  border-radius: 0;
  background: linear-gradient(#fafafa, #e0e0e0);
  color: #000;
  font-size: 12px;
}

.legacy-grid {
  width: 100%;
  margin: 0;
  overflow: auto;
  background: #fff;
  border: 0;
  border-bottom: 1px solid #8a8a8a;
  border-radius: 0;
}

.legacy-grid table {
  width: auto;
  min-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.legacy-grid th,
.legacy-grid td {
  height: 21px;
  padding: 2px 4px;
  border: 1px solid #d7d7d7;
  color: #000;
  background: #fff;
  font-size: 12px;
  font-weight: 400;
  line-height: 16px;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
}

.legacy-grid th {
  border-color: #808080;
  background: #efefef;
}

.legacy-grid tr.selected td {
  background: #d9ecff;
}

.legacy-grid td:nth-child(4),
.legacy-grid td:nth-child(18),
.legacy-grid td:nth-child(19) {
  text-align: left;
}

.finished-select-window .legacy-grid,
.finished-history-window .legacy-grid {
  height: calc(100vh - 204px);
}

.finished-delivery-window .legacy-upper-grid {
  height: 168px;
}

.finished-delivery-window .legacy-lower-grid {
  height: 126px;
  border-top: 3px solid #777;
}

.finished-invoice-window .legacy-grid {
  height: calc(100vh - 248px);
}

.legacy-bottom-form {
  border-top: 1px solid #777;
  border-bottom: 0;
}

.legacy-bottom-form select {
  width: 92px;
}

.legacy-invoice-lower {
  align-items: flex-start;
  min-height: 58px;
  border-top: 1px solid #777;
}

.legacy-invoice-lower textarea {
  width: 180px;
  height: 46px;
}

.legacy-red {
  color: #c00000 !important;
  font-weight: 700;
}

.legacy-empty-panel {
  margin: 28px 24px;
  padding: 22px;
  background: #f8f8f8;
  border: 1px solid #c8c8c8;
  color: #000;
}

/* ===== 手机端适配 ===== */
@media (max-width: 768px) {
  body {
    font-size: 14px;
  }

  /* 登录对话框 — 全宽居中 */
  .legacy-login-dialog {
    position: relative;
    left: auto;
    top: auto;
    width: calc(100vw - 16px);
    max-width: 400px;
    margin: 16px auto 0;
  }
  .login-shell .legacy-login-dialog {
    position: relative;
    left: auto;
    top: auto;
    width: calc(100vw - 16px);
    max-width: 400px;
    margin: 16px auto 0;
  }
  .legacy-login-dialog .dialog-body {
    margin: 20px 12px 16px;
    padding: 18px 16px 12px;
  }
  .login-field {
    grid-template-columns: 56px 1fr !important;
    gap: 6px;
    margin-bottom: 14px;
  }
  .login-field input {
    width: 100% !important;
    min-height: 40px !important;
    height: 40px !important;
    font-size: 16px;
    padding: 4px 8px;
  }
  .login-field button {
    grid-column: 1 / -1;
    min-height: 42px !important;
    height: 42px !important;
    width: 100%;
    font-size: 16px;
    margin-top: 6px;
  }
  .login-field label {
    font-size: 15px;
    text-align: left;
  }

  /* 公司名缩小 */
  .legacy-company {
    height: 36px;
    font-size: 20px;
    padding: 6px 10px 0;
  }

  /* 菜单栏 — 横向滚动 */
  .legacy-menu {
    height: auto;
    min-height: 32px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .legacy-menu button {
    min-height: 32px;
    height: 32px;
    font-size: 13px;
    padding: 0 10px;
  }

  /* 菜单 hover 改为 click（移动端无法 hover） */
  .menu-root:hover > .submenu,
  .menu-root:focus-within > .submenu {
    display: none;
  }
  .menu-root.open > .submenu {
    display: block;
    position: fixed;
    left: 8px;
    right: 8px;
    top: auto;
    min-width: auto;
    max-height: 60vh;
    overflow-y: auto;
    z-index: 2000;
  }
  .submenu-item > button {
    min-height: 42px;
    font-size: 15px;
    padding: 0 14px;
  }

  /* 工作区 */
  .legacy-workspace {
    min-height: auto;
    overflow: visible;
    padding: 4px;
  }

  /* 桌面图标 */
  .mdi-window {
    position: relative;
    left: auto;
    top: auto;
    right: auto;
    bottom: auto;
    border: none;
    background: transparent;
  }
  .desktop-window {
    padding: 8px;
    gap: 8px;
    justify-content: center;
  }
  .desktop-grid {
    gap: 8px;
    justify-content: center;
  }
  .desktop-grid button {
    width: 72px;
    height: 72px;
    font-size: 12px;
  }

  /* 标签页 — 横向滚动 */
  .tabs {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    gap: 2px;
    padding: 2px;
    -webkit-overflow-scrolling: touch;
  }
  .tabs button {
    min-width: auto;
    min-height: 36px;
    padding: 0 12px;
    font-size: 13px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* 用户区域 */
  .user-area {
    font-size: 13px;
    gap: 6px;
  }

  /* 表格 — 横向滚动 */
  .table-wrap {
    -webkit-overflow-scrolling: touch;
  }
  table {
    font-size: 12px;
  }
  th, td {
    padding: 6px 8px;
  }

  /* 条目表格 */
  .item-table {
    margin: 0 4px;
    width: calc(100% - 8px);
    max-height: 50vh;
    border-radius: 0;
  }

  /* 表单 — 单列堆叠 */
  .form-grid {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }
  .filter-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px;
  }

  /* 工具栏 */
  .toolbar {
    grid-template-columns: 1fr !important;
    gap: 8px;
    padding: 10px;
  }
  .toolbar button {
    min-height: 42px;
    font-size: 14px;
  }

  /* 输入控件增大 */
  input, select, textarea {
    min-height: 38px;
    font-size: 16px !important;
  }
  select {
    font-size: 16px !important;
  }

  /* 按钮增大 */
  button {
    min-height: 40px;
    padding: 0 14px;
  }

  /* 经典窗口适配 */
  .classic-window {
    margin: 0;
    border: none;
  }
  .classic-titlebar {
    height: 34px;
    font-size: 14px;
  }

  /* 订单列表 */
  .order-editor {
    padding-bottom: 8px;
  }
  .order-editor > .form-grid,
  .order-editor > .wide-label {
    margin: 8px;
  }

  /* 隐藏桌面版滚动条风格，用原生滚动 */
  .legacy-grid {
    height: auto !important;
    max-height: 50vh;
    overflow: auto;
  }

  /* 表单中的数字/短输入框不要被撑满 */
  input[type="number"] {
    max-width: 120px;
  }

  /* 标题栏程序名 */
  .legacy-programbar {
    height: auto;
    min-height: 28px;
    padding: 4px 8px;
    font-size: 13px;
  }

  /* 标题窗口放大 */
  .mdi-caption {
    height: 28px;
    font-size: 13px;
  }

  /* section 头 */
  .section-head {
    font-size: 14px;
    padding: 10px 12px;
  }

  /* compact list on mobile */
  .compact-list {
    max-height: 40vh;
  }
}

