:root {
  --bg: #f3f7fc;
  --panel: rgba(255, 255, 255, 0.72);
  --panel-solid: #ffffff;
  --panel-soft: rgba(255, 255, 255, 0.54);
  --glass: rgba(255, 255, 255, 0.58);
  --glass-strong: rgba(255, 255, 255, 0.78);
  --glass-dark: rgba(18, 24, 38, 0.68);
  --ink: #172033;
  --muted: #667085;
  --line: rgba(116, 132, 158, 0.26);
  --line-strong: rgba(89, 105, 130, 0.38);
  --nav: rgba(255, 255, 255, 0.62);
  --nav-active: rgba(31, 111, 235, 0.12);
  --blue: #1f6feb;
  --blue-weak: rgba(31, 111, 235, 0.11);
  --green: #0f8f68;
  --amber: #b86b00;
  --red: #c62828;
  --ff-red: #d71920;
  --shadow: 0 18px 55px rgba(23, 32, 51, 0.11), 0 2px 12px rgba(23, 32, 51, 0.06);
  --glass-shadow: 0 24px 70px rgba(23, 32, 51, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.72);
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 8%, rgba(255, 255, 255, 0.92) 0 12%, transparent 34%),
    radial-gradient(circle at 82% 6%, rgba(122, 181, 255, 0.46) 0 16%, transparent 35%),
    radial-gradient(circle at 58% 82%, rgba(255, 150, 166, 0.22) 0 14%, transparent 38%),
    linear-gradient(135deg, #f8fbff 0%, #edf3fb 46%, #e9eef9 100%);
  background-attachment: fixed;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  font-size: 13px;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(115deg, rgba(255,255,255,0.46), transparent 28%),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.13) 0 1px, transparent 1px 90px);
  mix-blend-mode: screen;
  opacity: 0.55;
}

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

.sidebar {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.54)),
    radial-gradient(circle at 24% 0%, rgba(122, 181, 255, 0.26), transparent 44%),
    radial-gradient(circle at 90% 92%, rgba(215, 25, 32, 0.08), transparent 42%);
  backdrop-filter: blur(24px) saturate(1.42);
  -webkit-backdrop-filter: blur(24px) saturate(1.42);
  color: var(--ink);
  min-height: 100vh;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-right: 1px solid rgba(255, 255, 255, 0.78);
  box-shadow: 16px 0 48px rgba(23, 32, 51, 0.08), inset -1px 0 0 rgba(116, 132, 158, 0.14);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 52px;
  padding: 0 4px 14px;
  border-bottom: 1px solid rgba(116, 132, 158, 0.18);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.72), rgba(255,255,255,0.12)),
    linear-gradient(135deg, #172033 0%, #4b5563 52%, var(--ff-red) 52%, var(--ff-red) 100%);
  font-weight: 800;
  letter-spacing: 0;
  border-radius: 14px;
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.36), 0 12px 28px rgba(23,32,51,0.16);
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel-head h3,
.panel-head span {
  margin: 0;
}

.brand h1 {
  font-size: 16px;
  line-height: 1.2;
  font-weight: 760;
}

.brand p {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 4px;
}

.nav-group-label {
  margin: 12px 10px 4px;
  color: #73839a;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nav-step {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  margin-right: 8px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
  flex: 0 0 auto;
}

.nav-btn,
.ghost-btn,
.primary-btn,
.danger-btn,
.file-btn {
  min-height: 38px;
  border: 1px solid transparent;
  cursor: pointer;
  border-radius: 999px;
  padding: 8px 11px;
  font-weight: 650;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.nav-btn {
  display: flex;
  align-items: center;
  color: #4f5f75;
  background: rgba(255, 255, 255, 0.34);
  text-align: left;
  border-left: 0;
  border-color: transparent;
  border-radius: 14px;
}

.nav-btn.active,
.nav-btn:hover {
  color: #0f3f8f;
  background: linear-gradient(135deg, rgba(255,255,255,0.78), rgba(235, 244, 255, 0.72));
  border-color: rgba(31, 111, 235, 0.16);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.86), 0 10px 22px rgba(31,111,235,0.09);
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid rgba(116, 132, 158, 0.18);
}

.app-version-card {
  display: grid;
  gap: 2px;
  padding: 10px 11px;
  border: 1px solid rgba(116, 132, 158, 0.18);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255,255,255,0.74), rgba(255,255,255,0.42));
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--ink);
}

