/* 外贸管家系统主样式。
   覆盖桌面、平板、手机和小程序 web-view，保持管理后台清爽、可扫描。 */
:root {
  --workspace-bg: #eef7ff;
  --bg: var(--workspace-bg);
  --surface: #ffffff;
  --surface-2: #f7fbff;
  --surface-raised: #ffffff;
  --surface-panel: #ffffff;
  --surface-muted: #f5f9ff;
  --text: #17242e;
  --muted: #687887;
  --border: #d8e8f6;
  --border-soft: #e2eef8;
  --accent: #2f86ff;
  --accent-strong: #166fdc;
  --accent-soft: #eaf4ff;
  --green: var(--accent);
  --green-soft: var(--accent-soft);
  --blue: #256fbd;
  --blue-soft: #eef5ff;
  --amber: #b87411;
  --amber-soft: #fff6e3;
  --red: #bf3d3d;
  --red-soft: #fff0ef;
  --sidebar-bg: #ffffff;
  --sidebar-bg-2: #f8fbfd;
  --sidebar-text: #20303b;
  --focus: rgba(47, 134, 255, 0.20);
  --shadow: 0 14px 30px rgba(23, 32, 38, 0.08);
  --shadow-soft: 0 8px 24px rgba(31, 44, 56, 0.05);
  --shadow-panel: 0 1px 2px rgba(15, 25, 33, 0.04), 0 12px 28px rgba(31, 44, 56, 0.055);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  overflow-x: hidden;
  background: var(--workspace-bg);
  overscroll-behavior-x: none;
}

body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-x: none;
}

#app {
  min-height: 100vh;
  background: var(--bg);
}

@supports (min-height: 100dvh) {
  #app {
    min-height: 100dvh;
  }
}

.loading {
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.login-page {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  overflow: hidden;
  background: linear-gradient(135deg, #f8fbfd 0%, #eef5f8 48%, #f5f8fb 100%);
}

.login-panel {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(221, 230, 238, 0.88);
  border-radius: 8px;
  box-shadow: 0 20px 46px rgba(21, 35, 45, 0.12);
  padding: 30px;
  overflow: hidden;
}

.login-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--green), #67c5e8);
}

.login-panel h1 {
  margin: 24px 0 20px;
  font-size: 26px;
  line-height: 1.15;
}

.login-panel p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  margin: 8px 0 20px;
}

.login-panel form {
  display: grid;
  gap: 15px;
}

.login-panel label {
  gap: 8px;
}

.login-panel input {
  min-height: 46px;
  padding: 10px 13px;
  background: #fbfdff;
}

.login-panel .primary {
  min-height: 46px;
  margin-top: 2px;
  font-size: 15px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #12232b;
  font-size: 18px;
}

.login-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(180deg, #11a78d, #0c8f78);
  color: white;
  font-weight: 800;
  box-shadow: 0 10px 20px rgba(12, 143, 120, 0.22);
}

.form-error {
  min-height: 36px;
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid #f3c3bf;
  background: var(--red-soft);
  color: var(--red);
  border-radius: 8px;
  font-size: 13px;
}

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

button {
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--focus);
}

input::placeholder {
  color: #9aa7b3;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #102026;
  color: white;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: grid;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: #e7fff6;
  color: #0f604f;
  border-radius: 8px;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 15px;
  line-height: 1.3;
}

.brand span,
.sidebar-footer span {
  color: #b7c5c9;
  font-size: 12px;
  margin-top: 4px;
}

nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  border: 0;
  background: transparent;
  color: #d9e4e7;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 8px;
  text-align: left;
}

.nav-item svg,
.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item.active,
.nav-item:hover {
  background: #1d363e;
  color: white;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.main {
  min-width: 0;
  padding: 26px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 25px;
  line-height: 1.25;
}

.topbar p,
.muted {
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
}

.topbar-actions,
.toolbar-row,
.button-row,
.form-actions,
.row-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.link-banner {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 10px 14px;
  background: #f0faf6;
  border: 1px solid #d3eee4;
  border-radius: 8px;
  color: #17483e;
  font-size: 13px;
  box-shadow: 0 1px 2px rgba(23, 32, 38, 0.03);
}

.link-banner span {
  color: var(--text);
}

.topbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.search,
input,
select,
textarea {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  min-height: 38px;
  padding: 8px 10px;
  outline: none;
}

.search {
  width: min(300px, 45vw);
}

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

.primary,
.ghost,
.danger,
.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 38px;
  border-radius: 8px;
  padding: 8px 14px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  white-space: nowrap;
}

