:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #66737d;
  --line: #d7dde2;
  --panel: #f6f8fa;
  --paper: #ffffff;
  --accent: #0f766e;
  --accent-dark: #0b5d57;
  --warn: #b45309;
  --danger: #b91c1c;
  --focus: rgba(15, 118, 110, 0.16);
  --tab-bg: #edf1f3;
  --sidebar: #20272d;
  --sidebar-ink: #eef4f2;
  --sidebar-muted: #a8b4bc;
  --sidebar-active: #2d6a62;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

button,
input {
  font: inherit;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef3f5;
}

.login-view[hidden] {
  display: none;
}

.login-card {
  width: min(380px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px;
  border: 1px solid #d8e0e5;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(19, 32, 42, 0.12);
}

.login-card h1,
.login-card p {
  margin: 0;
}

.login-card h1 {
  font-size: 24px;
}

.login-card p,
.login-card small {
  color: var(--muted);
}

.login-card .login-compliance-note {
  padding: 10px 12px;
  border: 1px solid #dbe4e9;
  border-radius: 6px;
  background: #f6f9fa;
  font-size: 13px;
  line-height: 1.5;
}

.login-card label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
}

.login-card input {
  height: 38px;
  border: 1px solid #cfd8df;
  border-radius: 6px;
  padding: 0 10px;
  outline: none;
}

.login-card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

.login-card .remember-login {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

.login-card .remember-login input {
  width: 16px;
  height: 16px;
  padding: 0;
  accent-color: var(--accent);
}

.login-card .primary {
  height: 38px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

#loginError {
  min-height: 18px;
  color: var(--danger);
}

.app-shell {
  height: 100vh;
  min-width: 0;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  background: var(--paper);
}

.app-shell.nav-collapsed {
  grid-template-columns: 64px minmax(0, 1fr);
}

.sidebar {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-right: 1px solid #11181d;
  background: var(--sidebar);
  color: var(--sidebar-ink);
}

.sidebar-head {
  min-height: 56px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 30px;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-title {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.sidebar-title strong,
.sidebar-title span,
.sidebar-foot span,
.sidebar-foot small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-title strong {
  font-size: 14px;
}

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

.icon-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  padding: 0;
  background: rgba(255, 255, 255, 0.06);
  color: var(--sidebar-ink);
  font-size: 20px;
  line-height: 1;
}

.icon-btn:hover {
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.1);
}

.module-nav {
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
}

.module-btn {
  width: 100%;
  height: 42px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin: 1px 0;
  border: 0;
  border-radius: 6px;
  padding: 0 8px;
  background: transparent;
  color: var(--sidebar-ink);
  text-align: left;
}

.module-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.module-btn.active {
  background: var(--sidebar-active);
}

.module-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 15px;
}

.module-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.module-btn small {
  color: var(--sidebar-muted);
  font-size: 11px;
}

.module-btn.active small {
  color: #d7f1ea;
}

.sidebar-foot {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
}

.sidebar-logout {
  height: 26px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--sidebar-ink);
  font-size: 12px;
}

.app-shell.nav-collapsed .sidebar-head {
  grid-template-columns: 40px;
  justify-items: center;
  padding: 10px 8px;
}

.app-shell.nav-collapsed .brand-mark {
  width: 34px;
}

.app-shell.nav-collapsed .sidebar-title,
.app-shell.nav-collapsed .module-text,
.app-shell.nav-collapsed .module-btn small,
.app-shell.nav-collapsed .sidebar-foot {
  display: none;
}

.app-shell.nav-collapsed .icon-btn {
  grid-row: 2;
  transform: rotate(180deg);
}

.app-shell.nav-collapsed .module-nav {
  padding: 8px 6px;
}

.app-shell.nav-collapsed .module-btn {
  grid-template-columns: 1fr;
  justify-items: center;
  padding: 0;
}

.workspace {
  min-height: 0;
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) 54px;
  background: var(--paper);
}

.workspace.placeholder-mode {
  grid-template-rows: auto minmax(0, 1fr);
}

.workspace.placeholder-mode .actions,
.workspace.placeholder-mode .formula-bar,
.workspace.placeholder-mode .status-line,
.workspace.placeholder-mode .table-wrap,
.workspace.placeholder-mode .sheet-bar,
.workspace.placeholder-mode .toolbar .sheet-heading:nth-child(2) {
  display: none;
}

.workspace.inventory-mode .module-placeholder {
  display: none;
}

.module-placeholder {
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 32px;
  background: #fff;
}

.module-placeholder div {
  display: grid;
  gap: 10px;
  justify-items: center;
  color: var(--muted);
}

.module-placeholder h2 {
  margin: 0;
  color: var(--ink);
  font-size: 64px;
  font-weight: 720;
  letter-spacing: 0;
}

.module-placeholder p {
  display: none;
}

.workspace.user-management-mode .module-placeholder {
  display: block;
  overflow: auto;
  padding: 18px;
  background: #f4f7f8;
}

.workspace.user-management-mode .module-placeholder > div {
  display: block;
  color: var(--ink);
}

.workspace.user-management-mode .module-placeholder .user-management div {
  display: block;
  gap: normal;
  justify-items: stretch;
  color: inherit;
}

.workspace.dashboard-mode .module-placeholder {
  display: block;
  overflow: auto;
  padding: 22px;
  background:
    linear-gradient(135deg, rgba(15, 101, 86, 0.10), transparent 34%),
    linear-gradient(225deg, rgba(37, 99, 235, 0.08), transparent 30%),
    #f4f7f8;
}

.workspace.dashboard-mode .module-placeholder > div {
  display: block;
  color: var(--ink);
}

.dashboard-page {
  max-width: 1480px;
  margin: 0 auto;
  display: grid !important;
  gap: 16px;
  user-select: text;
}

.dashboard-head {
  display: flex !important;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.dashboard-head h2,
.dashboard-loading h2 {
  margin: 0;
  color: #111827;
  font-size: 28px;
  font-weight: 820;
}

.dashboard-loading p {
  display: block;
  margin: 6px 0 0;
  color: #61707d;
}

.dashboard-metrics {
  display: grid !important;
  grid-template-columns: repeat(5, minmax(132px, 1fr));
  gap: 12px;
}

.dashboard-range-panel {
  display: grid !important;
  gap: 12px;
  border: 1px solid rgba(15, 101, 86, 0.14);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

.dashboard-range-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 210px)) 90px;
  align-items: end;
  gap: 10px;
}

.dashboard-range-form label {
  display: grid;
  gap: 5px;
  color: #52616d;
  font-size: 12px;
  font-weight: 760;
}

.dashboard-range-form input {
  height: 34px;
  border: 1px solid #cfdbe1;
  border-radius: 5px;
  padding: 0 10px;
  background: #fff;
  color: #172026;
  font: inherit;
  font-weight: 700;
}

.dashboard-range-form button {
  height: 34px;
  border: 1px solid #0f8f79;
  border-radius: 5px;
  background: #0f8f79;
  color: #fff;
  font: inherit;
  font-weight: 780;
}

.dashboard-custom-result {
  display: grid !important;
  gap: 12px;
}

.dashboard-custom-metrics {
  grid-template-columns: minmax(180px, 260px);
}

.dashboard-range-loading,
.dashboard-range-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 6px;
  background: #eef6f3;
  color: #52616d;
  font-size: 13px;
  font-weight: 700;
}

.dashboard-range-error {
  background: #fff1f2;
  color: #b42318;
}

.dashboard-metric {
  min-height: 112px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(15, 101, 86, 0.16);
  border-radius: 8px;
  padding: 16px;
  background: linear-gradient(160deg, #ffffff 0%, #eef8f4 100%);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
}

.dashboard-metric::before {
  content: "";
  position: absolute;
  right: -24px;
  top: -34px;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: rgba(22, 160, 133, 0.16);
}

.dashboard-metric span {
  color: #5d6b76;
  font-size: 13px;
  font-weight: 650;
}

.dashboard-metric strong {
  display: block;
  margin-top: 12px;
  color: #0f6556;
  font-size: 30px;
  line-height: 1;
  font-weight: 860;
  font-variant-numeric: tabular-nums;
}

.dashboard-metric small {
  display: block;
  margin-top: 6px;
  color: #65737e;
}

.dashboard-chart-panel {
  overflow: hidden;
  border: 1px solid rgba(15, 101, 86, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.08);
}

.dashboard-chart-panel header {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px 10px;
}

.dashboard-chart-panel h3 {
  margin: 0;
  color: #172026;
  font-size: 17px;
  font-weight: 780;
}

.dashboard-chart-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: #5f6d78;
  font-size: 12px;
}

.dashboard-chart-summary span {
  padding: 5px 8px;
  border-radius: 999px;
  background: #eef6f3;
  white-space: nowrap;
}

.dashboard-chart-summary strong {
  color: #0f6556;
  font-weight: 820;
  font-variant-numeric: tabular-nums;
}