.app-version-card span,
.app-version-card small {
  color: var(--muted);
  font-size: 11px;
}

.app-version-card strong {
  font-size: 14px;
  letter-spacing: 0.02em;
}

.file-btn {
  display: grid;
  place-items: center;
  color: var(--ink);
  border-color: rgba(116, 132, 158, 0.18);
  background: rgba(255, 255, 255, 0.48);
}

.file-btn input {
  display: none;
}

.app {
  min-width: 0;
  padding: 0 22px 22px;
  position: relative;
  z-index: 1;
  overflow-x: clip;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 64px;
  margin: 0 -22px 18px;
  padding: 14px 22px;
  background: rgba(255, 255, 255, 0.62);
  border-bottom: 1px solid rgba(255, 255, 255, 0.52);
  box-shadow: 0 18px 44px rgba(23, 32, 51, 0.08);
  backdrop-filter: blur(18px) saturate(1.42);
  -webkit-backdrop-filter: blur(18px) saturate(1.42);
  position: sticky;
  top: 0;
  z-index: 18;
}

.topbar h2 {
  font-size: 20px;
  font-weight: 760;
}

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

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

.toolbar {
  justify-content: flex-end;
}

.toolbar select {
  width: auto;
  min-width: 170px;
}

.inline-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.inline-field input {
  min-width: 138px;
  height: 30px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
}

.monthly-slip-export {
  background: linear-gradient(135deg, rgba(239, 246, 255, 0.92), rgba(248, 250, 252, 0.96));
}