.primary {
  background: linear-gradient(180deg, #3b9cff 0%, var(--accent-strong) 100%);
  color: white;
  box-shadow: 0 8px 18px rgba(47, 134, 255, 0.18);
}

.primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ghost {
  background: white;
  color: var(--text);
  border-color: var(--border);
  box-shadow: 0 1px 2px rgba(28, 43, 56, 0.04);
}

.danger {
  background: var(--red-soft);
  color: var(--red);
  border-color: #f3c3bf;
}

.small {
  min-height: 32px;
  padding: 6px 10px;
}

.toolbar-row {
  justify-content: space-between;
  margin-bottom: 16px;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  background: white;
  border-radius: 8px;
  padding: 3px;
}

.segmented button {
  border: 0;
  background: transparent;
  border-radius: 6px;
  padding: 7px 14px;
  color: var(--muted);
}

.segmented button.active {
  background: var(--accent);
  color: white;
}

.period-label {
  color: var(--muted);
  font-size: 13px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

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

.kpi {
  min-height: 112px;
  padding: 16px;
  display: grid;
  gap: 8px;
}

.kpi span,
.kpi small {
  color: var(--muted);
  font-size: 12px;
}

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

.kpi.green {
  background: var(--surface-panel);
}

.kpi.blue {
  background: var(--surface-panel);
}

.kpi.amber {
  background: var(--surface-panel);
}

.kpi.red {
  background: var(--surface-panel);
}

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

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

.panel {
  padding: 18px;
  overflow: hidden;
}

.panel + .panel,
.editor {
  margin-top: 16px;
}

.wide {
  grid-column: span 2;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-title h2 {
  font-size: 16px;
  line-height: 1.35;
  letter-spacing: 0;
}

.panel-title span {
  color: #748491;
  font-size: 12px;
  line-height: 1.5;
}

.panel-title-with-filter {
  align-items: flex-end;
}

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

.inline-filter select {
  min-width: 132px;
  min-height: 34px;
  padding: 6px 9px;
}

.bars {
  display: grid;
  gap: 14px;
}

.bar-row {
  display: grid;
  grid-template-columns: 50px 1fr 110px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: #edf1f3;
  overflow: hidden;
}

.bar {
  height: 100%;
  border-radius: inherit;
}

.bar.green {
  background: var(--green);
}

.bar.gray {
  background: #7b8a94;
}

.bar.blue {
  background: var(--blue);
}

.bar.amber {
  background: var(--amber);
}

.stat-line {
  min-height: 48px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.stat-line:last-child {
  border-bottom: 0;
}

.stat-line span {
  color: var(--text);
}

.stat-line strong {
  color: var(--blue);
}

.stat-line em {
  grid-column: 1 / -1;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.table-wrap {
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  overflow-x: auto;
  background: #fff;
}

table {
  width: 100%;
  min-width: max(1080px, 100%);
  border-collapse: separate;
  border-spacing: 0;
  table-layout: auto;
  font-size: 13px;
}

th,
td {
  border-bottom: 1px solid var(--border-soft);
  padding: 12px 12px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.45;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7fbff;
  color: #51606d;
  font-weight: 800;
  font-size: 12px;
}

td {
  color: #25313a;
}

th:last-child,
td:last-child {
  width: 220px;
}

.order-customer-cell {
  display: inline-flex;
  min-width: 138px;
  flex-direction: column;
  gap: 4px;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
}

.order-customer-cell strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

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

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

tbody tr:hover {
  background: #f8fbfd;
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.icon-btn {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border: 1px solid var(--border-soft);
  background: white;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--text);
  box-shadow: 0 1px 2px rgba(28, 43, 56, 0.04);
}

.link-action {
  min-width: 70px;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border: 1px solid #d5e7f8;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
  white-space: nowrap;
  margin-right: 6px;
}

.customer-editor {
  padding: 22px 24px 20px;
}

.customer-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 14px 18px;
  align-items: end;
}

.customer-form-grid .wide-field {
  grid-column: 1 / -1;
}

.customer-form-grid textarea {
  min-height: 86px;
}

.customer-list-panel {
  padding: 14px;
}

.customer-list-panel .table-wrap {
  border-radius: 8px;
}

.customer-title-cell {
  display: grid;
  gap: 4px;
}

.customer-title-cell strong {
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.customer-title-cell span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.customer-tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  max-width: 100%;
  padding: 4px 10px;
  border: 1px solid #cce7dd;
  border-radius: 999px;
  background: #eefaf5;
  color: #08735f;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: keep-all;
}

.customer-table-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.customer-table-actions .link-action {
  margin-right: 0;
}

.danger-icon {
  color: var(--red);
  font-size: 18px;
}

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

label {
  display: grid;
  gap: 6px;
  color: #34434d;
  font-size: 13px;
}

label span {
  font-weight: 700;
}

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

.form-actions {
  margin-top: 14px;
  justify-content: flex-end;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-color: var(--border);
  color: var(--text);
}

.file-button input {
  display: none;
}

.permissions {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}

.permissions legend {
  padding: 0 6px;
  color: #34434d;
  font-weight: 700;
}

.permission-grid {
  display: grid;
  gap: 6px;
}

.permission-row {
  min-height: 34px;
  display: grid;
  grid-template-columns: minmax(96px, 1.1fr) repeat(4, minmax(86px, 1fr));
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: var(--surface-2);
  border-radius: 8px;
}

.permission-row strong {
  font-size: 13px;
}

.check {
  display: inline-grid;
  grid-template-columns: 18px auto;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  line-height: 1.1;
  font-weight: 400;
  white-space: nowrap;
}

.permissions .check input {
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  margin: 0;
  padding: 0;
  border-radius: 4px;
  box-shadow: none;
}

.empty {
  min-height: 96px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: #f8fafc;
  border: 1px dashed #d8e3ec;
  border-radius: 8px;
}

@media (max-width: 1180px) {
  .shell {
    grid-template-columns: 220px 1fr;
  }

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

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

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

/* 手机端：表格转为卡片、侧边栏转为抽屉，保证小屏可操作。 */
@media (max-width: 760px) {
  .shell {
    grid-template-columns: 1fr;
  }

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

  nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    display: grid;
  }

  .topbar-actions,
  .toolbar-row {
    justify-content: flex-start;
  }

  .search {
    width: 100%;
  }

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

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

  .main {
    padding: 18px;
  }

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

  .bar-row strong {
    grid-column: 2;
  }
}

/* V3 dashboard */
.shell-v3 {
  grid-template-columns: 248px minmax(0, 1fr);
  background: var(--workspace-bg);
}

.sidebar-v3 {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 20;
  width: 248px;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--sidebar-text);
  background: var(--surface-panel);
  border-right: 1px solid var(--border-soft);
  box-shadow: 2px 0 18px rgba(31, 44, 56, 0.04);
  padding: 0;
  gap: 0;
}

.brand-v3 {
  min-height: 82px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  background: var(--surface-panel);
  border-bottom: 1px solid var(--border-soft);
}

.brand-v3::before {
  content: "贸";
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  background: linear-gradient(145deg, #3b9cff 0%, var(--accent-strong) 100%);
  color: #fff;
  font-size: 20px;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(47, 134, 255, 0.20);
}

.brand-v3 > div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.brand-v3 strong {
  font-size: 21px;
  letter-spacing: 0;
  color: var(--text);
}

.brand-v3 span {
  color: var(--muted);
  line-height: 1.45;
}

.sidebar-v3 nav {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 5px;
  margin-top: 10px;
  padding: 0 10px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.nav-item-v3 {
  position: relative;
  min-height: 46px;
  border-radius: 8px;
  padding: 0 13px;
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 700;
}

.nav-item-v3 svg {
  width: 20px;
  height: 20px;
}

.nav-item-v3.active,
.nav-item-v3:hover {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.nav-item-v3.active::before {
  content: "";
  position: absolute;
  left: 0;
  width: 3px;
  height: 22px;
  border-radius: 999px;
  background: var(--accent);
}

.sidebar-v3 .sidebar-footer {
  padding: 16px 20px 20px;
}

.sidebar-v3 .sidebar-footer span {
  color: #7b8995;
}

.mobile-bottom-nav {
  display: none;
}

.mobile-header-v3,
.mobile-menu-toggle,
.mobile-header-logout,
.mobile-drawer-close,
.mobile-drawer-backdrop {
  display: none;
}

/* Shared drawer controls; responsive rules only control their visibility. */
.mobile-menu-toggle,
.mobile-drawer-close {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  flex: 0 0 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  color: #52616f;
  box-shadow: none;
  transform: none;
  line-height: 1;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.mobile-menu-toggle svg,
.mobile-drawer-close svg {
  display: block;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.mobile-menu-toggle:hover,
.mobile-drawer-close:hover {
  transform: none;
}

@media (hover: hover) {
  .mobile-menu-toggle:hover,
  .mobile-drawer-close:hover {
    background: #eff6ff;
    border-color: #bfd7f4;
    color: var(--accent-strong);
  }
}

.mobile-menu-toggle:active,
.mobile-drawer-close:active {
  background: #e4efff;
  border-color: #9cc3f5;
  color: var(--accent-strong);
  transform: none;
}

.mobile-menu-toggle:focus-visible,
.mobile-drawer-close:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
  border-color: #9cc3f5;
  box-shadow: none;
}

@media (prefers-reduced-motion: reduce) {
  .mobile-menu-toggle,
  .mobile-drawer-close {
    transition: none;
  }
}

.main-v3 {
  position: relative;
  z-index: 1;
  width: calc(100% - 248px);
  margin-left: 248px;
  padding: 0 24px 28px;
  min-width: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f7fbff 0%, #eef7ff 100%);
}

.topbar-v3 {
  position: relative;
  z-index: 5;
  min-height: 70px;
  margin: 0 -24px 14px;
  padding: 9px 28px;
  align-items: center;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border-soft);
  box-shadow: 0 1px 2px rgba(22, 34, 44, 0.04), 0 10px 26px rgba(31, 44, 56, 0.045);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.topbar-v3 > div:first-child {
  min-width: 0;
}

.topbar-v3 h1 {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.25;
}

.dashboard-greeting {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.dashboard-greeting > span:last-child {
  min-width: 0;
}

.topbar-v3 p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.topbar-actions-v3 {
  align-items: center;
  gap: 10px;
}

.search-box {
  width: min(520px, 34vw);
  height: 44px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--surface-panel);
  box-shadow: 0 1px 2px rgba(28, 43, 56, 0.04);
}

.search-box svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: #8696a6;
  stroke-width: 2;
}

.search-box input {
  border: 0;
  min-height: 36px;
  padding: 0;
  box-shadow: none;
}

.search-submit {
  min-height: 30px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  background: var(--accent-strong);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: none;
}

.search-clear {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: var(--surface-muted);
  color: #536473;
  cursor: pointer;
}

.search-clear svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
}

.result-summary {
  min-height: 44px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0 0 12px;
  padding: 10px 14px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: #fff;
  color: #607080;
  font-weight: 700;
  box-shadow: var(--shadow-soft);
}

.result-summary span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.45;
}

.result-summary strong {
  color: #263440;
}

.result-summary em {
  color: #8291a0;
  font-style: normal;
}

.account-chip {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  color: #23313c;
  font-weight: 800;
  padding: 4px 8px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.account-chip:hover {
  background: var(--surface-muted);
  border-color: var(--border-soft);
}

.account-chip svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.avatar {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--accent) 0%, #256fbd 100%);
  color: #fff;
  font-weight: 800;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.small-avatar {
  width: 32px;
  height: 32px;
  font-size: 12px;
}

.large-avatar {
  width: 64px;
  height: 64px;
  font-size: 24px;
}

.greeting-avatar {
  width: 40px;
  height: 40px;
  font-size: 16px;
}

.main-v3::before {
  content: "";
  position: absolute;
  top: 72px;
  left: 0;
  right: 0;
  height: 300px;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(234, 244, 255, 0.72) 0%, rgba(238, 247, 255, 0) 100%);
}

.main-v3 > section,
.main-v3 > .dashboard-toolbar,
.main-v3 > .kpi-grid,
.main-v3 > .dashboard-layout,
.main-v3 > .link-banner,
.main-v3 > .result-summary {
  max-width: 1680px;
  margin-left: auto;
  margin-right: auto;
}

.topbar-v3 {
  min-height: 70px;
  padding: 10px 30px;
}

.topbar-v3 h1 {
  letter-spacing: 0;
}

.topbar-actions-v3 .primary,
.topbar-actions-v3 .ghost {
  min-height: 38px;
  padding-inline: 16px;
}

.search-box {
  height: 42px;
  border-color: var(--border-soft);
  box-shadow: 0 8px 20px rgba(23, 36, 48, 0.045);
}

.panel {
  border-radius: 8px;
  background: var(--surface-panel);
  border-color: var(--border-soft);
  box-shadow: 0 1px 2px rgba(15, 25, 33, 0.04), 0 14px 30px rgba(31, 44, 56, 0.055);
}

.panel-title {
  min-height: 36px;
}

.panel-title h2 {
  color: #132331;
  font-weight: 900;
}

.panel-title span {
  font-weight: 700;
}

.editor {
  position: relative;
  padding: 24px;
  overflow: hidden;
}

.editor::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, #17b69e, rgba(47, 134, 255, 0.34), rgba(255, 255, 255, 0));
}

.editor .panel-title {
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border-soft);
}

.form-grid {
  gap: 16px 18px;
  align-items: end;
}

.form-grid label {
  min-width: 0;
}

.form-grid label span {
  color: #263847;
  font-size: 13px;
}

.form-grid input,
.form-grid select,
.form-grid textarea,
.avatar-edit-row > input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border-color: var(--border);
  background: var(--surface-panel);
  color: #122231;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.form-grid input[readonly],
.form-grid textarea[readonly] {
  background: #f8fbfd;
  color: #415363;
}

.form-grid textarea {
  min-height: 104px;
  line-height: 1.6;
}

.form-actions {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}

.table-wrap {
  border-color: var(--border-soft);
  box-shadow: 0 8px 22px rgba(31, 44, 56, 0.04);
}

.table-shell {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.table-shell[data-has-pagination="true"][data-page-size="10"] {
  grid-template-rows: minmax(796px, 1fr) auto;
  align-content: stretch;
}

.table-shell[data-has-pagination="true"][data-page-size="10"] .table-wrap {
  min-height: 796px;
}

.table-shell[data-has-pagination="true"][data-page-size="10"] th,
.table-shell[data-has-pagination="true"][data-page-size="10"] td {
  height: 72px;
}

.table-shell[data-has-pagination="true"][data-page-size="10"] th {
  height: 74px;
}

.table-pagination {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 2px 2px 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.pagination-summary,
.pagination-controls,
.pagination-jump {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.pagination-summary {
  gap: 10px;
  color: #708292;
  font-size: 12px;
  font-weight: 700;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.pagination-summary span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  background: #f5f9ff;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  white-space: nowrap;
  flex: 0 0 auto;
}

.pagination-controls {
  gap: 6px;
  justify-content: flex-end;
  min-width: max-content;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.page-btn {
  min-width: 34px;
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: #fff;
  color: #405363;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  flex: 0 0 auto;
  box-shadow: 0 1px 2px rgba(28, 43, 56, 0.04);
}

.page-btn.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 14px rgba(47, 134, 255, 0.18);
}

.page-btn:disabled {
  cursor: not-allowed;
  opacity: 0.46;
  transform: none;
}

.pagination-page-status,
.pagination-ellipsis,
.pagination-jump {
  color: #708292;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  flex: 0 0 auto;
}

.dashboard-simple-pagination {
  min-height: 42px;
  align-self: end;
  padding-top: 4px;
}

.dashboard-simple-pagination .pagination-summary {
  gap: 8px;
}

.dashboard-simple-pagination .pagination-controls {
  gap: 8px;
}

.bulk-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
}

.bulk-action-bar > div:first-child {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.bulk-action-bar strong {
  color: #1c2d3a;
  font-size: 14px;
}

.bulk-action-bar span {
  color: #738696;
  font-size: 12px;
  font-weight: 700;
}

.bulk-action-controls {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.bulk-action-controls .compact {
  min-height: 32px;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12px;
}

.danger-text {
  color: #d94747;
  border-color: #ffd4d4;
  background: #fffafa;
}

.pagination-jump {
  gap: 5px;
  margin-left: 4px;
}

.pagination-jump input {
  width: 58px;
  min-height: 32px;
  padding: 5px 8px;
  border-radius: 8px;
  text-align: center;
}

th {
  height: 44px;
  background: var(--surface-muted);
  color: #485b6b;
  letter-spacing: 0;
}

td {
  height: 58px;
}

tbody tr:nth-child(even) {
  background: #fbfcfd;
}

tbody tr:hover {
  background: #f2faf7;
}

.row-actions {
  gap: 8px;
  width: 170px;
  min-width: 170px;
  justify-content: flex-start;
  flex-wrap: nowrap;
}

.icon-btn {
  width: 36px;
  height: 36px;
  flex-basis: 36px;
  border-color: #dce7ef;
}

.link-action {
  min-height: 32px;
  padding: 6px 11px;
}

.status {
  min-height: 26px;
  padding: 4px 10px;
}

.dashboard-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr minmax(160px, 220px) minmax(160px, 220px);
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.date-range,
.quick-tabs,
.dashboard-toolbar select {
  min-height: 40px;
  background: var(--surface-panel);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(28, 43, 56, 0.035);
}

.date-range {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  color: #334452;
  font-weight: 800;
}

.date-range input {
  width: 100%;
  min-width: 0;
  min-height: 0;
  height: 30px;
  border: 0;
  background: transparent;
  padding: 0;
  color: #273846;
  font-weight: 800;
  box-shadow: none;
}

.date-range input:focus-visible {
  border-color: transparent;
  box-shadow: none;
}

.quick-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(78px, 1fr));
  overflow: visible;
}

.quick-tabs button {
  border: 0;
  border-right: 1px solid var(--border-soft);
  background: var(--surface-panel);
  color: #506171;
  font-weight: 800;
  min-height: 40px;
  padding: 6px 10px;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
}

.quick-tabs button:last-child {
  border-right: 0;
}

.quick-tabs button.active {
  background: var(--accent);
  color: #fff;
}

.dashboard-toolbar .primary {
  min-height: 40px;
  font-weight: 800;
  justify-content: center;
  text-align: center;
}

.operating-toolbar {
  grid-template-columns: minmax(260px, 340px) minmax(360px, 1fr);
}

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

.compact-kpis {
  grid-template-columns: repeat(3, minmax(160px, 1fr));
}

.operating-kpis {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.operating-table-panel .panel-title {
  align-items: center;
}

.operating-table-panel .panel-title span {
  color: #708293;
  font-weight: 800;
}

.profit-toolbar {
  grid-template-columns: minmax(300px, 340px) minmax(420px, 1fr) auto;
}

.profit-period-note {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  color: #708293;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--surface-panel);
  box-shadow: 0 1px 2px rgba(28, 43, 56, 0.035);
}

.profit-kpis {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.profit-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.14fr) minmax(0, 0.86fr);
  gap: 14px;
  align-items: stretch;
}

.profit-workbench .panel {
  min-height: 342px;
}

.profit-workbench .panel + .panel {
  margin-top: 0;
}

.profit-ledger-panel,
.profit-order-panel {
  padding: 20px;
}

.profit-ledger-panel .table-wrap,
.profit-order-panel .table-wrap {
  overflow-x: hidden;
}

.profit-ledger-panel table,
.profit-order-panel table {
  min-width: 0;
  table-layout: fixed;
}

.profit-ledger-panel th:nth-child(1) {
  width: 132px;
}

.profit-ledger-panel th:nth-child(2) {
  width: 118px;
}

.profit-ledger-panel th:nth-child(4),
.profit-ledger-panel th:nth-child(5) {
  width: 112px;
}

.profit-ledger-panel th:nth-child(6) {
  width: 142px;
}

.profit-ledger-panel th:nth-child(7) {
  width: 118px;
}

.compact-cell {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.compact-cell strong,
.compact-cell small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-cell strong {
  color: #263744;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.25;
}

.compact-cell small {
  color: #778897;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
}

.profit-bars {
  display: grid;
  gap: 9px;
  margin: -2px 0 14px;
}

.profit-bar-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  color: #34495a;
  font-size: 13px;
  font-weight: 900;
}

.profit-bar-row b {
  height: 10px;
  display: block;
  overflow: hidden;
  border-radius: 999px;
  background: #edf4fb;
}

.profit-bar-row i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #77b8ff, var(--accent));
}

.profit-bar-row.cost i {
  background: linear-gradient(90deg, #ffd38a, #b87411);
}

.profit-bar-row.negative i {
  background: linear-gradient(90deg, #ff9aa0, #d63c45);
}

.profit-bar-row strong {
  color: #263744;
}

body .kpi-grid-v3.profit-kpis {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

body .profit-workbench {
  grid-template-columns: minmax(0, 1.14fr) minmax(0, 0.86fr);
}

@media (max-width: 1180px) {
  body .profit-toolbar {
    grid-template-columns: minmax(260px, 340px) minmax(320px, 1fr);
  }

  body .profit-period-note {
    grid-column: 1 / -1;
  }

  body .kpi-grid-v3.profit-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body .profit-workbench {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 940px) and (max-height: 520px) and (orientation: landscape) {
  body .profit-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  body .profit-period-note {
    grid-column: 1 / -1;
  }

  body .kpi-grid-v3.profit-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  body .profit-workbench {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  body .profit-toolbar {
    grid-template-columns: 1fr;
  }

  body .profit-period-note {
    min-height: 40px;
    width: 100%;
  }

  body .kpi-grid-v3.profit-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  body .profit-kpis.kpi-grid-v3 > * {
    grid-column: auto;
    min-height: 112px;
    order: 0;
  }

  body .profit-workbench {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  body .profit-ledger-panel,
  body .profit-order-panel {
    padding: 16px;
  }

  body .profit-ledger-panel .table-wrap,
  body .profit-order-panel .table-wrap {
    overflow-x: visible;
  }

  body .profit-bar-row {
    grid-template-columns: 68px minmax(0, 1fr) auto;
    gap: 8px;
  }
}

.kpi-v3 {
  min-height: 96px;
  position: relative;
  overflow: hidden;
  background: var(--surface-panel);
  gap: 5px;
  padding: 12px;
  border-color: var(--border-soft);
  box-shadow: 0 1px 2px rgba(15, 25, 33, 0.035), 0 10px 20px rgba(31, 44, 56, 0.045);
}

.operating-kpis .kpi-v3 {
  min-height: 112px;
  order: 0;
}

.profit-kpis .kpi-v3 {
  min-height: 112px;
  order: 0;
}

.dashboard-kpis {
  grid-template-columns: repeat(20, minmax(0, 1fr));
  gap: 10px;
}

.dashboard-kpis .kpi-v3 {
  grid-column: span 4;
}

.dashboard-kpis .kpi-metric-income {
  grid-column: span 5;
}

.dashboard-kpis .kpi-metric-other-income {
  grid-column: span 5;
}

.dashboard-kpis .kpi-metric-margin {
  grid-column: span 5;
}

.dashboard-kpis .kpi-metric-profit {
  grid-column: span 5;
}

.kpi-v3::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: rgba(47, 134, 255, 0.28);
}

.kpi-v3 .kpi-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.kpi-v3 .kpi-head span {
  color: #40505e;
  font-size: 12px;
  font-weight: 800;
}

.kpi-v3 i {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  font-style: normal;
  border-radius: 8px;
  background: var(--accent-soft);
}

.kpi-v3 svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
}

.kpi-v3 strong {
  color: var(--accent-strong);
  font-size: 21px;
  font-weight: 900;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.kpi-v3.blue strong,
.kpi-v3.blue i {
  color: #1f6ed4;
}

.kpi-v3.blue i {
  background: #eaf3ff;
}

.kpi-v3.green strong,
.kpi-v3.green i,
.kpi-v3.teal strong,
.kpi-v3.teal i {
  color: var(--accent);
}

.kpi-v3.green i,
.kpi-v3.teal i {
  background: var(--accent-soft);
}

.kpi-v3.red strong,
.kpi-v3.red i {
  color: #d63c45;
}

.kpi-v3.red i {
  background: #fff0ef;
}

.kpi-v3.amber strong,
.kpi-v3.amber i {
  color: #b87411;
}

.kpi-v3.amber i {
  background: #fff6e3;
}

.kpi-v3 small {
  color: #7d8b98;
  font-size: 12px;
  font-weight: 700;
}

.kpi-v3 small.compare {
  color: #14a86a;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}

.dashboard-half {
  grid-column: span 4;
}

.dashboard-layout .panel {
  min-height: 220px;
  border-color: var(--border-soft);
  box-shadow: var(--shadow-panel);
}

.dashboard-layout .panel + .panel {
  margin-top: 0;
}

.dashboard-layout .table-wrap {
  overflow-x: visible;
}

.dashboard-layout table {
  min-width: 0;
  table-layout: fixed;
  font-size: 12px;
}

.dashboard-layout th:last-child,
.dashboard-layout td:last-child {
  width: auto;
}

.dashboard-layout th,
.dashboard-layout td {
  padding: 10px 9px;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.span-2 {
  grid-column: span 2;
}

.span-4 {
  grid-column: span 4;
}

.chart-panel {
  min-height: 360px;
}

.bank-panel {
  display: flex;
  flex-direction: column;
}

.chart-legend {
  display: flex;
  justify-content: flex-end;
  gap: 14px;
  margin: 0 0 8px;
  color: #526574;
  font-weight: 700;
  font-size: 13px;
}

.dot {
  width: 10px;
  height: 10px;
  display: inline-block;
  margin-right: 5px;
  border-radius: 50%;
}

.dot.green {
  background: #12b99f;
}

.dot.blue {
  background: #1d78ff;
}

.dot.orange {
  background: #ff8133;
}

.trend-chart {
  height: 250px;
  display: grid;
  grid-template-columns: repeat(12, minmax(28px, 1fr));
  gap: 8px;
  align-items: end;
  padding: 14px 8px 0;
  border-left: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
  background:
    linear-gradient(#edf3f7 1px, transparent 1px) 0 0 / 100% 25%,
    #fff;
}

.trend-col {
  height: 100%;
  display: grid;
  grid-template-rows: 1fr 24px;
  align-items: end;
  gap: 6px;
}

.trend-col span {
  text-align: center;
  color: #566777;
  font-size: 12px;
  font-weight: 800;
}

.bar-stack {
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
}

.bar-stack i {
  width: 9px;
  min-height: 4px;
  border-radius: 2px 2px 0 0;
}

.bar-income {
  background: #12b99f;
}

.bar-cost {
  background: #2f86ff;
}

.bar-profit {
  background: #ff8133;
}

.trend-col.active span {
  color: #0e9d8c;
}

.dashboard-bank-table {
  display: grid;
  flex: 1;
  min-height: 250px;
  align-content: stretch;
}

.dashboard-bank-table .table-wrap {
  height: 100%;
  min-height: 250px;
  border-radius: 12px;
}

.dashboard-bank-table table {
  width: 100%;
  min-width: 0;
}

.dashboard-bank-table th:first-child,
.dashboard-bank-table td:first-child {
  width: 44%;
  text-align: left;
}

.dashboard-bank-table th:nth-child(2),
.dashboard-bank-table td:nth-child(2) {
  width: 22%;
  text-align: center;
}

.dashboard-bank-table th:nth-child(3),
.dashboard-bank-table td:nth-child(3) {
  width: 34%;
  text-align: right;
}

.dashboard-bank-table tbody tr:last-child td {
  background: #f0f6ff;
}

.expense-breakdown {
  display: grid;
  gap: 10px;
}

.expense-breakdown-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 11px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--surface-muted);
}

.expense-breakdown-row div,
.expense-breakdown-row b {
  position: relative;
  z-index: 1;
}

.expense-breakdown-row strong,
.expense-breakdown-row span {
  display: block;
  overflow-wrap: anywhere;
}

.expense-breakdown-row strong {
  color: #263541;
  font-size: 14px;
}

.expense-breakdown-row span {
  margin-top: 3px;
  color: #657380;
  font-size: 12px;
}

.expense-breakdown-row b {
  color: #0e8f7f;
  font-size: 14px;
}

.expense-breakdown-row em {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, #11a99a, #2f86ff);
}

.donut-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 138px;
}

.donut {
  width: 118px;
  height: 118px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
}

.donut > div {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  align-content: center;
  border-radius: 50%;
  background: #fff;
  text-align: center;
  box-shadow: inset 0 0 0 1px var(--border-soft);
}

.donut span {
  color: #738391;
  font-size: 11px;
  font-weight: 800;
}

.donut strong {
  color: #202c36;
  font-size: 14px;
}

.donut-legend {
  display: grid;
  gap: 8px;
  min-width: 138px;
}

.donut-legend span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #536371;
  font-size: 13px;
  font-weight: 700;
}

.donut-legend i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.donut-legend b {
  color: #566575;
}

.split-panel {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 12px;
  align-items: center;
}

.avatar-field {
  align-items: start;
}

.avatar-edit-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.avatar-edit-row > input[name="avatarInitial"] {
  width: 92px;
  text-align: center;
  font-weight: 900;
}

.profile-editor {
  margin-bottom: 16px;
}

.status-done {
  background: #e8f8ef;
  color: #119456;
}

.status-warn {
  background: #fff4d8;
  color: #b06b00;
}

.status-red {
  background: var(--red-soft);
  color: var(--red);
}

.status-info {
  background: #eaf4ff;
  color: #1677ff;
}

.danger-icon svg {
  stroke: var(--red);
}

@media (max-width: 1460px) {
  .kpi-grid-v3:not(.dashboard-kpis) {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

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

  .dashboard-half,
  .span-2,
  .span-4 {
    grid-column: span 1;
  }

  .split-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1380px) {
  .dashboard-toolbar {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

@media (max-width: 1120px) {
  .dashboard-toolbar {
    grid-template-columns: 1fr 1fr;
  }

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

  .dashboard-half,
  .span-2 {
    grid-column: span 1;
  }
}

/* 平板端：保留左侧紧凑导航，同时压缩表格和表单宽度。 */
@media (min-width: 761px) and (max-width: 1120px) {
  .shell-v3 {
    display: block;
    grid-template-columns: 84px minmax(0, 1fr);
  }

  .sidebar-v3 {
    width: 84px;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .main-v3 {
    width: calc(100% - 84px);
    margin-left: 84px;
    padding: 0 18px 24px;
  }

  .topbar-v3 {
    margin: 0 -18px 14px;
    padding: 10px 20px;
    align-items: flex-start;
  }

  .topbar-actions-v3 {
    flex: 1 1 360px;
  }

  .topbar-actions-v3 .search-box {
    width: min(420px, 100%);
  }

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

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

  .form-grid,
  .customer-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .form-grid .wide-field,
  .customer-form-grid .wide-field,
  .form-grid textarea,
  .customer-form-grid textarea {
    grid-column: 1 / -1;
  }

  .mobile-bottom-nav {
    display: none;
  }

  .sidebar-v3 {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .brand-v3 {
    min-height: 72px;
    justify-content: center;
    padding: 14px 0;
  }

  .brand-v3::before {
    content: "贸";
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 20px;
    font-weight: 900;
  }

  .brand-v3 > div {
    display: none;
  }

  .brand-v3 strong {
    display: none;
  }

  .brand-v3 span,
  .sidebar-v3 .sidebar-footer,
  .nav-item-v3 span {
    display: none;
  }

  .sidebar-v3 nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 10px 12px;
    scrollbar-width: thin;
  }

  .nav-item-v3 {
    width: 60px;
    margin-inline: auto;
    justify-content: center;
    padding: 0;
  }
}

@media (min-width: 761px) and (max-width: 1120px) and (orientation: portrait) {
  body {
    overflow-x: hidden;
    padding-bottom: env(safe-area-inset-bottom);
    background: linear-gradient(180deg, #f7fbfd 0%, #eef5f8 100%);
  }

  .shell-v3 {
    display: block;
    grid-template-columns: 1fr;
    background: transparent;
  }

  .mobile-header-v3 {
    position: sticky;
    top: 0;
    z-index: 68;
    display: flex;
    min-height: 52px;
    align-items: center;
    gap: 9px;
    padding: 7px 12px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--border-soft);
    box-shadow: 0 8px 20px rgba(31, 44, 56, 0.08);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    isolation: isolate;
  }

  .mobile-header-title {
    display: grid;
    min-width: 0;
    gap: 3px;
  }

  .mobile-header-title strong {
    font-size: 17px;
    line-height: 1.2;
  }

  .mobile-header-title span {
    color: var(--muted);
    font-size: 10.5px;
  }

  .mobile-header-logout {
    display: inline-flex;
    min-width: 66px;
    min-height: 40px;
    margin-left: auto;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    border-color: var(--border-soft);
    box-shadow: 0 8px 18px rgba(31, 44, 56, 0.08);
    font-weight: 900;
  }

  .mobile-menu-toggle,
  .mobile-drawer-close {
    display: inline-flex;
  }

  .mobile-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: block;
    border: 0;
    padding: 0;
    background: rgba(8, 20, 27, 0.24);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }

  .shell-v3.mobile-drawer-open .mobile-drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar.sidebar-v3 {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 80;
    display: flex;
    width: min(276px, 84vw);
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    max-height: none;
    overflow: hidden auto;
    overscroll-behavior: contain;
    padding: 0;
    gap: 0;
    transform: translate3d(-100%, 0, 0);
    transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.22s ease;
    will-change: transform;
    background: var(--surface-panel);
    border-right: 1px solid var(--border-soft);
    border-bottom: 0;
    box-shadow: 22px 0 42px rgba(7, 18, 25, 0);
  }

  .shell-v3.mobile-drawer-open .sidebar.sidebar-v3 {
    transform: translate3d(0, 0, 0);
    box-shadow: 22px 0 42px rgba(31, 44, 56, 0.16);
  }

  .brand-v3 {
    position: relative;
    top: auto;
    z-index: 50;
    min-height: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 14px 12px;
    background: var(--surface-panel);
    border-bottom: 1px solid var(--border-soft);
    box-shadow: none;
  }

  .brand-v3::before {
    content: none;
  }

  .brand-v3 > div {
    display: grid;
    border-left-color: var(--accent);
  }

  .brand-v3 strong {
    display: block;
    font-size: 18px;
    color: var(--text);
  }

  .brand-v3 span {
    display: block;
    font-size: 11px;
    color: var(--muted);
  }

  .sidebar-v3 nav {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 8px 10px 10px;
  }

  .nav-item-v3 {
    width: auto;
    min-height: 42px;
    margin-inline: 0;
    justify-content: flex-start;
    padding: 0 13px;
    font-size: 14px;
  }

  .nav-item-v3 span {
    display: inline;
  }

  .mobile-drawer-nav .nav-item-v3 {
    border-radius: 12px;
    color: var(--sidebar-text);
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
  }

  .mobile-drawer-nav .nav-item-v3.active,
  .mobile-drawer-nav .nav-item-v3:hover {
    background: var(--accent-soft);
    color: var(--accent-strong);
  }

  .mobile-drawer-nav .nav-item-v3:active {
    transform: scale(0.98);
  }

  .mobile-drawer-nav .nav-item-v3.active::before {
    left: 0;
    width: 3px;
    height: 22px;
    border-radius: 999px;
  }

  .sidebar-v3 .sidebar-footer {
    display: grid;
    gap: 8px;
    padding: 12px 14px 16px;
  }

  .sidebar-v3 .sidebar-footer span {
    color: var(--muted);
  }

  .sidebar-v3 .sidebar-footer .ghost {
    min-height: 42px;
    border-color: var(--border-soft);
    background: var(--surface-muted);
    color: var(--text);
    box-shadow: none;
  }

  .main-v3 {
    margin-top: 0;
    padding: 0 14px 22px;
  }

  .kpi-grid-v3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dashboard-kpis .kpi-v3 {
    grid-column: auto;
  }

  .kpi-metric-income { order: 1; }
  .kpi-metric-other-income { order: 2; }
  .kpi-metric-receivable { order: 3; }
  .kpi-metric-operating-expense { order: 4; }
  .kpi-metric-margin { order: 5; }
  .kpi-metric-payable { order: 6; }
  .kpi-metric-cost { order: 7; }
  .kpi-metric-profit { order: 8; }
  .kpi-metric-tax { order: 9; }

  .main-v3::before {
    display: none;
  }

  .topbar {
    display: grid;
  }

  .topbar-v3 {
    position: static;
    margin: 0 -14px 10px;
    padding: 12px 16px 14px;
    border-radius: 0 0 20px 20px;
    align-items: stretch;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 12px 28px rgba(31, 44, 56, 0.09);
  }

  .topbar-v3 h1 {
    font-size: 21px;
  }

  .topbar-v3 p {
    font-size: 12px;
    line-height: 1.55;
  }

  .topbar-actions-v3 {
    flex: initial;
    width: 100%;
    align-items: stretch;
  }

  .topbar-actions-v3 [data-action="logout"] {
    display: none;
  }

  .topbar-actions-v3 .search-box {
    width: 100%;
  }

  .dashboard-greeting {
    align-items: flex-start;
    gap: 10px;
  }

  .greeting-avatar {
    width: 38px;
    height: 38px;
  }

  .search-box {
    position: relative;
    width: 100%;
    height: auto;
    min-height: 48px;
    grid-template-columns: 22px minmax(0, 1fr) auto;
    border-radius: 16px;
    box-shadow: 0 10px 22px rgba(31, 44, 56, 0.08);
  }

  .search-box input {
    padding-right: 34px;
  }

  .search-clear {
    position: absolute;
    right: 70px;
    top: 9px;
    width: 28px;
    height: 28px;
  }

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

  .dashboard-toolbar {
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    background: var(--surface-panel);
    box-shadow: var(--shadow-soft);
  }

  .operating-toolbar {
    grid-template-columns: 1fr;
  }

  .date-range,
  .dashboard-toolbar select {
    height: auto;
    min-height: 44px;
    border-radius: 12px;
  }

  .date-range input {
    height: 38px;
    font-size: 14px;
  }

  .quick-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    height: auto;
    border-radius: 12px;
    overflow: visible;
  }

  .quick-tabs button {
    min-height: 44px;
    font-weight: 900;
  }

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

  .dashboard-kpis .kpi-v3 {
    grid-column: auto;
  }

  .operating-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-grid-v3.operating-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-v3 {
    min-height: 104px;
    border-radius: 14px;
    padding: 14px;
  }

  .kpi-v3:last-child {
    grid-column: auto;
  }

  .kpi-metric-income { order: 1; }
  .kpi-metric-other-income { order: 2; }
  .kpi-metric-receivable { order: 3; }
  .kpi-metric-operating-expense { order: 4; }
  .kpi-metric-margin { order: 5; }
  .kpi-metric-payable { order: 6; }
  .kpi-metric-cost { order: 7; }
  .kpi-metric-profit { order: 8; }
  .kpi-metric-tax { order: 9; }

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

  .dashboard-layout {
    gap: 12px;
  }

  .panel {
    padding: 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 12px 26px rgba(31, 44, 56, 0.08);
  }

  .panel-title {
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 12px;
  }

  .panel-title h2 {
    font-size: 17px;
  }

  .panel-title span {
    text-align: left;
  }

  .panel-title-with-filter {
    flex-direction: column;
    align-items: stretch;
  }

  .inline-filter {
    width: 100%;
    justify-content: space-between;
  }

  .inline-filter select {
    flex: 1;
    min-width: 0;
  }

  .editor {
    padding: 16px;
    border-radius: 14px;
  }

  .editor::before {
    border-radius: 14px 14px 0 0;
  }

  .link-banner,
  .result-summary {
    border-radius: 14px;
  }

  .trend-chart {
    height: 280px;
    gap: 6px;
    overflow-x: auto;
  }

  .bar-stack i {
    width: 8px;
  }

  .donut-wrap {
    flex-direction: column;
  }

  .table-wrap {
    border: 0;
    overflow-x: visible;
    background: transparent;
    box-shadow: none;
  }

  table {
    display: block;
    width: 100%;
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 12px;
  }

  tbody tr {
    display: grid;
    gap: 0;
    grid-auto-rows: auto;
    align-items: stretch;
    padding: 14px;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 10px 22px rgba(31, 44, 56, 0.08);
    transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.18s ease;
  }

  tbody tr:active {
    transform: scale(0.99);
    box-shadow: 0 7px 16px rgba(31, 44, 56, 0.08);
  }

  tbody tr:nth-child(even),
  tbody tr:hover {
    background: #fff;
  }

  td {
    display: grid;
    grid-template-columns: minmax(92px, 34%) minmax(0, 1fr);
    gap: 10px;
    width: 100%;
    height: auto;
    min-height: 0;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-soft);
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.45;
    align-items: start;
  }

  td:first-child {
    padding-top: 0;
  }

  td:last-child {
    width: 100%;
    padding-bottom: 0;
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    color: #7a8a96;
    font-size: 12px;
    font-weight: 800;
  }

  td[data-label="操作"] {
    grid-template-columns: 1fr;
  }

  td[data-label="操作"]::before {
    display: none;
  }

  td[data-label="操作"] .row-actions,
  td[data-label="操作"] .customer-table-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .row-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    min-width: 0;
  }

  .customer-table-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  .icon-btn,
  .link-action {
    width: 100%;
    min-width: 0;
    min-height: 42px;
  }

  .icon-btn {
    flex-basis: auto;
  }

  .toolbar-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .toolbar-row .segmented,
  .toolbar-row .button-row {
    width: 100%;
  }

  .toolbar-row .segmented {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .toolbar-row .segmented button {
    min-height: 42px;
    padding-inline: 8px;
  }

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

  .form-grid,
  .customer-form-grid {
    grid-template-columns: 1fr;
    gap: 13px;
  }

  .form-grid label span {
    color: #607282;
    font-size: 12px;
  }

  .form-grid input,
  .form-grid select,
  .form-grid textarea,
  .avatar-edit-row > input {
    border-radius: 12px;
    background: #fbfdff;
  }

  .permissions {
    padding: 12px;
    border-radius: 14px;
    background: #fff;
  }

  .permission-grid {
    gap: 8px;
  }

  .permission-row {
    grid-template-columns: 1fr;
    min-height: auto;
    align-items: stretch;
    gap: 8px;
    padding: 10px;
  }

  .permission-row strong {
    font-size: 14px;
  }

  .avatar-edit-row {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
  }

  .form-actions,
  .button-row {
    width: 100%;
    align-items: stretch;
  }

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

  input,
  select,
  textarea,
  .primary,
  .ghost,
  .danger,
  .file-button {
    min-height: 44px;
    font-size: 15px;
  }

  .small {
    min-height: 40px;
  }

  .topbar-actions-v3 .primary,
  .topbar-actions-v3 .ghost,
  .button-row .primary,
  .button-row .ghost,
  .button-row .file-button {
    width: 100%;
  }

  .customer-list-panel {
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .empty {
    min-height: 120px;
    padding: 18px;
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #f7fbfd 100%);
    text-align: center;
  }
}

/* Enterprise table contract: full single-line data, sticky key columns, compact action rail. */
.table-shell {
  isolation: isolate;
}

.table-wrap {
  position: relative;
  overflow-x: auto;
  overflow-y: visible;
}

.enterprise-table {
  width: 100%;
  min-width: max(1080px, 100%);
  table-layout: fixed;
}

.table-shell-customers .enterprise-table {
  min-width: max(1120px, 100%);
}

.table-shell-orders .enterprise-table,
.table-shell-purchases .enterprise-table,
.table-shell-receipts .enterprise-table {
  min-width: max(1480px, 100%);
}

.enterprise-table th,
.enterprise-table td {
  height: 50px;
  max-width: none;
  padding: 9px 12px;
  background-clip: padding-box;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: keep-all;
  overflow-wrap: normal;
}

.enterprise-table .text-cell {
  text-align: left;
  min-width: 150px;
}

.enterprise-table .center-cell,
.enterprise-table .date-cell,
.enterprise-table .select-cell {
  text-align: center;
  min-width: 92px;
}

.enterprise-table .date-cell {
  min-width: 112px;
}

.enterprise-table .number-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
  min-width: 124px;
}

.enterprise-table .action-cell {
  text-align: right;
  min-width: 150px;
  overflow: visible;
}

.enterprise-table td.number-cell .money-short {
  display: inline-block;
  text-align: right;
}

.enterprise-table th.select-cell,
.enterprise-table td.select-cell,
.enterprise-table th[data-label="选择"],
.enterprise-table td[data-label="选择"] {
  width: 54px;
  min-width: 54px;
  text-align: center;
}

.table-shell-operationLogs th:first-child,
.table-shell-operationLogs td[data-label="选择"],
.table-shell-deletedRecords th:first-child,
.table-shell-deletedRecords td[data-label="选择"] {
  width: 54px;
  min-width: 54px;
  text-align: center;
}

.bulk-check {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.customer-list-panel td {
  height: 48px;
  padding-top: 8px;
  padding-bottom: 8px;
}

.customer-title-cell {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.customer-title-cell strong,
.customer-title-cell span {
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: keep-all;
}

.customer-title-cell span::before {
  content: "/";
  margin-right: 8px;
  color: #9aa7b3;
}

.table-shell[data-sticky-action="true"] th:last-child,
.table-shell[data-sticky-action="true"] td:last-child {
  position: sticky;
  right: 0;
  z-index: 6;
  min-width: 128px;
  width: 128px;
  padding-inline: 10px;
  text-align: center;
  background: var(--surface-panel);
  box-shadow: -8px 0 16px rgba(31, 44, 56, 0.06);
}

.table-shell[data-sticky-action="true"] th:last-child {
  z-index: 8;
  background: var(--surface-muted);
}

.compact-actions {
  position: relative;
  display: inline-flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

td[data-label="操作"] .compact-actions,
.compact-actions.customer-table-actions,
.compact-actions.row-actions {
  display: inline-flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: nowrap;
}

.compact-actions .link-action,
.compact-actions .icon-btn {
  margin: 0;
}

.action-menu {
  position: relative;
  display: inline-flex;
}

.action-menu summary {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: #fff;
  color: #405363;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  list-style: none;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 1px 2px rgba(28, 43, 56, 0.04);
}

.action-menu summary::-webkit-details-marker {
  display: none;
}

.action-menu[open] summary {
  border-color: #bcd8f5;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.action-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 30;
  display: grid;
  min-width: 116px;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 30px rgba(31, 44, 56, 0.14);
}

.action-menu-panel .link-action,
.action-menu-panel .icon-btn {
  width: 100%;
  min-width: 92px;
  justify-content: center;
}

@media (max-width: 760px),
  (max-width: 940px) and (max-height: 520px) and (orientation: landscape),
  (min-width: 761px) and (max-width: 1120px) and (orientation: portrait) {
  .table-wrap {
    overflow-x: auto;
    overflow-y: visible;
  }

  .enterprise-table {
    width: max-content;
    min-width: max(1040px, 100%);
  }

  .table-shell-customers .enterprise-table {
    min-width: max(1040px, 100%);
  }

  .table-shell-orders .enterprise-table,
  .table-shell-purchases .enterprise-table,
  .table-shell-receipts .enterprise-table {
    min-width: max(1320px, 100%);
  }

  .enterprise-table th,
  .enterprise-table td {
    height: 48px;
    padding: 8px 10px;
  }

  .table-shell[data-sticky-action="true"] th:last-child,
  .table-shell[data-sticky-action="true"] td:last-child {
    position: sticky;
    right: 0;
    min-width: 128px;
    width: 128px;
    text-align: center;
    background: var(--surface-panel);
  }
}

td[data-label="操作"] .compact-actions.customer-table-actions,
td[data-label="操作"] .compact-actions.row-actions {
  display: inline-flex;
  width: 100%;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .table-wrap {
    max-width: 100%;
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    background: #fff;
    box-shadow: var(--shadow-soft);
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
  }

  .dashboard-layout .table-wrap,
  body .profit-ledger-panel .table-wrap,
  body .profit-order-panel .table-wrap {
    max-width: 100%;
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    background: #fff;
    box-shadow: var(--shadow-soft);
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
  }

  table,
  .dashboard-layout table {
    display: table;
    width: max-content;
    min-width: max(920px, 100%);
    border-collapse: separate;
    border-spacing: 0;
    table-layout: auto;
  }

  .dashboard-bank-table table {
    min-width: max(560px, 100%);
  }

  table {
    display: table;
    width: max-content;
    min-width: max(920px, 100%);
    border-collapse: separate;
    border-spacing: 0;
    table-layout: auto;
  }

  thead {
    display: table-header-group;
  }

  tbody {
    display: table-row-group;
  }

  tbody tr {
    display: table-row;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    transition: background 0.18s ease;
  }

  tbody tr:active {
    transform: none;
    box-shadow: none;
  }

  tbody tr:nth-child(even) {
    background: #fbfcfd;
  }

  tbody tr:hover {
    background: #f2faf7;
  }

  th,
  td,
  .dashboard-layout th,
  .dashboard-layout td {
    display: table-cell;
    width: auto;
    height: 52px;
    min-height: 0;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-soft);
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: normal;
    word-break: keep-all;
    line-height: 1.4;
    vertical-align: middle;
  }

  td:last-child,
  th:last-child,
  .dashboard-layout td:last-child,
  .dashboard-layout th:last-child {
    width: auto;
  }

  td::before {
    content: none;
    display: none;
  }

  td[data-label="操作"] {
    min-width: 150px;
  }

  td[data-label="操作"] .row-actions,
  td[data-label="操作"] .customer-table-actions {
    width: max-content;
    flex-wrap: nowrap;
  }

  .row-actions,
  .customer-table-actions {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    grid-template-columns: none;
    width: max-content;
    min-width: 0;
  }

  .icon-btn,
  .link-action {
    width: auto;
    min-width: 44px;
  }

  .cell-detail-popover {
    display: none;
  }
}

/* Enterprise logic UI refresh: grouped navigation, module workbenches, and responsive business panels. */
.sidebar-nav {
  gap: 10px;
}

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

.nav-group h3 {
  margin: 8px 10px 2px;
  color: #7a8da1;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
}

.nav-group > div {
  display: grid;
  gap: 4px;
}

.enterprise-flow-grid,
.module-command-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 14px;
  margin: 0 0 14px;
}

.enterprise-flow-grid {
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.75fr) minmax(260px, 0.75fr);
}

.enterprise-panel {
  min-height: 100%;
  overflow: hidden;
}

.enterprise-flow-panel {
  min-height: 180px;
}

.enterprise-workflow {
  display: grid;
  grid-template-columns: repeat(6, minmax(132px, 1fr));
  gap: 10px;
}

.workflow-step {
  display: grid;
  min-height: 124px;
  align-content: start;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f6fbff 100%);
}

.workflow-step i {
  display: inline-flex;
  width: 34px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: #e8f2ff;
  color: var(--accent-strong);
  font-style: normal;
  font-weight: 900;
}

.workflow-step strong {
  color: var(--text);
  font-size: 15px;
}

.workflow-step span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.enterprise-mini-list {
  display: grid;
  gap: 8px;
}

.enterprise-mini-row {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: #fff;
}

.enterprise-mini-row .mini-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
}

.enterprise-mini-row.amber .mini-dot {
  background: #d58a14;
}

.enterprise-mini-row.red .mini-dot {
  background: #e5484d;
}

.enterprise-mini-row.green .mini-dot,
.enterprise-mini-row.teal .mini-dot {
  background: #16a085;
}

.enterprise-mini-row strong,
.enterprise-mini-row small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.enterprise-mini-row strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
}

.enterprise-mini-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.enterprise-mini-row b {
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
}

.enterprise-metric-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.enterprise-metric-list > div {
  display: grid;
  gap: 6px;
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
}

.enterprise-metric-list span {
  color: #63778c;
  font-size: 12px;
  font-weight: 900;
}

.enterprise-metric-list strong {
  min-width: 0;
  overflow: hidden;
  color: var(--accent-strong);
  font-size: 20px;
  font-weight: 950;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.enterprise-metric-list small {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.module-kpis {
  margin-bottom: 14px;
}

.module-count-summary {
  display: inline-grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  max-width: 100%;
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f5faff 100%);
  box-shadow: var(--shadow-soft);
}

.module-count-summary span {
  color: #63778c;
  font-size: 13px;
  font-weight: 900;
}

.module-count-summary strong {
  color: var(--accent-strong);
  font-size: 22px;
  font-weight: 950;
  line-height: 1;
  white-space: nowrap;
}

.module-count-summary small {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.module-workbench-panel {
  min-height: auto;
  margin: 0 0 14px;
}

.module-workbench-panel .enterprise-metric-list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.module-command-grid + .panel,
.enterprise-flow-grid + .dashboard-layout {
  margin-top: 0;
}

.dashboard-side-panel .empty,
.module-command-grid .empty {
  min-height: 104px;
}

.table-shell {
  max-width: 100%;
}

.table-wrap {
  scrollbar-width: thin;
  scrollbar-color: rgba(47, 134, 255, 0.34) transparent;
}

.table-wrap::-webkit-scrollbar {
  height: 10px;
}

.table-wrap::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: rgba(47, 134, 255, 0.34);
  background-clip: padding-box;
}

td[data-full-value],
th[data-full-value] {
  cursor: help;
}

@media (max-width: 1380px) {
  .enterprise-flow-grid {
    grid-template-columns: 1fr;
  }

  .enterprise-workflow {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .module-command-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 761px) and (max-width: 1120px) {
  .nav-group h3 {
    display: none;
  }

  .sidebar-v3 nav.sidebar-nav {
    gap: 8px;
  }

  .nav-group > div {
    gap: 8px;
  }

  .enterprise-flow-grid,
  .module-command-grid {
    grid-template-columns: 1fr;
  }

  .enterprise-workflow {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .enterprise-metric-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 940px) and (max-height: 520px) and (orientation: landscape) {
  .enterprise-flow-grid,
  .module-command-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .enterprise-workflow {
    display: flex;
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  .workflow-step {
    min-width: 172px;
    min-height: 104px;
    scroll-snap-align: start;
  }

  .enterprise-metric-list {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
  }
}

@media (max-width: 760px) {
  .nav-group {
    gap: 8px;
  }

  .nav-group h3 {
    margin: 12px 4px 4px;
    color: #708399;
    font-size: 12px;
  }

  .nav-group > div {
    gap: 8px;
  }

  .enterprise-flow-grid,
  .module-command-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 10px;
  }

  .enterprise-workflow {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  .workflow-step {
    min-width: 172px;
    min-height: 112px;
    padding: 12px;
    scroll-snap-align: start;
  }

  .enterprise-metric-list {
    grid-template-columns: 1fr;
  }

  .enterprise-metric-list > div {
    min-height: 72px;
    padding: 12px;
  }

  .enterprise-mini-row {
    min-height: 50px;
    padding: 9px 10px;
  }

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

  .dashboard-kpis .kpi-v3 {
    min-width: 0;
  }

  .dashboard-kpis .kpi-v3 strong {
    font-size: clamp(17px, 5.2vw, 24px);
  }

  .module-kpis.kpi-grid-v3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .module-kpis .kpi-v3 strong {
    font-size: clamp(18px, 5.5vw, 25px);
  }
}

/* Enterprise feature additions */
.project-archive-panel {
  border-top: 4px solid rgba(47, 134, 255, 0.24);
}

.task-panel {
  border-top: 4px solid rgba(22, 111, 220, 0.24);
}

.audit-panel {
  border-top: 4px solid rgba(47, 134, 255, 0.18);
}

.recycle-panel {
  border-top: 4px solid rgba(191, 61, 61, 0.18);
}

.project-kpis,
.task-kpis {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.attachment-field {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px dashed #bfd9f2;
  border-radius: 8px;
  background: linear-gradient(180deg, #fbfdff, #f5faff);
}

.attachment-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.attachment-field-head > span {
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 10px;
}

.attachment-empty {
  min-height: 70px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  color: var(--muted);
  background: white;
  font-size: 13px;
}

.attachment-thumb {
  position: relative;
  margin: 0;
  min-height: 124px;
  display: grid;
  grid-template-rows: 84px auto;
  gap: 7px;
  padding: 8px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: white;
  box-shadow: 0 8px 18px rgba(30, 70, 110, 0.06);
}

.attachment-thumb img,
.attachment-thumb > span {
  width: 100%;
  height: 84px;
  border-radius: 6px;
  background: #eef6ff;
  object-fit: cover;
}

.attachment-thumb > span {
  display: grid;
  place-items: center;
  color: var(--accent);
}

.attachment-thumb > span svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.attachment-thumb figcaption {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.attachment-thumb .icon-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
  background: rgba(255, 255, 255, 0.94);
}

.attachment-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid #d7e7f6;
  border-radius: 999px;
  color: #617386;
  background: #f7fbff;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.attachment-count.has-files {
  color: #166fdc;
  border-color: #b9d8ff;
  background: #eaf4ff;
}

.project-archive-panel .compact-cell strong,
.task-panel .compact-cell strong {
  max-width: 280px;
}

.task-panel .status-red,
.recycle-panel .danger-icon {
  box-shadow: 0 8px 16px rgba(191, 61, 61, 0.08);
}

@media (max-width: 760px) {
  .project-kpis,
  .task-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .attachment-field {
    padding: 12px;
  }

  .attachment-field-head {
    align-items: stretch;
  }

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

  .attachment-thumb {
    min-height: 112px;
    grid-template-rows: 74px auto;
  }

  .attachment-thumb img,
  .attachment-thumb > span {
    height: 74px;
  }
}

@media (max-width: 760px) {
  .table-shell {
    max-width: 100%;
    gap: 10px;
  }

  .table-pagination {
    gap: 8px;
    padding: 0 2px;
  }

  .pagination-summary {
    gap: 6px;
  }

  .pagination-summary span {
    min-height: 30px;
    padding: 0 8px;
  }

  .pagination-controls {
    justify-content: flex-end;
    gap: 6px;
    padding-bottom: 2px;
  }

  .page-btn {
    min-width: 38px;
    min-height: 34px;
    flex: 0 0 auto;
  }

  .pagination-page-status,
  .pagination-ellipsis,
  .pagination-jump {
    flex: 0 0 auto;
  }

  .pagination-jump input {
    width: 56px;
  }
}

td[data-full-value],
.kpi-v3 strong[data-full-value] {
  cursor: help;
}

td[data-full-value]:focus-visible,
.kpi-v3 strong[data-full-value]:focus-visible {
  outline: 2px solid rgba(47, 134, 255, 0.45);
  outline-offset: 2px;
  border-radius: 6px;
}

.kpi-v3 strong {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.dashboard-layout th,
.dashboard-layout td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: normal;
  word-break: keep-all;
}

.cell-detail-popover {
  position: absolute;
  z-index: 120;
  max-width: min(420px, calc(100vw - 24px));
  padding: 10px 12px;
  border: 1px solid rgba(187, 210, 232, 0.88);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  color: var(--text);
  box-shadow: 0 16px 34px rgba(31, 44, 56, 0.16);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.14s ease, transform 0.14s ease;
  white-space: normal;
  overflow-wrap: anywhere;
}

.cell-detail-popover.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 760px) {
  .table-wrap {
    max-width: 100%;
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    background: #fff;
    box-shadow: var(--shadow-soft);
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
  }

  .dashboard-layout .table-wrap,
  body .profit-ledger-panel .table-wrap,
  body .profit-order-panel .table-wrap {
    max-width: 100%;
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    background: #fff;
    box-shadow: var(--shadow-soft);
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
  }

  table,
  .dashboard-layout table {
    display: table;
    width: max-content;
    min-width: max(920px, 100%);
    border-collapse: separate;
    border-spacing: 0;
    table-layout: auto;
  }

  .dashboard-bank-table table {
    min-width: max(560px, 100%);
  }

  thead {
    display: table-header-group;
  }

  tbody {
    display: table-row-group;
  }

  tbody tr {
    display: table-row;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    transition: background 0.18s ease;
  }

  tbody tr:active {
    transform: none;
    box-shadow: none;
  }

  tbody tr:nth-child(even) {
    background: #fbfcfd;
  }

  tbody tr:hover {
    background: #f2faf7;
  }

  th,
  td,
  .dashboard-layout th,
  .dashboard-layout td {
    display: table-cell;
    width: auto;
    height: 52px;
    min-height: 0;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-soft);
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: normal;
    word-break: keep-all;
    line-height: 1.4;
    vertical-align: middle;
  }

  td:last-child,
  th:last-child,
  .dashboard-layout td:last-child,
  .dashboard-layout th:last-child {
    width: auto;
  }

  td::before {
    content: none;
    display: none;
  }

  td[data-label="操作"] {
    min-width: 150px;
  }

  td[data-label="操作"] .row-actions,
  td[data-label="操作"] .customer-table-actions {
    width: max-content;
    flex-wrap: nowrap;
  }

  .row-actions,
  .customer-table-actions {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    grid-template-columns: none;
    width: max-content;
    min-width: 0;
  }

  .icon-btn,
  .link-action {
    width: auto;
    min-width: 44px;
  }

  .cell-detail-popover {
    display: none;
  }
}

@media (max-width: 1460px) and (min-width: 1181px) {
  .profit-kpis {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  .profit-toolbar {
    grid-template-columns: minmax(260px, 340px) minmax(320px, 1fr);
  }

  .profit-period-note {
    grid-column: 1 / -1;
  }

  .profit-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .profit-workbench {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 940px) and (max-height: 520px) and (orientation: landscape) {
  .profit-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .profit-period-note {
    grid-column: 1 / -1;
  }

  .profit-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .profit-workbench {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .profit-toolbar {
    grid-template-columns: 1fr;
  }

  .profit-period-note {
    min-height: 40px;
    width: 100%;
  }

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

  .profit-kpis .kpi-v3 {
    min-height: 112px;
    order: 0;
  }

  .profit-workbench {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .profit-ledger-panel,
  .profit-order-panel {
    padding: 16px;
  }

  .profit-ledger-panel .table-wrap,
  .profit-order-panel .table-wrap {
    overflow-x: visible;
  }

  .profit-bar-row {
    grid-template-columns: 68px minmax(0, 1fr) auto;
    gap: 8px;
  }
}

@media (max-width: 1460px) and (min-width: 1181px) {
  .profit-kpis {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  .profit-toolbar {
    grid-template-columns: minmax(260px, 340px) minmax(320px, 1fr);
  }

  .profit-period-note {
    grid-column: 1 / -1;
  }

  .profit-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .profit-workbench {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 940px) and (max-height: 520px) and (orientation: landscape) {
  .profit-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .profit-period-note {
    grid-column: 1 / -1;
  }

  .profit-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .profit-workbench {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .profit-toolbar {
    grid-template-columns: 1fr;
  }

  .profit-period-note {
    min-height: 40px;
    width: 100%;
  }

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

  .profit-kpis .kpi-v3 {
    min-height: 112px;
    order: 0;
  }

  .profit-workbench {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .profit-ledger-panel,
  .profit-order-panel {
    padding: 16px;
  }

  .profit-ledger-panel .table-wrap,
  .profit-order-panel .table-wrap {
    overflow-x: visible;
  }

  .profit-bar-row {
    grid-template-columns: 68px minmax(0, 1fr) auto;
    gap: 8px;
  }
}

@media (max-width: 1460px) and (min-width: 1181px) {
  .profit-kpis {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  .profit-toolbar {
    grid-template-columns: minmax(260px, 340px) minmax(320px, 1fr);
  }

  .profit-period-note {
    grid-column: 1 / -1;
  }

  .profit-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .profit-workbench {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 940px) and (max-height: 520px) and (orientation: landscape) {
  .profit-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .profit-period-note {
    grid-column: 1 / -1;
  }

  .profit-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .profit-workbench {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .profit-toolbar {
    grid-template-columns: 1fr;
  }

  .profit-period-note {
    min-height: 40px;
    width: 100%;
  }

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

  .profit-kpis .kpi-v3 {
    min-height: 112px;
    order: 0;
  }

  .profit-workbench {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .profit-ledger-panel,
  .profit-order-panel {
    padding: 16px;
  }

  .profit-ledger-panel .table-wrap,
  .profit-order-panel .table-wrap {
    overflow-x: visible;
  }

  .profit-bar-row {
    grid-template-columns: 68px minmax(0, 1fr) auto;
    gap: 8px;
  }
}

@media (max-width: 1460px) and (min-width: 1181px) {
  .profit-kpis {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  .profit-toolbar {
    grid-template-columns: minmax(260px, 340px) minmax(320px, 1fr);
  }

  .profit-period-note {
    grid-column: 1 / -1;
  }

  .profit-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .profit-workbench {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 940px) and (max-height: 520px) and (orientation: landscape) {
  .profit-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .profit-period-note {
    grid-column: 1 / -1;
  }

  .profit-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .profit-workbench {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .profit-toolbar {
    grid-template-columns: 1fr;
  }

  .profit-period-note {
    min-height: 40px;
    width: 100%;
  }

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

  .profit-kpis .kpi-v3 {
    min-height: 112px;
    order: 0;
  }

  .profit-workbench {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .profit-ledger-panel,
  .profit-order-panel {
    padding: 16px;
  }

  .profit-ledger-panel .table-wrap,
  .profit-order-panel .table-wrap {
    overflow-x: visible;
  }

  .profit-bar-row {
    grid-template-columns: 68px minmax(0, 1fr) auto;
    gap: 8px;
  }
}

@media (max-width: 940px) and (max-height: 520px) and (orientation: landscape) {
  body {
    overflow-x: hidden;
    padding-bottom: env(safe-area-inset-bottom);
    background: linear-gradient(180deg, #f7fbfd 0%, #eef5f8 100%);
  }

  body.mobile-drawer-locked {
    overflow: hidden;
    touch-action: none;
  }

  .shell-v3 {
    display: block;
    grid-template-columns: 1fr;
    background: transparent;
  }

  .mobile-header-v3 {
    position: sticky;
    top: 0;
    z-index: 68;
    display: flex;
    min-height: 48px;
    align-items: center;
    gap: 10px;
    padding: 4px 12px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--border-soft);
    box-shadow: 0 8px 20px rgba(31, 44, 56, 0.08);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    isolation: isolate;
  }

  .mobile-header-title {
    display: grid;
    min-width: 0;
    gap: 1px;
  }

  .mobile-header-title strong {
    font-size: 16px;
    line-height: 1.15;
  }

  .mobile-header-title span {
    max-width: 58vw;
    overflow: hidden;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-header-logout {
    display: inline-flex;
    min-width: 60px;
    min-height: 38px;
    margin-left: auto;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    border-color: var(--border-soft);
    box-shadow: 0 8px 18px rgba(31, 44, 56, 0.08);
    font-weight: 900;
  }

  .mobile-menu-toggle,
  .mobile-drawer-close {
    display: inline-flex;
  }

  .mobile-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: block;
    border: 0;
    padding: 0;
    opacity: 0;
    pointer-events: none;
    background: rgba(10, 20, 28, 0.26);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: opacity 0.22s ease;
  }

  .shell-v3.mobile-drawer-open .mobile-drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar.sidebar-v3 {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 80;
    display: flex;
    flex-direction: column;
    width: min(328px, 72vw);
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    max-height: none;
    overflow: hidden auto;
    overscroll-behavior: contain;
    padding: 0;
    gap: 0;
    transform: translate3d(-100%, 0, 0);
    transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.22s ease;
    will-change: transform;
    background: var(--surface-panel);
    border-right: 1px solid var(--border-soft);
    border-bottom: 0;
    box-shadow: 22px 0 42px rgba(7, 18, 25, 0);
  }

  .shell-v3.mobile-drawer-open .sidebar.sidebar-v3 {
    transform: translate3d(0, 0, 0);
    box-shadow: 22px 0 42px rgba(31, 44, 56, 0.16);
  }

  .brand-v3 {
    position: relative;
    top: auto;
    z-index: 50;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 3px 10px;
    background: var(--surface-panel);
    border-bottom: 1px solid var(--border-soft);
    box-shadow: none;
  }

  .brand-v3::before {
    content: none;
  }

  .brand-v3 > div {
    display: grid;
    min-width: 0;
    gap: 2px;
    border-left-color: var(--accent);
  }

  .brand-v3 strong {
    display: block;
    color: var(--text);
    font-size: 16px;
  }

  .brand-v3 span {
    display: none;
    overflow: hidden;
    color: var(--muted);
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sidebar-v3 nav {
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 2px 8px 4px;
  }

  .nav-item-v3 {
    width: auto;
    min-height: 30px;
    margin-inline: 0;
    justify-content: flex-start;
    padding: 0 10px;
    border-radius: 10px;
    font-size: 12px;
  }

  .nav-item-v3 svg {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
  }

  .nav-item-v3 span {
    display: inline;
  }

  .mobile-drawer-nav .nav-item-v3 {
    min-height: 30px;
    border-radius: 10px;
    color: var(--sidebar-text);
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
  }

  .mobile-drawer-nav .nav-item-v3.active,
  .mobile-drawer-nav .nav-item-v3:hover {
    background: var(--accent-soft);
    color: var(--accent-strong);
  }

  .mobile-drawer-nav .nav-item-v3:active {
    transform: scale(0.98);
  }

  .sidebar-v3 .sidebar-footer {
    display: none;
    gap: 8px;
    justify-content: space-between;
    margin-top: auto;
    padding: 8px 12px 10px;
  }

  .sidebar-v3 .sidebar-footer span {
    display: block;
    color: var(--muted);
    font-size: 10px;
  }

  .main-v3 {
    margin-top: 0;
    padding: 0 12px 14px;
  }

  .main-v3::before {
    display: none;
  }

  .topbar-v3 {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 42vw);
    align-items: center;
    gap: 8px;
    margin: 0 -12px 8px;
    padding: 8px 12px;
    border-radius: 0 0 16px 16px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 10px 22px rgba(31, 44, 56, 0.08);
  }

  .topbar-v3 h1 {
    font-size: 18px;
    line-height: 1.2;
  }

  .topbar-v3 p {
    max-width: 100%;
    overflow: hidden;
    font-size: 10.5px;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .dashboard-greeting {
    align-items: center;
    gap: 8px;
  }

  .greeting-avatar {
    width: 32px;
    height: 32px;
    font-size: 13px;
  }

  .topbar-actions-v3 {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 8px;
    width: 100%;
  }

  .topbar-actions-v3 .search-box {
    grid-column: 1;
    width: 100%;
    min-height: 40px;
    border-radius: 14px;
    box-shadow: 0 8px 18px rgba(31, 44, 56, 0.055);
  }

  .topbar-actions-v3 [data-action="logout"] {
    display: none;
  }

  .topbar-actions-v3 .primary,
  .topbar-actions-v3 .account-chip {
    grid-column: 1 / -1;
    width: 100%;
  }

  .dashboard-toolbar {
    grid-template-columns: minmax(210px, 1fr) minmax(120px, 0.7fr) minmax(120px, 0.7fr) 86px;
    gap: 8px;
    margin-bottom: 8px;
    padding: 8px;
    border-radius: 14px;
  }

  .operating-toolbar {
    grid-template-columns: minmax(210px, 1fr) minmax(300px, 1.2fr);
  }

  .date-range,
  .dashboard-toolbar select,
  .dashboard-toolbar .primary {
    min-height: 40px;
    border-radius: 12px;
  }

  .quick-tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .quick-tabs button {
    min-height: 38px;
    padding-inline: 6px;
    font-size: 12px;
  }

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

  .dashboard-kpis .kpi-v3 {
    grid-column: auto;
  }

  .operating-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-grid-v3.operating-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-v3 {
    min-height: 82px;
    padding: 10px;
    border-radius: 14px;
  }

  .kpi-v3:last-child {
    grid-column: auto;
  }

  .kpi-metric-income { order: 1; }
  .kpi-metric-other-income { order: 2; }
  .kpi-metric-receivable { order: 3; }
  .kpi-metric-operating-expense { order: 4; }
  .kpi-metric-margin { order: 5; }
  .kpi-metric-payable { order: 6; }
  .kpi-metric-cost { order: 7; }
  .kpi-metric-profit { order: 8; }
  .kpi-metric-tax { order: 9; }

  .kpi-v3 .kpi-head span {
    font-size: 10.5px;
  }

  .kpi-v3 i {
    width: 34px;
    height: 34px;
    border-radius: 12px;
  }

  .kpi-v3 svg {
    width: 20px;
    height: 20px;
    stroke-width: 2.6;
  }

  .kpi-v3 strong {
    font-size: 18px;
  }

  .kpi-v3 small {
    font-size: 10px;
  }

  .dashboard-layout {
    gap: 10px;
  }

  .panel {
    padding: 12px;
    border-radius: 14px;
  }

  .panel-title {
    gap: 8px;
    margin-bottom: 10px;
  }

  .panel-title h2 {
    font-size: 16px;
  }

  .table-wrap {
    border: 0;
    overflow-x: visible;
    background: transparent;
    box-shadow: none;
  }

  table {
    display: block;
    width: 100%;
    min-width: 0;
  }

  thead {
    display: none;
  }

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

  tbody tr {
    display: grid;
    gap: 0;
    grid-auto-rows: auto;
    align-items: stretch;
    padding: 12px;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 10px 22px rgba(31, 44, 56, 0.08);
    transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.18s ease;
  }

  tbody tr:active {
    transform: scale(0.99);
    box-shadow: 0 7px 16px rgba(31, 44, 56, 0.08);
  }

  td {
    display: grid;
    grid-template-columns: minmax(86px, 30%) minmax(0, 1fr);
    gap: 8px;
    width: 100%;
    height: auto;
    min-height: 0;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-soft);
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.38;
  }

  td::before {
    content: attr(data-label);
    color: #7a8a96;
    font-size: 11px;
    font-weight: 800;
  }

  .editor {
    padding: 12px;
    border-radius: 14px;
  }

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

  .form-grid .wide-field,
  .customer-form-grid .wide-field,
  .form-grid textarea,
  .customer-form-grid textarea {
    grid-column: 1 / -1;
  }

  input,
  select,
  textarea,
  .primary,
  .ghost,
  .danger,
  .file-button {
    min-height: 40px;
    font-size: 14px;
  }

  .form-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    position: sticky;
    bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 22;
    gap: 8px;
    margin: 12px -4px 0;
    padding: 8px;
    border: 1px solid rgba(216, 227, 236, 0.88);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 14px 30px rgba(31, 44, 56, 0.14);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }
}

@media (max-width: 760px) {
  .topbar-actions-v3 {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 8px;
    width: 100%;
  }

  .topbar-actions-v3 .search-box {
    grid-column: 1;
    width: 100%;
    min-height: 44px;
    border-radius: 16px;
    box-shadow: 0 8px 18px rgba(31, 44, 56, 0.055);
  }

  .topbar-actions-v3 [data-action="logout"] {
    display: none;
  }

  .topbar-actions-v3 .primary,
  .topbar-actions-v3 .account-chip {
    grid-column: 1 / -1;
    width: 100%;
  }

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

  .dashboard-kpis .kpi-v3 {
    grid-column: auto;
  }

  .operating-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-grid-v3.operating-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-v3:last-child {
    grid-column: auto;
  }

  .kpi-metric-income { order: 1; }
  .kpi-metric-other-income { order: 2; }
  .kpi-metric-receivable { order: 3; }
  .kpi-metric-operating-expense { order: 4; }
  .kpi-metric-margin { order: 5; }
  .kpi-metric-payable { order: 6; }
  .kpi-metric-cost { order: 7; }
  .kpi-metric-profit { order: 8; }
  .kpi-metric-tax { order: 9; }

  tbody tr {
    transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.18s ease;
  }

  tbody tr:active {
    transform: scale(0.99);
    box-shadow: 0 7px 16px rgba(31, 44, 56, 0.08);
  }

  label:focus-within {
    transform: translateY(-1px);
  }

  .form-actions {
    position: sticky;
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 22;
    margin: 16px -4px 0;
    padding: 10px;
    border: 1px solid rgba(216, 227, 236, 0.88);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 14px 30px rgba(31, 44, 56, 0.14);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }
}

@media (max-width: 760px) {
  body.mobile-drawer-locked {
    overflow: hidden;
    touch-action: none;
  }

  button,
  input,
  select,
  textarea,
  .file-button {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-header-v3 {
    position: sticky;
    top: 0;
    z-index: 68;
    min-height: 52px;
    padding: 7px 12px 7px 10px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .mobile-header-title strong {
    font-size: 16px;
  }

  .topbar-v3 {
    margin: 0 -14px 10px;
    padding: 12px 16px 14px;
    border-radius: 0 0 20px 20px;
  }

  .topbar-v3 > div:first-child {
    min-width: 0;
  }

  .topbar-v3 h1 {
    font-size: 19px;
  }

  .topbar-v3 p {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11.5px;
  }

  .dashboard-greeting {
    gap: 8px;
  }

  .greeting-avatar {
    width: 34px;
    height: 34px;
    font-size: 14px;
  }

  .topbar-actions-v3 {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 8px;
    width: 100%;
  }

  .topbar-actions-v3 .search-box {
    grid-column: 1;
    width: 100%;
    min-height: 44px;
    border-radius: 16px;
    box-shadow: 0 8px 18px rgba(31, 44, 56, 0.055);
  }

  .topbar-actions-v3 [data-action="logout"] {
    display: none;
  }

  .topbar-actions-v3 .primary,
  .topbar-actions-v3 .account-chip {
    grid-column: 1 / -1;
    width: 100%;
  }

  .dashboard-toolbar {
    gap: 8px;
    margin-bottom: 10px;
    padding: 10px;
    border-radius: 16px;
  }

  .date-range {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 6px;
    padding: 0 10px;
    font-size: 12px;
  }

  .quick-tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .quick-tabs button {
    min-height: 40px;
    padding-inline: 6px;
    font-size: 13px;
  }

  .panel-title .segmented {
    flex: 0 0 auto;
    max-width: 176px;
    padding: 2px;
    border-radius: 10px;
  }

  .panel-title .segmented button {
    min-height: 30px;
    padding: 4px 9px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
    word-break: keep-all;
  }

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

  .dashboard-kpis .kpi-v3 {
    grid-column: auto;
  }

  .operating-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-grid-v3.operating-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-v3 {
    min-height: 96px;
    padding: 12px;
    box-shadow: 0 1px 2px rgba(15, 25, 33, 0.035), 0 10px 20px rgba(31, 44, 56, 0.05);
  }

  .kpi-v3:last-child {
    grid-column: auto;
  }

  .kpi-v3 .kpi-head {
    gap: 6px;
  }

  .kpi-v3 .kpi-head span {
    font-size: 11.5px;
  }

  .kpi-v3 i {
    width: 26px;
    height: 26px;
  }

  .kpi-v3 strong {
    font-size: 20px;
  }

  .kpi-v3 small {
    font-size: 11.5px;
  }

  tbody {
    gap: 10px;
  }

  tbody tr {
    padding: 12px;
    border-radius: 16px;
    box-shadow: 0 12px 24px rgba(31, 44, 56, 0.075);
    transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.18s ease;
  }

  tbody tr:active {
    transform: scale(0.99);
    box-shadow: 0 7px 16px rgba(31, 44, 56, 0.08);
  }

  td {
    grid-template-columns: minmax(82px, 32%) minmax(0, 1fr);
    gap: 8px;
    padding: 8px 0;
  }

  label {
    transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  label:focus-within {
    transform: translateY(-1px);
  }

  input,
  select,
  textarea {
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  }

  .search-box:focus-within,
  .form-grid label:focus-within input,
  .form-grid label:focus-within select,
  .form-grid label:focus-within textarea,
  .customer-form-grid label:focus-within input,
  .customer-form-grid label:focus-within select,
  .customer-form-grid label:focus-within textarea {
    border-color: rgba(47, 134, 255, 0.62);
    box-shadow: 0 0 0 3px rgba(47, 134, 255, 0.12), 0 10px 22px rgba(31, 44, 56, 0.055);
  }

  .editor {
    padding: 14px;
  }

  .form-actions {
    position: sticky;
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 22;
    margin: 16px -4px 0;
    padding: 10px;
    border: 1px solid rgba(216, 227, 236, 0.88);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 14px 30px rgba(31, 44, 56, 0.14);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }
}

@media (prefers-reduced-motion: no-preference) {
  @keyframes mobileSurfaceIn {
    from {
      opacity: 0;
      transform: translateY(8px);
    }

    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .dashboard-toolbar,
  .kpi-v3,
  .panel {
    animation: mobileSurfaceIn 0.26s cubic-bezier(0.2, 0.8, 0.2, 1) both;
  }
}

@media (max-width: 760px) {
  body {
    overflow-x: hidden;
    padding-bottom: env(safe-area-inset-bottom);
    background: linear-gradient(180deg, #f7fbfd 0%, #eef5f8 100%);
  }

  .login-page {
    min-height: 100vh;
    min-height: 100dvh;
    padding: 16px;
    place-items: center;
  }

  .login-panel {
    width: 100%;
    max-width: 420px;
    padding: 24px 18px 20px;
    border-radius: 14px;
    box-shadow: 0 16px 34px rgba(21, 35, 45, 0.13);
  }

  .login-panel h1 {
    margin: 20px 0 16px;
    font-size: 24px;
  }

  .login-panel p {
    margin-bottom: 16px;
    font-size: 12px;
  }

  .login-brand {
    gap: 10px;
    font-size: 17px;
  }

  .login-mark {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

  .shell-v3 {
    display: block;
    grid-template-columns: 1fr;
    background: transparent;
  }

  .mobile-header-v3 {
    position: sticky;
    top: 0;
    z-index: 68;
    display: flex;
    min-height: 52px;
    align-items: center;
    gap: 9px;
    padding: 7px 12px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--border-soft);
    box-shadow: 0 8px 20px rgba(31, 44, 56, 0.08);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    isolation: isolate;
  }

  .mobile-header-title {
    display: grid;
    min-width: 0;
    gap: 3px;
  }

  .mobile-header-title strong {
    font-size: 17px;
    line-height: 1.2;
  }

  .mobile-header-title span {
    color: var(--muted);
    font-size: 10.5px;
  }

  .mobile-header-logout {
    display: inline-flex;
    min-width: 62px;
    min-height: 42px;
    margin-left: auto;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    background: #fff;
    color: var(--text);
    box-shadow: 0 8px 18px rgba(31, 44, 56, 0.08);
    font-weight: 900;
  }

  .mobile-menu-toggle,
  .mobile-drawer-close {
    display: inline-flex;
  }

  .mobile-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: block;
    border: 0;
    padding: 0;
    background: rgba(8, 20, 27, 0.24);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
  }

  .shell-v3.mobile-drawer-open .mobile-drawer-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar.sidebar-v3 {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 80;
    display: flex;
    width: min(276px, 84vw);
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    max-height: none;
    overflow: hidden auto;
    overscroll-behavior: contain;
    padding: 0;
    gap: 0;
    transform: translate3d(-100%, 0, 0);
    transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.22s ease;
    will-change: transform;
    background: var(--surface-panel);
    border-right: 1px solid var(--border-soft);
    border-bottom: 0;
    box-shadow: 22px 0 42px rgba(7, 18, 25, 0);
  }

  .shell-v3.mobile-drawer-open .sidebar.sidebar-v3 {
    transform: translate3d(0, 0, 0);
    box-shadow: 22px 0 42px rgba(31, 44, 56, 0.16);
  }

  .brand-v3 {
    position: relative;
    top: auto;
    z-index: 50;
    min-height: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 14px 12px;
    background: var(--surface-panel);
    border-bottom: 1px solid var(--border-soft);
    box-shadow: none;
  }

  .brand-v3 strong {
    font-size: 18px;
    color: var(--text);
  }

  .brand-v3 span {
    font-size: 11px;
    color: var(--muted);
  }

  .sidebar-v3 nav {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 8px 10px 10px;
  }

  .nav-item-v3 {
    min-height: 46px;
    justify-content: flex-start;
    padding: 0 13px;
    font-size: 14px;
  }

  .mobile-drawer-nav .nav-item-v3 {
    border-radius: 12px;
    color: var(--sidebar-text);
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
  }

  .mobile-drawer-nav .nav-item-v3.active,
  .mobile-drawer-nav .nav-item-v3:hover {
    background: var(--accent-soft);
    color: var(--accent-strong);
  }

  .mobile-drawer-nav .nav-item-v3:active {
    transform: scale(0.98);
  }

  .mobile-drawer-nav .nav-item-v3.active::before {
    left: 0;
    width: 3px;
    height: 22px;
    border-radius: 999px;
  }

  .main-v3 {
    margin-top: 0;
    padding: 0 14px 22px;
  }

  .main-v3::before {
    display: none;
  }

  .topbar-v3 {
    position: static;
    margin: 0 -14px 10px;
    padding: 12px 16px 14px;
    border-radius: 0 0 20px 20px;
    align-items: stretch;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 12px 28px rgba(31, 44, 56, 0.09);
  }

  .topbar-v3 h1 {
    font-size: 21px;
  }

  .topbar-v3 p {
    font-size: 12px;
    line-height: 1.55;
  }

  .dashboard-greeting {
    align-items: flex-start;
    gap: 10px;
  }

  .greeting-avatar {
    width: 38px;
    height: 38px;
  }

  .search-box {
    position: relative;
    width: 100%;
    height: auto;
    min-height: 48px;
    grid-template-columns: 22px minmax(0, 1fr) auto;
    border-radius: 16px;
    box-shadow: 0 10px 22px rgba(31, 44, 56, 0.08);
  }

  .search-box input {
    padding-right: 34px;
  }

  .search-clear {
    position: absolute;
    right: 70px;
    top: 9px;
    width: 28px;
    height: 28px;
  }

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

  .dashboard-toolbar {
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    background: var(--surface-panel);
    box-shadow: var(--shadow-soft);
  }

  .date-range,
  .dashboard-toolbar select {
    height: auto;
    min-height: 44px;
    border-radius: 12px;
  }

  .date-range input {
    height: 38px;
    font-size: 14px;
  }

  .quick-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    height: auto;
    border-radius: 12px;
    overflow: visible;
  }

  .quick-tabs button {
    min-height: 44px;
    font-weight: 900;
  }

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

  .dashboard-kpis .kpi-v3 {
    grid-column: auto;
  }

  .operating-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-grid-v3.operating-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-metric-income { order: 1; }
  .kpi-metric-other-income { order: 2; }
  .kpi-metric-receivable { order: 3; }
  .kpi-metric-operating-expense { order: 4; }
  .kpi-metric-margin { order: 5; }
  .kpi-metric-payable { order: 6; }
  .kpi-metric-cost { order: 7; }
  .kpi-metric-profit { order: 8; }
  .kpi-metric-tax { order: 9; }

  .kpi-v3 {
    min-height: 104px;
    border-radius: 14px;
    padding: 14px;
  }

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

  .dashboard-layout {
    gap: 12px;
  }

  .panel {
    padding: 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 12px 26px rgba(31, 44, 56, 0.08);
  }

  .panel-title {
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 12px;
  }

  .panel-title h2 {
    font-size: 17px;
  }

  .panel-title span {
    text-align: left;
  }

  .panel-title-with-filter {
    flex-direction: column;
    align-items: stretch;
  }

  .inline-filter {
    width: 100%;
    justify-content: space-between;
  }

  .inline-filter select {
    flex: 1;
    min-width: 0;
  }

  .editor {
    padding: 16px;
    border-radius: 14px;
  }

  .editor::before {
    border-radius: 14px 14px 0 0;
  }

  .link-banner,
  .result-summary {
    border-radius: 14px;
  }

  .trend-chart {
    height: 280px;
    gap: 6px;
    overflow-x: auto;
  }

  .bar-stack i {
    width: 8px;
  }

  .donut-wrap {
    flex-direction: column;
  }

  .sidebar-v3 {
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .sidebar-v3 nav {
    display: grid;
  }

  .sidebar-v3 .sidebar-footer {
    display: grid;
    gap: 8px;
    padding: 12px 14px 16px;
  }

  .sidebar-v3 .sidebar-footer .ghost {
    min-height: 42px;
    border-color: rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    box-shadow: none;
  }

  .table-wrap {
    border: 0;
    overflow-x: visible;
    background: transparent;
    box-shadow: none;
  }

  table {
    display: block;
    width: 100%;
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 12px;
  }

  tbody tr {
    display: grid;
    gap: 0;
    grid-auto-rows: auto;
    align-items: stretch;
    padding: 14px;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 10px 22px rgba(31, 44, 56, 0.08);
    transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.18s ease;
  }

  tbody tr:active {
    transform: scale(0.99);
    box-shadow: 0 7px 16px rgba(31, 44, 56, 0.08);
  }

  tbody tr:nth-child(even),
  tbody tr:hover {
    background: #fff;
  }

  td {
    display: grid;
    grid-template-columns: minmax(92px, 34%) minmax(0, 1fr);
    gap: 10px;
    width: 100%;
    height: auto;
    min-height: 0;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-soft);
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.45;
    align-items: start;
  }

  td:first-child {
    padding-top: 0;
  }

  td:last-child {
    width: 100%;
    padding-bottom: 0;
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    color: #7a8a96;
    font-size: 12px;
    font-weight: 800;
  }

  td[data-label="操作"] {
    grid-template-columns: 1fr;
  }

  td[data-label="操作"]::before {
    display: none;
  }

  td[data-label="操作"] .row-actions,
  td[data-label="操作"] .customer-table-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .row-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
    min-width: 0;
  }

  .customer-table-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  .icon-btn,
  .link-action {
    width: 100%;
    min-width: 0;
    min-height: 42px;
  }

  .icon-btn {
    flex-basis: auto;
  }

  .toolbar-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .toolbar-row .segmented,
  .toolbar-row .button-row {
    width: 100%;
  }

  .toolbar-row .segmented {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .toolbar-row .segmented button {
    min-height: 42px;
    padding-inline: 8px;
  }

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

  .form-grid,
  .customer-form-grid {
    grid-template-columns: 1fr;
    gap: 13px;
  }

  .form-grid label span {
    color: #607282;
    font-size: 12px;
  }

  .form-grid input,
  .form-grid select,
  .form-grid textarea,
  .avatar-edit-row > input {
    border-radius: 12px;
    background: #fbfdff;
  }

  .permissions {
    padding: 10px;
    border-radius: 14px;
    background: #fff;
  }

  .permission-grid {
    gap: 8px;
  }

  .permission-row {
    grid-template-columns: 1fr;
    min-height: auto;
    align-items: stretch;
    gap: 8px;
    padding: 10px;
  }

  .permission-row strong {
    font-size: 14px;
  }

  .avatar-edit-row {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
  }

  .form-actions,
  .button-row {
    width: 100%;
    align-items: stretch;
  }

  .topbar-actions-v3 {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch;
    gap: 8px;
    width: 100%;
  }

  .topbar-actions-v3 .search-box {
    grid-column: 1;
    width: 100%;
    min-height: 44px;
    border-radius: 16px;
    box-shadow: 0 8px 18px rgba(31, 44, 56, 0.055);
  }

  .topbar-actions-v3 [data-action="logout"] {
    grid-column: 2;
    width: auto;
    min-width: 66px;
    padding-inline: 12px;
    border-radius: 12px;
  }

  .topbar-actions-v3 .account-chip {
    grid-column: 1 / -1;
    width: 100%;
  }

  .topbar-actions-v3 {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 8px;
    width: 100%;
  }

  .topbar-actions-v3 [data-action="logout"] {
    display: none;
  }

  .form-actions {
    display: grid;
    grid-template-columns: 1fr;
    position: sticky;
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 22;
    margin: 16px -4px 0;
    padding: 10px;
    border: 1px solid rgba(216, 227, 236, 0.88);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 14px 30px rgba(31, 44, 56, 0.14);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  input,
  select,
  textarea,
  .primary,
  .ghost,
  .danger,
  .file-button {
    min-height: 44px;
    font-size: 15px;
  }

  .small {
    min-height: 40px;
  }

  .topbar-actions-v3 .primary,
  .topbar-actions-v3 .ghost,
  .button-row .primary,
  .button-row .ghost,
  .button-row .file-button {
    width: 100%;
  }

  .customer-list-panel {
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .empty {
    min-height: 120px;
    padding: 18px;
    border-radius: 14px;
    background: linear-gradient(180deg, #ffffff 0%, #f7fbfd 100%);
    text-align: center;
  }
}

/* Final enterprise dashboard and drawer fit after all navigation overrides. */
@media (min-width: 1181px) {
  .enterprise-flow-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .enterprise-flow-panel {
    grid-column: 1 / -1;
  }

  .enterprise-workflow {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (max-width: 940px) and (max-height: 520px) and (orientation: landscape) {
  .sidebar.sidebar-v3 {
    gap: 0;
  }

  .sidebar-v3 nav.sidebar-nav {
    gap: 4px 8px;
    padding: 2px 8px 4px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-group,
  .nav-group > div {
    gap: 4px;
  }

  .nav-group {
    display: contents;
  }

  .nav-group > div {
    display: contents;
  }

  .nav-group h3 {
    display: none;
  }

  .mobile-drawer-nav .nav-item-v3 {
    height: auto;
    min-height: 36px;
    padding: 6px 10px;
  }
}

/* Final override: mobile tables stay real tables and scroll horizontally. */
@media (max-width: 760px) {
  .table-wrap {
    max-width: 100%;
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    background: #fff;
    box-shadow: var(--shadow-soft);
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
  }

  .dashboard-layout .table-wrap,
  body .profit-ledger-panel .table-wrap,
  body .profit-order-panel .table-wrap {
    max-width: 100%;
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    background: #fff;
    box-shadow: var(--shadow-soft);
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
  }

  table,
  .dashboard-layout table {
    display: table;
    width: max-content;
    min-width: max(920px, 100%);
    border-collapse: separate;
    border-spacing: 0;
    table-layout: auto;
  }

  .dashboard-bank-table table {
    min-width: max(560px, 100%);
  }

  table {
    display: table;
    width: max-content;
    min-width: max(920px, 100%);
    border-collapse: separate;
    border-spacing: 0;
    table-layout: auto;
  }

  thead {
    display: table-header-group;
  }

  tbody {
    display: table-row-group;
  }

  tbody tr {
    display: table-row;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    transition: background 0.18s ease;
  }

  tbody tr:active {
    transform: none;
    box-shadow: none;
  }

  tbody tr:nth-child(even) {
    background: #fbfcfd;
  }

  tbody tr:hover {
    background: #f2faf7;
  }

  th,
  td,
  .dashboard-layout th,
  .dashboard-layout td {
    display: table-cell;
    width: auto;
    height: 52px;
    min-height: 0;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-soft);
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: normal;
    word-break: keep-all;
    line-height: 1.4;
    vertical-align: middle;
  }

  td:last-child,
  th:last-child,
  .dashboard-layout td:last-child,
  .dashboard-layout th:last-child {
    width: auto;
  }

  td::before {
    content: none;
    display: none;
  }

  td[data-label="操作"] {
    min-width: 150px;
  }

  td[data-label="操作"] .row-actions,
  td[data-label="操作"] .customer-table-actions {
    width: max-content;
    flex-wrap: nowrap;
  }

  .row-actions,
  .customer-table-actions {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    grid-template-columns: none;
    width: max-content;
    min-width: 0;
  }

  .icon-btn,
  .link-action {
    width: auto;
    min-width: 44px;
  }

  .cell-detail-popover {
    display: none;
  }
}

/* Final mobile web-view guard: avoid white gutters during elastic scrolling. */
@media (max-width: 760px) {
  html,
  body,
  #app {
    background: linear-gradient(180deg, #f7fbfd 0%, #eef5f8 100%);
  }

  html,
  body {
    height: 100%;
    min-height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  body {
    position: relative;
    z-index: 0;
  }

  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: linear-gradient(180deg, #f7fbfd 0%, #eef5f8 100%);
  }

  #app {
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .shell-v3 {
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    background: linear-gradient(180deg, #f7fbfd 0%, #eef5f8 100%);
  }

  .main-v3 {
    min-height: calc(100vh - 52px);
    min-height: calc(100dvh - 52px);
  }
}

/* Final touch-target closure for tablet portrait and phone landscape. */
.search-submit,
.search-clear {
  min-height: 36px;
  height: 36px;
}

.search-clear {
  width: 36px;
}

[data-salary-month-filter] {
  min-height: 36px;
  height: 36px;
}

@media (max-width: 940px) and (max-height: 520px) and (orientation: landscape) {
  .search-submit,
  .search-clear,
  .dashboard-toolbar input,
  .toolbar-row input,
  .toolbar-row select,
  .toolbar-row .segmented button {
    min-height: 38px;
    height: 38px;
  }

  .search-clear {
    width: 38px;
  }

  [data-salary-month-filter] {
    min-height: 38px;
    height: 38px;
  }
}

/* Final phone KPI guard: module pages need wider cards than the dashboard grid. */
@media (max-width: 760px) and (orientation: portrait) {
  .project-kpis.kpi-grid-v3,
  .task-kpis.kpi-grid-v3,
  .module-kpis.kpi-grid-v3:not(.dashboard-kpis) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .project-kpis.kpi-grid-v3 .kpi-v3,
  .task-kpis.kpi-grid-v3 .kpi-v3,
  .module-kpis.kpi-grid-v3:not(.dashboard-kpis) .kpi-v3 {
    min-height: 104px;
    min-width: 0;
    padding: 12px;
  }

  .project-kpis.kpi-grid-v3 .kpi-v3 strong,
  .task-kpis.kpi-grid-v3 .kpi-v3 strong,
  .module-kpis.kpi-grid-v3:not(.dashboard-kpis) .kpi-v3 strong {
    max-width: none;
    overflow: visible;
    font-size: clamp(18px, 5.2vw, 24px);
    text-overflow: clip;
    white-space: nowrap;
  }
}

@media (max-width: 760px), (max-width: 940px) and (max-height: 520px) and (orientation: landscape) {
  .cell-detail-popover {
    display: block;
    position: fixed;
  }
}

/* Enterprise polish pass: login, empty panels, touch targets, and settings density. */
.login-page {
  place-items: center;
  padding: clamp(22px, 4vw, 54px);
  background:
    radial-gradient(circle at 18% 14%, rgba(47, 134, 255, 0.16), transparent 28%),
    radial-gradient(circle at 86% 82%, rgba(24, 169, 153, 0.12), transparent 30%),
    linear-gradient(135deg, #edf6ff 0%, #f8fbff 48%, #eef7ff 100%);
}

.login-shell {
  width: min(1320px, 100%);
  min-height: 620px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 500px;
  overflow: hidden;
  border: 1px solid rgba(176, 205, 232, 0.82);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 70px rgba(31, 71, 111, 0.16);
}

.login-intro {
  display: grid;
  align-content: center;
  gap: 20px;
  padding: 64px 72px;
  color: #ffffff;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 255, 255, 0.18), transparent 24%),
    linear-gradient(135deg, #166fdc 0%, #2f86ff 56%, #18a999 100%);
}

.login-intro .login-brand {
  color: #ffffff;
}

.login-intro .login-mark {
  background: rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24), 0 12px 24px rgba(10, 65, 132, 0.18);
}

.login-intro h1 {
  max-width: 540px;
  margin: 0;
  color: #ffffff;
  font-size: clamp(42px, 4vw, 54px);
  line-height: 1.08;
  letter-spacing: 0;
}

.login-intro p {
  max-width: 560px;
  margin: 0;
  color: rgba(255, 255, 255, 0.88);
  font-size: 16px;
  line-height: 1.7;
  font-weight: 700;
}

.login-copy-mobile {
  display: none;
}

.login-feature-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  max-width: 520px;
  margin-top: 4px;
}

.login-feature-grid span {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
}

.login-panel.login-panel-v3 {
  width: 100%;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 0;
  border: 0;
  border-radius: 0;
  background:
    radial-gradient(circle at 50% 18%, rgba(47, 134, 255, 0.06), transparent 32%),
    linear-gradient(180deg, #ffffff 0%, #f9fcff 100%);
  box-shadow: none;
  padding: 64px 60px;
}

.login-panel.login-panel-v3::before {
  display: none;
}

.login-form-head {
  width: 100%;
  max-width: 390px;
  display: grid;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 24px;
}

.login-panel.login-panel-v3 h2 {
  margin: 0;
  color: #122230;
  font-size: 32px;
  font-weight: 950;
  line-height: 1.12;
  letter-spacing: 0;
}

.login-panel-note {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
  font-weight: 850;
}

.login-panel.login-panel-v3 form {
  width: 100%;
  max-width: 390px;
  gap: 14px;
}

.login-panel.login-panel-v3 label {
  display: grid;
  gap: 7px;
  color: #263745;
  font-weight: 900;
}

.login-panel.login-panel-v3 input {
  height: 48px;
  border-radius: 12px;
  border-color: #cfe1f2;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 0 rgba(31, 71, 111, 0.03);
}

.login-panel.login-panel-v3 .primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 50px;
  margin-top: 2px;
  border-radius: 12px;
  font-weight: 950;
  text-align: center;
  box-shadow: 0 14px 28px rgba(27, 114, 225, 0.2);
}

.login-safe-hint {
  width: 100%;
  max-width: 390px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 34px 0 0;
  padding-top: 18px;
  border-top: 1px solid #dbe8f5;
  color: #8a9bae;
  font-size: 13px;
  line-height: 1;
  font-weight: 900;
  white-space: nowrap;
}

.login-safe-hint svg {
  width: 16px;
  height: 16px;
  color: #9fb2c6;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
}

@media (min-width: 761px) and (max-width: 1120px) {
  .login-shell {
    grid-template-columns: minmax(0, 1fr) 430px;
    min-height: 560px;
  }

  .login-intro,
  .login-panel.login-panel-v3 {
    padding: 38px;
  }

  .login-panel.login-panel-v3 form {
    max-width: 380px;
  }
}

.dashboard-side-panel.panel {
  min-height: auto;
}

.dashboard-side-panel.enterprise-panel,
.tax-workbench-panel.enterprise-panel {
  display: flex;
  flex-direction: column;
}

.dashboard-side-panel .enterprise-mini-list,
.dashboard-side-panel .empty,
.tax-workbench-panel .enterprise-metric-list {
  flex: 1 1 auto;
}

.tax-workbench-panel .enterprise-metric-list {
  grid-auto-rows: 1fr;
}

.dashboard-side-panel .empty,
.module-command-grid .empty {
  min-height: 78px;
  padding: 16px;
}

.settings-grid {
  align-items: start;
}

.settings-grid > .panel,
.settings-command-grid .enterprise-panel {
  min-height: auto;
}

.settings-command-grid {
  align-items: start;
}

.settings-workbench-panel .enterprise-metric-list > div {
  min-height: 74px;
}

.settings-workbench-panel .enterprise-mini-row {
  min-height: 50px;
}

.permission-row .check {
  min-height: 36px;
  padding: 6px 8px;
  border-radius: 8px;
}

.search-submit,
.search-clear {
  min-height: 36px;
  height: 36px;
}

.search-clear {
  width: 36px;
}

@media (max-width: 760px) {
  .login-page {
    min-height: 100svh;
    min-height: 100dvh;
    align-items: center;
    justify-items: center;
    padding: 12px;
    overflow-y: auto;
    background:
      radial-gradient(circle at 20% 10%, rgba(47, 134, 255, 0.16), transparent 28%),
      linear-gradient(180deg, #eaf4ff 0%, #f7fbff 100%);
  }

  .login-shell {
    width: 100%;
    max-width: 420px;
    min-height: min(720px, calc(100svh - 20px));
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 278px auto;
    align-content: start;
    border-radius: 28px;
    border: 1px solid rgba(181, 211, 239, 0.82);
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    box-shadow: 0 20px 52px rgba(31, 71, 111, 0.16);
  }

  .login-intro {
    gap: 8px;
    align-content: end;
    padding: 42px 28px 70px;
    background:
      radial-gradient(circle at 18% 20%, rgba(255, 255, 255, 0.16), transparent 28%),
      linear-gradient(135deg, #1878ee 0%, #2d93f4 52%, #18a999 100%);
  }

  .login-intro .login-brand {
    gap: 12px;
  }

  .login-intro .login-mark {
    width: 38px;
    height: 38px;
    font-size: 19px;
  }

  .login-intro h1 {
    font-size: clamp(30px, 7.3vw, 38px);
    line-height: 1.06;
    white-space: nowrap;
  }

  .login-intro p {
    max-width: 300px;
    font-size: clamp(14px, 3.9vw, 17px);
    line-height: 1.25;
    font-weight: 950;
  }

  .login-copy-desktop {
    display: none;
  }

  .login-copy-mobile {
    display: inline;
  }

  .login-feature-grid {
    display: none;
  }

  .login-panel.login-panel-v3 {
    width: calc(100% - 34px);
    max-width: none;
    justify-self: center;
    align-content: start;
    gap: 14px;
    min-height: 0;
    margin-top: -54px;
    margin-bottom: 18px;
    padding: 24px 22px 22px;
    border: 1px solid #dbeafa;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 22px 46px rgba(31, 71, 111, 0.16);
  }

  .login-form-head {
    max-width: none;
    gap: 6px;
    margin-bottom: 0;
  }

  .login-panel.login-panel-v3 h2 {
    font-size: clamp(26px, 6.8vw, 32px);
    line-height: 1.05;
  }

  .login-panel-note {
    margin: 0;
    color: #6f8093;
    font-size: clamp(13px, 3.4vw, 15px);
    line-height: 1.35;
  }

  .login-panel.login-panel-v3 form {
    max-width: none;
    gap: 12px;
  }

  .login-panel.login-panel-v3 label {
    gap: 6px;
    font-size: 14px;
  }

  .login-panel.login-panel-v3 input,
  .login-panel.login-panel-v3 .primary {
    height: 48px;
    min-height: 48px;
    border-radius: 12px;
    font-size: 15px;
  }

  .login-panel.login-panel-v3 .primary {
    margin-top: 2px;
    font-size: 16px;
  }

  .login-safe-hint {
    display: none;
  }

  .search-submit,
  .search-clear {
    min-height: 38px;
    height: 38px;
  }

  .search-clear {
    width: 38px;
  }

  .permission-row .check {
    min-height: 40px;
    background: #f8fbff;
  }
}

@media (max-width: 940px) and (max-height: 520px) and (orientation: landscape) {
  .login-page {
    padding: 12px;
    align-items: start;
    overflow-y: auto;
  }

  .login-shell {
    min-height: auto;
    grid-template-columns: minmax(0, 0.9fr) 390px;
  }

  .login-intro,
  .login-panel.login-panel-v3 {
    padding: 24px;
  }

  .login-intro h1 {
    font-size: 28px;
  }

  .search-submit,
  .search-clear,
  .dashboard-toolbar input,
  .toolbar-row input {
    min-height: 38px;
    height: 38px;
  }

  .search-clear {
    width: 38px;
  }

  .toolbar-row .segmented button,
  .toolbar-row select {
    min-height: 38px;
    height: 38px;
  }
}

@media (max-width: 940px) and (max-height: 520px) and (orientation: landscape) {
  html,
  body,
  #app {
    background: linear-gradient(180deg, #f7fbfd 0%, #eef5f8 100%);
  }

  html,
  body {
    height: 100%;
    min-height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  body {
    position: relative;
    z-index: 0;
  }

  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: linear-gradient(180deg, #f7fbfd 0%, #eef5f8 100%);
  }

  #app {
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .shell-v3 {
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    background: linear-gradient(180deg, #f7fbfd 0%, #eef5f8 100%);
  }

  .main-v3 {
    min-height: calc(100vh - 48px);
    min-height: calc(100dvh - 48px);
  }
}

@media (min-width: 761px) and (max-width: 1120px) and (orientation: portrait) {
  html,
  body,
  #app {
    background: linear-gradient(180deg, #f7fbfd 0%, #eef5f8 100%);
  }

  html,
  body {
    height: 100%;
    min-height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  body {
    position: relative;
    z-index: 0;
  }

  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: linear-gradient(180deg, #f7fbfd 0%, #eef5f8 100%);
  }

  #app {
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .shell-v3 {
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    background: linear-gradient(180deg, #f7fbfd 0%, #eef5f8 100%);
  }

  .main-v3 {
    min-height: calc(100vh - 52px);
    min-height: calc(100dvh - 52px);
  }
}

/* Enterprise layout alignment pass: unify block rhythm across all business screens. */
.main-v3 > .dashboard-toolbar,
.main-v3 > .kpi-grid,
.main-v3 > .enterprise-flow-grid,
.main-v3 > .module-command-grid,
.main-v3 > .dashboard-layout,
.main-v3 > .panel,
.main-v3 > .settings-grid,
.main-v3 > .settings-overview-panel,
.main-v3 > .settings-enterprise-layout,
.main-v3 > .toolbar-row,
.main-v3 > .link-banner,
.main-v3 > .result-summary {
  width: 100%;
}

.main-v3 > .panel,
.main-v3 > .settings-grid,
.main-v3 > .module-command-grid,
.main-v3 > .enterprise-flow-grid,
.main-v3 > .dashboard-layout {
  margin-bottom: 14px;
}

.panel,
.enterprise-panel,
.kpi-v3,
.dashboard-toolbar,
.result-summary,
.link-banner {
  border-radius: 8px;
}

.panel {
  padding: 18px;
  overflow: hidden;
}

.panel-title {
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-title h2 {
  font-size: 18px;
  line-height: 1.25;
}

.panel-title span {
  color: #718294;
  font-size: 12px;
  line-height: 1.35;
}

.kpi-grid-v3 {
  align-items: stretch;
  gap: 12px;
}

.kpi-v3 {
  min-height: 112px;
  display: grid;
  grid-template-rows: auto minmax(30px, 1fr) auto;
  align-content: stretch;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid var(--border-soft);
}

.kpi-v3 .kpi-head {
  min-height: 30px;
}

.kpi-v3 strong {
  align-self: center;
  font-size: 24px;
  line-height: 1.08;
}

.kpi-v3 small {
  min-height: 18px;
  line-height: 1.35;
}

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

.dashboard-kpis .kpi-v3,
.dashboard-kpis .kpi-metric-income,
.dashboard-kpis .kpi-metric-other-income,
.dashboard-kpis .kpi-metric-margin,
.dashboard-kpis .kpi-metric-profit {
  grid-column: auto;
}

.dashboard-kpis .kpi-metric-income { order: 1; }
.dashboard-kpis .kpi-metric-other-income { order: 2; }
.dashboard-kpis .kpi-metric-profit { order: 3; }
.dashboard-kpis .kpi-metric-cost { order: 4; }
.dashboard-kpis .kpi-metric-operating-expense { order: 5; }
.dashboard-kpis .kpi-metric-margin { order: 6; }
.dashboard-kpis .kpi-metric-receivable { order: 7; }
.dashboard-kpis .kpi-metric-payable { order: 8; }
.dashboard-kpis .kpi-metric-tax { order: 9; }

.customer-kpis,
.order-kpis,
.purchase-kpis,
.receipt-kpis,
.salary-kpis,
.task-kpis {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.project-kpis {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.operating-kpis,
.tax-kpis {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.enterprise-flow-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: 14px;
}

.enterprise-flow-panel {
  grid-column: 1 / -1;
  min-height: 166px;
}

.enterprise-panel {
  display: flex;
  min-height: 176px;
  flex-direction: column;
  padding: 18px;
}

.enterprise-panel .panel-title {
  flex: 0 0 auto;
}

.enterprise-panel .empty,
.enterprise-panel .enterprise-mini-list,
.enterprise-panel .enterprise-metric-list,
.enterprise-panel .enterprise-workflow {
  flex: 1 1 auto;
}

.enterprise-workflow {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.workflow-step {
  min-height: 98px;
  align-content: start;
  padding: 13px;
}

.module-command-grid,
.settings-command-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
  gap: 14px;
}

.module-command-grid .enterprise-panel,
.settings-command-grid .enterprise-panel {
  min-height: 182px;
}

/* Grid gaps replace the vertical margins used by stacked panels. */
.module-command-grid > :is(.receipt-workbench-panel, .ledger-workbench-panel, .salary-workbench-panel, .tax-workbench-panel) {
  margin-top: 0;
}

.enterprise-mini-row {
  min-height: 52px;
}

.enterprise-metric-list {
  grid-auto-rows: 1fr;
}

.enterprise-metric-list > div {
  min-height: 82px;
}

.dashboard-layout {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(330px, auto);
  align-items: stretch;
  gap: 14px;
}

.dashboard-layout .panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
}

.dashboard-layout .panel-title {
  flex: 0 0 auto;
}

.dashboard-layout .table-shell,
.dashboard-layout .dashboard-bank-table {
  flex: 1 1 auto;
  min-height: 0;
}

.chart-panel,
.bank-panel {
  min-height: 350px;
}

.trend-chart {
  flex: 1 1 auto;
  min-height: 250px;
}

.dashboard-bank-table {
  align-content: stretch;
}

.dashboard-bank-table .table-shell,
.dashboard-bank-table .table-wrap {
  height: 100%;
}

.dashboard-bank-table .enterprise-table .text-cell {
  text-align: left;
}

.dashboard-bank-table .enterprise-table .center-cell,
.dashboard-bank-table .enterprise-table .date-cell {
  text-align: center;
}

.dashboard-bank-table .enterprise-table .number-cell {
  text-align: right;
}

.settings-grid {
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  align-items: stretch;
  gap: 14px;
}

.settings-grid > .panel {
  min-height: 230px;
}

.table-shell {
  width: 100%;
  min-width: 0;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border-radius: 8px;
  background: #fff;
}

table {
  width: 100%;
}

th,
td {
  vertical-align: middle;
}

td[data-full-value],
.compact-cell strong,
.compact-cell small,
.customer-title-cell strong,
.customer-title-cell span {
  min-width: 0;
}

.customer-tag,
.status,
.attachment-count {
  white-space: nowrap;
  word-break: keep-all;
}

.source-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 66px;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid rgba(47, 134, 255, 0.16);
  background: rgba(47, 134, 255, 0.08);
  color: #1f73df;
  font-size: 12px;
  font-weight: 950;
  line-height: 1;
  white-space: nowrap;
}

.source-chip.source-ledger {
  border-color: rgba(15, 159, 135, 0.16);
  background: rgba(15, 159, 135, 0.1);
  color: #0f8f79;
}

.empty {
  min-height: 84px;
  padding: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

@media (max-width: 1460px) and (min-width: 1181px) {
  .dashboard-kpis {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .customer-kpis,
  .order-kpis,
  .purchase-kpis,
  .receipt-kpis,
  .salary-kpis,
  .task-kpis {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .project-kpis {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

@media (max-width: 1180px) {
  .dashboard-kpis,
  .project-kpis,
  .customer-kpis,
  .order-kpis,
  .purchase-kpis,
  .receipt-kpis,
  .salary-kpis,
  .task-kpis,
  .module-kpis.kpi-grid-v3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .operating-kpis,
  .tax-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .enterprise-flow-grid,
  .module-command-grid,
  .settings-command-grid,
  .settings-grid,
  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .enterprise-flow-panel {
    grid-column: auto;
  }

  .enterprise-workflow {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px),
  (max-width: 940px) and (max-height: 520px) and (orientation: landscape),
  (min-width: 761px) and (max-width: 1120px) and (orientation: portrait) {
  html,
  body,
  #app,
  .shell-v3 {
    background: linear-gradient(180deg, #f7fbfd 0%, #eef5f8 100%);
  }

  .main-v3 {
    background: transparent;
  }

  .panel,
  .enterprise-panel,
  .kpi-v3,
  .dashboard-toolbar,
  .result-summary,
  .link-banner {
    border-radius: 14px;
  }

  .panel {
    padding: 14px;
  }

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

  .dashboard-kpis .kpi-metric-income { order: 1; }
  .dashboard-kpis .kpi-metric-other-income { order: 2; }
  .dashboard-kpis .kpi-metric-receivable { order: 3; }
  .dashboard-kpis .kpi-metric-operating-expense { order: 4; }
  .dashboard-kpis .kpi-metric-margin { order: 5; }
  .dashboard-kpis .kpi-metric-payable { order: 6; }
  .dashboard-kpis .kpi-metric-cost { order: 7; }
  .dashboard-kpis .kpi-metric-profit { order: 8; }
  .dashboard-kpis .kpi-metric-tax { order: 9; }

  .kpi-v3 {
    min-height: 96px;
    padding: 12px;
  }

  .kpi-v3 strong {
    font-size: clamp(17px, 4.8vw, 22px);
  }

  .module-kpis.kpi-grid-v3:not(.dashboard-kpis),
  .project-kpis.kpi-grid-v3,
  .task-kpis.kpi-grid-v3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .module-kpis.kpi-grid-v3:not(.dashboard-kpis) .kpi-v3 strong,
  .project-kpis.kpi-grid-v3 .kpi-v3 strong,
  .task-kpis.kpi-grid-v3 .kpi-v3 strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: clamp(16px, 4.6vw, 21px);
  }

  .enterprise-flow-grid,
  .module-command-grid,
  .settings-command-grid,
  .settings-grid,
  .dashboard-layout {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .enterprise-panel,
  .module-command-grid .enterprise-panel,
  .settings-command-grid .enterprise-panel {
    min-height: auto;
  }

  .enterprise-workflow {
    display: flex;
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }

  .workflow-step {
    min-width: 172px;
    min-height: 104px;
    scroll-snap-align: start;
  }

  .chart-panel,
  .bank-panel,
  .dashboard-layout .panel {
    min-height: auto;
  }

  .table-wrap,
  .dashboard-layout .table-wrap,
  body .profit-ledger-panel .table-wrap,
  body .profit-order-panel .table-wrap {
    max-width: 100%;
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    background: #fff;
    box-shadow: var(--shadow-soft);
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
    contain: paint;
  }

  table,
  .dashboard-layout table {
    display: table;
    width: max-content;
    min-width: max(920px, 100%);
    border-collapse: separate;
    border-spacing: 0;
    table-layout: auto;
    background: #fff;
  }

  .dashboard-bank-table table {
    min-width: max(560px, 100%);
  }

  thead {
    display: table-header-group;
  }

  tbody {
    display: table-row-group;
  }

  tbody tr {
    display: table-row;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    transform: none;
  }

  tbody tr:active {
    transform: none;
    box-shadow: none;
  }

  th,
  td,
  .dashboard-layout th,
  .dashboard-layout td {
    display: table-cell;
    width: auto;
    height: 52px;
    min-height: 0;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-soft);
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: normal;
    word-break: keep-all;
    line-height: 1.4;
    vertical-align: middle;
  }

  td::before {
    content: none;
    display: none;
  }

  td[data-label="操作"] {
    min-width: 150px;
  }

  td[data-label="操作"] .row-actions,
  td[data-label="操作"] .customer-table-actions,
  .row-actions,
  .customer-table-actions {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    grid-template-columns: none;
    width: max-content;
    min-width: 0;
    flex-wrap: nowrap;
  }

  .icon-btn,
  .link-action {
    width: auto;
    min-width: 44px;
  }
}

@media (max-width: 940px) and (max-height: 520px) and (orientation: landscape) {
  .dashboard-kpis,
  .module-kpis.kpi-grid-v3,
  .project-kpis.kpi-grid-v3,
  .task-kpis.kpi-grid-v3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .kpi-v3 {
    min-height: 84px;
    padding: 10px;
  }

  .kpi-v3 strong {
    font-size: clamp(16px, 2.7vw, 20px);
  }
}

/* Final responsive contract: keep mobile/tablet scroll surfaces stable after visual alignment overrides. */
@media (max-width: 760px) {
  html,
  body,
  #app {
    background: linear-gradient(180deg, #f7fbfd 0%, #eef5f8 100%);
  }

  html,
  body {
    height: 100%;
    min-height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: linear-gradient(180deg, #f7fbfd 0%, #eef5f8 100%);
  }

  #app {
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .shell-v3 {
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    background: linear-gradient(180deg, #f7fbfd 0%, #eef5f8 100%);
  }

  .kpi-grid-v3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .module-kpis.kpi-grid-v3:not(.dashboard-kpis),
  .project-kpis.kpi-grid-v3,
  .task-kpis.kpi-grid-v3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table-wrap {
    max-width: 100%;
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    background: #fff;
    box-shadow: var(--shadow-soft);
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
    contain: paint;
  }

  table {
    display: table;
    width: max-content;
    min-width: max(920px, 100%);
    border-collapse: separate;
    border-spacing: 0;
    table-layout: auto;
    background: #fff;
  }

  .dashboard-bank-table table{
    min-width: max(560px, 100%);
  }

  thead {
    display: table-header-group;
  }

  tbody {
    display: table-row-group;
  }

  tbody tr {
    display: table-row;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    transform: none;
    transition: background 0.18s ease;
  }

  tbody tr:active {
    transform: none;
    box-shadow: none;
  }

  td {
    display: table-cell;
    width: auto;
    height: 52px;
    min-height: 0;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-soft);
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: normal;
    word-break: keep-all;
    line-height: 1.4;
    vertical-align: middle;
  }

  td::before {
    content: none;
    display: none;
  }

  label:focus-within {
    transform: translateY(-1px);
  }

  .form-actions {
    position: sticky;
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 22;
    margin: 16px -4px 0;
    padding: 10px;
    border: 1px solid rgba(216, 227, 236, 0.88);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.88);
    box-shadow: 0 14px 30px rgba(31, 44, 56, 0.14);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }
}

@media (max-width: 940px) and (max-height: 520px) and (orientation: landscape) {
  html,
  body,
  #app {
    background: linear-gradient(180deg, #f7fbfd 0%, #eef5f8 100%);
  }

  html,
  body {
    height: 100%;
    min-height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: linear-gradient(180deg, #f7fbfd 0%, #eef5f8 100%);
  }

  #app {
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .shell-v3 {
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    background: linear-gradient(180deg, #f7fbfd 0%, #eef5f8 100%);
  }

  .mobile-header-v3 {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
  }

  .main-v3 {
    padding-top: 52px;
  }
}

/* Keep settings audit records inside a fixed-height enterprise panel. */
.audit-panel-fixed .table-wrap {
  max-height: 360px;
  overflow-x: auto;
  overflow-y: auto;
}

@media (max-width: 760px),
  (min-width: 761px) and (max-width: 1120px) and (orientation: portrait) {
  .main-v3 {
    width: auto;
    margin-left: 0;
  }
}

@media (min-width: 761px) and (max-width: 1120px) and (orientation: landscape) {
  .sidebar-v3 {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 84px;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .main-v3 {
    width: calc(100% - 84px);
    margin-left: 84px;
  }
}

/* Desktop workspace final pass: keep the navigation pinned and remove centered dead space. */
@media (min-width: 1121px) {
  .shell-v3 {
    display: block;
    min-height: 100vh;
  }

  .sidebar-v3 {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 248px;
    height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .sidebar-v3 nav {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }

  .sidebar-v3 .sidebar-footer {
    flex: 0 0 auto;
  }

  .main-v3 {
    width: calc(100% - 248px);
    margin-left: 248px;
    padding-left: 18px;
    padding-right: 18px;
  }

  .topbar-v3 {
    margin-left: -18px;
    margin-right: -18px;
    padding-left: 24px;
    padding-right: 24px;
  }

  .main-v3 > .dashboard-toolbar,
  .main-v3 > .kpi-grid,
  .main-v3 > .enterprise-flow-grid,
  .main-v3 > .module-command-grid,
  .main-v3 > .dashboard-layout,
  .main-v3 > .panel,
  .main-v3 > .settings-grid,
  .main-v3 > .settings-overview-panel,
  .main-v3 > .settings-enterprise-layout,
  .main-v3 > .toolbar-row,
  .main-v3 > .link-banner,
  .main-v3 > .result-summary {
    max-width: none;
    margin-left: 0;
    margin-right: 0;
  }
}

/* Desktop enterprise shell and account permissions polish. */
.account-panel-polished {
  overflow: hidden;
  border: 1px solid rgba(197, 220, 240, 0.92);
  box-shadow: 0 16px 36px rgba(28, 85, 145, 0.08);
}

.account-overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0 16px;
}

.account-overview-card {
  min-height: 92px;
  display: grid;
  align-content: center;
  gap: 7px;
  padding: 16px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: linear-gradient(180deg, #fbfdff 0%, #f5f9fe 100%);
}

.account-overview-card span,
.account-overview-card small {
  color: #6b7d8d;
  font-weight: 700;
}

.account-overview-card strong {
  color: var(--accent-strong);
  font-size: 25px;
  line-height: 1;
}

.account-table-shell {
  margin-top: 8px;
}

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

.permission-section {
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: #fbfdff;
  overflow: hidden;
}

.permission-section h3 {
  margin: 0;
  padding: 12px 14px;
  color: #243748;
  font-size: 15px;
  background: #eef6ff;
  border-bottom: 1px solid var(--border-soft);
}

.permission-section .permission-grid {
  padding: 10px;
}

.permission-section .permission-row {
  background: #fff;
  border: 1px solid rgba(218, 231, 244, 0.86);
}

@media (min-width: 1121px) {
  .sidebar-v3 {
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(246, 250, 255, 0.98) 100%),
      var(--surface-panel);
    border-right: 1px solid #dce9f6;
    box-shadow: 12px 0 34px rgba(30, 82, 136, 0.07);
  }

  .brand-v3 {
    min-height: 96px;
    padding: 24px 20px 18px;
    background: transparent;
  }

  .brand-v3::before {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    box-shadow: 0 12px 24px rgba(47, 134, 255, 0.24);
  }

  .brand-v3 strong {
    font-size: 22px;
  }

  .sidebar-v3 nav.sidebar-nav,
  .sidebar-v3 nav {
    gap: 8px;
    margin-top: 4px;
    padding: 12px;
  }

  .sidebar-nav h3,
  .nav-group h3 {
    margin: 16px 10px 6px;
    color: #7b8b9a;
    font-size: 12px;
    font-weight: 900;
  }

  .nav-item-v3 {
    min-height: 44px;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 0 12px;
    transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, color 0.18s ease;
  }

  .nav-item-v3 svg {
    width: 19px;
    height: 19px;
  }

  .nav-item-v3:hover {
    background: #f4f9ff;
    border-color: #d9e9f9;
    box-shadow: 0 8px 18px rgba(31, 102, 181, 0.06);
  }

  .nav-item-v3.active {
    background: #eaf4ff;
    border-color: #cfe5ff;
    box-shadow: inset 3px 0 0 var(--accent), 0 8px 18px rgba(31, 102, 181, 0.08);
  }

  .nav-item-v3.active::before {
    content: none;
  }

  .sidebar-v3 .sidebar-footer {
    margin: 0 12px 12px;
    padding: 14px 8px 8px;
    border-top: 1px solid #e5eef7;
  }
}

@media (max-width: 1120px) {
  .account-overview-grid,
  .permission-section-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .account-overview-grid,
  .permission-section-grid {
    grid-template-columns: 1fr;
  }

  .account-overview-card {
    min-height: 78px;
  }
}

.settings-overview-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 0 0 16px;
}

.settings-overview-card {
  min-height: 112px;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
  box-shadow: 0 12px 28px rgba(28, 85, 145, 0.07);
}

.settings-overview-card span,
.settings-overview-card small {
  color: #6c7f90;
  font-weight: 800;
}

.settings-overview-card strong {
  color: var(--accent-strong);
  font-size: 28px;
  line-height: 1;
}

.settings-overview-card.green strong {
  color: #0f9f87;
}

.settings-overview-card.amber strong {
  color: #b56b0a;
}

.settings-enterprise-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: 16px;
  align-items: stretch;
  margin-bottom: 16px;
}

.settings-enterprise-column {
  display: grid;
  gap: 16px;
  align-content: start;
}

.settings-enterprise-column > .panel,
.settings-enterprise-column > .enterprise-panel {
  height: 100%;
  margin-top: 0;
}

/* Share row heights so both settings columns start and end together. */
@media (min-width: 1121px) {
  .settings-enterprise-column {
    grid-row: span 2;
    grid-template-rows: subgrid;
  }
}

.settings-permission-section .settings-workbench-panel .enterprise-metric-list,
.settings-permission-section .settings-workbench-panel .enterprise-mini-list {
  min-height: 174px;
}

.settings-action-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: 16px;
  align-items: stretch;
  margin-bottom: 16px;
}

.settings-action-grid > .panel,
.settings-action-grid > .enterprise-panel {
  height: 100%;
}

.settings-data-panel {
  display: grid;
  align-content: space-between;
  gap: 18px;
}

.settings-data-panel .muted {
  margin: 0;
  max-width: 680px;
  line-height: 1.7;
}

.settings-button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.settings-button-row button,
.settings-button-row .file-button {
  min-height: 42px;
  gap: 8px;
  padding: 0 18px;
}

.settings-button-row svg {
  width: 18px;
  height: 18px;
}

.tax-rate-card-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.tax-rate-card {
  min-height: 98px;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 14px 12px;
  border: 1px solid #dbeaf8;
  border-radius: 8px;
  background: #f8fbff;
}

.tax-rate-card span,
.tax-rate-card small {
  color: #6c7f90;
  font-weight: 800;
}

.tax-rate-card strong {
  color: var(--accent-strong);
  font-size: 24px;
  line-height: 1;
}

.settings-system-grid .enterprise-metric-list,
.settings-system-grid .enterprise-mini-list {
  min-height: 174px;
}

.audit-panel-fixed {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  max-height: 520px;
  overflow: hidden;
}

.audit-panel-fixed .bulk-action-bar {
  margin-bottom: 10px;
}

.audit-panel-fixed .table-shell {
  min-height: 0;
  overflow: hidden;
}

.audit-panel-fixed .table-wrap {
  max-height: 360px;
  overflow-y: auto;
}

.audit-panel-fixed .table-pagination {
  flex-shrink: 0;
}

@media (max-width: 1180px) {
  .tax-rate-card-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1120px) {
  .settings-overview-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-enterprise-layout,
  .settings-action-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .settings-overview-panel,
  .tax-rate-card-grid {
    grid-template-columns: 1fr;
  }

  .settings-overview-card,
  .tax-rate-card {
    min-height: 86px;
  }

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

.table-shell[data-table-id="orders"] th:first-child,
.table-shell[data-table-id="orders"] td:first-child,
.table-shell[data-table-id="purchases"] th:first-child,
.table-shell[data-table-id="purchases"] td:first-child,
.table-shell[data-table-id="receipts"] th:first-child,
.table-shell[data-table-id="receipts"] td:first-child {
  min-width: 64px;
  width: 64px;
  max-width: 64px;
}

.enterprise-table .customer-title-cell,
.enterprise-table .order-customer-cell,
.enterprise-table .compact-cell {
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}

.enterprise-table .customer-title-cell strong,
.enterprise-table .customer-title-cell span,
.enterprise-table .order-customer-cell strong,
.enterprise-table .order-customer-cell small,
.enterprise-table .compact-cell strong,
.enterprise-table .compact-cell small {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Final enterprise table scroll contract: key columns stay left-fixed; action columns scroll normally. */
.enterprise-table td[data-label="操作"],
.enterprise-table th:last-child {
  position: static;
  right: auto;
  z-index: auto;
  min-width: 176px;
  width: auto;
  padding-inline: 12px;
  text-align: right;
  background: transparent;
  box-shadow: none;
}

.enterprise-table td[data-label="操作"] {
  overflow: visible;
}

.enterprise-table td[data-label="操作"] .compact-actions,
.enterprise-table td[data-label="操作"] .compact-actions.customer-table-actions,
.enterprise-table td[data-label="操作"] .compact-actions.row-actions {
  display: inline-flex;
  width: max-content;
  min-width: 0;
  justify-content: flex-end;
  flex-wrap: nowrap;
}

.enterprise-table td[data-label="操作"] .link-action,
.enterprise-table td[data-label="操作"] .icon-btn {
  flex: 0 0 auto;
}

@media (max-width: 760px) {
  .kpi-grid-v3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Final block balance pass: keep analytic panels equal without stretching empty list panels. */
.dashboard-layout {
  grid-auto-rows: auto;
}

.dashboard-layout .dashboard-half {
  grid-column: auto;
}

.dashboard-layout .chart-panel,
.dashboard-layout .bank-panel {
  min-height: 350px;
}

.dashboard-layout .panel:not(.chart-panel):not(.bank-panel),
.dashboard-recent-panel {
  min-height: 0;
}

.dashboard-recent-panel .table-shell,
.dashboard-recent-panel .table-wrap {
  width: 100%;
  min-width: 0;
}

.dashboard-recent-panel .table-shell {
  display: grid;
  grid-template-rows: minmax(326px, 1fr) auto;
  align-content: stretch;
  min-height: 380px;
}

.dashboard-recent-panel .table-wrap {
  min-height: 326px;
  overflow-x: hidden;
}

.dashboard-simple-pagination {
  min-height: 42px;
  align-self: end;
}

.dashboard-simple-pagination .pagination-summary span {
  min-width: 72px;
  justify-content: center;
}

.dashboard-simple-pagination .page-btn {
  min-width: 70px;
}

.dashboard-recent-panel .enterprise-table {
  width: 100%;
  min-width: 100%;
  table-layout: fixed;
}

.dashboard-recent-panel th,
.dashboard-recent-panel td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: keep-all;
}

.dashboard-recent-panel th:nth-child(5),
.dashboard-recent-panel td:nth-child(5),
.dashboard-recent-panel td[data-label="金额"] {
  width: 86px;
  min-width: 86px;
}

.money-short {
  display: inline-block;
  max-width: 100%;
  white-space: nowrap;
}

.settings-grid {
  align-items: start;
}

.settings-grid > .panel {
  min-height: 0;
}

@media (max-width: 760px) {
  .dashboard-toolbar {
    padding: 10px;
  }

  .quick-tabs {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .quick-tabs button {
    min-height: 40px;
    padding-inline: 4px;
    font-size: 12px;
    white-space: nowrap;
  }

  .dashboard-layout .chart-panel,
  .dashboard-layout .bank-panel {
    min-height: auto;
  }

  .dashboard-layout .dashboard-half {
    grid-column: 1 / -1;
  }

  .dashboard-layout .panel:not(.chart-panel):not(.bank-panel) {
    min-height: 0;
  }

  .dashboard-recent-panel .table-wrap {
    min-height: 326px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
  }

  .dashboard-recent-panel .enterprise-table {
    display: table;
    width: max-content;
    min-width: max(920px, 100%);
    table-layout: auto;
  }
}

@media (max-width: 760px) {
  .table-shell .table-wrap,
  .dashboard-recent-panel .table-wrap {
    max-width: 100%;
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    background: #fff;
    box-shadow: var(--shadow-soft);
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
  }

  .table-shell .enterprise-table,
  .dashboard-recent-panel .enterprise-table {
    display: table;
    width: max-content;
    min-width: max(920px, 100%);
    table-layout: auto;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
  }

  .enterprise-table thead {
    display: table-header-group;
  }

  .enterprise-table tbody {
    display: table-row-group;
  }

  .enterprise-table tbody tr,
  .dashboard-layout .enterprise-table tbody tr {
    display: table-row;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    transition: background 0.18s ease;
  }

  .enterprise-table tbody tr:nth-child(even) {
    background: #fbfcfd;
  }

  .enterprise-table tbody tr:hover {
    background: #f2faf7;
  }

  .enterprise-table tbody tr:active {
    transform: none;
    box-shadow: none;
  }

  .enterprise-table th,
  .enterprise-table td,
  .dashboard-layout .enterprise-table th,
  .dashboard-layout .enterprise-table td {
    display: table-cell;
    width: auto;
    height: 52px;
    min-height: 0;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-soft);
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: normal;
    word-break: keep-all;
    line-height: 1.4;
    vertical-align: middle;
  }

  .enterprise-table td:first-child,
  .table-shell[data-table-id="orders"] .enterprise-table td:first-child,
  .table-shell[data-table-id="purchases"] .enterprise-table td:first-child,
  .table-shell[data-table-id="receipts"] .enterprise-table td:first-child {
    width: 64px;
    min-width: 64px;
    max-width: 64px;
  }

  .enterprise-table td::before {
    content: none;
    display: none;
  }

  .enterprise-table th.text-cell,
  .enterprise-table td.text-cell {
    text-align: left;
  }

  .enterprise-table th.center-cell,
  .enterprise-table td.center-cell,
  .enterprise-table th.date-cell,
  .enterprise-table td.date-cell {
    text-align: center;
  }

  .enterprise-table th.number-cell,
  .enterprise-table td.number-cell {
    text-align: right;
  }

  .enterprise-table td.number-cell .money-short {
    text-align: right;
  }

  .enterprise-table td.action-cell,
  .enterprise-table td[data-label="操作"] {
    min-width: 150px;
    padding-top: 10px;
    margin-top: 0;
    border-top: 0;
    text-align: right;
  }

  .enterprise-table td.action-cell::before,
  .enterprise-table td[data-label="操作"]::before {
    content: none;
  }

  .enterprise-table td[data-label="操作"] .compact-actions,
  .enterprise-table td[data-label="操作"] .compact-actions.customer-table-actions,
  .enterprise-table td[data-label="操作"] .compact-actions.row-actions {
    display: inline-flex;
    width: max-content;
    justify-content: flex-end;
    flex-wrap: nowrap;
  }
}

@media (max-width: 940px) and (max-height: 520px) and (orientation: landscape),
  (min-width: 761px) and (max-width: 1120px) and (orientation: portrait) {
  .dashboard-layout .chart-panel,
  .dashboard-layout .bank-panel {
    min-height: auto;
  }
}

@media (min-width: 761px) and (max-width: 1120px) and (orientation: portrait) {
  html,
  body,
  #app {
    background: linear-gradient(180deg, #f7fbfd 0%, #eef5f8 100%);
  }

  html,
  body {
    height: 100%;
    min-height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: linear-gradient(180deg, #f7fbfd 0%, #eef5f8 100%);
  }

  #app {
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .shell-v3 {
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    background: linear-gradient(180deg, #f7fbfd 0%, #eef5f8 100%);
  }

  .mobile-header-v3 {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
  }

  .main-v3 {
    padding-top: 52px;
  }
}

/* Final settings audit override: operation records scroll inside the panel. */
.audit-panel-fixed .table-wrap {
  max-height: 360px;
  overflow-x: auto;
  overflow-y: auto;
}

@media (max-width: 760px) {
  .table-pagination {
    flex-wrap: wrap;
    overflow-x: hidden;
  }

  .pagination-summary,
  .pagination-controls {
    width: 100%;
    min-width: 0;
  }

  .pagination-controls {
    justify-content: flex-end;
  }

  .pagination-controls > .page-btn:not([data-pagination-action]),
  .pagination-ellipsis,
  .pagination-jump {
    display: none;
  }

  .pagination-page-status {
    margin-inline: auto;
  }
}

/* Reserve a full page even when a filter leaves few or no records. */
.table-shell[data-fixed-height="true"] {
  --table-footer-height: 48px;
  --table-row-height: 52px;
  --table-header-height: 52px;
  --table-body-height: calc(var(--table-page-size) * var(--table-row-height));
  --table-page-height: calc(var(--table-header-height) + var(--table-body-height) + 14px);
  grid-template-rows: var(--table-page-height) auto;
  align-content: start;
}

.table-shell[data-fixed-height="true"][data-page-size="10"] {
  --table-row-height: 72px;
  --table-header-height: 74px;
}

.table-shell[data-fixed-height="true"] > .table-wrap {
  height: var(--table-page-height);
  min-height: var(--table-page-height);
  max-height: var(--table-page-height);
  overflow-y: auto;
}

.table-shell[data-fixed-height="true"] .enterprise-table th {
  height: var(--table-header-height);
}

.table-shell[data-fixed-height="true"] .enterprise-table td {
  height: var(--table-row-height);
}

.table-shell[data-fixed-height="true"] .table-empty-row td {
  height: var(--table-body-height);
  width: auto;
  max-width: none;
  padding: 0;
  border-bottom: 0;
  background: #fff;
}

.table-empty-state {
  position: absolute;
  inset: var(--table-header-height, 52px) 0 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}

.paginated-mini-list {
  container-type: inline-size;
  display: grid;
  grid-template-rows: 136px auto;
  align-content: start;
  gap: 8px;
  min-width: 0;
}

.paginated-mini-list .mini-list-viewport {
  height: 136px;
  min-width: 0;
  overflow: hidden;
}

.paginated-mini-list .enterprise-mini-list {
  height: 100%;
  grid-template-rows: repeat(2, 64px);
  align-content: start;
}

.paginated-mini-list .enterprise-mini-row {
  height: 64px;
  min-height: 0;
}

.paginated-mini-list .empty {
  height: 100%;
  min-height: 0;
}

@container (max-width: 700px) {
  .paginated-mini-list .pagination-jump {
    display: none;
  }
}

.table-shell[data-fixed-height="true"] > .table-pagination,
.paginated-mini-list > .table-pagination {
  height: 48px;
  min-height: 48px;
}

.audit-panel-fixed {
  height: 520px;
}

.audit-panel-fixed .table-shell[data-fixed-height="true"] {
  height: 100%;
  grid-template-rows: minmax(0, 1fr) var(--table-footer-height);
}

.audit-panel-fixed .table-shell[data-fixed-height="true"] > .table-wrap {
  height: 100%;
  min-height: 0;
  max-height: 100%;
}

@media (max-width: 760px) {
  .table-shell[data-fixed-height="true"] {
    --table-footer-height: 80px;
  }

  .table-shell[data-fixed-height="true"] > .table-pagination,
  .paginated-mini-list > .table-pagination {
    height: 80px;
    min-height: 80px;
  }
}
