:root {
  color-scheme: light;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --ink: #172327;
  --muted: #647277;
  --line: #dfe5e5;
  --soft: #f4f7f6;
  --paper: #ffffff;
  --nav: #123744;
  --nav-active: #20596a;
  --primary: #0f7182;
  --primary-hover: #095d6c;
  --warning: #b96325;
  --warning-soft: #fff2e8;
  --success: #34745f;
  --success-soft: #e9f5ef;
  --danger: #ad3d3d;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: #edf1f0; font-size: 14px; letter-spacing: 0; }
button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
.hidden { display: none !important; }
h1, h2, h3 { color: var(--ink); font-weight: 800; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #e7edeb;
}
.login-panel {
  width: min(440px, 100%);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 40px;
  box-shadow: 0 12px 34px rgba(31, 58, 63, .09);
}
.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--primary);
  font-weight: 800;
  border-radius: 6px;
}
.brand-mark.small { width: 38px; height: 38px; font-size: 12px; }
.login-panel h1 { margin: 22px 0 6px; font-size: 25px; }
.login-panel > p { color: var(--muted); margin: 0 0 28px; }
.login-panel label, .edit-form label { display: grid; gap: 7px; font-weight: 600; font-size: 13px; }
.login-panel form { display: grid; gap: 9px; }
.password-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 8px; }
input, select {
  height: 38px;
  min-width: 0;
  border: 1px solid #cdd6d5;
  border-radius: 5px;
  background: white;
  color: var(--ink);
  padding: 0 11px;
  outline: none;
}
textarea {
  min-height: 92px;
  min-width: 0;
  border: 1px solid #cdd6d5;
  border-radius: 5px;
  background: white;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
  resize: vertical;
  font: inherit;
}
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 113, 130, .12); }
textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15, 113, 130, .12); }
label.readonly-field input,
label.readonly-field select {
  background: #edf3f2;
  color: #53676b;
  cursor: not-allowed;
}
.form-hint { margin-top: 10px; color: var(--muted); font-size: 12px; }
.form-error { min-height: 18px; margin-top: 8px; color: var(--danger); font-size: 13px; }

