/* ══════════════════════════════════════════
   XLSX 条件求和 · 样式表
   ══════════════════════════════════════════ */

/* ── Reset & Variables ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --sidebar-w: 380px;
  --c-primary: #2563eb;
  --c-primary-hover: #1d4ed8;
  --c-primary-light: #eff6ff;
  --c-success: #16a34a;
  --c-success-hover: #15803d;
  --c-danger: #dc2626;
  --c-bg: #f1f5f9;
  --c-card: #ffffff;
  --c-border: #e2e8f0;
  --c-border-hover: #cbd5e1;
  --c-text: #1e293b;
  --c-text-secondary: #64748b;
  --c-text-muted: #94a3b8;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .05);
  --shadow: 0 1px 3px rgba(0, 0, 0, .1), 0 1px 2px rgba(0, 0, 0, .06);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, .08);
  --transition: 150ms ease;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
}

html,
body {
  height: 100%;
  font-family: var(--font);
  color: var(--c-text);
  background: var(--c-bg);
  font-size: 14px;
  line-height: 1.5;
}

[hidden] {
  display: none !important;
}

body {
  display: flex;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--c-card);
  border-right: 1px solid var(--c-border);
  z-index: 10;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--c-border);
}

.app-logo {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.sidebar-header h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -.01em;
  flex: 1;
}

.header-github-link {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: all var(--transition);
}

.header-github-link:hover {
  background: #f8fafc;
  border-color: var(--c-border);
}

.header-github-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
}

.sidebar-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--c-border) transparent;
}

.panel-execute-bottom {
  margin-top: auto;
  border-top: 1px solid var(--c-border);
}

/* ── Panel (sidebar section) ── */
.panel {
  padding: 14px 20px;
  border-bottom: 1px solid var(--c-border);
  animation: fadeIn .2s ease;
}

.panel[hidden] {
  display: none;
}

.panel-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--c-text-secondary);
  margin-bottom: 10px;
}

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

/* ── File display ── */
.file-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.file-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--c-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-name.loaded {
  color: var(--c-text);
  font-weight: 500;
}

/* ── Input ── */
.input {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  font-family: var(--font);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-card);
  color: var(--c-text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.input::placeholder {
  color: var(--c-text-muted);
}

.hint {
  font-size: 12px;
  color: var(--c-text-muted);
  margin-top: 6px;
  margin-bottom: 10px;
}

.logic-toggle {
  display: inline-flex;
  gap: 4px;
  border: 1px solid var(--c-border);
  background: #fff;
  border-radius: 999px;
  padding: 2px;
}

.logic-btn {
  border: none;
  background: transparent;
  color: var(--c-text-secondary);
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
  padding: 6px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
}

.logic-btn:hover:not(.active) {
  background: #f1f5f9;
  color: var(--c-text);
}

.logic-btn.active {
  background: #dbeafe;
  color: #1d4ed8;
}

/* ── Select small ── */
.select-sm {
  padding: 4px 8px;
  font-size: 12px;
  font-family: var(--font);
  border: 1px solid var(--c-border);
  border-radius: 4px;
  background: var(--c-card);
  color: var(--c-text);
  cursor: pointer;
}

.select-sm:focus {
  outline: none;
  border-color: var(--c-primary);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--c-primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--c-primary-hover);
}

.btn-success {
  background: var(--c-success);
  color: #fff;
}

.btn-success:hover:not(:disabled) {
  background: var(--c-success-hover);
}

.btn-outline {
  background: var(--c-card);
  color: var(--c-text);
  border: 1px solid var(--c-border);
}

.btn-outline:hover {
  border-color: var(--c-border-hover);
  background: #f8fafc;
}

.btn-ghost {
  background: none;
  color: var(--c-primary);
  padding: 6px 10px;
}

.btn-ghost:hover {
  background: var(--c-primary-light);
}

.btn-block {
  width: 100%;
}