.dashboard-chart-wrap {
  padding: 0 12px 12px;
  overflow-x: auto;
}

.dashboard-line-chart {
  width: 100%;
  min-width: 760px;
  height: 260px;
  display: block;
}

.chart-grid {
  stroke: #dfe8e7;
  stroke-width: 1;
}

.chart-y-label,
.chart-x-label {
  fill: #667783;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart-y-label {
  text-anchor: end;
}

.chart-x-label {
  text-anchor: middle;
}

.chart-area {
  fill: url(#dashboardLineFill);
}

.chart-line {
  fill: none;
  stroke: #0f8f79;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-point {
  fill: #ffffff;
  stroke: #0f8f79;
  stroke-width: 2.4;
}

.dashboard-table-panel {
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(15, 101, 86, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.08);
}

.dashboard-table-panel header {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.dashboard-table-panel h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 780;
}

.dashboard-table-panel header span {
  color: #65737e;
  font-size: 13px;
}

.dashboard-table-wrap {
  max-height: min(520px, calc(100vh - 310px));
  overflow: auto;
}

.dashboard-table {
  width: 100%;
  min-width: 860px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  user-select: text;
}

.dashboard-table th,
.dashboard-table td {
  height: 42px;
  padding: 8px 12px;
  border-right: 1px solid #dfe6ea;
  border-bottom: 1px solid #dfe6ea;
  background: #fff;
}

.dashboard-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #e9efed;
  color: #33424d;
  font-weight: 760;
  text-align: right;
}

.dashboard-table thead th:first-child,
.dashboard-table tbody th {
  text-align: left;
  width: 190px;
  min-width: 190px;
  max-width: 190px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dashboard-table tbody th {
  color: #172026;
  font-weight: 680;
  background: #fbfcfd;
}

.dashboard-table td {
  min-width: 132px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.dashboard-bar {
  position: relative;
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 6px;
  border-radius: 4px;
  overflow: hidden;
}

.dashboard-bar::before {
  content: "";
  position: absolute;
  inset: 3px auto 3px 3px;
  width: var(--bar-width);
  border-radius: 4px;
  background: linear-gradient(90deg, rgba(22, 160, 133, 0.18), rgba(22, 160, 133, 0.46));
}

.dashboard-bar span {
  position: relative;
  z-index: 1;
  color: #172026;
}

.dashboard-loading {
  padding: 28px;
  border: 1px solid rgba(15, 101, 86, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.08);
}

.user-management {
  max-width: 1280px;
  margin: 0 auto;
}

.module-page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 14px;
}

.module-page-head h2,
.module-page-head p,
.admin-panel h3 {
  margin: 0;
}

.module-page-head h2 {
  font-size: 24px;
}

.module-page-head p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.admin-panel {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  border: 1px solid #d9e1e6;
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
  background: #fff;
}

.admin-panel button,
.admin-panel input,
.admin-panel select {
  font: inherit;
}

.admin-panel button {
  height: 30px;
  border: 1px solid #cfd8df;
  border-radius: 5px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}

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

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

.user-form {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.user-form .panel-title {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

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

.user-form input,
.user-form select {
  height: 30px;
  border: 1px solid #cfd8df;
  border-radius: 5px;
  padding: 0 8px;
  color: var(--ink);
  background: #fff;
}

.user-form .inline-check {
  grid-template-columns: 18px auto;
  align-items: center;
  color: var(--ink);
}

.user-form .inline-check input {
  height: auto;
}

.user-form .wide-field {
  grid-column: span 2;
}

.user-form > button.primary {
  width: 96px;
  justify-self: start;
}

.user-list-panel {
  margin-top: 14px;
  overflow-x: auto;
}

.user-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.user-table th,
.user-table td {
  border-bottom: 1px solid #e2e8ec;
  padding: 8px;
  text-align: left;
  white-space: nowrap;
}

.user-table th {
  background: #f6f8fa;
  color: #46535d;
  font-weight: 800;
}

.user-table td:nth-child(6) {
  min-width: 140px;
  white-space: normal;
}

.state-pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 800;
}

.state-pill.ok {
  background: #dcfce7;
  color: #166534;
}

.state-pill.muted {
  background: #e5e7eb;
  color: #4b5563;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 10px;
}

.role-card {
  border: 1px solid #e1e7eb;
  border-radius: 6px;
  padding: 10px;
  background: #fbfcfd;
}

.role-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

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

.permission-row {
  display: grid;
  grid-template-columns: minmax(72px, 1fr) 54px 54px;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  border-bottom: 1px solid #e7edf1;
  padding: 3px 0;
  font-size: 13px;
}

.permission-row > span {
  font-weight: 700;
}

.permission-row label {
  display: inline-grid;
  grid-template-columns: 16px auto;
  align-items: center;
  gap: 4px;
  color: #33424d;
}

.permission-row input {
  margin: 0;
}

.workspace.user-management-mode .module-page-head,
.workspace.user-management-mode .panel-title {
  display: flex;
}

.workspace.user-management-mode .user-form,
.workspace.user-management-mode .role-grid,
.workspace.user-management-mode .permission-grid,
.workspace.user-management-mode .permission-row {
  display: grid;
}

.workspace.user-management-mode .module-placeholder .user-management .module-page-head,
.workspace.user-management-mode .module-placeholder .user-management .panel-title {
  display: flex;
}

.workspace.user-management-mode .module-placeholder .user-management .user-form,
.workspace.user-management-mode .module-placeholder .user-management .role-grid,
.workspace.user-management-mode .module-placeholder .user-management .permission-grid,
.workspace.user-management-mode .module-placeholder .user-management .permission-row {
  display: grid;
}

.workspace.user-management-mode .user-list-panel,
.workspace.user-management-mode .module-page-head > div {
  display: block;
}

.workspace.user-management-mode .module-placeholder .user-management .user-list-panel,
.workspace.user-management-mode .module-placeholder .user-management .module-page-head > div {
  display: block;
}

.workspace.user-management-mode .state-pill {
  display: inline-flex;
}

.workspace.user-management-mode .module-placeholder .user-management .state-pill {
  display: inline-flex;
}

.workspace.operation-log-mode .module-placeholder {
  overflow: auto;
  padding: 18px;
  background: #eef3f5;
}

.operation-log-page {
  display: grid;
  gap: 14px;
  max-width: none;
  margin: 0 auto;
}

.operation-log-filter {
  display: grid;
  grid-template-columns: 180px 180px minmax(260px, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.operation-log-filter label {
  display: grid;
  gap: 5px;
  color: #51606b;
  font-size: 13px;
  font-weight: 700;
}

.operation-log-filter input,
.operation-log-filter select {
  height: 34px;
  border: 1px solid #cfd8df;
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  font: inherit;
}

.operation-log-table-wrap {
  max-height: calc(100vh - 210px);
  overflow: auto;
  border: 1px solid #dbe4e9;
  border-radius: 8px;
  background: #fff;
}

.operation-log-table {
  width: 100%;
  min-width: 1160px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}

.operation-col-time {
  width: 118px;
}

.operation-col-user {
  width: 76px;
}

.operation-col-type {
  width: 88px;
}

.operation-col-action {
  width: 112px;
}

.operation-col-module {
  width: 86px;
}

.operation-col-sheet {
  width: 126px;
}

.operation-col-range {
  width: 96px;
}

.operation-col-summary {
  width: auto;
}

.operation-log-table th,
.operation-log-table td {
  border-bottom: 1px solid #e5ecef;
  padding: 9px 10px;
  vertical-align: top;
  text-align: left;
  overflow-wrap: anywhere;
}

.operation-log-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7fafb;
  color: #42515c;
}

.operation-time-cell,
.operation-user-cell,
.operation-action-cell,
.operation-sheet-cell,
.operation-range-cell {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.operation-time-cell {
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}

.operation-date,
.operation-clock {
  display: block;
  white-space: nowrap;
}

.operation-summary {
  color: #17212b;
  font-weight: 600;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.operation-details {
  margin-top: 5px;
  color: #5b6872;
}

.operation-details summary {
  cursor: pointer;
  width: max-content;
  color: #51606b;
  font-weight: 700;
}

.operation-log-table pre {
  max-width: 100%;
  max-height: 96px;
  overflow: auto;
  margin: 6px 0;
  padding: 8px;
  border-radius: 6px;
  background: #f5f7f8;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.35;
}

.operation-details small {
  display: block;
  color: #687782;
}

.password-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.28);
}

.change-password-dialog {
  width: min(380px, calc(100vw - 32px));
  border: 1px solid #d8e0e5;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 50px rgba(15, 23, 42, 0.2);
}

.change-password-dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e3e9ee;
  padding: 12px 14px;
}

.change-password-dialog h3 {
  margin: 0;
  font-size: 17px;
}

.change-password-dialog header button {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 5px;
  background: #eef3f5;
  font-size: 18px;
}

#changePasswordForm {
  display: grid;
  gap: 10px;
  padding: 14px;
}

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

#changePasswordForm input {
  height: 34px;
  border: 1px solid #cfd8df;
  border-radius: 5px;
  padding: 0 9px;
  color: var(--ink);
}