.monthly-slip-export .action-hint {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.dirty-indicator {
  border: 1px solid #f59e0b;
  border-radius: 4px;
  background: #fffbeb;
  color: #92400e;
  font-size: 12px;
  font-weight: 750;
  padding: 7px 10px;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  padding: 7px 9px;
  min-height: 34px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

select:focus,
input:focus,
textarea:focus {
  outline: none;
  border-color: rgba(31, 111, 235, 0.55);
  box-shadow: 0 0 0 4px rgba(31, 111, 235, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

input.missing-field,
select.missing-field,
textarea.missing-field {
  border-color: #f59e0b;
  background: #fffbeb;
  box-shadow: inset 3px 0 0 #f59e0b;
}

textarea {
  resize: vertical;
  min-height: 68px;
}

.primary-btn {
  color: #fff;
  background: linear-gradient(135deg, #1d6fe8, #174fae);
  border-color: rgba(255, 255, 255, 0.32);
  box-shadow: 0 10px 25px rgba(31, 111, 235, 0.26), inset 0 1px 0 rgba(255,255,255,0.24);
}

.primary-btn:hover {
  background: linear-gradient(135deg, #2b7df2, #1550b5);
  transform: translateY(-1px);
}

.ghost-btn {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.56);
  border-color: var(--line);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.ghost-btn:hover {
  background: rgba(255, 255, 255, 0.78);
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.sidebar .ghost-btn {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.48);
  border-color: rgba(116, 132, 158, 0.18);
}

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

.mini-danger-btn {
  min-height: 30px;
  border: 1px solid #fecaca;
  border-radius: 999px;
  background: rgba(255, 245, 245, 0.78);
  color: var(--red);
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
  padding: 5px 8px;
}

.mini-danger-btn:hover {
  background: #fee2e2;
}

.mini-btn {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
  padding: 5px 8px;
}

.mini-btn:hover {
  background: #f3f4f6;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.kpi,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(18px) saturate(1.28);
  -webkit-backdrop-filter: blur(18px) saturate(1.28);
}

.kpi {
  padding: 14px 16px;
  border-top: 0;
  position: relative;
  overflow: hidden;
}

.kpi::before,
.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255,255,255,0.62), transparent 38%, rgba(255,255,255,0.16));
  opacity: 0.78;
}

.kpi::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  top: 0;
  height: 3px;
  border-radius: 0 0 999px 999px;
  background: #8b95a5;
}

.kpi:nth-child(2) {
  box-shadow: var(--glass-shadow), 0 8px 28px rgba(31, 111, 235, 0.08);
}

.kpi:nth-child(2)::after {
  background: #2563eb;
}

.kpi:nth-child(3) {
  box-shadow: var(--glass-shadow), 0 8px 28px rgba(183, 110, 0, 0.08);
}

.kpi:nth-child(3)::after {
  background: #b76e00;
}

.kpi:nth-child(4) {
  box-shadow: var(--glass-shadow), 0 8px 28px rgba(215, 25, 32, 0.09);
}

.kpi:nth-child(4)::after {
  background: var(--ff-red);
}

.kpi span {
  position: relative;
  z-index: 1;
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
  font-weight: 700;
}

.kpi strong {
  position: relative;
  z-index: 1;
  font-size: 24px;
  line-height: 1;
}

.kpi.danger strong {
  color: var(--red);
}

.dashboard-grid,
.doc-layout,
.split {
  display: grid;
  gap: 12px;
  align-items: start;
}

.health-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.health-item {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 10px;
  align-items: flex-start;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.52);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
}

.health-item .dot {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.health-item.warn .dot {
  background: var(--amber);
}

.health-item.danger .dot {
  background: var(--red);
}

.health-item strong {
  display: block;
  margin-bottom: 3px;
  font-size: 13px;
}

.health-item p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

[hidden] {
  display: none !important;
}

.warehouse-view-switch {
  padding-bottom: 8px;
}

.warehouse-view-switch button {
  min-width: 210px;
}

.compact-tabs {
  margin: 6px 0 10px;
}

.compact-tabs button {
  min-width: 150px;
}

.warehouse-mode-hint {
  margin: 0 0 12px;
  padding: 9px 12px;
  border-left: 0;
  border: 1px solid rgba(255,255,255,0.55);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.54);
  color: var(--muted);
  font-size: 12px;
}

.form-section {
  padding: 9px 12px;
  border-left: 0;
  border: 1px solid rgba(31, 111, 235, 0.18);
  border-radius: 14px;
  background: rgba(237, 244, 255, 0.72);
  color: #163f7a;
  font-weight: 700;
  font-size: 13px;
}

.workflow-tip {
  margin: 10px 0 14px;
  padding: 10px 12px;
  border: 1px solid rgba(31, 111, 235, 0.18);
  border-radius: 16px;
  background: rgba(243, 247, 255, 0.68);
  color: #244b82;
  font-size: 13px;
  line-height: 1.55;
}

.workflow-steps ol {
  margin: 8px 0 0 18px;
  padding: 0;
}

.workflow-steps li {
  margin: 3px 0;
}

.workflow-note,
.inline-warning {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-left: 0;
  border: 1px solid rgba(245, 158, 11, 0.22);
  border-radius: 14px;
  background: rgba(255, 247, 237, 0.74);
  color: #9a3412;
  font-weight: 750;
}

.inline-warning {
  font-size: 12px;
  line-height: 1.5;
}

.legacy-inventory-fields details {
  border: 1px dashed var(--line-strong);
  border-radius: 4px;
  padding: 8px 10px;
  background: #fbfcfe;
}

.legacy-inventory-fields summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 760;
}

.inventory-operation-block {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

[data-movement-field][hidden] {
  display: none !important;
}

.table-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: #1f5fbf;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.tracking-toolbar,
.ledger-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.tracking-toolbar label,
.ledger-filters label {
  display: grid;
  gap: 5px;
  min-width: 180px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.tracking-toolbar input,
.ledger-filters input,
.ledger-filters select {
  min-height: 38px;
}

.tracking-link {
  display: inline-grid;
  place-items: center;
  text-decoration: none;
}

.tracking-frame-wrap {
  min-height: 620px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #f8fafc;
}

#trackingFrame {
  width: 100%;
  height: 720px;
  border: 0;
  background: #fff;
}

.tracking-placeholder {
  min-height: 620px;
  display: grid;
  place-content: center;
  gap: 10px;
  padding: 30px;
  text-align: center;
  color: var(--muted);
}

.tracking-placeholder strong {
  color: var(--ink);
  font-size: 18px;
}

.ledger-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.ledger-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--ff-red);
  border-radius: 4px;
  background: #fff;
}

.ledger-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.ledger-card strong {
  font-size: 18px;
}

.freight-settings {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.freight-settings label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.freight-estimate-wrap {
  margin: 14px;
}

.freight-estimate-table input,
.freight-estimate-table select {
  width: 100%;
  min-width: 86px;
  min-height: 34px;
  padding: 6px 7px;
  font-size: 12px;
}

.freight-estimate-table td:nth-child(1) input,
.freight-estimate-table td:nth-child(2) input,
.freight-estimate-table td:nth-child(3) input {
  min-width: 120px;
}

.freight-estimate-table td:nth-child(2) select {
  min-width: 260px;
}

.freight-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 10px;
  padding: 0 14px 14px;
}