.btn-lg {
  padding: 10px 24px;
  font-size: 15px;
  font-weight: 600;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

.btn-icon-img {
  width: 16px;
  height: 16px;
  object-fit: contain;
  flex-shrink: 0;
}

.btn-primary .btn-icon-img,
.btn-success .btn-icon-img {
  filter: brightness(0) invert(1);
}

.mobile-only {
  display: none;
}

.btn-icon {
  padding: 4px;
  border-radius: 4px;
  background: none;
  border: none;
  color: var(--c-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: all var(--transition);
}

.btn-icon:hover {
  color: #1d4ed8;
  background: #dbeafe;
}

/* ── Rules ── */
.rules-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.rules-empty {
  border: 1px dashed #cbd5e1;
  background: #f8fafc;
  color: #64748b;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
}

.btn-add-rule {
  margin-top: 8px;
  border-style: dashed;
  border-color: #93c5fd;
  color: #1d4ed8;
  background: #eff6ff;
}

.btn-add-rule:hover {
  border-style: solid;
  border-color: #2563eb;
  background: #dbeafe;
}

.btn-add-rule .btn-icon-img {
  filter: brightness(0) saturate(100%) invert(32%) sepia(90%) saturate(2450%) hue-rotate(213deg) brightness(95%) contrast(95%);
}

.btn-add-rule:hover .btn-icon-img {
  filter: brightness(0) saturate(100%) invert(27%) sepia(84%) saturate(2614%) hue-rotate(214deg) brightness(88%) contrast(101%);
}

.rule-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: #f8fafc;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  animation: slideIn .15s ease;
}

.rule-row:hover {
  border-color: #bfdbfe;
  box-shadow: 0 0 0 2px #eff6ff;
}

.rule-head {
  display: none;
}

.rule-content {
  min-width: 0;
  flex: 1;
}

.rule-title {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 2px;
}

.rule-summary {
  font-size: 13px;
  color: #1e293b;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rule-hit {
  font-size: 12px;
  color: #64748b;
  margin-top: 3px;
}

.hit-number {
  color: #2563eb;
  font-weight: 700;
  margin: 0 2px;
}

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

.rule-field-group,
.rule-cmp-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px;
  border: 1px solid var(--c-border);
  background: #fff;
  border-radius: 999px;
  flex-shrink: 0;
}

.opt-btn {
  border: none;
  background: transparent;
  color: var(--c-text-secondary);
  font-size: 12px;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.opt-btn.active {
  background: #dbeafe;
  color: #1d4ed8;
}

.rule-value {
  width: 100%;
  padding: 5px 8px;
  font-size: 12px;
  border: 1px solid var(--c-border);
  border-radius: 4px;
  font-family: var(--font);
  background: #fff;
  color: var(--c-text);
  appearance: none;
}

.rule-row .rule-value-wrap {
  flex: 1;
  min-width: 110px;
  display: flex;
  align-items: center;
}

.rule-row .btn-icon {
  flex-shrink: 0;
  background: transparent;
}

.rule-edit-btn:hover {
  color: #1d4ed8;
  background: #dbeafe;
}

.rule-delete-btn:hover {
  color: var(--c-danger);
  background: #fef2f2;
}

.inline-color-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px 2px 6px;
  border: 1px solid #dbe2ea;
  border-radius: 999px;
  background: #f8fafc;
  vertical-align: middle;
}

.inline-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, .2);
  flex-shrink: 0;
}

.inline-color-label {
  font-size: 12px;
  color: #334155;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.color-swatch-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.swatch-btn {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(15, 23, 42, .25);
  cursor: pointer;
  padding: 0;
}

.swatch-btn.active {
  box-shadow: 0 0 0 2px #2563eb;
}

.swatch-custom-btn {
  height: 22px;
  border: 1px dashed #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 12px;
  cursor: pointer;
}

.swatch-custom-btn.active {
  border-style: solid;
  background: #dbeafe;
}

.swatch-custom-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.formula-input-active {
  border-color: var(--c-primary) !important;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, .15) !important;
  background: #f0f6ff !important;
}

.rule-value:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, .12);
}

/* ══ Main area ══ */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ── Empty state ── */
.empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 60px 40px;
  border: 2px dashed var(--c-border);
  border-radius: 16px;
  max-width: 440px;
  width: 100%;
  margin: 24px;
  transition: all .25s ease;
}

.drop-zone.drag-over {
  border-color: var(--c-primary);
  background: var(--c-primary-light);
  transform: scale(1.01);
}

.drop-zone .drop-icon {
  color: var(--c-text-muted);
  margin-bottom: 20px;
}

.empty-file-icon {
  width: 64px;
  height: 64px;
  object-fit: contain;
  opacity: .55;
  filter: grayscale(1) brightness(1.75);
}

.drop-zone.drag-over .drop-icon {
  color: var(--c-primary);
}

.drop-zone h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--c-text);
}

.drop-zone p {
  font-size: 13px;
  color: var(--c-text-muted);
  margin-bottom: 14px;
  line-height: 1.6;
}

.feature-list {
  width: 100%;
  text-align: center;
  max-width: 360px;
  margin: 0 auto 16px;
  padding-left: 0;
  list-style-position: inside;
  color: var(--c-text-secondary);
  font-size: 13px;
  line-height: 1.8;
}