#changePasswordError {
  min-height: 18px;
  color: var(--danger);
}

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

.dialog-actions button {
  height: 32px;
  border: 1px solid #cfd8df;
  border-radius: 5px;
  padding: 0 12px;
  background: #fff;
  font-weight: 700;
}

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

.background-save-dialog {
  width: min(420px, calc(100vw - 32px));
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.24);
  padding: 18px;
}

.background-save-dialog header {
  margin-bottom: 10px;
}

.background-save-dialog h3 {
  margin: 0;
  color: #991b1b;
  font-size: 20px;
}

.background-save-dialog p {
  margin: 8px 0;
  color: #334155;
  line-height: 1.5;
}

.background-save-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 8px 10px;
  color: #991b1b !important;
  word-break: break-word;
}

.background-save-dialog footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.background-save-dialog button {
  min-width: 96px;
  height: 36px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #0f172a;
  font-weight: 700;
}

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

.toolbar {
  display: block;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.edit-lock-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 36px;
  padding: 6px 14px;
  border-bottom: 1px solid #f4c7c7;
  background: #fff1f2;
  color: #991b1b;
  font-size: 14px;
  font-weight: 700;
}

.edit-lock-banner[hidden] {
  display: none;
}

.edit-lock-banner button {
  height: 26px;
  border: 1px solid #ef9a9a;
  border-radius: 5px;
  padding: 0 10px;
  background: #fff;
  color: #991b1b;
  font-weight: 800;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font-weight: 750;
  flex: 0 0 auto;
}

.toolbar h1,
.toolbar h2 {
  margin: 0;
  letter-spacing: 0;
}

.toolbar h1 {
  font-size: 17px;
}

.toolbar p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dot::before {
  content: "/";
  margin: 0 6px;
  color: #9aa5ad;
}

.sheet-heading {
  min-width: 0;
}

.toolbar h2 {
  font-size: 20px;
}

.actions {
  display: block;
  width: 100%;
}

.toolbar-layout {
  width: 100%;
  display: grid;
  grid-template-columns: max-content 96px 84px 96px minmax(374px, 1fr);
  align-items: stretch;
  gap: 6px;
}

.toolbar-left {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.toolbar-right {
  min-width: 0;
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  gap: 4px;
  flex-wrap: nowrap;
  align-self: end;
}

.screenshot-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.mobile-tools-toggle,
.mobile-tools-menu {
  display: none;
}

.toolbar-right .download,
.toolbar-right button {
  padding-left: 8px;
  padding-right: 8px;
}

.toolbar-right .download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  line-height: 1;
  white-space: nowrap;
}

.screenshot-sheet-btn {
  height: 32px;
  min-width: 48px;
  font-weight: 700;
}

.toolbar-row-main,
.toolbar-row-format {
  min-height: 26px;
}

.toolbar-row-format {
  flex-wrap: nowrap;
}

.filter-split-control {
  height: 28px;
}

.filter-split-control button {
  height: 26px;
  font-weight: 700;
}

.filter-split-control button:first-child {
  padding: 0 10px;
}

.filter-split-control button + button {
  width: auto;
  padding: 0 9px;
}

#clearFilterBtn[hidden] {
  display: none;
}

.format-tools {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.format-tools button,
.format-tools select,
.split-color-control {
  height: 24px;
  min-width: 30px;
  border: 1px solid #d5dde3;
  border-radius: 5px;
  background: #fff;
}

.format-tools button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
  font-weight: 800;
}

.wrap-merge-stack {
  display: grid;
  grid-template-rows: 24px 24px;
  gap: 4px;
  box-sizing: border-box;
  align-self: stretch;
  width: 96px;
  transform: translateY(7px);
}

.wrap-merge-stack > button,
.wrap-merge-stack .split-menu-control {
  width: 96px;
}

.wrap-merge-stack > button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  height: 24px;
  min-width: 96px;
  border: 1px solid #d5dde3;
  border-radius: 5px;
  padding: 0 7px;
  background: #fff;
  font-size: 16px;
  font-weight: 800;
}

.wrap-merge-stack .split-menu-control button:first-child {
  flex: 1 1 auto;
  justify-content: flex-start;
  font-size: 16px;
  font-weight: 800;
}

.wrap-merge-stack .split-menu-control button:last-child {
  flex: 0 0 24px;
  width: 24px;
  min-width: 24px;
  padding: 0;
}

.icon-btn-tool {
  width: 30px;
  min-width: 30px;
  position: relative;
}

.brush-icon {
  padding: 0 !important;
}

.brush-icon svg {
  width: 17px;
  height: 17px;
  display: block;
  margin: auto;
  overflow: visible;
}

.brush-icon svg path {
  fill: #fff;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brush-icon svg path:nth-child(n + 2) {
  fill: none;
}

.format-tools button.active {
  border-color: #167867;
  background: #dff4ee;
  color: #0f6556;
}

.split-menu-control {
  height: 24px;
  display: inline-flex;
  overflow: hidden;
  border: 1px solid #d5dde3;
  border-radius: 5px;
  background: #fff;
}

.split-menu-control button {
  height: 22px;
  min-width: 0;
  border: 0;
  border-radius: 0;
  padding: 0 6px;
}

.split-menu-control button + button {
  width: 22px;
  border-left: 1px solid #d5dde3;
  color: var(--muted);
}

.filter-split-control button + button {
  width: auto;
  min-width: 44px;
  padding: 0 9px;
  color: var(--ink);
}

#findBtn {
  height: 26px;
  min-width: 44px;
  padding: 0 10px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
}

.font-size-stack {
  position: relative;
  height: 24px;
  display: inline-flex;
  align-items: center;
  align-self: center;
  overflow: visible;
}

.font-size-stepper {
  position: absolute;
  left: 0;
  top: -30px;
  display: inline-flex;
  gap: 3px;
}

.font-size-stepper button {
  width: 31px;
  height: 22px;
  min-width: 31px;
  padding: 0;
  font-weight: 800;
  line-height: 1;
}

.font-size-stepper button:first-child {
  font-size: 17px;
}

.font-size-stepper button:last-child {
  font-size: 12px;
}

.font-size-control {
  height: 24px;
  display: inline-flex;
  overflow: hidden;
  border: 1px solid #d5dde3;
  border-radius: 5px;
  background: #fff;
}

.font-size-control input {
  width: 42px;
  height: 22px;
  border: 0;
  padding: 0 5px;
  text-align: center;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  outline: none;
  background: transparent;
}

.font-size-control button {
  width: 22px;
  height: 22px;
  min-width: 22px;
  border: 0;
  border-left: 1px solid #d5dde3;
  border-radius: 0;
  padding: 0;
  color: var(--muted);
}

.format-tools select {
  padding: 0 6px;
}

.split-color-control {
  display: inline-flex;
  align-items: stretch;
  overflow: hidden;
  padding: 0;
}

.split-color-control button {
  height: 22px;
  min-width: 0;
  border: 0;
  border-radius: 0;
  padding: 0 6px;
}

.color-apply-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
}

.color-apply-btn .color-swatch-box {
  width: 14px;
  height: 14px;
  border: 1px solid #9aa5ad;
  border-radius: 3px;
}

.color-pick-btn {
  width: 22px;
  border-left: 1px solid #d5dde3 !important;
  color: var(--muted);
}

.split-color-control input[type="color"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.align-grid {
  display: grid;
  grid-template-columns: repeat(3, 22px);
  grid-template-rows: repeat(2, 1fr);
  align-items: center;
  justify-items: center;
  gap: 3px;
  padding: 4px 5px;
  align-self: stretch;
  border: 1px solid #d5dde3;
  border-radius: 6px;
  background: #fff;
}

.align-icon {
  display: grid;
  place-items: center;
  width: 22px;
  min-width: 22px;
  height: 22px;
  padding: 0;
  color: #26323b;
  font-size: 12px;
  font-weight: 750;
  line-height: 1;
}

.number-format-panel {
  display: grid;
  grid-template-rows: 24px 24px;
  gap: 4px;
  align-self: stretch;
  width: 96px;
  transform: translateY(7px);
}

.number-format-panel label {
  display: block;
  width: 96px;
  height: 24px;
}

.number-format-panel select,
.number-format-panel button {
  width: 96px;
  height: 24px;
  border: 1px solid #d5dde3;
  border-radius: 5px;
  padding: 0 18px 0 8px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
  line-height: 22px;
  text-align: left;
  box-sizing: border-box;
}

.number-format-panel select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #5f6b75 50%), linear-gradient(135deg, #5f6b75 50%, transparent 50%);
  background-position: calc(100% - 11px) 9px, calc(100% - 7px) 9px;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  text-align-last: left;
}

.number-format-panel button {
  padding-right: 8px;
}

