:root {
  color-scheme: light;
  --ink: #152842;
  --muted: #566a83;
  --blue: #205acb;
  --blue-dark: #1649b0;
  --blue-pale: #eaf2ff;
  --line: #d9e3ef;
  --header: #edf3fb;
  --sidebar: 46px;
  --col-header: 31px;
  font: 16px/1.4 "SimSun", "宋体", "Songti SC", "STSong", "Noto Serif CJK SC", "Noto Serif SC", serif;
  color: var(--ink);
  background: #fff;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  min-height: 34px;
  padding: 5px 12px;
  font-size: .875rem;
  cursor: pointer;
  white-space: nowrap;
}
button:hover { background: var(--blue-pale); border-color: #b9cef1; }
button:disabled { color: #8090a5; cursor: default; opacity: .64; }
button:disabled:hover { background: #fff; border-color: var(--line); }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid #3575e6;
  outline-offset: 1px;
}
button.primary { color: #fff; background: var(--blue); border-color: var(--blue); font-weight: 650; }
button.primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
input:not([type=checkbox]):not([type=radio]):not([type=file]), textarea, select {
  min-width: 0;
  border: 1px solid #ccd9e9;
  border-radius: 5px;
  background-color: #fff;
  padding: 5px 8px;
}
select {
  appearance: none;
  background: linear-gradient(45deg, transparent 50%, #5d718b 50%) calc(100% - 13px) 53% / 5px 5px no-repeat,
    linear-gradient(135deg, #5d718b 50%, transparent 50%) calc(100% - 8px) 53% / 5px 5px no-repeat;
  padding-right: 26px;
}
input:is([type=checkbox], [type=radio]) { accent-color: var(--blue); width: 16px; height: 16px; margin: 0; }

#workspace { height: 100dvh; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; min-height: 60px; flex: none; align-items: center; justify-content: space-between;
  gap: 12px; padding: 8px 18px; border-bottom: 1px solid var(--line);
}
.identity, .top-actions { display: flex; align-items: center; gap: 8px; min-width: 0; }
.identity { gap: 10px; }
.brand {
  flex: none; display: grid; grid-template-columns: repeat(2, 7px); grid-template-rows: repeat(2, 7px);
  gap: 2px; justify-content: center; align-content: center; height: 30px; width: 30px;
  border-radius: 7px; background: var(--blue);
}
.brand i { background: #fff; border-radius: 1px; }
.brand i:nth-child(4) { opacity: .6; }
.identity #template-name {
  font-size: 1.1rem; font-weight: 750; letter-spacing: .01em; width: clamp(135px, 21vw, 270px);
  background: transparent; border-color: transparent; padding: 3px 4px;
}
.identity #template-name:hover, .identity #template-name:focus { border-color: #b9cef1; }
.save-status {
  display: flex; align-items: center; gap: 7px; white-space: nowrap; font-size: .75rem; color: var(--muted);
  border-left: 1px solid var(--line); padding-left: 9px;
}
.save-state[data-saved="true"] { color: #187552; }
.save-status time { font-variant-numeric: tabular-nums; }
.toolbar {
  display: flex; align-items: center; min-height: 43px; gap: 6px; padding: 4px 12px;
  background: #f7faff; border-bottom: 1px solid var(--line); overflow-x: auto;
}
.tool-group { display: flex; gap: 2px; align-items: center; padding-right: 6px; border-right: 1px solid var(--line); }
.tool-group:last-child { padding-right: 0; border-right: 0; }
.tool {
  min-height: 32px; border-color: transparent; background: transparent;
  border-radius: 5px; display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px;
}
.tool[aria-pressed="true"] { color: var(--blue); border-color: #b9cff6; background: var(--blue-pale); }
.icon-tool { min-width: 34px; justify-content: center; font-size: 1.3rem; line-height: 1; }
.strong-tool { font-weight: bold; font-size: 1rem; }
.fill-tool { display: flex; align-items: center; }
.fill-swatch { flex: none; width: 14px; height: 14px; border: 1px solid #8babc9; border-radius: 2px; }
.fill-tool .fill-options { padding-inline: 5px; }
.fill-tool .fill-options::after { margin-inline: 3px; }
#font-size { min-width: 60px; justify-content: space-between; }
.tool-pop::after, .in-cell-chevron { content: ""; width: 6px; height: 6px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); margin: -3px 1px 0 4px; }
.formula-bar { height: 41px; display: flex; align-items: center; gap: 8px; padding: 5px 12px; border-bottom: 1px solid var(--line); }
.formula-bar input { height: 30px; font-size: .875rem; }
.formula-bar #address { width: 110px; }
.formula-bar #formula { flex: 1 1 auto; }
.formula-symbol { color: #647b97; font-size: 1.1rem; font-style: italic; margin-inline: 3px; }
.trial-banner {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 5px 17px;
  background: #eff6ff; border-bottom: 1px solid #c8daf5; font-size: .875rem;
}
.trial-label { color: var(--blue-dark); font-weight: 700; }
.trial-banner button { margin-left: auto; }

.viewport { flex: 1 1 auto; overflow: auto; position: relative; scrollbar-color: #b7c6d8 #f2f6fb; }
.sheet { position: relative; outline: 0; user-select: none; background: #fff; }
.column-heads { position: sticky; top: 0; height: var(--col-header); z-index: 6; background: var(--header); }
.row-heads { position: sticky; left: 0; width: var(--sidebar); height: 0; z-index: 5; }
.col-head, .row-head, .corner {
  position: absolute; display: grid; place-items: center; background: var(--header);
  color: #3c5675; font-size: .8125rem; border-right: 1px solid #cfdbea; border-bottom: 1px solid #cfdbea;
}
.col-head { height: var(--col-header); top: 0; }
.row-head { width: var(--sidebar); left: 0; }
.corner {
  position: sticky; left: 0; top: 0; width: var(--sidebar); height: var(--col-header); z-index: 2;
  place-items: end; padding: 0 7px 6px 0;
}
.corner::before { content: ""; border: 6px solid transparent; border-right-color: #a9bfd8; border-bottom-color: #a9bfd8; }
.col-head.selected, .row-head.selected { background: #dceaff; color: #1d4fa6; font-weight: 700; }
.resize-grip { position: absolute; z-index: 1; touch-action: none; }
.col-head .resize-grip { right: -3px; top: 0; bottom: 0; width: 7px; cursor: col-resize; }
.row-head .resize-grip { bottom: -3px; left: 0; right: 0; height: 7px; cursor: row-resize; }
.resize-grip:hover { background: #7caaf4; }
.grid-cells { position: absolute; top: var(--col-header); left: var(--sidebar); }
.detail-outline { position: absolute; z-index: 2; pointer-events: none; border: 2px dashed #4281c8; }
.detail-tools {
  position: absolute; z-index: 2; display: flex; align-items: center; justify-content: flex-end;
  gap: 6px; padding: 3px 5px; border: 1px solid #a7c4e8; background: #f6faff;
}
.detail-tools button { min-height: 26px; padding: 1px 8px; }
.detail-tools .add-detail { color: var(--blue-dark); font-weight: 650; }
.grid-row { display: contents; }
.cell {
  position: absolute; display: flex; align-items: center; overflow: hidden;
  border-right: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 3px 7px; background: #fff; cursor: cell; font-size: 12pt;
}
.cell.selected-cell { background-image: linear-gradient(#246bd514, #246bd514); }
.cell-text { display: block; width: 100%; white-space: pre; overflow: hidden; text-overflow: ellipsis; }
.cell.wrap .cell-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.cell.content-border { border: 1px solid #6683a6; }
.cell.content-border.field-border { border-color: #8fb6e2; }
.cell.field-cell { padding: 3px 5px; }
.cell[data-detail-selection] { justify-content: center; }
.cell[data-detail-selection] input { cursor: pointer; }
.binding-highlight {
  position: absolute; z-index: 4; pointer-events: none;
  border: 2px solid #ffbf57; background: #ffcb6f24;
}
.sheet.picking-position .cell { cursor: crosshair; }
.selection {
  position: absolute; z-index: 4; pointer-events: none;
  border: 2px solid #2161d7; box-shadow: inset 0 0 0 1px #ffffff75;
}
.selection::after {
  content: ""; position: absolute; right: -3px; bottom: -3px; width: 6px; height: 6px; background: #2161d7;
}
.inline-editor {
  position: absolute; z-index: 7; resize: none; box-shadow: inset 0 0 0 1px #2161d7;
}
.field-chrome {
  pointer-events: none; display: flex; align-items: center; gap: 5px; min-width: 0;
  min-height: 23px; width: 100%; border: 1px solid #d7e3f2; border-radius: 4px;
  background: #fff; padding: 1px 6px; color: inherit; font-size: inherit;
}
.field-chrome .cell-text { flex: 1; }
.field-chrome:not(.is-default):not(.files-chip) .cell-text { opacity: .7; }
.field-chrome .in-cell-chevron { flex: none; margin-right: 4px; }
.field-chrome.files-chip { width: auto; color: var(--blue-dark); border-color: #c4d7f6; }
.trial-mode .cell { cursor: default; }
.trial-field { display: flex; align-items: center; gap: 6px; min-width: 0; width: 100%; font-size: inherit; }
.trial-field > input, .trial-field > select { min-width: 0; width: 100%; height: 25px; text-align: inherit; padding-top: 1px !important; padding-bottom: 1px !important; }
.trial-mode .trial-field > input[type="date"] { padding-inline: 4px; }
.trial-field > input[type="date"]::-webkit-calendar-picker-indicator { margin-inline-start: 0; }
.trial-field button { min-height: 24px; height: 25px; padding: 0 7px; color: var(--blue-dark); font-size: inherit; }
.trial-field button:first-of-type:only-of-type { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.cell.choice-cell { padding: 4px 5px; gap: 6px; }
.choice-list { display: flex; flex: 1; min-width: 0; flex-wrap: wrap; gap: 3px 10px; line-height: 1.25; }
.choice-option { display: inline-flex; align-items: flex-start; min-width: 0; max-width: 100%; gap: 4px; }
.choice-option > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.choice-option > input, .choice-marker { flex: none; width: 14px; height: 14px; margin-top: .16em; }
.choice-other { display: flex; flex: 1 0 100%; min-width: 0; align-items: start; gap: 4px; }
.choice-other > .choice-option { flex: none; padding-block: 2px; }
.choice-other-text {
  flex: 1; min-width: 0; min-height: 24px; padding: 1px 4px;
  font: inherit; overflow-wrap: anywhere; border: 1px solid var(--line); border-radius: 4px;
}
.choice-other > input.choice-other-text[type="text"] { height: 24px; padding: 1px 4px; }
.choice-marker { display: inline-grid; place-items: center; border: 1px solid #6683a6; border-radius: 2px; }
.choice-marker.radio { border-radius: 50%; }
.choice-marker.radio.checked::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #2159aa; }
.choice-marker.checkbox.checked::after { content: ""; width: 4px; height: 8px; border: solid #2159aa; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.cell.choice-measure { position: fixed; left: 0; top: 0; height: auto; visibility: hidden; pointer-events: none; }
.required-mark { color: #b42c3a; font-weight: 700; flex: none; }
.print-cell:not(.choice-cell) .required-mark { margin-left: 4px; }
.statusbar {
  display: flex; align-items: center; gap: 14px; height: 35px; flex: none;
  background: #f4f8fd; border-top: 1px solid var(--line); padding-inline: 13px; color: var(--muted); font-size: .8125rem;
}
.sheet-tab { border-radius: 4px; padding: 3px 10px; background: #fff; border: 1px solid #d4e0ef; color: var(--blue-dark); font-weight: 650; }
.selection-status { font-variant-numeric: tabular-nums; }
.shortcuts { margin-left: auto; }

.popup {
  position: fixed; max-height: calc(100dvh - 16px); overflow: auto; z-index: 20;
  width: max-content; min-width: 145px; max-width: calc(100vw - 16px);
  padding: 5px; border: 1px solid #cedaea; border-radius: 8px; background: #fff;
  box-shadow: 0 10px 25px #15284226, 0 2px 5px #15284212;
}
.popup.menu { min-width: 164px; }
.popup.submenu { min-width: 164px; }
.popup .menu-item {
  display: block; width: 100%; text-align: left; background: transparent; border-color: transparent;
  min-height: 32px; padding-inline: 9px;
}
.popup .menu-item:hover, .popup .menu-item:focus-visible { background: var(--blue-pale); }
.popup .submenu-trigger { display: flex; align-items: center; justify-content: space-between; }
.submenu-chevron { color: var(--muted); margin-left: 10px; }
.submenu-trigger[aria-expanded="true"] { background: var(--blue-pale); }
.popup .fill-choice { display: flex; align-items: center; gap: 8px; }
.popup .fill-choice[aria-pressed="true"] { background: var(--blue-pale); border-color: #bfd3ef; }
.menu-divider { height: 1px; background: var(--line); margin: 4px 5px; }
.popup.form-popup { width: min(334px, calc(100vw - 16px)); padding: 13px; }
.popup-header { display: flex; align-items: center; gap: 8px; justify-content: space-between; margin-bottom: 8px; font-weight: 700; }
.popup-header small { color: var(--muted); font-size: .8125rem; font-weight: 400; margin-left: auto; }
.field-popup-header { gap: 6px; margin-bottom: 0; font-size: 1rem; }
.field-popup-header > span { white-space: nowrap; }
.field-popup-header small { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field-popup-header .close-icon, .field-popup-actions { flex: none; }
.field-popup-actions { display: flex; gap: 6px; }
.field-popup-actions button { min-height: 29px; padding: 3px 8px; }
.popup-form { display: grid; gap: 9px; font-size: .875rem; }
.popup-form label:not(.check-line, .choice-option) { display: grid; gap: 3px; }
.popup-form textarea { min-height: 58px; resize: vertical; }
.cell-address-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: end; }
.cell-address-row button { min-height: 32px; padding: 3px 7px; }
.choice-defaults { display: grid; gap: 4px; }
.choice-defaults .choice-list { max-height: 124px; overflow: auto; }
.check-line { display: flex; align-items: center; gap: 7px; }
.requirement { padding: 2px 0 0; border: 0; margin: 0; display: flex; gap: 18px; }
.requirement legend { padding: 0; }
.form-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.popup-form .danger-lite { justify-self: start; color: #a63a35; }
.form-error { min-height: 0; color: #a63038; font-size: .8125rem; }
.palette { display: grid; grid-template-columns: repeat(5, 28px); gap: 5px; padding: 6px; }
.palette button { border: 1px solid #bfcee0; width: 28px; min-height: 26px; height: 26px; padding: 0; }
.palette button:hover { outline: 2px solid #3265bf; }
.file-popup { width: min(400px, calc(100vw - 16px)); padding: 9px; }
.file-list { display: grid; gap: 4px; }
.file-row { display: flex; align-items: center; gap: 5px; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: .8125rem; }
.file-row span { margin-right: auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row button { padding-inline: 5px; min-height: 27px; font-size: .8125rem; }
.toast {
  position: fixed; z-index: 30; bottom: 50px; left: 50%; transform: translateX(-50%);
  max-width: min(520px, 92vw); background: #193151; color: #fff; border-radius: 7px;
  padding: 9px 15px; font-size: .875rem; box-shadow: 0 4px 16px #14284034;
}

dialog { color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 0; }
dialog::backdrop { background: #15284255; }
.templates-dialog, .screenshot-dialog { width: min(500px, 92vw); max-height: 80vh; padding: 16px; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.screenshot-dialog p { margin: 10px 0; font-size: .875rem; color: var(--muted); }
.screenshot-dialog input { width: 100%; }
.screenshot-list { margin: 10px 0 0; padding: 0 0 0 25px; max-height: 34vh; overflow: auto; }
.screenshot-list li { padding: 5px 0; }
.screenshot-entry { display: flex; align-items: center; gap: 4px; }
.screenshot-entry span { min-width: 0; margin-right: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.screenshot-entry button { padding: 0 5px; min-height: 26px; font-size: .8125rem; }
.screenshot-dialog .screenshot-status[data-error="true"] { color: #a82625; }
.screenshot-actions { display: flex; justify-content: flex-end; gap: 6px; }
dialog h1 { font-size: 1.15rem; margin: 0; }
.close-icon { height: 29px; min-height: 29px; width: 29px; padding: 0; font-size: 1.125rem; line-height: 1; }
.search-input { width: 100%; margin-bottom: 8px; }
.saved-templates { max-height: 55vh; overflow: auto; }
.saved-template { display: flex; width: 100%; justify-content: space-between; gap: 10px; margin-top: 5px; }
.saved-template strong { max-width: 65%; overflow: hidden; text-overflow: ellipsis; }
.saved-template span, .empty { color: var(--muted); }
.empty { margin: 12px 0 4px; font-size: .875rem; }
.print-dialog { width: min(1320px, 96vw); height: min(900px, 92vh); max-width: none; max-height: none; overflow: hidden; }
.print-dialog[open] { display: flex; flex-direction: column; }
.standalone-print #workspace, .standalone-print #detach-print { display: none; }
.standalone-print .print-dialog[open] {
  position: fixed; inset: 0; width: 100%; height: 100%; margin: 0; border: 0; border-radius: 0;
}
.print-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); flex: none; }
.print-controls label { display: flex; align-items: center; gap: 5px; font-size: .875rem; }
.print-title { flex: 1 1 155px; min-width: 140px; }
#print-metadata { color: var(--muted); font-size: .8125rem; }
#print-connection { display: block; color: var(--muted); font-size: .8125rem; }
.print-zoom { display: flex; flex: none; gap: 4px; align-items: center; font-size: .875rem; }
#print-zoom-value { min-width: 39px; text-align: center; font-variant-numeric: tabular-nums; }
.print-zoom button { padding-inline: 8px; }
.print-view { background: #e9eff6; flex: 1 1 auto; min-height: 0; overflow: auto; scrollbar-gutter: stable; padding: 14px; }
.print-view.can-pan { cursor: grab; }
.print-view.is-panning { cursor: grabbing; user-select: none; }
.print-message { width: fit-content; max-width: 100%; margin: 0 auto 10px; padding: 6px 10px; border-radius: 5px; background: #fff5df; color: #754813; font-size: .875rem; }
.print-pages { display: flex; flex-direction: column; align-items: center; gap: 18px; width: max-content; min-width: 100%; }
.page-shell { position: relative; flex: none; width: 0; height: 0; overflow: hidden; box-shadow: 0 3px 15px #172e4f25; }
.physical-page { position: relative; background: #fff; overflow: hidden; transform-origin: top left; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
.page-body { position: absolute; transform-origin: top left; }
.print-cell { position: absolute; display: flex; align-items: center; overflow: hidden; padding: 2px 6px; border: 0 solid #6683a6; cursor: inherit; }
.print-cell.content-border { border-width: 1px; }
.page-number { position: absolute; right: 12mm; bottom: 7mm; color: #50617a; font-size: 11px; }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; padding: 6px 9px; }
  .top-actions { flex-wrap: wrap; gap: 4px; }
  .top-actions button { padding-inline: 7px; }
  .statusbar { padding-inline: 6px; gap: 6px; }
  .shortcuts { display: none; }
}

@media print {
  html, body { width: auto; height: auto; margin: 0; padding: 0; background: #fff; }
  #workspace, #popup, #toast, #templates-dialog, #screenshot-dialog, .print-controls, .print-message { display: none !important; }
  #print-dialog[open], .standalone-print #print-dialog[open] { display: block; position: static; width: auto; height: auto; border: 0; border-radius: 0; margin: 0; overflow: visible; }
  #print-dialog::backdrop { display: none; }
  .print-view, .print-pages { display: block; background: #fff; padding: 0; margin: 0; overflow: visible; }
  .print-pages { width: auto; min-width: 0; }
  .page-shell {
    box-shadow: none; width: var(--physical-width) !important; height: var(--physical-height) !important;
    break-inside: avoid; break-after: page; page-break-after: always;
  }
  .page-shell:last-child { break-after: auto; page-break-after: auto; }
  .physical-page { transform: none !important; }
}