.feature-list li {
  margin-bottom: 2px;
}

.exclude-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.exclude-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.exclude-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
  border-radius: 14px;
  font-size: 12px;
}

.btn-outline.is-active {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1d4ed8;
}

.drop-hint {
  font-size: 12px;
  color: var(--c-text-muted);
  margin-top: 12px;
}

/* ── Preview state ── */
.preview-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.preview-state[hidden] {
  display: none;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--c-card);
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#btn-zoom-reset {
  min-width: 74px;
}

.preview-note {
  font-size: 12px;
  color: #94a3b8;
  padding: 0 8px;
  white-space: nowrap;
  align-self: center;
}

.row-info {
  font-size: 12px;
  color: var(--c-text-muted);
}

/* ── View tabs ── */
.view-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
}

.view-tab {
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--c-text-muted);
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
}

.view-tab:hover:not(.active) {
  background: #f1f5f9;
  color: var(--c-text);
}

.view-tab.active {
  background: var(--c-primary);
  color: #fff;
  border-color: var(--c-primary);
}

.view-tab.is-disabled {
  color: var(--c-text-muted);
  opacity: .6;
  cursor: not-allowed;
}

.view-tab.is-disabled:hover {
  background: none;
  color: var(--c-text-muted);
}

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

/* ── Sheet tabs ── */
.sheet-tabs {
  display: flex;
  gap: 0;
  padding: 0 16px;
  background: #f8fafc;
  border-bottom: 1px solid var(--c-border);
  overflow-x: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}

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

.sheet-tab {
  padding: 8px 18px;
  font-size: 13px;
  white-space: nowrap;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--c-text-muted);
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition);
}

.sheet-tab:hover:not(.active) {
  color: var(--c-text);
  background: #f1f5f9;
}

.sheet-tab.active {
  color: var(--c-primary);
  border-bottom-color: var(--c-primary);
  font-weight: 600;
}

/* ── Table ── */
.table-container {
  flex: 1;
  overflow: auto;
  position: relative;
  touch-action: pan-x pan-y pinch-zoom;
}

.table-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .7);
  z-index: 5;
}

.preview-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  touch-action: pan-x pan-y pinch-zoom;
}

.preview-table th,
.preview-table td {
  padding: 5px 14px;
  border: 1px solid var(--c-border);
  white-space: nowrap;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f0f3f7;
  font-weight: 600;
  text-align: center;
  font-size: 12px;
  color: var(--c-text-secondary);
  border-bottom: 2px solid var(--c-border);
}

.preview-table tbody td {
  text-align: right;
}

.preview-table tbody td.cell-text {
  text-align: left;
}

.preview-table td.manual-excluded {
  background: #fee2e2 !important;
  color: #991b1b !important;
  box-shadow: inset 0 0 0 1px #fca5a5;
  cursor: pointer;
}

.preview-table td.pickable-cell {
  cursor: pointer;
}

.preview-table td.calc-highlight {
  position: relative;
  box-shadow: inset 0 0 0 2px #2563eb;
  animation: calcFlow 1.1s linear infinite;
}

@keyframes calcFlow {
  0% {
    box-shadow: inset 0 0 0 2px #2563eb;
  }

  50% {
    box-shadow: inset 0 0 0 2px #60a5fa;
  }

  100% {
    box-shadow: inset 0 0 0 2px #2563eb;
  }
}

.preview-table .col-rownum {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #f8fafc;
  text-align: center;
  color: var(--c-text-muted);
  font-size: 12px;
  min-width: 46px;
  border-right: 2px solid var(--c-border);
}

.preview-table thead th.col-rownum {
  z-index: 4;
  left: 0;
  background: #eaecf1;
}

.preview-table .sum-row td {
  font-weight: 700;
  background: #fffde7 !important;
}

