:root {
  font-family: "Microsoft YaHei UI", "Segoe UI", sans-serif;
  color: #172127;
  background: #eef2f3;
  font-synthesis: none;
  --ink: #172127;
  --muted: #66747c;
  --line: #d4dde1;
  --soft-line: #e5ebee;
  --surface: #ffffff;
  --surface-soft: #f7f9fa;
  --header: #17313a;
  --teal: #087f8c;
  --teal-dark: #066771;
  --focus: #0b84a5;
  --danger: #b42318;
}

* { box-sizing: border-box; }

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

body { background: #eef2f3; }

button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

[hidden] { display: none !important; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #edf1f2;
}

.auth-panel {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 32px;
  box-shadow: 0 16px 40px rgba(22, 47, 56, 0.10);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--header);
  color: #fff;
  font-size: 21px;
  font-weight: 700;
  margin-bottom: 22px;
}

.auth-panel h1 { margin: 0; font-size: 24px; }
.auth-panel > p { margin: 10px 0 24px; color: var(--muted); line-height: 1.65; }
.auth-panel form { display: grid; gap: 16px; }
.auth-panel label { display: grid; gap: 7px; font-size: 14px; font-weight: 600; }

input, select {
  min-height: 38px;
  border: 1px solid #bcc9ce;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 7px 10px;
  outline: none;
}

input:focus, select:focus, button:focus-visible {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(11, 132, 165, 0.15);
  outline: none;
}

.form-error { min-height: 21px; margin: -4px 0 0; color: var(--danger); font-size: 13px; }

.button, .icon-button, .text-button {
  border: 1px solid #bac7cc;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  min-height: 36px;
}