.freight-estimate-note {
  margin: 0 14px 14px;
}

.selection-cell {
  width: 42px;
  text-align: center;
}

.selection-cell input {
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 0;
  accent-color: var(--ff-red);
}

.drag-handle {
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--muted);
  cursor: grab;
  font-size: 18px;
  line-height: 1;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.drag-handle:active {
  cursor: grabbing;
}

.form-hint {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid #d9e2ec;
  border-radius: 6px;
  background: #f6f9fc;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.source-inventory-card {
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 13px;
  font-weight: 760;
  line-height: 1.5;
}

tr.product-dragging {
  opacity: 0.45;
}

tr.product-drop-target {
  box-shadow: inset 0 3px 0 var(--ff-red);
}

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

.split {
  grid-template-columns: minmax(560px, 1.25fr) minmax(360px, 0.75fr);
}

.doc-layout {
  grid-template-columns: minmax(560px, 1.1fr) minmax(380px, 0.9fr);
}

.stack {
  display: grid;
  gap: 14px;
  align-content: start;
}

.panel {
  min-width: 0;
  overflow: hidden;
  position: relative;
}

.panel-head {
  min-height: 52px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(255, 255, 255, 0.42);
  position: relative;
  z-index: 1;
}

.panel-head h3 {
  font-size: 15px;
  font-weight: 760;
}

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

.panel-head input,
.panel-head select {
  max-width: 300px;
}

.table-wrap {
  overflow: auto;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.55);
  position: relative;
  z-index: 1;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  white-space: nowrap;
}

.compact-table table {
  min-width: 680px;
}

.audit-table,
.shipment-ledger-table,
.ledger-table {
  min-width: 920px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  font-size: 12px;
}

th {
  color: #4f5b6b;
  background: linear-gradient(180deg, rgba(255,255,255,0.92) 0%, rgba(239,244,250,0.92) 100%);
  position: sticky;
  top: 0;
  z-index: 1;
  font-weight: 760;
  border-bottom-color: var(--line-strong);
}

tbody tr:nth-child(even) {
  background: rgba(248, 250, 252, 0.66);
}

.ledger-table td:nth-child(2),
.ledger-table th:nth-child(2) {
  font-weight: 760;
}

.shipment-ledger-table td:nth-child(3) {
  min-width: 140px;
}

tr[data-id] {
  cursor: pointer;
}

tr[data-inventory-id]:not([data-inventory-id^="SHIPMENT|"]) {
  cursor: pointer;
}

tr[data-id]:hover,
tr[data-inventory-id]:not([data-inventory-id^="SHIPMENT|"]):hover,
tr.selected {
  background: var(--blue-weak);
  box-shadow: inset 4px 0 0 #1f5fbf, 0 4px 18px rgba(31, 111, 235, 0.08);
}

tr.closed-row {
  color: #64748b;
  background: rgba(248, 250, 252, 0.72);
}

.inventory-product-title {
  color: var(--ink);
  font-weight: 760;
  text-decoration: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 2px 7px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 11px;
  font-weight: 700;
}

.badge.warn {
  background: #fff7ed;
  color: var(--amber);
}

.badge.success {
  background: #dcfce7;
  color: #166534;
}

.badge.closed {
  background: #e5e7eb;
  color: #475569;
}

.badge.danger {
  background: #fee2e2;
  color: var(--red);
}

.form-panel {
  align-self: start;
}

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

.accordion-panel {
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.62);
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}

.accordion-panel > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.48);
  color: var(--ink);
  cursor: pointer;
  font-size: 14px;
  font-weight: 820;
  border-bottom: 1px solid transparent;
  user-select: none;
}

.accordion-panel > summary::-webkit-details-marker {
  display: none;
}

