:root {
  --bg: #f4f7f8;
  --panel: #ffffff;
  --panel-soft: #eef3f4;
  --line: #d8e1e4;
  --text: #17202a;
  --muted: #61707d;
  --primary: #0f766e;
  --primary-dark: #0b5e58;
  --danger: #b42318;
  --blue: #2557a7;
  --selection: #2563eb;
  --shadow: 0 18px 48px rgba(23, 32, 42, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
  overflow: hidden;
}

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

button {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--text);
  padding: 0 8px;
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  border-color: #adc0c5;
  background: #f9fbfb;
}

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

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

button.danger {
  color: var(--danger);
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 4px 7px;
}

.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  height: 100%;
}

.app-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 6px 10px 0;
  background: #17202a;
  color: #eef6f6;
  border-bottom: 1px solid #24313d;
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  padding-bottom: 6px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}

.brand-title {
  display: none;
  font-size: 15px;
  font-weight: 700;
}

.db-path {
  display: none;
  max-width: 320px;
  margin-top: 3px;
  color: #adc0c5;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabs {
  display: flex;
  align-items: end;
  gap: 4px;
  min-width: 0;
  overflow-x: auto;
  padding-top: 8px;
}

.tab-button {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 124px;
  height: 32px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: #24313d;
  color: #d7e3e5;
  padding: 0 7px;
  cursor: pointer;
}

.tab-title,
.subtab-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-edit,
.subtab-edit {
  margin-left: auto;
  min-width: 24px;
  width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
}

.inline-rename-input {
  flex: 1 1 auto;
  min-width: 70px;
  height: 24px;
  padding: 2px 5px;
}

.tab-button.active {
  background: var(--bg);
  color: var(--text);
}

.tab-count {
  min-width: 28px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.16);
  color: inherit;
  padding: 3px 8px;
  font-size: 12px;
  text-align: center;
}

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