.button { padding: 7px 13px; font-weight: 600; }
.button:hover, .icon-button:hover { background: #f2f6f7; }
.button.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.button.primary:hover { background: var(--teal-dark); }
.button.danger { border-color: #d9a8a3; color: var(--danger); }
.button.small { min-height: 32px; padding: 5px 9px; font-size: 13px; }
.button.wide { width: 100%; min-height: 42px; }
.button:disabled, .icon-button:disabled { cursor: not-allowed; opacity: 0.5; }

.icon-button {
  width: 38px;
  min-width: 38px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border-color: transparent;
}
.icon-button.bordered { border-color: #bac7cc; }
.icon-button svg, .search-box svg, .drop-icon svg { width: 20px; height: 20px; fill: currentColor; }
.text-button { min-height: 30px; border: 0; color: var(--teal); padding: 3px 6px; background: transparent; }

.app-shell { min-height: 100vh; }

.app-header {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px clamp(16px, 3vw, 34px);
  background: var(--header);
  color: #fff;
}

.app-header h1 { margin: 0; font-size: 22px; }
.app-header p { margin: 3px 0 0; color: #b9c9ce; font-size: 13px; }
.header-actions { display: flex; align-items: center; gap: 9px; }
.app-header .icon-button { color: #fff; background: transparent; border-color: #567078; }
.app-header .icon-button:hover { background: #28464f; }
.status-pill { border: 1px solid #567078; border-radius: 999px; padding: 5px 10px; color: #dce7e9; font-size: 13px; }

.workspace { padding: 14px clamp(12px, 2vw, 26px) 20px; }

.drop-zone {
  min-height: 70px;
  display: flex;
  align-items: center;
  gap: 13px;
  border: 1px dashed #6eabb5;
  border-radius: 6px;
  background: #e7f3f4;
  padding: 12px 18px;
  color: #235660;
  cursor: pointer;
}
.drop-zone.dragging { background: #d6ecef; border-color: var(--teal); }
.drop-zone strong, .drop-zone span { display: block; }
.drop-zone span { margin-top: 2px; color: #5b747a; font-size: 13px; }
.drop-icon { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; }
.drop-icon svg { width: 28px; height: 28px; }
.drop-actions { margin-left: auto; flex: 0 0 auto; }

.progress-area { margin: 10px 0 0; }
.progress-copy { display: flex; justify-content: space-between; margin-bottom: 5px; color: var(--muted); font-size: 13px; }
progress { width: 100%; height: 8px; border: 0; border-radius: 4px; overflow: hidden; background: #dbe4e7; }
progress::-webkit-progress-bar { background: #dbe4e7; }
progress::-webkit-progress-value { background: var(--teal); }

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 170px 210px 150px 38px;
  gap: 8px;
  margin: 12px 0;
}
.search-group { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }
.search-box { position: relative; }
.search-box svg { position: absolute; left: 10px; top: 9px; color: #708087; }
.search-box input { width: 100%; padding-left: 37px; }
.search-button { min-width: 64px; }

.data-layout {
  min-height: 360px;
  height: calc(100vh - 330px);
  display: grid;
  grid-template-columns: minmax(220px, 18%) minmax(0, 1fr);
  gap: 12px;
}

.bin-panel, .records-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.section-heading {
  min-height: 57px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--soft-line);
  padding: 9px 12px;
}
.section-heading h2 { margin: 0; font-size: 15px; }
.section-heading span { color: var(--muted); font-size: 12px; }
.bin-list-actions { padding: 8px 10px; border-bottom: 1px solid var(--soft-line); }
.bin-list-actions .button { width: 100%; }
.bin-list { position: relative; overflow: auto; flex: 1; contain: strict; }
.bin-virtual-surface { position: relative; min-height: 100%; }
.bin-row {
  position: absolute;
  inset: 0 0 auto;
  display: grid;
  grid-template-columns: 28px minmax(68px, 1fr) auto;
  align-items: center;
  gap: 7px;
  height: 38px;
  box-sizing: border-box;
  padding: 4px 10px;
  border-bottom: 1px solid #edf1f2;
  font-size: 13px;
}
.bin-row:hover { background: #f3f7f8; }
.bin-row input { min-height: auto; }
.bin-main strong, .bin-main span { display: block; }
.bin-main span { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bin-count { color: #46626a; font-variant-numeric: tabular-nums; }
.table-actions { display: flex; gap: 6px; }

.table-scroll { position: relative; overflow: auto; flex: 1; background: #fff; }
table { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
th, td { height: 35px; padding: 6px 9px; border-bottom: 1px solid #e7ecee; border-right: 1px solid #eef2f3; white-space: nowrap; text-align: center; }
th { position: sticky; top: 0; z-index: 2; background: #e9eef0; color: #31454c; font-weight: 700; }
th:nth-child(2), td:nth-child(2) { min-width: 154px; }
th:nth-child(5), td:nth-child(5) { min-width: 145px; }
th:nth-child(10), td:nth-child(10) { min-width: 170px; text-align: left; }
th:nth-child(13), td:nth-child(13) { min-width: 130px; text-align: left; }
tbody tr:hover { background: #f3f8f9; }
tbody tr.checked { background: #e7f3f5; }
td.invalid { color: var(--danger); }
.check-col { width: 42px; min-width: 42px; }
td input[type="checkbox"] { min-height: auto; }
.cell-text { user-select: text; cursor: text; }
.empty-state { position: absolute; inset: 44px 0 0; display: grid; place-items: center; color: var(--muted); }

.pager {
  min-height: 49px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 11px;
  border-top: 1px solid var(--soft-line);
  color: var(--muted);
  font-size: 13px;
}
.pager label { display: flex; align-items: center; gap: 6px; }
.pager select { min-height: 32px; padding: 4px 7px; }
.pager-buttons { display: flex; align-items: center; gap: 5px; }
.pager-buttons .icon-button { width: 32px; min-width: 32px; min-height: 32px; font-size: 20px; }
#pageLabel { min-width: 90px; text-align: center; }

.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 61px;
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
}
.export-controls { display: flex; align-items: center; gap: 7px; }

.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 20; display: grid; gap: 8px; width: min(380px, calc(100vw - 36px)); }
.toast { padding: 11px 13px; border-radius: 6px; background: #17313a; color: #fff; box-shadow: 0 8px 26px rgba(0, 0, 0, 0.2); font-size: 13px; }
.toast.error { background: #8f241c; }

@media (max-width: 980px) {
  .toolbar { grid-template-columns: minmax(230px, 1fr) 1fr 1fr; }
  .toolbar .icon-button { grid-column: 3; justify-self: end; }
  .data-layout { grid-template-columns: 190px minmax(0, 1fr); height: calc(100vh - 350px); }
  .action-bar { align-items: flex-start; flex-direction: column; }
  .export-controls { width: 100%; flex-wrap: wrap; }
}

@media (max-width: 700px) {
  .app-header { min-height: 68px; }
  .app-header h1 { font-size: 18px; }
  .status-pill { display: none; }
  .workspace { padding: 10px; }
  .drop-zone { min-height: 62px; padding: 9px 11px; }
  .toolbar { grid-template-columns: 1fr 1fr; }
  .search-group { grid-column: 1 / -1; }
  .toolbar .icon-button { grid-column: auto; justify-self: stretch; width: auto; }
  .data-layout { height: auto; min-height: 0; grid-template-columns: 1fr; }
  .bin-panel { max-height: 230px; }
  .records-panel { min-height: 520px; height: calc(100vh - 260px); }
  .records-heading { align-items: flex-start; }
  .table-actions { flex-wrap: wrap; justify-content: flex-end; }
  .pager { align-items: flex-start; flex-direction: column; }
  .pager-buttons { width: 100%; justify-content: space-between; }
  .action-bar { position: static; }
  .export-controls { display: grid; grid-template-columns: 1fr 1fr; }
  .export-controls select, .export-controls .danger { grid-column: 1 / -1; }
}