.toolbar-row {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.toolbar-row-main,
.toolbar-row-format {
  flex-wrap: nowrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  background: rgba(20, 28, 33, 0.28);
}

.modal-backdrop[hidden] {
  display: none;
}

.cell-format-dialog {
  width: min(720px, calc(100vw - 28px));
  min-height: 430px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  border: 1px solid #b9c4cb;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 22px 60px rgba(17, 24, 29, 0.25);
}

.cell-format-dialog header {
  height: 42px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 750;
}

.cell-format-body {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  min-height: 0;
}

.format-category-list {
  padding: 8px;
  border-right: 1px solid var(--line);
  background: #f7f9fa;
}

.format-category-list button {
  width: 100%;
  height: 30px;
  border: 0;
  border-radius: 5px;
  padding: 0 10px;
  background: transparent;
  text-align: left;
  color: var(--ink);
}

.format-category-list button.active {
  background: #dff4ee;
  color: #0f6556;
  font-weight: 750;
}

.format-options-pane {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
}

.format-sample {
  min-height: 54px;
  display: grid;
  align-content: center;
  padding: 9px 11px;
  border: 1px solid #d5dde3;
  border-radius: 6px;
  background: #fbfcfd;
}

.format-option-grid {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 8px 10px;
  align-items: center;
}

.format-option-grid label {
  color: var(--muted);
  font-size: 12px;
}

.format-option-grid input,
.format-option-grid select {
  height: 28px;
  min-width: 0;
  border: 1px solid #d5dde3;
  border-radius: 5px;
  padding: 0 8px;
  background: #fff;
}

.conditional-rule-list {
  display: grid;
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.conditional-rule-list strong {
  color: var(--ink);
  font-size: 13px;
}

.conditional-rule-item {
  min-height: 26px;
  display: flex;
  align-items: center;
  padding: 5px 7px;
  border: 1px solid #e1e6ea;
  border-radius: 5px;
  background: #fbfcfd;
  color: var(--ink);
}

.cell-format-dialog footer {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 12px;
  border-top: 1px solid var(--line);
}

.cell-format-dialog footer button {
  height: 28px;
  border: 1px solid #cbd3d9;
  border-radius: 5px;
  padding: 0 14px;
  background: #fff;
}

.cell-format-dialog footer button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.outbound-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2100;
  pointer-events: none;
}

.outbound-backdrop[hidden] {
  display: none;
}

.outbound-dialog {
  position: fixed;
  right: 18px;
  top: 92px;
  width: min(430px, calc(100vw - 28px));
  max-height: calc(100vh - 116px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid #cbd5dd;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.24);
  pointer-events: auto;
}

.outbound-dialog header {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}

.outbound-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.outbound-dialog header strong {
  color: #991b1b;
  font-size: 16px;
}

.outbound-dialog header button {
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  font-size: 20px;
}

.outbound-pick-mode-btn,
.outbound-mobile-restore {
  display: none;
}

.outbound-body {
  min-height: 0;
  display: grid;
  gap: 12px;
  overflow: auto;
  padding: 12px;
  touch-action: pan-y;
}

.outbound-section-title {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.outbound-coil-rows {
  display: grid;
  gap: 6px;
}

.outbound-coil-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) 28px;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.outbound-coil-row .outbound-coil-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #7a8590;
  font-size: 11px;
  font-weight: 750;
}

.outbound-coil-row span,
.outbound-fields span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.outbound-coil-row input,
.outbound-fields input {
  height: 30px;
  min-width: 0;
  border: 1px solid #cbd5dd;
  border-radius: 5px;
  padding: 0 8px;
  background: #fff;
}

.outbound-fields input.date-default-value {
  color: #a5adb5;
}

.outbound-coil-row button {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid #d3dbe2;
  border-radius: 5px;
  background: #fff;
  color: #991b1b;
  font-weight: 800;
}

.outbound-coils small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.outbound-coils,
.outbound-fields {
  min-height: 0;
}

.outbound-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.outbound-fields label {
  display: grid;
  gap: 4px;
  margin: 0;
}

.outbound-customer-field {
  position: relative;
}

.outbound-customer-suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 3px);
  z-index: 3;
  display: grid;
  gap: 2px;
  max-height: 168px;
  overflow: auto;
  padding: 4px;
  border: 1px solid #cbd5dd;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.16);
}

.outbound-customer-suggestions[hidden] {
  display: none;
}

.outbound-customer-suggestions button {
  min-height: 34px;
  display: grid;
  gap: 2px;
  border: 0;
  border-radius: 4px;
  padding: 5px 7px;
  background: transparent;
  text-align: left;
}

.outbound-customer-suggestions button:hover,
.outbound-customer-suggestions button.active {
  background: #e8f5f1;
}

.outbound-customer-suggestions button.active {
  outline: 2px solid #16a085;
}

.outbound-customer-suggestions strong {
  color: var(--ink);
  font-size: 12px;
}

.outbound-customer-suggestions small {
  color: var(--muted);
  font-size: 11px;
}

.outbound-salesman-field {
  display: grid;
  gap: 4px;
}

.outbound-salesman-options {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
}

.outbound-salesman-options button {
  height: 30px;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #cbd5dd;
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  font-weight: 750;
  line-height: 1;
}

.outbound-salesman-options button.active {
  border-color: #13806d;
  background: #16a085;
  color: #fff;
}

.outbound-error {
  min-height: 18px;
  color: #b91c1c;
  font-size: 12px;
  font-weight: 700;
}

.outbound-dialog footer {
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 12px;
  border-top: 1px solid var(--line);
}

.outbound-dialog footer button {
  height: 28px;
  border: 1px solid #cbd5dd;
  border-radius: 5px;
  padding: 0 14px;
  background: #fff;
}

.outbound-dialog footer button.danger {
  border-color: #b91c1c;
  background: #dc2626;
  color: #fff;
  font-weight: 800;
}

.toolbar-row-main {
  justify-content: flex-start;
}

.find-box {
  position: fixed;
  top: 118px;
  right: 22px;
  z-index: 75;
  width: min(360px, calc(100vw - 44px));
  border: 1px solid #c7d1d8;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.18);
}

.find-box[hidden] {
  display: none;
}

.find-dialog-header {
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 14px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}

.find-dialog-header strong {
  font-size: 15px;
}

.find-dialog-header button {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  font-size: 20px;
  line-height: 1;
}

.find-dialog-header button:hover {
  background: #eef3f6;
}

.find-dialog-body {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
}

.find-box input {
  width: 100%;
  min-width: 0;
  height: 32px;
  border: 1px solid #c8d3d8;
  border-radius: 5px;
  padding: 0 10px;
  outline: none;
  font-size: 14px;
}

.find-box input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

.find-dialog-actions {
  display: flex;
  gap: 6px;
}

.find-box button {
  height: 32px;
  border: 1px solid #c8d3d8;
  border-radius: 5px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
  white-space: nowrap;
}

.find-box button:hover {
  background: #eef6f4;
}

.find-dialog-body small {
  grid-column: 1 / -1;
  min-height: 18px;
  color: var(--muted);
}

.view-control {
  height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 5px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.view-control select {
  height: 28px;
  width: 84px;
  min-width: 84px;
  max-width: 84px;
  border: 0;
  background: transparent;
  color: var(--ink);
  outline: none;
}

.field-control {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.field-control.grow {
  flex: 1 1 220px;
}

.field-control input,
.field-control select {
  min-width: 120px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  outline: none;
  background: #fff;
}

.field-control.grow input {
  width: 100%;
}

.field-control input:focus,
.field-control select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--focus);
}

button,
.download {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 11px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

button:hover,
.download:hover {
  border-color: #aeb8bf;
}

.toolbar-right .screenshot-sheet-btn {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.toolbar-right .screenshot-sheet-btn:hover {
  border-color: #0f6b5d;
  background: #0f6b5d;
  color: #fff;
}

.outbound-btn,
#mobileOutboundBtn {
  border-color: #b91c1c;
  background: #dc2626;
  color: #fff;
  font-weight: 800;
}

.outbound-btn:hover,
#mobileOutboundBtn:hover {
  border-color: #991b1b;
  background: #b91c1c;
  color: #fff;
}

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

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.formula-bar {
  min-height: 36px;
  display: grid;
  grid-template-columns: 82px 34px minmax(260px, 506px) 62px minmax(260px, 1fr);
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-bottom: 1px solid var(--line);
  background: #f5f8f8;
}

.formula-name,
.formula-fx,
.formula-bar input,
.formula-bar .status-line,
.formula-jump-controls button {
  height: 28px;
  border: 1px solid #c8d3d8;
  border-radius: 5px;
  background: #fff;
}

.formula-name,
.formula-fx {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.formula-bar input {
  min-width: 0;
  padding: 0 9px;
  color: var(--ink);
  outline: none;
  font: inherit;
}

.formula-bar input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus);
}

.formula-jump-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  min-width: 0;
}