.primary-button, .secondary-button {
  min-height: 38px;
  border-radius: 5px;
  padding: 0 15px;
  border: 1px solid transparent;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
}
.primary-button { color: white; background: var(--primary); }
.primary-button:hover { background: var(--primary-hover); }
.primary-button:disabled { background: #9db3b6; cursor: not-allowed; }
.secondary-button { color: #2a4148; background: white; border-color: #cbd5d5; }
.secondary-button:hover { background: var(--soft); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 212px minmax(0, 1fr); transition: grid-template-columns .18s ease; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 212px;
  display: flex;
  flex-direction: column;
  background: var(--nav);
  color: white;
  padding: 20px 14px;
  transition: width .18s ease, padding .18s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 22px; border-bottom: 1px solid rgba(255,255,255,.12); position: relative; }
.sidebar-copy { min-width: 0; }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand strong { font-size: 15px; }
.sidebar-brand span { margin-top: 2px; color: #aec2c7; font-size: 12px; }
.sidebar-toggle {
  width: 28px;
  height: 28px;
  margin-left: auto;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 4px;
  color: #d8e7ea;
  background: rgba(255,255,255,.08);
  font-size: 20px;
  line-height: 1;
}
.sidebar-toggle:hover { background: var(--nav-active); color: white; }
.sidebar nav {
  display: grid;
  gap: 5px;
  margin-top: 18px;
  overflow-y: auto;
  overflow-x: hidden;
  align-content: start;
  flex: 1 1 auto;
  padding-bottom: 10px;
  scrollbar-width: thin;
}
.nav-group { display: grid; gap: 4px; margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,.12); }
.nav-group-title {
  width: 100%;
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  border: 0;
  border-radius: 5px;
  color: #8fb1b8;
  background: transparent;
  font-size: 11px;
  font-weight: 700;
  text-align: left;
}
.nav-group-title:hover { color: white; background: rgba(255,255,255,.07); }
.nav-group-items { display: grid; gap: 4px; }
.nav-group-chevron { margin-left: auto; color: #89a7ad; transition: transform .18s ease; }
.nav-group-collapsed .nav-group-items { display: none; }
.nav-group-collapsed .nav-group-chevron { transform: rotate(-90deg); }
.nav-subitem { min-height: 36px; padding-left: 24px; color: #bfd2d6; }
.nav-item {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 12px;
  color: #d6e2e4;
  background: transparent;
  border: 0;
  border-radius: 5px;
  text-align: left;
}
.nav-item:hover, .nav-item.active { color: white; background: var(--nav-active); }
.nav-icon { width: 18px; text-align: center; font-size: 18px; }
.sidebar-bottom { flex: 0 0 auto; margin-top: auto; }
.current-user-badge {
  display: grid;
  gap: 2px;
  margin: 0 6px 8px;
  padding: 10px 9px;
  border-top: 1px solid rgba(255,255,255,.12);
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.current-user-badge strong { overflow: hidden; color: white; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.current-user-badge span { color: #9fb9bf; font-size: 10px; }
body.sidebar-collapsed .app-shell { grid-template-columns: 76px minmax(0, 1fr); }
body.sidebar-collapsed .sidebar { width: 76px; padding-inline: 10px; }
body.sidebar-collapsed .sidebar-brand { justify-content: center; padding-inline: 0; }
body.sidebar-collapsed .sidebar-copy,
body.sidebar-collapsed .nav-item > :not(.nav-icon),
body.sidebar-collapsed .nav-group-title > :not(.nav-icon) { display: none; }
body.sidebar-collapsed .sidebar-toggle { position: absolute; left: 20px; top: 58px; margin: 0; }
body.sidebar-collapsed .sidebar nav { margin-top: 54px; }
body.sidebar-collapsed .nav-item { justify-content: center; padding: 0; font-size: 0; }
body.sidebar-collapsed .nav-group-title { justify-content: center; padding: 0; }
body.sidebar-collapsed .nav-group-items { display: none; }
body.sidebar-collapsed .current-user-badge { display: none; }

.workspace { grid-column: 2; min-width: 0; padding: 0 30px 40px; }
.workspace-view.hidden { display: none; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 12;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 0;
  padding: 26px 0 18px;
  background: #edf1f0;
}
.topbar h1 { margin: 0; font-size: 26px; font-weight: 800; }
.topbar p { margin: 5px 0 0; color: var(--muted); }
.header-actions { display: flex; gap: 9px; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); background: var(--paper); border-radius: 7px; margin-bottom: 18px; overflow: hidden; }
.billing-summary-grid, .bulk-summary-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
#billingView .summary-grid {
  position: sticky;
  top: var(--sticky-topbar-bottom, 88px);
  z-index: 11;
  margin-bottom: 0;
}
.metric { min-width: 0; padding: 18px 20px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric > span, .metric small { display: block; color: var(--muted); }
.metric > span { font-size: 12px; font-weight: 700; }
.metric strong { display: block; margin: 8px 0 3px; font-size: 25px; }
.metric strong em { font-size: 15px; font-style: normal; font-weight: 600; }
.metric small { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.warning-metric { border-top: 3px solid #d98243; padding-top: 15px; }
.warning-metric strong { color: var(--warning); }

.content-section { margin-top: 18px; background: var(--paper); border: 1px solid var(--line); border-radius: 7px; overflow: visible; }
.toolbar { min-height: 66px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px 18px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.toolbar-left { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; min-width: 0; }
.content-section > .toolbar {
  position: sticky;
  top: var(--sticky-toolbar-top, 88px);
  z-index: 10;
  background: var(--paper);
}
.toolbar-note { color: var(--muted); font-size: 12px; }
.toolbar-actions { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.month-control { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
.month-control select { width: 126px; }
.segmented { display: flex; height: 34px; border: 1px solid #cbd5d5; border-radius: 5px; overflow: hidden; }
.segmented button { min-width: 60px; padding: 0 11px; border: 0; border-right: 1px solid #cbd5d5; color: #4e6064; background: white; }
.segmented button:last-child { border-right: 0; }
.segmented button.active { color: white; background: #44646d; }
.search-control { position: relative; width: min(320px, 34vw); }
.search-control input { width: 100%; padding-left: 34px; }
.search-symbol { position: absolute; left: 11px; top: 8px; color: #6f7e82; font-size: 18px; pointer-events: none; }
#bulkBillingView .bulk-search-control { width: min(220px, 22vw); }
#billingView .topbar,
#bulkBillingView .topbar { padding: 14px 0 10px; }
#billingView .topbar h1,
#bulkBillingView .topbar h1 { font-size: 23px; }
#billingView .topbar p,
#bulkBillingView .topbar p { margin-top: 2px; }
#billingView .summary-grid,
#bulkBillingView .summary-grid { margin-bottom: 0; }
#billingView .metric,
#bulkBillingView .metric { padding: 10px 14px; }
#billingView .metric strong,
#bulkBillingView .metric strong { margin: 4px 0 1px; font-size: 20px; }
#billingView .content-section,
#bulkBillingView .content-section { margin-top: 8px; }
#billingView .toolbar,
#bulkBillingView .toolbar { min-height: 54px; gap: 8px 12px; padding: 8px 12px; }
.quick-filter-bar { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.quick-filter-button.active { color: white; border-color: #44646d; background: #44646d; }
.quick-filter-button.empty { border-style: dashed; color: var(--muted); }
.inline-filter { display: flex; align-items: flex-end; gap: 8px; }
.inline-filter label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
.inline-filter select, .inline-filter input { width: 138px; }
.active-filter-tags {
  min-width: 120px;
  max-width: 420px;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.filter-tag {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  border: 1px solid #bfd5d6;
  border-radius: 999px;
  color: #28525c;
  background: #eef7f7;
  font-size: 11px;
  font-weight: 800;
}
.filter-tag span { font-size: 13px; line-height: 1; }
.filter-tag-empty { color: var(--muted); font-size: 11px; }
.compact-button { min-width: 48px; padding-inline: 10px; }

.table-wrap {
  width: 100%;
  max-height: calc(100vh - var(--sticky-table-head-top, 180px));
  overflow: auto;
}
table { width: 100%; min-width: 2280px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
#bulkRecordsTable { border-collapse: separate; border-spacing: 0; }
#bulkRecordsTable thead {
  position: sticky;
  top: 0;
  z-index: 10;
  transform: translateZ(0);
}
#bulkRecordsTable thead th { top: auto; }
th, td { height: 48px; padding: 8px 11px; border-bottom: 1px solid #e6ebea; text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; z-index: 6; height: 44px; color: #40555b; background: #f2f6f5; font-size: 13px; font-weight: 800; text-transform: none; }
td { color: #2b3a3e; font-size: 12px; }
tbody tr:hover { background: #f8fbfa; }
.table-total-row td {
  border-top: 2px solid #d7e1df;
  background: #f6faf9;
  font-weight: 800;
}
tbody tr.table-total-row:hover,
tbody tr.table-total-row:hover .locked-column { background: #f6faf9; }
.table-total-row .locked-column { background: #f6faf9; }
.total-label { color: #28525c; }
.inline-editable-cell {
  cursor: text;
  background:
    linear-gradient(135deg, rgba(0, 116, 126, .08), rgba(0, 116, 126, 0) 28px),
    #fff;
  box-shadow: inset 0 0 0 1px rgba(0, 116, 126, .08);
}
.inline-editable-cell.inline-empty-cell::after {
  content: "双击填写";
  margin-left: 6px;
  color: #789095;
  font-size: 10px;
  font-weight: 700;
}
.inline-editable-cell:hover { background: #eef7f7; }
.inline-editable-cell.inline-empty-cell:hover::after { color: var(--primary); }
.inline-cell-editor {
  width: 100%;
  min-width: 108px;
  height: 32px;
  padding-inline: 8px;
}
.draggable-column { cursor: grab; user-select: none; }
.draggable-column.dragging { opacity: .55; }
.drag-target { box-shadow: inset 2px 0 0 var(--primary); }
.column-title { display: inline-block; vertical-align: middle; }
.column-sort-button,
.column-lock-button {
  width: 24px;
  height: 24px;
  margin-left: 5px;
  border: 0;
  border-radius: 4px;
  color: #8a999c;
  background: transparent;
  font-size: 12px;
  line-height: 1;
}
.column-sort-button:hover,
.column-sort-button.active,
.column-lock-button:hover,
.column-lock-button.active { color: var(--primary); background: #e7f1f1; }
#bulkRecordsHead th {
  height: 44px;
}
#bulkRecordsFilterHead th {
  z-index: 5;
  height: 42px;
  padding: 5px 8px;
  background: #f8fbfa;
  box-shadow: inset 0 -1px 0 #dfe7e6;
}
.header-filter-control {
  width: 100%;
  min-width: 96px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid #d5dfde;
  border-radius: 4px;
  color: #2b3a3e;
  background: white;
  font: inherit;
  font-size: 12px;
}
.header-filter-control.active { border-color: var(--primary); background: #edf7f7; }
.locked-column {
  position: sticky;
  z-index: 2;
  background: #ffffff;
  box-shadow: 1px 0 0 #dfe7e6;
}
tbody tr:hover .locked-column { background: #f8fbfa; }
th.locked-column {
  z-index: 9;
  background: #f7f9f8;
  box-shadow: 1px 0 0 #d7e1df, 6px 0 10px rgba(24, 58, 66, .06);
}
#bulkRecordsFilterHead th.locked-column {
  z-index: 8;
  background: #f8fbfa;
}
.bulk-shipment-row > td {
  height: auto;
  vertical-align: top;
}
.bulk-group-cell {
  padding-top: 0;
  padding-bottom: 0;
}
.bulk-group-lines { min-height: 46px; }
.bulk-group-line {
  min-height: 46px;
  display: flex;
  align-items: center;
  padding: 5px 3px;
  border-bottom: 1px solid #e6ebea;
}
.bulk-group-line:last-child { border-bottom: 0; }
.bulk-group-cell.number .bulk-group-line { justify-content: flex-end; }
.bulk-group-shared-cell { vertical-align: middle !important; }
.bulk-group-shared-value {
  min-height: 46px;
  display: flex;
  align-items: center;
}
.bulk-group-cell.number .bulk-group-shared-value { justify-content: flex-end; }
.bulk-group-line.inline-editable-cell {
  margin-inline: -3px;
  padding-inline: 6px;
}
.bulk-group-line .attachment-drop { width: 100%; }
.bulk-group-select { width: 16px; height: 16px; accent-color: var(--primary); }
.number { text-align: right; }
.channel-cell { max-width: 230px; overflow: hidden; text-overflow: ellipsis; }
.status-chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 7px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.status-chip.normal { color: var(--success); background: var(--success-soft); }
.status-chip.missing { color: var(--warning); background: var(--warning-soft); }
.marker-cell { border: 0; cursor: pointer; }
.carrier-chip { display: inline-block; min-width: 65px; color: #28525c; font-weight: 700; }
.missing-fba { color: var(--warning); font-weight: 700; }
.edit-button { width: 30px; height: 30px; border: 1px solid #d2dada; background: white; color: #3f5c63; border-radius: 4px; font-size: 15px; }
.edit-button:hover { border-color: var(--primary); color: var(--primary); }
.select-column { width: 42px; text-align: center; }
.select-column input, td > input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); }
.boolean-button { min-width: 50px; height: 28px; border: 1px solid #ced8d7; border-radius: 4px; background: white; color: #647277; font-size: 11px; }
.boolean-button.on { color: var(--success); border-color: #9fc4b5; background: var(--success-soft); }
.attachment-links { display: flex; gap: 5px; }
.attachment-link { color: var(--primary); text-decoration: none; font-weight: 700; }
.attachment-file {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 24px;
  padding-left: 6px;
  border: 1px solid #d5e0df;
  border-radius: 4px;
  background: white;
}
.attachment-delete {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-left: 1px solid #e0e7e6;
  color: var(--danger);
  background: transparent;
  font-size: 15px;
  line-height: 1;
}
.attachment-delete:hover { background: #fff0f0; }
.filter-count { min-width: 18px; height: 18px; display: inline-grid; place-items: center; border-radius: 9px; color: white; background: var(--warning); font-size: 10px; }
.attachment-drop {
  min-width: 88px;
  min-height: 34px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 5px 8px;
  border: 1px dashed #c7d4d3;
  border-radius: 4px;
  background: #fbfdfc;
  color: #6a797d;
  cursor: pointer;
}
.attachment-drop:hover, .attachment-drop.dragover {
  border-color: var(--primary);
  background: #edf7f7;
  color: var(--primary);
}
.attachment-drop-links { display: flex; gap: 5px; min-height: 15px; }
.attachment-empty { color: #9aa6a8; }
.attachment-drop-hint { font-size: 10px; line-height: 1; }
.table-footer { min-height: 45px; display: flex; justify-content: space-between; align-items: center; padding: 0 16px; color: var(--muted); font-size: 11px; background: #fafcfc; }
.pager-actions { display: inline-flex; align-items: center; gap: 10px; }
.footer-page-size select { width: 96px; }
.link-button { text-decoration: none; }
.subsection-header { min-height: 64px; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 18px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #fafcfc; }
.subsection-header h2 { margin: 0; font-size: 19px; }
.subsection-header p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.month-confirm { display: grid; gap: 7px; margin-top: 14px; color: var(--muted); font-size: 12px; font-weight: 700; }
.month-confirm input { min-height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; font: inherit; color: var(--text); background: white; }
.customs-form { padding: 18px; }
.form-band { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.form-band label, .form-grid label, .config-panel label { display: grid; gap: 7px; font-size: 13px; font-weight: 700; }
.field-map-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; padding: 18px; border-top: 1px solid var(--line); }
.field-map-grid label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.field-map-grid input { min-height: 38px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; font: inherit; color: var(--text); background: white; }
.secondary-button.danger { color: var(--danger); border-color: #e2bbbb; }
.mapping-page-section, .invoice-template-section { overflow: hidden; }
.mapping-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: calc(100vh - 145px); }
.mapping-side-panel { padding: 20px; border-right: 1px solid var(--line); background: #f7f9f8; }
.mapping-side-panel label { display: grid; gap: 8px; color: #53666b; font-size: 12px; font-weight: 700; }
.mapping-side-copy { display: grid; gap: 7px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.mapping-side-copy strong { font-size: 13px; }
.mapping-side-copy span { color: var(--muted); font-size: 12px; line-height: 1.6; }
.mapping-main-panel { min-width: 0; padding: 20px; }
.mapping-main-panel .form-band { grid-template-columns: 1.1fr 1.3fr 120px; }
.mapping-main-panel .field-map-grid { margin-top: 18px; padding: 18px 0 0; grid-template-columns: repeat(auto-fit, minmax(430px, 1fr)); }
.mapping-field-row {
  display: grid;
  grid-template-columns: minmax(150px, .9fr) minmax(190px, 1.15fr) 34px;
  gap: 10px;
  align-items: end;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafcfc;
}
.mapping-field-row label { display: grid; gap: 7px; color: #53666b; font-size: 12px; font-weight: 800; }
.mapping-field-row input,
.mapping-field-row select { width: 100%; min-width: 0; }
.settings-form > .modal-actions, .mapping-main-panel > .modal-actions { border-top: 1px solid var(--line); }
.custom-column-layout {
  display: grid;
  grid-template-columns: minmax(280px, .8fr) minmax(320px, 1.2fr);
  gap: 18px;
  padding: 18px 22px 0;
}
.custom-column-editor-panel,
.custom-column-list-panel {
  display: grid;
  align-content: start;
  gap: 12px;
}
.custom-column-editor-panel label { display: grid; gap: 7px; color: #40555b; font-size: 13px; font-weight: 800; }
.custom-column-list-panel {
  min-height: 220px;
  padding-left: 18px;
  border-left: 1px solid var(--line);
}
.custom-column-list-panel h3 { margin: 0; font-size: 17px; font-weight: 800; }
.custom-column-list-panel .column-settings-list { max-height: 330px; overflow-y: auto; }
.template-selector-bar {
  display: grid;
  grid-template-columns: minmax(260px, 420px) 1fr auto;
  gap: 14px;
  align-items: end;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: #f8faf9;
}
.template-selector-bar label { display: grid; gap: 7px; color: #40555b; font-size: 13px; font-weight: 800; }
.template-selector-bar .toolbar-note { align-self: center; }
.template-project-bar { display: grid; grid-template-columns: minmax(190px, 1fr) minmax(190px, 1fr) minmax(170px, .8fr) auto; gap: 14px; align-items: end; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.template-project-bar label { display: grid; gap: 7px; color: #40555b; font-size: 13px; font-weight: 800; }
.invoice-template-section .settings-form { height: calc(100vh - 150px); display: flex; flex-direction: column; overflow: hidden; }
.template-selector-bar, .template-project-bar { flex: 0 0 auto; }
.invoice-builder-layout { flex: 1 1 auto; min-height: 0; display: grid; grid-template-columns: 270px minmax(0, 1fr); overflow: hidden; }
.invoice-field-palette { min-height: 0; overflow-y: auto; padding: 20px; border-right: 1px solid var(--line); background: #f7f9f8; }
.invoice-field-palette h2, .panel-heading h2 { margin: 0; font-size: 18px; font-weight: 800; }
.invoice-field-palette h2:not(:first-child) { margin-top: 24px; }
.invoice-field-palette p, .panel-heading p { margin: 7px 0 14px; color: var(--muted); font-size: 12px; line-height: 1.55; }
.field-chip-list { display: flex; flex-wrap: wrap; gap: 7px; }
.field-chip { min-height: 30px; padding: 0 9px; border: 1px solid #bfd0d1; border-radius: 4px; color: #31555e; background: white; font-size: 12px; font-weight: 700; cursor: grab; }
.field-chip:hover { border-color: var(--primary); color: var(--primary); }
.invoice-column-panel { min-width: 0; min-height: 0; display: flex; flex-direction: column; padding: 20px; overflow: hidden; }
.panel-heading { display: flex; justify-content: space-between; gap: 14px; }
.invoice-template-columns { min-height: 0; overflow-y: auto; display: grid; gap: 8px; margin-top: 14px; padding-right: 4px; }
.invoice-column-panel .panel-heading,
.invoice-column-panel .form-error,
.invoice-column-panel .modal-actions { flex: 0 0 auto; }
.contract-template-section { padding: 0; }
.contract-template-form { padding: 20px; display: grid; gap: 18px; }
.contract-template-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.contract-template-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.contract-template-editor label { display: grid; gap: 7px; color: #40555b; font-size: 13px; font-weight: 800; }
.contract-template-editor textarea { min-height: 86px; resize: vertical; line-height: 1.55; }
.contract-template-editor label:nth-child(4),
.contract-template-editor label:nth-child(5) { grid-column: 1 / -1; }
.contract-template-editor label:nth-child(4) textarea { min-height: 190px; }
.invoice-column-row { display: grid; grid-template-columns: 28px minmax(160px, .9fr) minmax(150px, .62fr) minmax(260px, 1.35fr) 34px; gap: 10px; align-items: start; padding: 12px; border: 1px solid var(--line); border-radius: 6px; background: white; }
.invoice-column-row.dragging { opacity: .55; }
.invoice-column-row label { display: grid; gap: 6px; color: #52676c; font-size: 12px; font-weight: 800; }
.invoice-column-row input,
.invoice-column-row select { width: 100%; min-width: 0; }
.drag-handle { align-self: center; color: #8a999c; font-size: 18px; cursor: grab; }
.invoice-source-drop { display: grid; gap: 6px; min-width: 0; color: #52676c; font-size: 12px; font-weight: 800; }
.invoice-source-label { display: block; }
.field-name-toggle { display: inline-flex !important; align-items: center; justify-self: start; gap: 7px !important; min-height: 25px; color: #52676c; font-size: 11px !important; font-weight: 700 !important; cursor: pointer; }
.field-name-toggle input { width: 15px; height: 15px; margin: 0; accent-color: var(--primary); }
.field-name-toggle:has(input:disabled) { color: #9aa5a7; cursor: not-allowed; }
.invoice-source-drop.dragover { padding: 5px; outline: 2px dashed var(--primary); border-radius: 5px; background: #edf7f7; }
.composite-field-editor { display: grid; gap: 7px; }
.composite-field-list { display: flex; flex-wrap: wrap; gap: 6px; min-height: 34px; align-items: center; padding: 5px; border: 1px dashed #bfd0d1; border-radius: 5px; background: #f8fbfa; }
.composite-field-token { display: inline-flex; align-items: center; gap: 5px; min-height: 25px; padding: 0 5px 0 8px; border: 1px solid #bad0d1; border-radius: 4px; color: #28525c; background: white; font-size: 11px; font-weight: 800; }
.composite-field-label-toggle { display: inline-flex !important; grid-template-columns: none !important; align-items: center; gap: 3px !important; min-height: auto; color: #607376 !important; font-size: 10px !important; font-weight: 700 !important; cursor: pointer; }
.composite-field-label-toggle input { width: 12px; height: 12px; margin: 0; accent-color: var(--primary); }
.composite-field-token button { width: 20px; height: 20px; padding: 0; border: 0; color: #7f8f92; background: transparent; font-size: 15px; }
.composite-field-token button:hover { color: var(--danger); }
.composite-empty { padding-left: 5px; color: var(--muted); font-size: 11px; font-weight: 600; }
.composite-field-editor small { color: var(--muted); font-size: 10px; font-weight: 600; line-height: 1.4; }
.template-delete-button { align-self: center; color: var(--danger); }
.subject-credit-layout { display: grid; grid-template-columns: minmax(360px, .72fr) minmax(0, 1.65fr); }
.subject-credit-layout > .config-panel { min-width: 0; }
.subject-credit-layout .config-panel:first-child { display: grid; align-content: start; gap: 14px; }
.subject-custom-inputs { display: grid; gap: 14px; }
.subject-field-manager { display: grid; gap: 12px; margin-bottom: 18px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.subject-field-manager h2 { margin-bottom: 4px; }
.subject-field-manager p { margin: 0; color: var(--muted); font-size: 12px; }
.subject-custom-field-list { display: grid; gap: 8px; }
.subject-custom-field-row { display: grid; grid-template-columns: minmax(0, 1fr) 34px; gap: 8px; align-items: center; }
.subject-field-delete { color: var(--danger); }
.subject-field-empty { min-height: 38px; display: grid; place-items: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 5px; font-size: 12px; }
.subject-field-actions, .recycle-inline-actions { display: inline-flex; gap: 8px; align-items: center; }
.subject-credit-table { width: 100%; max-width: 100%; max-height: calc(100vh - 210px); }
.subject-credit-table table { min-width: 1480px; }
.subject-address-cell { max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.column-settings-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 20px 22px; }
.column-setting-item { display: flex; align-items: center; gap: 9px; min-height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 5px; font-weight: 700; }
.column-setting-item input { width: 16px; height: 16px; accent-color: var(--primary); }
.quick-filter-editor {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 18px 22px 0;
}
.quick-filter-card {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fafcfc;
}
.quick-filter-card label {
  display: grid;
  gap: 7px;
  color: #40555b;
  font-size: 12px;
  font-weight: 800;
}
.quick-filter-condition-list { display: grid; gap: 10px; }
.quick-filter-condition-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.export-field-toolbar { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 22px 0; }
.export-fields-list { max-height: min(52vh, 520px); overflow-y: auto; align-content: start; }
.modal-actions-padded { padding: 14px 22px 20px; border-top: 1px solid var(--line); }
.recycle-toolbar { min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 18px; border-bottom: 1px solid var(--line); background: #fafcfc; }
.recycle-toolbar > span { color: var(--muted); font-size: 12px; font-weight: 800; }
.billing-recycle-table { max-height: min(62vh, 620px); }
.billing-recycle-table table { min-width: 1120px; }
.recycle-empty { height: 180px; color: var(--muted); text-align: center; }
.product-name-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.compact-table table { min-width: 900px; }
.customs-history-table table { min-width: 1480px; }
.row-actions { display: inline-flex; justify-content: flex-end; align-items: center; gap: 5px; }
.mini-button { min-height: 28px; display: inline-flex; align-items: center; justify-content: center; padding: 0 8px; border: 1px solid #ced8d7; border-radius: 4px; color: #2a4148; background: white; font-size: 11px; font-weight: 700; line-height: 1; text-decoration: none; vertical-align: middle; }
.mini-button:hover { border-color: var(--primary); color: var(--primary); }
.mini-button.danger { color: var(--danger); border-color: #e2bbbb; }
.mini-button.warning { color: #8f541f; border-color: #e4c09e; }
.status-tag { display: inline-flex; max-width: 210px; padding: 4px 7px; border-radius: 4px; font-size: 11px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.status-success { color: var(--success); background: var(--success-soft); }
.status-fail { color: var(--danger); background: #fdecec; }
.status-wait { color: #365d84; background: #edf4fb; }
.config-layout { display: grid; grid-template-columns: minmax(260px, .8fr) minmax(0, 1.4fr); gap: 0; }
.config-panel { padding: 20px; border-right: 1px solid var(--line); }
.config-panel:last-child { border-right: 0; }
.config-panel h2 { margin: 0 0 14px; font-size: 19px; font-weight: 800; }
.user-management-section { overflow: hidden; }
.user-management-layout { display: grid; grid-template-columns: minmax(330px, .7fr) minmax(620px, 1.5fr); min-height: calc(100vh - 145px); }
.user-editor { display: grid; align-content: start; gap: 16px; background: #f8faf9; }
.user-editor .subsection-header,
.user-list-panel .subsection-header { min-height: auto; margin: -20px -20px 0; border-top: 0; }
.user-form-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.user-form-fields label:not(.check-field) { grid-column: 1 / -1; }
.permission-editor { display: grid; gap: 10px; }
.permission-editor h3 { margin: 0; font-size: 15px; }
.permission-grid { display: grid; gap: 10px; }
.permission-group {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid #e0e8e7;
  border-radius: 6px;
  background: #f9fbfa;
}
.permission-group h4 { margin: 0; color: #27474f; font-size: 13px; font-weight: 800; }
.permission-group-options { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.permission-option {
  min-height: 48px;
  display: flex !important;
  grid-template-columns: auto 1fr !important;
  align-items: center;
  gap: 9px !important;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: white;
}
.permission-option input { width: 16px; height: 16px; flex: 0 0 auto; accent-color: var(--primary); }
.permission-option span { display: grid; gap: 1px; }
.permission-option strong { color: #31484e; font-size: 12px; }
.permission-option small { color: var(--muted); font-size: 10px; }
.permission-option.disabled { background: #f0f4f3; }
.user-list-panel { min-width: 0; }
.login-record-panel { grid-column: 1 / -1; min-width: 0; }
.login-record-table-wrap { max-height: 360px; margin: 0 -20px -20px; }
.login-record-table-wrap table { min-width: 920px; }
.audit-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 220px) minmax(160px, 220px) minmax(240px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #f8faf9;
}
.audit-toolbar label {
  display: grid;
  gap: 7px;
  color: #40555b;
  font-size: 13px;
  font-weight: 800;
}
.audit-table-wrap,
.backup-table-wrap { max-height: calc(100vh - 280px); }
.audit-table-wrap table { min-width: 1680px; }
.backup-table-wrap table { min-width: 1080px; }
.audit-pager {
  min-height: 58px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.backup-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}
.backup-schedule-panel {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) repeat(6, minmax(118px, 160px)) auto;
  gap: 14px;
  align-items: end;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: #f8faf9;
}
.backup-schedule-panel h2 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 850;
  color: var(--text);
}
.backup-schedule-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.backup-schedule-panel label {
  display: grid;
  gap: 7px;
  color: #40555b;
  font-size: 13px;
  font-weight: 800;
}
.backup-summary-grid .metric { border-bottom: 0; }
.log-result-chip,
.backup-status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 800;
}
.log-result-chip.success,
.backup-status-chip.success { color: var(--success); background: var(--success-soft); }
.log-result-chip.fail,
.backup-status-chip.failed { color: var(--danger); background: #fdecec; }
.backup-status-chip.running { color: #365d84; background: #edf4fb; }
.audit-message-cell,
.audit-fields-cell,
.audit-change-cell,
.backup-message-cell {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.audit-change-cell { max-width: 420px; white-space: normal; line-height: 1.55; }
.audit-fields-cell { max-width: 240px; white-space: normal; line-height: 1.55; }
.user-table-wrap { max-height: calc(100vh - 220px); margin: 0 -20px -20px; }
.user-table-wrap table { min-width: 1080px; }
.user-table-wrap td:first-child strong { font-size: 13px; }
.current-user-mark { display: block; margin-top: 3px; color: var(--primary); font-size: 10px; font-weight: 700; }
.permission-tags { display: flex; flex-wrap: wrap; gap: 4px; max-width: 430px; white-space: normal; }
.permission-tags span,
.ip-rule-tags span {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  padding: 0 6px;
  border: 1px solid #cedcda;
  border-radius: 4px;
  color: #3c5b62;
  background: #f5f9f8;
  font-size: 10px;
  font-weight: 700;
}
.ip-rule-tags { display: flex; flex-wrap: wrap; gap: 4px; max-width: 260px; white-space: normal; }
.permission-tags em,
.ip-rule-tags em { color: var(--muted); font-size: 11px; font-style: normal; }
.user-list-empty { height: 180px; color: var(--muted); text-align: center; }
.error-text { color: var(--danger); }
.xml-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 18px; }
.xml-grid h3 { margin: 0 0 8px; font-size: 14px; }
.xml-box { min-height: 220px; max-height: 58vh; margin: 0; padding: 12px; overflow: auto; border: 1px solid var(--line); border-radius: 5px; background: #f8faf9; color: #26383d; font-family: Consolas, "SFMono-Regular", monospace; font-size: 12px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.status-box { margin: 18px; min-height: 140px; }
.empty-state { min-height: 410px; display: grid; place-items: center; align-content: center; text-align: center; padding: 30px; }
.empty-icon { width: 54px; height: 54px; display: grid; place-items: center; border: 1px solid #cad6d5; color: var(--primary); font-size: 27px; border-radius: 7px; }
.empty-state h2 { margin: 18px 0 6px; font-size: 18px; }
.empty-state p { margin: 0 0 19px; color: var(--muted); }

.modal-layer, .drawer-layer { position: fixed; inset: 0; z-index: 20; background: rgba(12, 29, 34, .42); }
.modal-layer { display: grid; place-items: center; padding: 20px; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: white; border-radius: 7px; box-shadow: 0 18px 56px rgba(0,0,0,.18); }
.edit-modal { width: min(720px, 100%); }
.wide-modal { width: min(1040px, 100%); }
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 21px; font-weight: 800; }
.modal-header p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.icon-button { width: 34px; height: 34px; flex: 0 0 auto; border: 0; border-radius: 4px; background: transparent; color: #5c6b6f; font-size: 25px; line-height: 1; }
.icon-button:hover { background: var(--soft); }
#uploadForm, #bulkUploadForm { padding: 22px; }
#mappingForm, #invoiceForm { padding: 22px; }
.drop-zone { min-height: 190px; display: grid; place-items: center; align-content: center; gap: 9px; border: 1px dashed #9db0b3; border-radius: 6px; background: #f8faf9; color: var(--muted); cursor: pointer; line-height: 1.55; }
.drop-zone.dragover { border-color: var(--primary); background: #edf7f7; }
.drop-zone strong { color: var(--ink); font-size: 15px; }
.drop-zone span:last-child { font-size: 12px; }
.file-list, .file-item { line-height: 1.55; }
.upload-symbol { color: var(--primary); font-size: 31px; }
.file-list { display: grid; gap: 8px; margin-top: 12px; }
.file-item { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 5px; }
.file-item span { color: var(--muted); font-size: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 18px; }
.edit-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 22px; }
.wide-field { grid-column: 1 / -1; }
.check-field { display: flex !important; grid-template-columns: auto 1fr; align-items: center; justify-content: flex-start; gap: 8px !important; min-height: 38px; padding: 0 11px; border: 1px solid var(--line); border-radius: 5px; }
.check-field input { width: 16px; height: 16px; accent-color: var(--primary); }
.attachment-section { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding-top: 4px; }
.attachment-section > div { padding: 13px; border: 1px solid var(--line); border-radius: 5px; }
.attachment-list { min-height: 24px; margin: 8px 0; color: var(--muted); font-size: 12px; }
.attachment-list .attachment-file { display: flex; width: 100%; justify-content: space-between; margin: 6px 0; }
.attachment-list a { display: block; min-width: 0; color: var(--primary); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-action { display: inline-flex !important; width: auto; color: var(--primary); cursor: pointer; font-weight: 700; }
.compact-drop { min-height: 145px; }
.filter-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 22px; }
.filter-form label { display: grid; gap: 7px; font-size: 13px; font-weight: 700; }
.radio-option { display: flex; align-items: center; gap: 9px; min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 5px; margin-bottom: 9px; font-weight: 700; }
.radio-option input { width: 16px; height: 16px; accent-color: var(--primary); }

.drawer-layer { display: flex; justify-content: flex-end; }
.drawer { width: min(440px, 100%); height: 100%; overflow: auto; background: white; box-shadow: -12px 0 40px rgba(0,0,0,.14); }
.imports-list { display: grid; gap: 0; }
.import-item { padding: 16px 22px; border-bottom: 1px solid var(--line); }
.import-item strong { display: block; margin-bottom: 6px; overflow-wrap: anywhere; }
.import-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; color: var(--muted); font-size: 12px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 40; max-width: 380px; padding: 12px 15px; color: white; background: #244b55; border-radius: 5px; box-shadow: 0 10px 30px rgba(0,0,0,.18); }

@media (min-width: 981px) {
  body:has(#billingView:not(.hidden)), body:has(#bulkBillingView:not(.hidden)) { overflow: hidden; }
  .workspace:has(#billingView:not(.hidden)), .workspace:has(#bulkBillingView:not(.hidden)) { height: 100vh; overflow: hidden; padding-bottom: 16px; }
  #billingView:not(.hidden),
  #bulkBillingView:not(.hidden) {
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr);
  }
  #billingView > .topbar,
  #billingView > .summary-grid,
  #billingView > .content-section > .toolbar,
  #bulkBillingView > .topbar,
  #bulkBillingView > .summary-grid,
  #bulkBillingView > .content-section > .toolbar {
    position: static;
  }
  #billingView > .content-section,
  #bulkBillingView > .content-section {
    min-height: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
  }
  #billingView .table-wrap, #bulkBillingView .table-wrap { min-height: 0; max-height: none; }
}

@media (max-width: 980px) {
  #billingView > .topbar,
  #billingView > .summary-grid,
  #billingView > .content-section > .toolbar,
  #bulkBillingView > .topbar,
  #bulkBillingView > .summary-grid,
  #bulkBillingView > .content-section > .toolbar { position: static; }
  #billingView .table-wrap {
    min-height: 280px;
    max-height: calc(100vh - 180px);
  }
  #bulkBillingView .table-wrap {
    min-height: 280px;
    max-height: calc(100vh - 180px);
  }
  .app-shell { grid-template-columns: 76px minmax(0, 1fr); }
  .sidebar { width: 76px; padding-inline: 10px; }
  .sidebar-brand { justify-content: center; padding-inline: 0; }
  .sidebar-copy, .nav-item:not(.active) > :not(.nav-icon), .nav-item.active > :not(.nav-icon) { display: none; }
  .nav-group-title > :not(.nav-icon) { display: none; }
  .sidebar-toggle { display: none; }
  body.sidebar-collapsed .sidebar nav { margin-top: 18px; }
  .nav-item { justify-content: center; padding: 0; font-size: 0; }
  .nav-icon { font-size: 18px; }
  .workspace { grid-column: 2; padding: 22px 18px 34px; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .billing-summary-grid .metric:nth-child(2n),
  .bulk-summary-grid .metric:nth-child(2n) { border-right: 0; }
  .billing-summary-grid .metric:nth-child(-n+4),
  .bulk-summary-grid .metric:nth-child(-n+4) { border-bottom: 1px solid var(--line); }
  #bulkBillingView .bulk-search-control { width: min(280px, 100%); }
  .active-filter-tags { max-width: 100%; }
  .quick-filter-editor { grid-template-columns: 1fr; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .form-band { grid-template-columns: 1fr 1fr; }
  .mapping-layout, .invoice-builder-layout, .subject-credit-layout, .user-management-layout { grid-template-columns: 1fr; }
  .backup-schedule-panel { grid-template-columns: 1fr 1fr; }
  .backup-schedule-panel > div { grid-column: 1 / -1; }
  .mapping-side-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .invoice-field-palette { border-right: 0; border-bottom: 1px solid var(--line); }
  .invoice-column-row { grid-template-columns: 24px 1fr 150px 1fr 34px; }
  .template-selector-bar { grid-template-columns: 1fr auto; }
  .template-selector-bar .toolbar-note { grid-column: 1 / -1; grid-row: 2; }
  .mapping-main-panel .field-map-grid { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
  .config-layout, .xml-grid { grid-template-columns: 1fr; }
  .config-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .user-table-wrap { max-height: 520px; }
  .search-control { width: 100%; }
  .inline-filter { width: 100%; align-items: stretch; }
  .inline-filter label { flex: 1; }
  .inline-filter select, .inline-filter input { width: 100%; }
  .toolbar-actions { width: 100%; justify-content: flex-end; }
}

@media (max-width: 620px) {
  .app-shell { display: grid; grid-template-columns: 76px minmax(0, 1fr); }
  .sidebar { inset: 0 auto 0 0; z-index: 10; width: 76px; height: auto; flex-direction: column; align-items: stretch; padding: 10px; }
  .sidebar-brand { display: flex; justify-content: center; padding: 0 0 10px; }
  .sidebar-copy, .sidebar-toggle { display: none; }
  .current-user-badge { display: none; }
  .sidebar-bottom { display: block; }
  .sidebar nav { width: 100%; grid-template-columns: 1fr; margin: 8px 0 0; }
  .workspace { grid-column: 2; padding: 18px 12px 26px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar h1 { font-size: 19px; }
  .topbar p { display: none; }
  .header-actions { width: 100%; flex-wrap: wrap; }
  .header-actions .secondary-button:has(> span) { width: 40px; padding: 0; font-size: 0; }
  .header-actions .secondary-button:has(> span) span { font-size: 18px; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .backup-summary-grid, .backup-schedule-panel { grid-template-columns: 1fr; }
  .backup-schedule-panel > div { grid-column: auto; }
  .metric { padding: 14px; }
  .metric strong { font-size: 16px; line-height: 1.25; }
  .metric strong em { font-size: 12px; }
  .metric small { display: none; }
  .toolbar-left { align-items: stretch; flex-direction: column; }
  .form-band, .form-grid { grid-template-columns: 1fr; }
  .mapping-main-panel .form-band, .mapping-main-panel .field-map-grid { grid-template-columns: 1fr; }
  .mapping-field-row, .custom-column-layout { grid-template-columns: 1fr; }
  .custom-column-list-panel { padding-left: 0; border-left: 0; border-top: 1px solid var(--line); padding-top: 14px; }
  .template-selector-bar, .template-project-bar, .invoice-column-row, .contract-template-grid, .contract-template-editor { grid-template-columns: 1fr; }
  .template-selector-bar .toolbar-note { grid-column: auto; grid-row: auto; }
  .drag-handle { display: none; }
  .column-settings-list { grid-template-columns: 1fr; }
  .recycle-toolbar { align-items: stretch; flex-direction: column; }
  .recycle-toolbar .header-actions { width: 100%; }
  .recycle-toolbar .header-actions button { flex: 1; }
  .subsection-header { align-items: stretch; flex-direction: column; }
  .subsection-header .header-actions { flex-wrap: wrap; }
  .month-control { justify-content: space-between; }
  .month-control select { flex: 1; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; }
  .inline-filter { flex-wrap: wrap; }
  .inline-filter label { flex: 1 1 145px; }
  .inline-filter .compact-button { flex: 1 1 100%; }
  .edit-form { grid-template-columns: 1fr; }
  .wide-field { grid-column: auto; }
  .attachment-section, .filter-form { grid-template-columns: 1fr; }
  .user-form-fields, .permission-group-options { grid-template-columns: 1fr; }
}