.accordion-panel > summary::after {
  content: "展开 / Open";
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.accordion-panel[open] > summary {
  border-bottom-color: var(--line);
}

.accordion-panel[open] > summary::after {
  content: "收起 / Close";
}

.accordion-panel > .form-grid,
.accordion-panel > .compact-form,
.accordion-panel > .detail-head,
.accordion-panel > .table-wrap,
.accordion-panel > .embedded-form,
.accordion-panel > .calc-line {
  margin-left: 0;
  margin-right: 0;
}

.accordion-panel.detail-block {
  padding: 0;
}

.accordion-panel > .detail-head {
  padding: 12px 14px 0;
}

.accordion-panel > .table-wrap {
  margin: 12px 14px;
}

.detail-block {
  border-top: 0;
  padding: 12px 14px 14px;
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.detail-head h4,
.detail-head p {
  margin: 0;
}

.detail-head h4 {
  font-size: 14px;
}

.detail-head p {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.compact-table {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
}

.compact-table th,
.compact-table td {
  padding: 8px 10px;
  font-size: 12px;
}

.embedded-form {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(248, 250, 252, 0.7);
  padding: 10px;
}

.row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

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

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

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

.bar-list,
.list,
.checklist {
  padding: 12px 14px 14px;
  display: grid;
  gap: 8px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 3fr 42px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.bar-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(231, 235, 240, 0.84);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #4f8df4, #1f5fbf);
  border-radius: inherit;
}

.list-item {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 9px 10px;
  display: grid;
  gap: 4px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.65);
}

.list-item strong {
  font-size: 13px;
}

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

.option-list {
  padding: 12px 14px 14px;
  display: grid;
  gap: 7px;
}

.option-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,0.62);
  padding: 7px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.option-item span {
  overflow-wrap: anywhere;
}

.action-row {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.text-link {
  color: var(--blue);
  font-size: 12px;
  font-weight: 750;
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

.compact-form {
  max-height: 590px;
  overflow: auto;
}

.calc-line {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f8fafc;
  color: var(--ink);
  font-size: 11px;
  line-height: 1.5;
  padding: 9px;
}

.declaration-assistant {
  border: 1px solid #dbe7ff;
  background: linear-gradient(135deg, #f7fbff 0%, #f3f7ff 100%);
  border-radius: 12px;
  padding: 12px;
}

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

.assistant-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

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

.assistant-hint {
  margin-top: 10px;
  color: #40506a;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-line;
}

.assistant-hint.warning {
  color: #8a5a00;
}

.audit-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  padding: 14px;
}

.audit-principles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  padding: 0 14px 14px;
}

.audit-principles .check {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 10px;
}

.audit-principles p {
  margin: 0;
  color: #334155;
  line-height: 1.55;
}

.audit-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.audit-toolbar input[type="search"] {
  min-width: min(360px, 100%);
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: #475569;
  font-size: 12px;
  white-space: nowrap;
}

.inline-check input {
  width: auto;
  margin: 0;
}

.finance-control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}

.finance-card {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
}

.finance-card h4 {
  margin: 0 0 4px;
}

.locked-form {
  opacity: 0.64;
}

.locked-form input,
.locked-form select,
.locked-form textarea {
  cursor: not-allowed;
}

.locked-form button:disabled,
.locked-form input:disabled,
.locked-form select:disabled,
.locked-form textarea:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.audit-table td:nth-child(5),
.audit-table th:nth-child(5) {
  min-width: 240px;
}

.audit-group-row td {
  background: #f8fafc;
  padding: 10px;
}

.audit-group-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-left: 5px solid #94a3b8;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.9));
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.07);
  padding: 14px 16px;
}

.audit-group-row.error .audit-group-card {
  border-left-color: #dc2626;
}

.audit-group-row.warn .audit-group-card {
  border-left-color: #d97706;
}

.audit-group-row.pass .audit-group-card {
  border-left-color: #16a34a;
}

.audit-group-main {
  min-width: 0;
}

.audit-group-title {
  color: #0f172a;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.45;
}

.audit-group-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: #64748b;
  font-size: 12px;
}

.audit-group-checks {
  margin: 10px 0 0;
  padding-left: 18px;
  color: #334155;
  line-height: 1.55;
}

.audit-group-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-width: 150px;
}

.audit-detail-row td {
  background: #fff;
}

.audit-values {
  white-space: pre-line;
  color: #334155;
  font-size: 12px;
  line-height: 1.55;
}

.audit-action {
  color: #475569;
  line-height: 1.5;
}

.field-muted {
  opacity: 0.48;
}

.field-muted input,
.field-muted select {
  background: #eef2f7;
  cursor: not-allowed;
}

.output {
  margin: 0;
  min-height: 420px;
  padding: 14px;
  overflow: auto;
  white-space: pre-wrap;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  background: #fbfcfe;
}