.formula-jump-controls button {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 0;
  color: #0f766e;
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.formula-jump-controls button:hover {
  border-color: #8fb9b2;
  background: #eef8f6;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 0 10px;
  overflow: hidden;
  color: var(--muted);
  background: #fff;
  font-size: 13px;
}

.status-line span {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


.status-line.error {
  color: var(--danger);
}

.status-line.ok {
  color: var(--accent-dark);
  background: #eefaf4;
}

.status-line.save {
  color: #0f766e;
  background: #eefaf4;
}

.toast-message {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 80;
  min-width: 92px;
  max-width: min(280px, calc(100vw - 36px));
  padding: 9px 14px;
  border-radius: 6px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.16s ease, transform 0.16s ease;
  font-size: 14px;
  font-weight: 700;
  overflow-wrap: anywhere;
  pointer-events: none;
}

.toast-message.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-message[style*="left"].show {
  transform: translate(-50%, 0);
}

.toast-message.mobile-center-toast {
  left: 50%;
  top: 50%;
  right: auto;
  transform: translate(-50%, calc(-50% - 8px)) scale(var(--toast-scale, 1));
  transform-origin: center center;
}

.toast-message.mobile-center-toast.show {
  transform: translate(-50%, -50%) scale(var(--toast-scale, 1));
}

.toast-message.ok {
  color: #0f5f3f;
  background: #dff7ea;
  border: 1px solid #9fdec0;
}

.toast-message.save {
  color: #0f766e;
  background: #e7f8ef;
  border: 1px solid #8fd7b1;
}

.toast-message.error {
  color: #b42318;
  background: #fff1f0;
  border: 1px solid #f3aaa3;
}

.table-wrap {
  min-height: 0;
  overflow: auto;
  background: #cfd6dc;
  position: relative;
  scrollbar-gutter: stable;
  overscroll-behavior: none;
  touch-action: pan-x pan-y pinch-zoom;
}

.table-wrap.pinch-zooming #dataTable,
.table-wrap.pinch-zooming .image-layer {
  will-change: transform;
  backface-visibility: hidden;
  transform-style: flat;
}

.table-wrap.pinch-zooming th,
.table-wrap.pinch-zooming td:first-child,
.table-wrap.pinch-zooming .excel-col-header,
.table-wrap.pinch-zooming .excel-corner,
.table-wrap.pinch-zooming .row-number,
.table-wrap.pinch-zooming .frozen-col,
.table-wrap.pinch-zooming .frozen-row {
  position: static !important;
}

.table-wrap.pinch-zooming td:hover {
  background: inherit;
}

.table-wrap.pinch-zooming td.selected-cell::after,
.table-wrap.pinch-zooming .image-resize-handle,
.table-wrap.pinch-zooming .image-rotate-handle {
  display: none !important;
}

.table-wrap.pinch-zooming td.selected-range {
  box-shadow: none;
}

.table-wrap.pinch-zooming .sheet-image.selected {
  outline: none;
}

.pinch-zoom-badge {
  position: sticky;
  left: 50%;
  top: 50%;
  z-index: 60;
  width: max-content;
  min-width: 64px;
  margin: 0 auto;
  padding: 8px 12px;
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.78);
  color: #fff;
  font-size: 15px;
  font-weight: 750;
  text-align: center;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.image-layer {
  position: absolute;
  inset: 0 auto auto 0;
  z-index: 20;
  pointer-events: none;
  width: 0;
  height: 0;
  overflow: visible;
  contain: layout size;
}

.sheet-image {
  position: absolute;
  transform-origin: center center;
  pointer-events: auto;
  cursor: move;
}

.sheet-image img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: fill;
  user-select: none;
  -webkit-user-drag: none;
}

.sheet-image.selected {
  outline: 2px solid #167867;
  outline-offset: 2px;
}

.image-resize-handle,
.image-rotate-handle {
  display: none;
  position: absolute;
  z-index: 2;
  box-sizing: border-box;
  border: 1px solid #0f6556;
  background: #fff;
}

.sheet-image.selected .image-resize-handle,
.sheet-image.selected .image-rotate-handle {
  display: block;
}

.image-resize-nw,
.image-resize-ne,
.image-resize-se,
.image-resize-sw {
  width: 12px;
  height: 12px;
}

.image-resize-nw {
  left: -8px;
  top: -8px;
  cursor: nwse-resize;
}

.image-resize-ne {
  right: -8px;
  top: -8px;
  cursor: nesw-resize;
}

.image-resize-se {
  right: -8px;
  bottom: -8px;
  cursor: nwse-resize;
}

.image-resize-sw {
  left: -8px;
  bottom: -8px;
  cursor: nesw-resize;
}

.image-resize-e,
.image-resize-w {
  top: 50%;
  width: 12px;
  height: 18px;
  transform: translateY(-50%);
  cursor: ew-resize;
}

.image-resize-e {
  right: -8px;
}

.image-resize-w {
  left: -8px;
}

.image-resize-n,
.image-resize-s {
  left: 50%;
  width: 18px;
  height: 12px;
  transform: translateX(-50%);
  cursor: ns-resize;
}

.image-resize-n {
  top: -8px;
}

.image-resize-s {
  bottom: -8px;
}

.image-rotate-handle {
  top: -30px;
  left: 50%;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  transform: translateX(-50%);
  cursor: grab;
}

.image-rotate-handle::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 13px;
  width: 1px;
  height: 16px;
  background: #0f6556;
}

table {
  width: max-content;
  min-width: max-content;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  font-size: 13px;
  user-select: none;
  background: #fff;
}

col.index-col {
  width: 52px;
}

col.add-col {
  width: 52px;
}

th,
td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 0;
  vertical-align: top;
  background: #fff;
}

td.outside-used-row,
td.outside-used-col,
th.outside-used-col,
td.row-number-cell.outside-used-row {
  background: #dfe4e8;
}

td.outside-used-row .cell-editor,
td.outside-used-col .cell-editor {
  color: #8a949c;
}

td.outside-used-row:hover,
td.outside-used-col:hover {
  background: #d5dce1;
}

.data-table-no-grid td {
  border-right-color: transparent;
  border-bottom-color: transparent;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 34px;
  padding: 7px 8px;
  background: #e9efed;
  text-align: left;
  white-space: nowrap;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
}

thead tr:nth-child(2) th {
  top: 34px;
}

.excel-col-header,
.excel-corner,
.row-number {
  position: sticky;
  background: #f2f5f6;
  color: var(--muted);
  text-align: center;
  font-weight: 650;
}

.excel-corner {
  cursor: pointer;
}

.excel-col-header.active-axis,
.row-number-cell.active-axis,
.excel-corner.active-axis {
  background: #93cdc2;
  color: #083f36;
  font-weight: 750;
}

.field-header {
  background: #e9efed;
}

th:first-child,
td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  width: 52px;
  min-width: 52px;
  max-width: 52px;
  text-align: center;
  background: #f2f5f6;
  color: var(--muted);
}

th:first-child {
  z-index: 4;
}

.frozen-row td {
  position: sticky;
  top: 34px;
  z-index: 3;
}

.frozen-row td:first-child {
  z-index: 6;
}

.frozen-col,
.frozen-col-header {
  position: sticky;
  left: 52px;
  z-index: 3;
}

.frozen-col-header {
  z-index: 4;
}

.frozen-row .frozen-col {
  z-index: 5;
}

.excel-corner {
  z-index: 5;
}

.field-header-row th:first-child {
  z-index: 5;
}

.excel-col-header.active-axis,
td.row-number-cell.active-axis {
  background: #93cdc2;
  color: #083f36;
  font-weight: 750;
}

td.row-number-cell {
  position: sticky;
  vertical-align: middle;
  line-height: 1;
}

.hidden-row-gap-marker,
.hidden-col-gap-marker {
  position: absolute;
  z-index: 7;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  border-radius: 999px;
  background: #16a34a;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 10px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18);
}

.row-number-cell.has-hidden-row-gap,
.excel-col-header.has-hidden-col-gap {
  overflow: visible;
}

.hidden-row-gap-marker {
  top: -6px;
  left: 50%;
  min-width: 22px;
  height: 10px;
  padding: 0 4px;
  transform: translateX(-50%);
  font-family: Arial, sans-serif;
  letter-spacing: 0;
}

.hidden-col-gap-marker {
  top: 50%;
  left: -9px;
  width: 10px;
  height: 20px;
  transform: translateY(-50%);
  writing-mode: vertical-rl;
}

td .cell-editor {
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0 !important;
  padding: 7px 8px;
  background: transparent !important;
  color: var(--ink);
  outline: none !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  caret-color: transparent;
  user-select: none;
  font: inherit;
  appearance: none;
  -webkit-appearance: none;
  box-shadow: none !important;
  border-radius: 0;
}

td:focus-within,
td .cell-editor:focus,
td .cell-editor:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

.compact-height-row .cell-editor {
  height: calc(var(--row-height) - 1px) !important;
  padding-top: 0;
  padding-bottom: 0;
}

.compact-height-row td {
  height: var(--row-height) !important;
  max-height: var(--row-height) !important;
  overflow: hidden !important;
}