/* ── Loading overlay ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(255, 255, 255, .85);
  z-index: 100;
  backdrop-filter: blur(4px);
}

.loading-overlay[hidden] {
  display: none;
}

.loading-text {
  font-size: 14px;
  color: var(--c-text-secondary);
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .42);
  backdrop-filter: blur(4px);
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  width: min(520px, 100%);
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: fadeIn .15s ease;
}

.modal-card-lg {
  width: min(720px, 100%);
}

.modal-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--c-border);
}

.modal-head h3 {
  font-size: 16px;
  line-height: 1.2;
}

.modal-body {
  padding: 14px 16px;
}

.modal-actions {
  padding: 12px 16px;
  border-top: 1px solid var(--c-border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-rule-builder {
  margin-top: 8px;
  border: 1px solid var(--c-border);
  border-radius: 10px;
  background: #f8fafc;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-hit-preview {
  margin-top: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  color: #64748b;
}

.modal-section {
  border: 1px solid #dbe2ea;
  background: #fff;
  border-radius: 10px;
  padding: 8px;
}

.modal-row-title {
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
  margin-bottom: 6px;
}

.modal-rule-line {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  min-width: 0;
}

.modal-rule-line .rule-field-group,
.modal-rule-line .rule-cmp-group {
  flex-shrink: 0;
}

.modal-rule-line .rule-value-wrap {
  min-width: 130px;
  flex: 1;
}

.formula-chip-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.formula-chip {
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  cursor: pointer;
}

.formula-chip.active {
  border-color: #93c5fd;
  background: #dbeafe;
  color: #1d4ed8;
}

/* ── Spinner ── */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--c-border);
  border-top-color: var(--c-primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

.spinner.lg {
  width: 36px;
  height: 36px;
  border-width: 4px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  background: var(--c-text);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all .3s ease;
  z-index: 200;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: var(--c-danger);
}

.mobile-pane-tabs {
  display: none;
}

/* ── Responsive ── */
@media (max-width: 860px) {
  :root {
    --sidebar-w: 100%;
  }

  body {
    flex-direction: column;
    font-size: 15px;
    line-height: 1.65;
    overflow: hidden;
  }

  .sidebar {
    width: 100%;
    min-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-right: none;
    border-bottom: 1px solid var(--c-border);
    z-index: 8;
    display: flex;
    flex-direction: column;
  }

  .sidebar-header {
    min-height: 56px;
    flex-shrink: 0;
  }

  .sidebar-body {
    height: calc(100vh - 56px - 48px);
    max-height: calc(100vh - 56px - 48px);
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    padding-bottom: 0;
  }

  .main {
    height: calc(100vh - 56px - 48px);
    min-height: calc(100vh - 56px - 48px);
    display: none;
    overflow: hidden;
  }

  body.mobile-pane-preview .sidebar-body {
    display: none;
  }

  body.mobile-pane-preview .main {
    display: flex;
  }

  .rule-line {
    flex-wrap: nowrap;
  }

  .modal-rule-line {
    flex-wrap: wrap;
  }

  .panel {
    padding: 16px 18px;
  }

  .hint {
    line-height: 1.7;
  }

  .mobile-only {
    display: none;
  }

  .preview-toolbar {
    padding: 8px 10px;
    gap: 8px;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
  }

  .view-tabs {
    width: auto;
    flex: 1;
    min-width: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    order: 1;
    scrollbar-width: none;
  }

  .view-tabs::-webkit-scrollbar {
    display: none;
  }

  .view-tab {
    padding: 6px 12px;
    font-size: 12px;
  }

  .preview-note {
    display: none;
  }

  .toolbar-right {
    width: auto;
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: 8px;
    order: 2;
    flex: 0 0 auto;
    margin-left: 8px;
  }

  .zoom-controls {
    display: none;
  }

  .toolbar-right .row-info {
    order: 1;
    margin-left: 0;
    text-align: right;
    white-space: nowrap;
  }

  #btn-download {
    display: none !important;
  }

  .sheet-tabs {
    padding: 0 10px;
  }

  .preview-state {
    overflow: hidden;
    min-height: 0;
  }

  body.mobile-download-visible .preview-state {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }

  .table-container {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .preview-table th,
  .preview-table td {
    padding: 7px 10px;
    max-width: 220px;
  }

  .mobile-pane-tabs {
    position: relative;
    display: flex;
    gap: 8px;
    padding: 8px 10px;
    background: rgba(248, 250, 252, .96);
    border-bottom: 1px solid var(--c-border);
    z-index: 9;
    flex-shrink: 0;
  }

  .panel-execute-bottom {
    position: sticky;
    bottom: 0;
    z-index: 12;
    background: #fff;
    border-top: 1px solid var(--c-border);
    margin-top: auto;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }

  .panel-download-bottom {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 14;
    background: #fff;
    border-top: 1px solid var(--c-border);
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  }

  .pane-tab {
    flex: 1;
    border: 1px solid var(--c-border);
    background: #fff;
    color: var(--c-text-secondary);
    border-radius: 10px;
    padding: 9px 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
  }

  .pane-tab.active {
    border-color: #93c5fd;
    background: #dbeafe;
    color: #1d4ed8;
  }
}