.topbar {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

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

h1 {
  font-size: 18px;
}

h2 {
  font-size: 20px;
}

.topline {
  color: var(--muted);
  margin-top: 4px;
  font-size: 13px;
}

.rename-bar,
.toolbar,
.template-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.subtab-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 6px 12px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.subtabs {
  display: flex;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
}

.subtab-button {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 132px;
  height: 30px;
  border-radius: 7px;
  background: #eef3f4;
  cursor: pointer;
}

.subtab-button.active {
  border-color: var(--primary);
  background: #e8f3f2;
  color: #0b5e58;
  font-weight: 700;
}

.toolbar {
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
  overflow-x: auto;
}

.toolbar button {
  flex: 0 0 auto;
}

.mode-panel {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(260px, 420px);
  gap: 12px;
  align-items: center;
  padding: 6px 12px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.mode-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.qr-check {
  display: none;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.qr-check.visible {
  display: grid;
}

.filterbar {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) auto minmax(150px, 180px) minmax(136px, 190px) minmax(136px, 190px) minmax(150px, 220px) auto;
  gap: 8px;
  align-items: center;
  padding: 6px 12px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.bulk-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 4px;
  min-width: 0;
}

.bulk-control button {
  width: 34px;
  min-width: 34px;
  padding: 0;
}

.search-wrap {
  position: relative;
}

.search-wrap input {
  padding-left: 32px;
}

.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.checkbox-line input {
  width: 16px;
}

.summary-strip {
  display: none;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 8px 12px;
}

.summary-tile {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
}

.summary-value {
  font-size: 16px;
  font-weight: 700;
}

.summary-label {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.table-shell {
  position: relative;
  min-height: 0;
  min-width: 0;
  padding: 0 12px 12px;
}

.selection-line {
  height: 22px;
  color: var(--muted);
  font-size: 13px;
}

.table-scroll {
  width: 100%;
  min-width: 0;
  height: calc(100% - 22px);
  overflow: scroll;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.data-grid {
  table-layout: fixed;
  width: max-content;
  min-width: max-content;
  border-collapse: separate;
  border-spacing: 0;
}

thead {
  position: sticky;
  top: 0;
  z-index: 3;
}

th,
td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid #edf2f3;
  padding: 1px 2px;
  text-align: left;
  vertical-align: top;
  font-size: 12px;
  line-height: 1.2;
  background: #fff;
}

th {
  background: var(--panel-soft);
  color: #42525e;
  font-weight: 700;
}

.excel-col-header {
  background: #e7edf1;
  border-bottom: 2px solid #9fb0ba;
  border-right-color: #c8d4da;
  text-align: center;
  vertical-align: middle;
}

.asset-row {
  --row-bg: #fff;
  --row-hover-bg: #f8fbfb;
  --row-accent: transparent;
}

.asset-row td {
  background: var(--row-bg);
}

.asset-row:hover td {
  background: var(--row-hover-bg);
}

.asset-row.color-yellow {
  --row-bg: #fbf0cf;
  --row-hover-bg: #f5e4b6;
  --row-accent: #b7791f;
}

.asset-row.color-green {
  --row-bg: #dfeee7;
  --row-hover-bg: #cce4d8;
  --row-accent: #2f855a;
}

.asset-row.color-red {
  --row-bg: #f5dfdf;
  --row-hover-bg: #edcccc;
  --row-accent: #c2413b;
}

.asset-row.color-blue {
  --row-bg: #dfe8f4;
  --row-hover-bg: #cbd9eb;
  --row-accent: #3568a8;
}

.asset-row td:first-child {
  box-shadow: inset 3px 0 0 var(--row-accent);
}

.asset-row.qr-hit td {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.asset-row.row-match td {
  outline: 1px solid rgba(183, 121, 31, 0.42);
  outline-offset: -1px;
}

.select-col {
  min-width: 28px;
  width: 28px;
}

.meta-toggle-col {
  min-width: 28px;
  width: 28px;
  text-align: center;
  background: var(--row-bg, var(--panel-soft));
}

.meta-collapse-toggle {
  width: 18px;
  min-width: 18px;
  height: 18px;
  min-height: 18px;
  padding: 0;
  border-radius: 5px;
  line-height: 1;
}

.data-grid.meta-collapsed .row-num-col,
.data-grid.meta-collapsed .status-col,
.data-grid.meta-collapsed .color-col,
.data-grid.meta-collapsed .tags-col,
.data-grid.meta-collapsed .notes-col,
.data-grid.meta-collapsed .qr-code-col,
.data-grid.meta-collapsed .qr-check-col {
  display: none;
}

.row-num-col {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 42px;
  width: 42px;
  background: var(--row-bg, var(--panel-soft));
}

.id-col {
  min-width: 76px;
  width: 76px;
}

.status-col {
  min-width: 96px;
  width: 96px;
}

.color-col {
  min-width: 72px;
  width: 72px;
}

.tags-col {
  min-width: 110px;
  width: 110px;
}

.notes-col {
  min-width: 130px;
  width: 130px;
}

.qr-code-col {
  min-width: 160px;
  width: 210px;
  overflow-wrap: anywhere;
}

.qr-check-col {
  min-width: 110px;
  width: 130px;
}

.date-col {
  min-width: 150px;
}

.data-col {
  position: relative;
  min-width: 44px;
  width: 76px;
  max-width: none;
}

.data-col-group {
  height: 22px;
  border-color: #b8c4ca;
  background: #f7fafa;
  color: #111827;
  text-align: center;
  white-space: normal;
}

.leaf-col {
  height: 52px;
  border-color: #b8c4ca;
}

.service-col {
  min-height: 52px;
  white-space: normal;
  text-align: center;
}

.column-name-input {
  width: 100%;
  min-width: 0;
  min-height: 28px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  padding: 1px 28px 20px 4px;
  font-weight: 700;
  text-align: center;
  line-height: 1.1;
  overflow: hidden;
  resize: none;
  white-space: normal;
}

.excel-column-name {
  font-size: 12px;
  min-height: 28px;
  padding-top: 0;
  padding-bottom: 0;
}

.column-name-input[readonly] {
  cursor: default;
}

.column-edit-button {
  position: absolute;
  top: 2px;
  right: 10px;
  z-index: 2;
  width: 20px;
  min-width: 20px;
  height: 20px;
  min-height: 20px;
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 12px;
  opacity: 0.72;
}

.column-edit-button:hover {
  background: #eef3f4;
  opacity: 1;
}

.service-resizable-col {
  position: relative;
  padding: 4px 48px 20px 6px;
}

.column-tools {
  position: absolute;
  right: 10px;
  bottom: 3px;
  display: flex;
  gap: 2px;
}

.service-tools {
  bottom: 3px;
}

.column-tool-button {
  width: 20px;
  min-width: 20px;
  height: 20px;
  min-height: 20px;
  border-radius: 4px;
  padding: 0;
  font-size: 12px;
  line-height: 1;
}

.column-tool-button.active {
  border-color: var(--primary);
  background: #dff1ef;
  color: var(--primary-dark);
}

.selected-col-header,
.selected-row-header {
  background: #dbeafe !important;
  color: #1d4ed8;
}

.column-name-input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  text-align: left;
}

.row-check {
  width: 12px;
  height: 12px;
}

.inline-select,
.inline-input {
  min-width: 100%;
  height: 24px;
  padding: 2px 4px;
}

.editable-cell {
  min-width: 172px;
  min-height: 30px;
  max-width: 340px;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 5px 6px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.grid-cell-editor {
  min-width: 100%;
  min-height: 22px;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 2px 3px;
  white-space: pre-wrap;
  overflow: visible;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.meta-select {
  min-width: 100%;
  height: 24px;
  border-radius: 3px;
  background: var(--row-bg, #fff);
  padding: 0 3px;
  font-size: 12px;
}

.meta-cell-editor {
  min-width: 100%;
  min-height: 22px;
  border: 1px solid transparent;
  border-radius: 3px;
  padding: 0 3px;
  background: transparent;
  white-space: pre-wrap;
  overflow: visible;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.meta-cell-editor:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
}

.data-cell,
.service-cell {
  user-select: none;
}

.data-cell.selected-cell,
.service-cell.selected-cell {
  background: var(--row-bg);
  box-shadow: inset 0 0 0 2px var(--selection);
}

.data-cell.selected-cell .grid-cell-editor,
.service-cell.selected-cell .meta-select,
.service-cell.selected-cell .meta-cell-editor,
.service-cell.selected-cell .meta-pill {
  background: transparent;
}

.data-cell.active-cell {
  position: relative;
  z-index: 1;
  box-shadow: inset 0 0 0 2px var(--selection);
}

.data-cell.active-cell::after {
  content: "";
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 6px;
  height: 6px;
  background: var(--selection);
}

.data-cell.selected-cell .grid-cell-editor:focus {
  background: #fff;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 22px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 4px;
  background: #fff;
  color: #42525e;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta-pill.qr-ok {
  border-color: #16a34a;
  background: #dcfce7;
  color: #166534;
}

.meta-pill.qr-wait {
  border-color: #cbd5e1;
  background: #f8fafc;
  color: #475569;
}

.column-toggle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 6px;
  margin-top: 10px;
  max-height: 280px;
  overflow: auto;
}

.column-size-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 76px auto;
  align-items: center;
  gap: 6px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 5px 7px;
  color: #42525e;
  font-size: 12px;
}

.column-size-row input[type="checkbox"] {
  width: 15px;
  height: 15px;
}

.column-size-row input[type="number"] {
  height: 26px;
  min-width: 0;
  padding: 2px 5px;
}

.column-size-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.column-size-row small {
  color: var(--muted);
}

.doc-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
}

.doc-preview-grid {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.doc-modal-panel {
  width: min(980px, 97vw);
  min-width: min(760px, 94vw);
  min-height: min(560px, 88vh);
}

.doc-modal-body {
  min-height: 0;
  overflow: auto;
  padding: 14px 18px;
}

.doc-type-row {
  min-height: 34px;
}

.doc-type-row.active {
  border-color: var(--primary);
  background: #e8f4f2;
}

.doc-preview-choice {
  margin-left: auto;
  width: 28px;
  min-width: 28px;
  padding: 0;
}

.template-note {
  color: var(--muted);
  font-size: 12px;
}

.doc-row-matrix {
  display: grid;
  grid-template-columns: 54px minmax(180px, 1fr) 86px 70px;
  gap: 0;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  max-height: 360px;
}

.doc-row-matrix > div,
.doc-row-check {
  min-height: 30px;
  border-right: 1px solid #eef3f4;
  border-bottom: 1px solid #eef3f4;
  padding: 6px 8px;
  font-size: 12px;
}

.doc-row-head {
  background: var(--panel-soft);
  color: #42525e;
  font-weight: 700;
}

.doc-row-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-row-check {
  display: grid;
  place-items: center;
}

.doc-row-check input {
  width: 15px;
  height: 15px;
}

.document-preview-pane {
  max-height: 320px;
  overflow: auto;
}

.word-preview-panel {
  width: min(900px, 96vw);
  min-width: min(720px, 94vw);
  min-height: min(620px, 90vh);
}

.word-preview-content {
  min-height: 0;
  overflow: auto;
  padding: 18px;
  background: #e9eef1;
}

.word-page {
  width: min(680px, 100%);
  min-height: 880px;
  margin: 0 auto;
  border: 1px solid #d8dde2;
  background: #fff;
  box-shadow: 0 12px 32px rgba(23, 32, 42, 0.14);
  padding: 64px 58px;
  color: #111827;
  font-family: "Times New Roman", Times, serif;
  font-size: 14px;
  line-height: 1.45;
}

.word-page-title {
  margin: 0 0 18px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  text-transform: uppercase;
}

.word-page-subtitle {
  margin-bottom: 22px;
  color: #6b7280;
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 12px;
  text-align: center;
}

.word-page p {
  margin: 0 0 12px;
  white-space: pre-wrap;
}

.word-doc-paragraph {
  margin: 0 0 8px;
  white-space: pre-wrap;
}

.word-doc-paragraph.empty {
  margin-bottom: 6px;
}

.word-doc-paragraph.center {
  text-align: center;
}

.word-doc-paragraph.right {
  text-align: right;
}

.word-doc-table {
  width: 100%;
  margin: 0 0 10px;
  border-collapse: collapse;
  table-layout: fixed;
}

.word-doc-table td {
  border: 1px solid #d1d5db;
  padding: 4px 6px;
  vertical-align: top;
  white-space: pre-wrap;
  word-break: break-word;
}

.scanner-status {
  padding: 0 18px 14px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.scanner-status a {
  color: var(--primary);
}

.doc-preview-line {
  border-bottom: 1px solid #eef3f4;
  padding: 6px 0;
  font-size: 13px;
  line-height: 1.35;
  white-space: pre-wrap;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 5px 7px;
  color: #42525e;
  font-size: 12px;
}

.check-row input {
  width: 15px;
  height: 15px;
}

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

.col-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
}

.col-resizer:hover {
  background: rgba(15, 118, 110, 0.22);
}

.column-filter-menu {
  display: none;
  position: fixed;
  z-index: 60;
  width: 250px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 10px;
}

.column-filter-menu.open {
  display: block;
}

.filter-menu-title {
  margin-bottom: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.filter-menu-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.filter-menu-actions button {
  flex: 1 1 0;
}

.grid-cell-editor:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
}

.grid-cell-editor.readonly {
  background: #f8fbfb;
  color: #34414c;
}

.editable-cell:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
}

.grid-cell-editor mark {
  background: #ffdf6b;
  color: inherit;
  padding: 0 1px;
}

.empty-state {
  display: none;
  position: absolute;
  inset: 60px 18px 18px;
  place-items: center;
  text-align: center;
  border: 1px dashed #b5c5ca;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.empty-title {
  font-size: 20px;
  font-weight: 700;
}

.empty-note {
  margin-top: 6px;
  color: var(--muted);
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(23, 32, 42, 0.36);
}

.modal.open {
  display: block;
}

.modal-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(640px, 94vw);
  max-height: min(760px, 92vh);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.modal-panel.wide {
  width: min(940px, 96vw);
}

.resizable-panel {
  resize: both;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  cursor: move;
}

.modal-header button,
.modal-header input,
.modal-header select,
.modal-header textarea {
  cursor: auto;
}

.modal-kicker {
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.icon-button {
  width: 36px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.field-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin: 14px 0 6px;
}

.modal-field-label {
  padding: 0 18px;
}

#importContent,
#columnsContent,
#docFields {
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.preview-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-width: 0;
}

.import-sheet-list {
  display: grid;
  gap: 12px;
}

.import-sheet-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.import-sheet-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 12px;
  align-items: end;
}

.import-sheet-header strong,
.import-sheet-header span {
  display: block;
}

.import-sheet-header span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.import-sheet-header label span {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.import-header-setting {
  display: grid;
  grid-template-columns: minmax(220px, 340px) minmax(0, 1fr);
  gap: 10px;
  align-items: end;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fbfb;
}

.import-header-setting label span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.import-header-setting small {
  color: var(--muted);
  font-size: 12px;
}

.import-sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.import-column-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
  gap: 6px;
  max-height: 210px;
  overflow: auto;
  margin-top: 10px;
  padding-right: 2px;
}

.import-column-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 2px 6px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fbfb;
  padding: 6px;
  font-size: 12px;
}

.import-column-card.selected {
  border-color: var(--primary);
  background: #e7f5f3;
}

.import-column-card input {
  width: 15px;
  height: 15px;
  grid-row: 1 / span 2;
}

.import-column-card span {
  min-width: 0;
  font-weight: 700;
}

.import-column-card small {
  min-width: 0;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-live-summary {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.import-table-preview {
  max-height: 390px;
  overflow: auto;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.import-table-caption {
  padding: 8px 10px 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.import-source-preview,
.import-result-preview {
  overflow: auto;
  border-top: 1px solid var(--line);
}

.import-source-preview {
  max-height: 260px;
}

.import-result-preview {
  max-height: 190px;
  border-bottom: 1px solid var(--line);
}

.import-table-preview table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.import-table-preview th,
.import-table-preview td {
  max-width: 220px;
  padding: 4px 6px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.import-table-preview th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #e7edf1;
}

.import-header-label-input {
  width: 100%;
  min-width: 132px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: #f8fbfb;
  padding: 4px 6px;
  color: var(--text);
  font: inherit;
  font-weight: 700;
}

.import-header-label-input:focus {
  border-color: var(--primary);
  background: #fff;
  outline: none;
}

.import-source-table th:nth-child(-n + 3),
.import-source-table td:nth-child(-n + 3) {
  position: sticky;
  z-index: 2;
  text-align: center;
  background: #fff;
}

.import-source-table th:nth-child(1),
.import-source-table td:nth-child(1) {
  left: 0;
  min-width: 58px;
}

.import-source-table th:nth-child(2),
.import-source-table td:nth-child(2) {
  left: 58px;
  min-width: 86px;
}

.import-source-table th:nth-child(3),
.import-source-table td:nth-child(3) {
  left: 144px;
  min-width: 84px;
}

.import-source-table th:nth-child(-n + 3) {
  z-index: 3;
  background: #dfe8ed;
}

.import-source-table input[type='checkbox'] {
  width: 15px;
  height: 15px;
}

.import-row-muted {
  color: #6f7c83;
  background: #f2f5f6;
}

.import-row-header-source {
  color: #164c5a;
  background: #dff2ef;
  font-weight: 700;
}

.import-row-muted td,
.import-row-muted td:nth-child(-n + 3) {
  background: #f2f5f6;
}

.import-row-header-source td,
.import-row-header-source td:nth-child(-n + 3) {
  background: #dff2ef;
}

.empty-import-preview {
  padding: 12px;
  color: var(--danger);
  font-size: 13px;
}

.preview-title {
  font-weight: 700;
  margin-bottom: 8px;
}

.sheet-row,
.mini-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  border-bottom: 1px solid #eef3f4;
  font-size: 13px;
}

.sheet-row small {
  flex: 1 0 100%;
  color: var(--muted);
}

.sheet-row:last-child,
.mini-row:last-child {
  border-bottom: 0;
}

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

.check-list.compact {
  max-height: min(54vh, 520px);
}

.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.check-item input {
  width: 16px;
}

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

.form-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 18px;
}

.printer-settings {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 18px 18px 0;
}

.form-row span,
.printer-settings span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.template-line {
  padding: 18px 18px 0;
}

.selected-template {
  color: var(--muted);
  font-size: 12px;
  padding: 8px 18px 0;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(12px);
  z-index: 40;
  max-width: min(720px, 92vw);
  border-radius: 8px;
  background: #17202a;
  color: #fff;
  padding: 12px 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

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

@media (max-width: 1120px) {
  .app-header,
  .topbar,
  .mode-panel,
  .filterbar {
    grid-template-columns: 1fr;
  }

  .tabs,
  .subtabs,
  .toolbar,
  .rename-bar {
    justify-content: flex-start;
  }
}

@media (max-width: 720px) {
  .summary-strip,
  .form-row,
  .printer-settings,
  .preview-grid {
    grid-template-columns: 1fr;
  }
}