td.text-spill-cell {
  position: relative;
  z-index: 7;
  overflow: visible;
}

.cell-spill-label {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  display: flex;
  align-items: center;
  padding: 7px 8px;
  white-space: nowrap;
  overflow: visible;
  color: var(--ink);
  background: transparent;
  pointer-events: none;
  z-index: 6;
  border: 0 !important;
  outline: 0 !important;
  box-shadow: none !important;
}

td.text-spill-cell.selected-cell .cell-spill-label,
td.text-spill-cell.selected-range .cell-spill-label {
  z-index: 9;
}

td.text-spill-cell:not(.selected-cell):not(.selected-range) {
  outline: none !important;
  box-shadow: none !important;
}

td.text-spill-cell .cell-editor {
  color: transparent;
  caret-color: transparent;
  position: relative;
  z-index: 7;
}

td.text-spill-cell .cell-editor:focus,
td.text-spill-cell .cell-editor[data-edit-mode="1"] {
  color: var(--ink);
  caret-color: auto;
}

td.text-spill-cell .cell-editor[data-edit-mode="1"] + .cell-spill-label {
  display: none;
}

td.wrap-text-cell {
  height: auto;
}

td.wrap-text-cell .cell-editor {
  height: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  text-overflow: clip;
}

td.wrap-text-cell textarea.cell-editor {
  display: block;
  resize: none;
  overflow: hidden;
}

td .cell-editor:focus {
  background: transparent;
}

td .cell-editor[data-edit-mode="1"] {
  caret-color: auto;
  user-select: text;
}

td .cell-editor[data-edit-mode="1"]:focus {
  background: var(--focus);
  overflow: visible;
}

td.selected-cell {
  position: relative;
  background: #a9d8cd !important;
}

td.selected-cell .cell-editor,
td.selected-cell .cell-spill-label {
  background: transparent !important;
  color: #111827 !important;
  -webkit-text-fill-color: #111827 !important;
  opacity: 1 !important;
}

td.selected-row,
td.selected-col {
  background: #c6e8df;
}

td.selected-range {
  background: #b7ded5;
}

td.outbound-selected-coil {
  background: #d8f6e4;
}

td.outbound-selected-coil-cell {
  position: relative;
  box-shadow: inset 0 0 0 2px #16a34a;
}

td.outbound-selected-coil-cell::before {
  content: "";
  position: absolute;
  inset: 2px;
  border: 1px solid rgba(22, 163, 74, 0.38);
  pointer-events: none;
}

td.selected-row input,
td.selected-col input,
td.selected-row textarea,
td.selected-col textarea {
  background: transparent;
  caret-color: transparent;
}

td.selected-cell::after {
  content: "";
  position: absolute;
  inset: -1px;
  border: 2px solid #0a6f60;
  pointer-events: none;
  z-index: 2;
}

.cell-fill-handle {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 8px;
  height: 8px;
  border: 1px solid #ffffff;
  background: #0a6f60;
  cursor: crosshair;
  z-index: 12;
  box-sizing: border-box;
}

td.selected-range {
  box-shadow: inset 0 0 0 1px rgba(10, 111, 96, 0.5);
}

.filter-header-cell {
  position: relative;
  overflow: hidden;
  background: #f7fbfa;
}

.filter-header-cell input {
  padding-right: 30px;
  font-weight: 650;
}

.cell-filter-btn {
  position: absolute;
  right: 2px;
  top: 2px;
  width: 28px;
  height: 28px;
  min-width: 28px;
  border: 1px solid #9aa9b5;
  border-radius: 5px;
  padding: 0;
  background: #ffffff;
  color: #26323b;
  line-height: 1;
  z-index: 1;
}

.cell-filter-btn::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  background: transparent;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 7px solid #5f5f5f;
  transform: translate(-50%, -28%);
  clip-path: none;
}

.cell-filter-btn::after {
  content: "";
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  display: none;
}

.cell-filter-btn.active {
  border: 1px solid #0f6c5f;
  border-color: #0f6c5f;
  background: #0f766e;
  color: #fff;
}

.cell-filter-btn.active::before {
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  border: 0;
  background: currentColor;
  transform: translate(-50%, -50%);
  clip-path: polygon(0 0, 100% 0, 62% 45%, 62% 100%, 38% 100%, 38% 45%);
}

.cell-filter-btn.active::after {
  display: block;
  right: 3px;
  bottom: 3px;
  width: 7px;
  height: 7px;
  border: 1px solid #fff;
  border-radius: 50%;
  background: #facc15;
}

.compact-height-row .filter-header-cell input {
  padding-right: 23px;
}

.compact-height-row .cell-filter-btn {
  right: 1px;
  top: 1px;
  width: 20px;
  height: 20px;
  min-width: 20px;
  border-radius: 4px;
}

.compact-height-row .cell-filter-btn::before {
  border-left-width: 5px;
  border-right-width: 5px;
  border-top-width: 6px;
}

.compact-height-row .cell-filter-btn.active::before {
  left: 50%;
  top: 50%;
  width: 9px;
  height: 9px;
  border: 0;
}

.compact-height-row .cell-filter-btn::after {
  right: 3px;
  bottom: 3px;
  border-left-width: 3px;
  border-right-width: 3px;
  border-top-width: 4px;
}

.compact-height-row .cell-filter-btn.active::after {
  right: 2px;
  bottom: 2px;
  width: 5px;
  height: 5px;
}

.filter-menu {
  position: fixed;
  z-index: 1200;
  width: 292px;
  max-height: 480px;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(80px, 1fr) auto;
  gap: 8px;
  padding: 10px;
  border: 1px solid #c9d1d8;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 34px rgba(23, 32, 38, 0.18);
}

.filter-menu[hidden] {
  display: none;
}

.filter-menu-title {
  font-size: 13px;
  font-weight: 750;
  color: var(--ink);
}

.filter-menu-search {
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 8px;
  outline: none;
}

.filter-menu-quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.filter-menu-quick-actions button {
  height: 28px;
  justify-content: center;
  padding: 0 4px;
  font-size: 12px;
}