.check {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 8px;
  align-items: start;
}

.check span:first-child {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--green);
  font-size: 12px;
}

.check.warn span:first-child {
  background: var(--amber);
}

.check.danger span:first-child {
  background: var(--red);
}

@media (max-width: 960px) {
  body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    padding: 12px;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 30;
    border-right: 0;
    border-bottom: 1px solid rgba(255,255,255,0.72);
  }

  .nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
  }

  .nav-btn {
    flex: 0 0 auto;
    min-width: max-content;
    text-align: center;
    white-space: nowrap;
    border-left: 0;
    border-bottom: 3px solid transparent;
  }

  .nav-btn.active,
  .nav-btn:hover {
    border-bottom-color: var(--blue);
  }

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

  .split,
  .doc-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar-footer {
    display: flex;
    gap: 10px;
  }

  .sidebar-footer > * {
    flex: 1;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 720px) {
  body {
    display: block;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .brand {
    gap: 10px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .brand h1 {
    font-size: 15px;
  }

  .brand p {
    font-size: 11px;
  }

  .nav {
    margin-left: -4px;
    margin-right: -4px;
  }

  .nav-btn {
    min-height: 40px;
    padding: 8px 10px;
    font-size: 13px;
  }

  .sidebar-footer {
    display: none;
  }

  .app {
    padding: 0 10px 12px;
  }

  .topbar {
    gap: 12px;
    margin: 0 -10px 12px;
    padding: 10px;
    }

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

  .topbar p {
    font-size: 12px;
  }

  .toolbar {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
  }

  .toolbar > * {
    width: 100%;
  }

  .dirty-indicator {
    border-radius: 6px;
    text-align: center;
  }

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

  .kpi {
    padding: 12px;
  }

  .kpi span {
    min-height: 30px;
    margin-bottom: 4px;
  }

  .kpi strong {
    font-size: 22px;
  }

  .panel {
    border-radius: 4px;
  }

  .panel-head {
    min-height: 0;
    padding: 12px;
    align-items: stretch;
    flex-direction: column;
  }

  .panel-head h3 {
    font-size: 15px;
  }

  .panel-head input,
  .panel-head select {
    max-width: none;
  }

  .form-grid {
    grid-template-columns: 1fr;
    padding: 12px;
    gap: 10px;
  }

  .detail-block {
    padding: 10px;
  }

  .detail-head {
    display: grid;
  }

  .detail-head .ghost-btn {
    width: 100%;
  }

  input,
  select,
  textarea,
  .nav-btn,
  .ghost-btn,
  .primary-btn,
  .danger-btn,
  .mini-btn,
  .file-btn,
  .mini-danger-btn {
    min-height: 44px;
  }

  .action-row {
    display: grid;
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .bar-list,
  .list,
  .checklist {
    padding: 12px;
  }

  .bar-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .bar-row strong {
    justify-self: end;
  }

  .table-wrap {
    overflow: visible;
  }

  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  table {
    white-space: normal;
  }

  tbody {
    display: grid;
    gap: 8px;
    padding: 10px;
  }

  tr {
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #fff;
    overflow: hidden;
  }

  td {
    border-bottom: 1px solid #eef1f6;
    padding: 9px 10px;
    display: grid;
    grid-template-columns: minmax(120px, 42%) minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    font-size: 13px;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  td:last-child {
    border-bottom: 0;
  }

  .row-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 750;
  }

  td[colspan] {
    display: block;
  }

  td[colspan]::before {
    content: "";
    display: none;
  }

  .output {
    min-height: 300px;
    max-height: 52vh;
    font-size: 12px;
    padding: 12px;
  }

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

  .calc-line {
    font-size: 11px;
  }
}

@media (max-width: 420px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  td {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

@media (min-width: 561px) and (max-width: 720px) {
  .table-wrap {
    overflow: auto;
  }

  table {
    display: table;
    width: 100%;
    min-width: 760px;
    white-space: nowrap;
    border-collapse: collapse;
  }

  thead {
    display: table-header-group;
  }

  tbody {
    display: table-row-group;
    padding: 0;
  }

  tr {
    display: table-row;
    border: 0;
    border-radius: 0;
    background: transparent;
    overflow: visible;
  }

  td,
  th {
    display: table-cell;
    width: auto;
    white-space: nowrap;
  }

  td::before {
    content: none;
  }
}