.filter-advanced {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.filter-advanced select,
.filter-advanced input,
.filter-color-button {
  width: 100%;
  min-width: 0;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0 7px;
  background: #fff;
}

.filter-color-picker {
  position: relative;
  min-width: 0;
}

.filter-color-button {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
}

.filter-color-button span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-color-swatch {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border: 1px solid #8b98a3;
  border-radius: 3px;
  background: linear-gradient(135deg, transparent 0 47%, #cbd5dc 48% 52%, transparent 53% 100%);
}

.filter-color-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-color-popover {
  position: absolute;
  z-index: 1300;
  left: 0;
  top: calc(100% + 4px);
  width: 132px;
  padding: 6px;
  border: 1px solid #c9d1d8;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 26px rgba(23, 32, 38, 0.18);
}

.filter-color-popover[hidden] {
  display: none;
}

.filter-color-popover button {
  width: 100%;
  height: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 5px;
  padding: 0 7px;
  background: transparent;
  color: var(--ink);
  font-size: 12px;
}

.filter-color-popover button:hover {
  background: #eef6f4;
}

.filter-value-list {
  min-height: 90px;
  max-height: 170px;
  overflow: auto;
  border: 1px solid #e1e6ea;
  border-radius: 6px;
  padding: 4px;
}

.filter-value-item {
  min-height: 26px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 4px;
  font-size: 13px;
}

.filter-value-item:hover {
  background: #f5f8f8;
}

.filter-menu-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.filter-menu-actions button {
  height: 28px;
  justify-content: center;
  padding: 0 6px;
}

.add-axis {
  width: 52px;
  min-width: 52px;
  max-width: 52px;
  padding: 3px;
  text-align: center;
  background: #cfd6dc;
}

.add-col-pad,
.add-row-pad {
  width: 52px;
  min-width: 52px;
  max-width: 52px;
  background: #cfd6dc;
}

.add-row .row-number-cell {
  height: 34px;
  padding: 3px;
}

.axis-add-btn {
  width: 26px;
  height: 26px;
  min-width: 26px;
  border: 1px solid #b9c6ce;
  border-radius: 5px;
  padding: 0;
  background: #fff;
  color: #167867;
  font-size: 18px;
  line-height: 1;
  font-weight: 750;
}

.axis-add-btn:hover:not(:disabled) {
  border-color: #167867;
  background: #e8f5f1;
}

.col-resize-handle,
.row-resize-handle {
  position: absolute;
  display: block;
  z-index: 6;
}

.col-resize-handle {
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
}

.row-resize-handle {
  left: 0;
  right: 0;
  bottom: -3px;
  height: 6px;
  cursor: row-resize;
}

.excel-col-header:hover .col-resize-handle,
.row-number-cell:hover .row-resize-handle {
  background: rgba(15, 118, 110, 0.22);
}

.formula-error input {
  color: var(--danger);
  background: #fff5f5;
}

.row-delete {
  width: 100%;
  height: 32px;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  color: var(--danger);
  font-weight: 700;
}

.context-menu {
  position: fixed;
  z-index: 1000;
  width: 188px;
  padding: 6px;
  border: 1px solid #c9d1d8;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(23, 32, 38, 0.16);
}

.context-menu[hidden] {
  display: none;
}

.context-menu button {
  width: 100%;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  border: 0;
  border-radius: 5px;
  padding: 0 9px;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.context-menu button:hover:not(:disabled) {
  background: #eef6f4;
}

.context-menu button:disabled {
  color: #a4adb5;
  opacity: 1;
}

.context-menu-separator {
  height: 1px;
  margin: 5px 3px;
  background: #e3e8ec;
}

.context-menu-label {
  padding: 5px 8px 4px;
  color: var(--muted);
  font-size: 12px;
}

.sheet-color-grid {
  display: grid;
  grid-template-columns: repeat(4, 28px);
  gap: 6px;
  padding: 4px 8px 7px;
}

.color-menu-item {
  width: 28px;
  height: 24px;
  min-width: 28px;
  border: 1px solid #bfc9d1;
  border-radius: 4px;
  padding: 0;
  background: #fff;
}

.color-menu-item:first-child::before {
  content: "";
  display: block;
  width: 20px;
  height: 1px;
  margin: 10px auto 0;
  background: #d33f3f;
  transform: rotate(-28deg);
}

.sheet-bar {
  height: 54px;
  min-height: 54px;
  max-height: 54px;
  display: flex;
  align-items: stretch;
  border-top: 1px solid #c8d0d6;
  background: var(--tab-bg);
  overflow: hidden;
}

.sheet-list {
  height: 53px;
  display: flex;
  align-items: flex-start;
  gap: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 5px 8px 8px;
  min-width: 0;
  scrollbar-gutter: stable;
}

.sheet-btn {
  --sheet-tab-color: #f8fafb;
  height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #cbd3d9;
  border-bottom: 0;
  border-radius: 7px 7px 0 0;
  padding: 0 13px;
  margin-right: 2px;
  background: var(--sheet-tab-color);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}

.sheet-btn:hover {
  filter: brightness(1.025);
}

.sheet-btn.active {
  position: relative;
  z-index: 1;
  border-color: #15856f;
  background: var(--sheet-tab-color, #dff4ee);
  color: #0f6556;
  font-weight: 650;
  box-shadow: inset 0 -3px 0 #16a085;
}

.sheet-btn:not([style*="--sheet-tab-color"]).active {
  --sheet-tab-color: #dff4ee;
}

.sheet-btn.dirty small {
  color: var(--danger);
  font-weight: 700;
}

.sheet-btn small {
  color: var(--muted);
  font-weight: 400;
}

.sheet-btn[data-dark-tab="true"] {
  color: #fff;
}

.sheet-btn[data-dark-tab="true"] small,
.sheet-btn[data-dark-tab="true"].dirty small,
.sheet-btn[data-dark-tab="true"][data-protected="true"] span::after {
  color: rgba(255, 255, 255, 0.84);
}

.sheet-add-btn {
  width: 34px;
  height: 34px;
  min-width: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #cbd3d9;
  border-radius: 7px 7px 0 0;
  margin-left: 4px;
  background: #fff;
  color: #167867;
  font-size: 21px;
  font-weight: 750;
  line-height: 1;
}

.sheet-add-btn:hover {
  border-color: #16a085;
  background: #e8f5f1;
}

.sheet-btn[data-protected="true"] span::after {
  content: "保护";
  display: inline-block;
  margin-left: 6px;
  color: var(--warn);
  font-size: 12px;
  font-weight: 400;
}

@media (max-width: 980px) {
  :root {
    --mobile-top-safe: max(12px, env(safe-area-inset-top, 0px));
  }

  html,
  body {
    height: auto;
    min-height: 100%;
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    position: relative;
    height: auto;
    min-height: 100dvh;
  }

  .app-shell.nav-collapsed {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 70;
    width: min(78vw, 260px);
    box-shadow: 18px 0 36px rgba(15, 23, 42, 0.22);
    transform: translateX(-100%);
    transition: transform 0.18s ease;
  }

  .app-shell:not(.nav-collapsed) .sidebar {
    transform: translateX(0);
  }

  .sidebar-head {
    grid-template-columns: 34px minmax(0, 1fr) 30px;
    justify-items: stretch;
    padding: 10px 12px;
  }

  .sidebar-title,
  .module-text,
  .module-btn small,
  .sidebar-foot {
    display: grid;
  }

  .module-btn {
    grid-template-columns: 30px minmax(0, 1fr) auto;
    justify-items: stretch;
    padding: 0 8px;
  }

  .icon-btn {
    position: fixed;
    top: calc(var(--mobile-top-safe) + 5px);
    left: 0;
    z-index: 90;
    width: 28px;
    height: 32px;
    border-radius: 0 8px 8px 0;
    border-color: rgba(15, 23, 42, 0.2);
    background: rgba(32, 39, 45, 0.92);
    color: #fff;
    box-shadow: 0 3px 10px rgba(15, 23, 42, 0.18);
    transform: none;
  }

  .app-shell.nav-collapsed .icon-btn {
    grid-row: auto;
    border-color: rgba(15, 23, 42, 0.2);
    background: rgba(32, 39, 45, 0.92);
    color: #fff;
  }

  .app-shell:not(.nav-collapsed) .icon-btn {
    border-color: rgba(15, 23, 42, 0.2);
    background: rgba(32, 39, 45, 0.92);
    color: #fff;
  }

  .icon-btn.mobile-floating-toggle {
    position: fixed;
    z-index: 120;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    min-width: 28px;
    height: 32px;
    padding: 0;
    border-radius: 0 8px 8px 0;
    border: 1px solid rgba(15, 23, 42, 0.28);
    background: rgba(32, 39, 45, 0.94);
    color: #fff;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2);
    font-size: 22px;
    font-weight: 800;
    line-height: 1;
  }

  .workspace,
  .workspace.placeholder-mode {
    grid-template-rows: calc(42px + var(--mobile-top-safe)) minmax(0, 1fr);
    height: auto;
    min-height: 100dvh;
  }

  .toolbar {
    display: none;
  }

  .formula-bar,
  .status-line {
    display: none;
  }

  .sheet-bar {
    grid-row: 1;
    position: sticky;
    top: 0;
    z-index: 60;
    height: calc(42px + var(--mobile-top-safe));
    min-height: calc(42px + var(--mobile-top-safe));
    max-height: calc(42px + var(--mobile-top-safe));
    padding-top: var(--mobile-top-safe);
    border-top: 0;
    border-bottom: 1px solid #c8d0d6;
    background: #f2f5f7;
  }

  .mobile-tools-toggle {
    position: fixed;
    right: 0;
    top: calc(var(--mobile-top-safe) + 43px);
    z-index: 95;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    min-width: 28px;
    height: 32px;
    padding: 0;
    border-radius: 8px 0 0 8px;
    border-color: rgba(100, 116, 139, 0.38);
    background: rgba(203, 213, 225, 0.9);
    color: #334155;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.1);
    font-size: 20px;
    font-weight: 700;
  }

  .mobile-tools-toggle[aria-expanded="true"] {
    background: rgba(180, 190, 204, 0.94);
    color: #0f766e;
  }

  .mobile-tools-menu {
    position: fixed;
    right: 0;
    top: calc(var(--mobile-top-safe) + 79px);
    z-index: 94;
    display: grid;
    grid-template-columns: 1fr;
    gap: 5px;
    width: 56px;
    padding: 5px 4px 6px;
    border: 1px solid rgba(100, 116, 139, 0.35);
    border-right: 0;
    border-radius: 8px 0 0 8px;
    background: rgba(241, 245, 249, 0.94);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
  }

  .mobile-tools-menu[hidden] {
    display: none;
  }

  .mobile-tools-menu button {
    height: 32px;
    min-width: 0;
    width: 100%;
    padding: 0;
    border-color: #cbd3d9;
    background: #fff;
    color: #111827;
    font-size: 14px;
    font-weight: 700;
  }

  #mobileSaveBtn,
  #mobileOutboundBtn,
  #mobileScreenshotTransferBtn,
  #mobileScreenshotContractBtn {
    border-color: #13806d;
    background: #16a085;
    color: #fff;
  }

  #mobileOutboundBtn {
    border-color: #991b1b;
    background: #dc2626;
  }

  .outbound-dialog {
    left: 8px;
    right: 8px;
    top: auto;
    bottom: 52px;
    width: auto;
    max-height: min(78dvh, 560px);
  }

  .outbound-pick-mode-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(153, 27, 27, 0.24) !important;
    border-radius: 6px;
    background: #fff5f5 !important;
    color: #991b1b;
    font-size: 18px !important;
    font-weight: 800;
    line-height: 1;
  }

  .outbound-mobile-restore {
    position: fixed;
    right: 0;
    top: calc(var(--mobile-top-safe) + 79px);
    z-index: 96;
    display: inline-grid;
    place-items: center;
    width: 28px;
    min-width: 28px;
    height: 32px;
    padding: 0;
    border: 1px solid rgba(153, 27, 27, 0.32);
    border-right: 0;
    border-radius: 8px 0 0 8px;
    background: rgba(254, 242, 242, 0.94);
    color: #991b1b;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.1);
    font-size: 18px;
    font-weight: 800;
  }

  .outbound-mobile-restore[hidden] {
    display: none;
  }

  .outbound-body {
    display: block;
    gap: 9px;
    padding: 10px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .outbound-coils {
    margin-bottom: 10px;
  }

  .outbound-coil-rows {
    max-height: 120px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-right: 2px;
  }

  .outbound-fields {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .outbound-coil-row {
    grid-template-columns: 16px minmax(0, 1fr) 26px;
  }

  .sheet-list {
    height: 41px;
    align-items: center;
    padding: 4px 36px 5px 32px;
    scrollbar-width: none;
  }

  .sheet-list::-webkit-scrollbar {
    display: none;
  }

  .sheet-btn {
    height: 31px;
    border: 1px solid #cbd3d9;
    border-radius: 6px;
    padding: 0 11px;
    font-size: 13px;
    box-shadow: none;
  }

  .sheet-btn.active {
    border-color: #13806d;
    box-shadow: inset 0 -2px 0 #16a085;
  }

  .sheet-add-btn {
    display: none;
  }

  .table-wrap {
    grid-row: 2;
    overflow: visible;
    scrollbar-gutter: auto;
  }

  .filter-menu {
    grid-template-rows: auto auto auto auto minmax(176px, 1fr) auto;
    gap: 6px;
    padding: 8px;
    border-radius: 7px;
  }

  .filter-menu-title {
    font-size: 12px;
  }

  .filter-menu-search,
  .filter-advanced select,
  .filter-advanced input,
  .filter-color-button,
  .filter-menu-actions button {
    height: 26px;
    font-size: 12px;
  }

  .filter-menu-quick-actions button {
    height: 26px;
    font-size: 11px;
  }

  .filter-value-list {
    min-height: 176px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: none;
    max-height: none;
    scrollbar-width: auto;
    scrollbar-color: #7f8d98 #edf2f5;
  }

  .filter-value-list::-webkit-scrollbar {
    width: 14px;
  }

  .filter-value-list::-webkit-scrollbar-thumb {
    border-radius: 999px;
    border: 3px solid #edf2f5;
    background: #7f8d98;
  }

  .filter-value-list::-webkit-scrollbar-track {
    border-radius: 999px;
    background: #edf2f5;
  }

  .filter-value-item {
    min-height: 24px;
    font-size: 12px;
  }

  td .cell-editor {
    touch-action: pan-x pan-y pinch-zoom;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
  }

  .filter-header-cell {
    height: 32px;
    max-height: 32px;
    overflow: hidden;
  }

  .filter-header-cell input.cell-editor,
  .filter-header-cell textarea.cell-editor {
    height: 31px;
    padding: 0 24px 0 6px;
    line-height: 31px;
  }

  .filter-header-cell .cell-filter-btn {
    right: 2px;
    top: 4px;
    width: 22px;
    height: 22px;
    min-width: 22px;
  }

  .filter-header-cell .cell-filter-btn::before {
    border-left-width: 5px;
    border-right-width: 5px;
    border-top-width: 6px;
  }

  #dataTable tbody tr {
    content-visibility: auto;
    contain-intrinsic-size: 28px;
  }

  #dataTable tbody tr.filter-header-row {
    content-visibility: visible;
    contain-intrinsic-size: auto;
  }

  #dataTable tbody tr.virtual-spacer-row {
    content-visibility: visible;
    contain-intrinsic-size: auto;
  }

  col.index-col,
  col.add-col {
    width: 30px;
  }

  th {
    height: 26px;
    padding: 4px 5px;
    font-size: 12px;
  }

  th:first-child,
  td:first-child {
    width: 30px;
    min-width: 30px;
    max-width: 30px;
    font-size: 11px;
  }

  .row-number-cell {
    padding: 0;
  }

  .hidden-row-gap-marker {
    top: -5px;
    min-width: 18px;
    height: 9px;
    padding: 0 3px;
    font-size: 9px;
    line-height: 9px;
  }

  .hidden-col-gap-marker {
    left: -8px;
    width: 9px;
    height: 18px;
    font-size: 9px;
    line-height: 9px;
  }

  .excel-col-header,
  .excel-corner {
    height: 26px;
    padding: 3px 4px;
  }

  .row-resize-handle,
  .col-resize-handle {
    display: none;
  }

  .excel-letter-row .add-axis,
  .add-row {
    display: none;
  }

  .module-placeholder {
    grid-row: 2;
  }

  .workspace.dashboard-mode,
  .workspace.dashboard-mode.placeholder-mode {
    grid-template-rows: minmax(0, 1fr);
    min-height: 100dvh;
    background: #eef4f3;
  }

  .workspace.dashboard-mode .module-placeholder {
    grid-row: 1;
    min-height: 100dvh;
    padding: calc(var(--mobile-top-safe) + 14px) 10px 18px;
    overflow-y: auto;
    overflow-x: hidden;
    background:
      linear-gradient(150deg, rgba(15, 101, 86, 0.12), transparent 38%),
      #eef4f3;
  }

  .dashboard-page {
    max-width: none;
    width: 100%;
    min-width: 0;
    gap: 10px;
  }

  .workspace.operation-log-mode .module-placeholder {
    grid-row: 2;
    padding: calc(var(--mobile-top-safe) + 12px) 10px 18px;
  }

  .operation-log-filter {
    grid-template-columns: 1fr;
  }

  .operation-log-table-wrap {
    max-height: calc(100dvh - 230px);
  }

  .operation-log-table {
    min-width: 860px;
    font-size: 12px;
  }

  .dashboard-head {
    min-height: 36px;
    align-items: center;
  }

  .dashboard-head h2,
  .dashboard-loading h2 {
    font-size: 22px;
    line-height: 1.2;
  }

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

  .dashboard-range-panel {
    padding: 10px;
    gap: 10px;
  }

  .dashboard-range-form {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .dashboard-range-form button {
    grid-column: 1 / -1;
  }

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

  .dashboard-metric {
    min-height: 82px;
    padding: 11px 12px;
    border-radius: 8px;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
  }

  .dashboard-metric:first-child {
    grid-column: 1 / -1;
  }

  .dashboard-metric::before {
    width: 68px;
    height: 68px;
    right: -18px;
    top: -24px;
  }

  .dashboard-metric span {
    font-size: 12px;
  }

  .dashboard-metric strong {
    margin-top: 8px;
    font-size: 24px;
  }

  .dashboard-metric small {
    margin-top: 4px;
    font-size: 11px;
  }

  .dashboard-chart-panel,
  .dashboard-table-panel {
    width: 100%;
    min-width: 0;
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  }

  .dashboard-chart-panel header,
  .dashboard-table-panel header {
    align-items: flex-start;
    padding: 11px 12px 8px;
  }

  .dashboard-chart-panel header {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .dashboard-chart-panel h3,
  .dashboard-table-panel h3 {
    font-size: 15px;
  }

  .dashboard-chart-summary {
    justify-content: flex-start;
    gap: 6px;
    font-size: 11px;
  }

  .dashboard-chart-summary span {
    padding: 4px 7px;
  }

  .dashboard-chart-wrap {
    padding: 0 6px 8px;
    overflow: hidden;
  }

  .dashboard-line-chart {
    min-width: 0;
    height: 210px;
  }

  .dashboard-table-wrap {
    max-height: none;
    overflow: visible;
  }

  .dashboard-table {
    min-width: 0;
    width: 100%;
    display: block;
    border-spacing: 0;
    font-size: 13px;
  }

  .dashboard-table thead {
    display: none;
  }

  .dashboard-table tbody {
    display: grid;
    gap: 8px;
    padding: 0 8px 10px;
  }

  .dashboard-table tr {
    display: grid;
    grid-template-columns: 1fr;
    overflow: hidden;
    border: 1px solid #d9e3e2;
    border-radius: 8px;
    background: #fff;
  }

  .dashboard-table tbody th {
    width: auto;
    min-width: 0;
    max-width: none;
    padding: 10px 11px 8px;
    border-right: 0;
    background: #f4faf8;
    color: #0f6556;
    font-size: 14px;
  }

  .dashboard-table td {
    min-width: 0;
    height: auto;
    display: grid;
    grid-template-columns: 70px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-right: 0;
    text-align: right;
  }

  .dashboard-table td::before {
    content: attr(data-label);
    color: #61707d;
    font-size: 12px;
    font-weight: 700;
    text-align: left;
  }

  .dashboard-bar {
    min-height: 26px;
  }

  .dashboard-bar span {
    font-weight: 720;
  }
}
