:root {
  color-scheme: light;
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-strong: #f9faf8;
  --line: #d9ded8;
  --text: #17201b;
  --muted: #647067;
  --accent: #256f5b;
  --accent-dark: #1f5e4d;
  --blue: #3268a8;
  --red: #b94545;
  --amber: #8a650c;
  --green-soft: #dff1e4;
  --blue-soft: #e8f0fa;
  --red-soft: #f6dddd;
  --yellow-soft: #fff2c6;
  --gray-soft: #ecefec;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--accent-dark);
}

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

button,
a.link-button,
.file-line {
  min-height: 38px;
}

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.badge {
  min-width: 18px;
  min-height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-size: 12px;
  line-height: 18px;
}

.trend-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.trend-up {
  color: #9f1f1f;
  background: var(--red-soft);
}

.trend-down {
  color: #1f5e4d;
  background: var(--green-soft);
}

.trend-flat {
  color: var(--muted);
  background: var(--gray-soft);
}

.ai-report-rendered {
  display: grid;
  gap: 10px;
  max-height: 520px;
  overflow: auto;
  white-space: normal;
}

.ai-report-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

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

.ai-report-card p {
  margin: 6px 0;
  line-height: 1.6;
  color: var(--text);
}

.metric-hot {
  color: var(--red);
  font-weight: 800;
}

.risk-hot {
  color: var(--amber);
  font-weight: 800;
}

.auth-body {
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(37, 111, 91, 0.08), rgba(37, 111, 91, 0)),
    var(--bg);
}

.auth-shell {
  width: min(460px, 100%);
}

.auth-panel {
  display: grid;
  gap: 18px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 45px rgba(23, 32, 27, 0.08);
}

.auth-brand {
  align-items: flex-start;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.auth-form input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: var(--accent);
  border-radius: 8px;
  flex: 0 0 auto;
}

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

.brand h1 {
  font-size: 20px;
  line-height: 1.2;
}

.brand p,
.panel p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.workspace {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
  max-width: 1580px;
  margin: 0 auto;
  overflow-x: hidden;
}

.side-panel,
.main-panel {
  display: grid;
  gap: 18px;
  align-content: start;
  min-width: 0;
}

.side-panel {
  position: sticky;
  top: 18px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  min-width: 0;
}

.page {
  display: none;
}

.page.active {
  display: grid;
  gap: 18px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-header.compact {
  margin-bottom: 12px;
}

.panel h2 {
  font-size: 18px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  min-height: 28px;
  padding: 3px 10px;
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--green-soft);
  font-size: 13px;
  white-space: nowrap;
}

.pill.warning {
  color: #765c13;
  background: var(--yellow-soft);
}

.file-line,
.primary-button,
.ghost-button,
.nav-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 12px;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

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

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

.ghost-button,
.file-line,
.nav-item {
  color: var(--text);
  background: var(--surface-strong);
  border-color: var(--line);
}

.ghost-button:hover,
.file-line:hover,
.nav-item:hover {
  border-color: var(--accent);
}

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

.nav-item {
  justify-content: flex-start;
  width: 100%;
}

.nav-item.active {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

.primary-button:disabled,
.ghost-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.primary-button.is-loading,
.ghost-button.is-loading,
.danger-action-button.is-loading {
  pointer-events: none;
}

.button-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  animation: hpdm-spin 0.7s linear infinite;
}

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

.full {
  width: 100%;
  margin-top: 10px;
}

.file-line {
  width: 100%;
}

.file-line input,
.dropzone input {
  display: none;
}

.message {
  min-height: 22px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.message.error {
  color: var(--red);
}

.message.success {
  color: var(--accent-dark);
}

.hint,
.help-box {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-strong);
  font-size: 13px;
  line-height: 1.5;
}

.hint.warning {
  color: var(--amber);
  background: var(--yellow-soft);
  border-color: #dec164;
}

.hint.success {
  color: var(--accent-dark);
  background: var(--green-soft);
  border-color: #a8d5b5;
}

.hint-list {
  display: grid;
  gap: 8px;
  margin: 10px 0;
}

.help-box summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 700;
}

.wide-hint {
  grid-column: 1 / -1;
}

.message.inline {
  margin-top: 0;
  align-self: center;
  min-width: 180px;
  overflow-wrap: anywhere;
}

.mini-table-wrap,
.table-wrap,
.file-table-wrap {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.table-wrap:not(.mini-table-wrap),
.file-table-wrap,
.data-table-shell {
  max-height: var(--table-visible-height, min(58vh, 620px));
  min-height: 90px;
  position: relative;
  background: var(--surface);
  scrollbar-gutter: stable both-edges;
  contain: paint;
}

.panel > .data-table-shell,
.panel .data-table-shell {
  min-height: 92px;
}

.table-scroll-top {
  max-width: 100%;
  height: 18px;
  margin: 10px 0 0;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: var(--surface-strong);
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  position: sticky;
  top: var(--table-scroll-sticky-top, 72px);
  z-index: 18;
}

.table-scroll-top + .table-wrap,
.table-scroll-top + .file-table-wrap {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.table-scroll-spacer {
  height: 1px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

.data-table {
  min-width: max(1040px, 100%);
  table-layout: auto;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

th {
  color: var(--muted);
  background: var(--surface-strong);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.data-table-shell th {
  position: sticky;
  top: 0;
  z-index: 3;
  box-shadow: 0 1px 0 var(--line);
}

.data-table td {
  min-width: 96px;
}

.data-table .id-cell {
  min-width: 132px;
  white-space: nowrap;
}

.data-table .metric-cell {
  min-width: 118px;
  white-space: nowrap;
  text-align: right;
}

.data-table .analysis-cell {
  min-width: 240px;
  max-width: 360px;
  white-space: normal;
}

.download-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 280px;
}

.download-actions .link-button,
.download-actions button {
  min-height: 32px;
}

.file-download-name {
  display: inline-block;
  max-width: 360px;
  overflow-wrap: anywhere;
}

.data-table .sticky-action {
  position: sticky;
  right: 0;
  z-index: 1;
  background: var(--surface);
}

.floating-table-scrollbar {
  position: fixed;
  bottom: max(12px, env(safe-area-inset-bottom));
  height: 20px;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid #b8c2bc;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 28px rgba(23, 32, 27, 0.18);
  z-index: 900;
  scrollbar-gutter: stable;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.floating-table-scrollbar.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.floating-table-scrollbar[hidden] {
  display: none !important;
}

.floating-table-scrollbar-spacer {
  height: 1px;
}

tr:last-child td {
  border-bottom: 0;
}

.mini-table td,
.mini-table th {
  padding: 8px 10px;
  font-size: 12px;
}

.dropzone {
  min-height: 150px;
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 22px;
  border: 1px dashed #93a29a;
  border-radius: 8px;
  background: #fbfcfb;
  cursor: pointer;
}

.dropzone.dragging {
  border-color: var(--accent);
  background: #eef7f2;
}

.drop-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  color: var(--blue);
  background: var(--blue-soft);
  border-radius: 8px;
}

.drop-title {
  font-weight: 700;
}

.drop-meta {
  color: var(--muted);
  font-size: 13px;
}

.import-dropzone {
  margin-top: 12px;
  min-height: 132px;
}

.import-queue {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.import-queue-header,
.import-queue-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto minmax(180px, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.import-queue-header {
  grid-template-columns: 1fr auto;
}

.queue-message {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.import-status-done {
  border-color: #a8d5b5;
  background: var(--green-soft);
}

.import-status-needs_review {
  border-color: #dec164;
  background: var(--yellow-soft);
}

.import-status-failed {
  border-color: #e0aaaa;
  background: var(--red-soft);
}

.small-button {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  align-items: end;
}

.filter-grid label,
.wide-label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

input[type="date"],
input[type="month"],
input[type="text"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%;
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
}

input[type="date"],
input[type="month"] {
  cursor: pointer;
}

textarea {
  resize: vertical;
}

.compact-input,
.unmatched-table select {
  width: 132px;
  min-height: 32px;
  padding: 5px 8px;
}

.wide-input {
  width: 220px;
}

.goal-edit-input {
  width: 118px;
  min-width: 96px;
}

.goal-remark-input {
  width: 180px;
}

.goal-target-stack {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 190px;
  white-space: nowrap;
}

.goal-save-button {
  min-width: 82px;
}

.settings-table input,
.settings-table textarea,
.settings-table select {
  min-width: 118px;
}

.settings-table .settings-textarea {
  width: 180px;
  min-height: 74px;
  white-space: pre-wrap;
}

.option-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: -4px 0 14px;
}

.toggle-line {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  color: var(--text);
  font-size: 14px;
}

.inline-toggle {
  align-self: end;
  padding-bottom: 1px;
}

.history-toggle {
  padding: 0 4px;
  white-space: nowrap;
}

.toggle-line input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.toolbar,
.result-actions,
.top-actions,
.row-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.row-actions .small-button {
  min-height: 32px;
  padding: 6px 9px;
}

.toolbar {
  margin-top: 14px;
}

.file-table-wrap,
.stack {
  margin-top: 14px;
}

.file-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.icon-button {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--muted);
  cursor: pointer;
}

.icon-button:hover {
  color: var(--red);
  border-color: var(--red);
}

.danger-button:hover {
  background: var(--red-soft);
}

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

.danger-action-button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid var(--red);
  border-radius: 6px;
  color: #ffffff;
  background: var(--red);
  cursor: pointer;
  white-space: normal;
}

.danger-action-button:disabled {
  border-color: var(--line);
  color: var(--muted);
  background: var(--gray-soft);
  cursor: not-allowed;
}

.muted-action {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.row-muted {
  color: var(--muted);
  background: var(--surface-strong);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--gray-soft);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.status-success {
  color: var(--accent-dark);
  background: var(--green-soft);
}

.status-partial,
.status-partial_success,
.status-importing {
  color: var(--amber);
  background: var(--yellow-soft);
}

.status-failed,
.status-deleted {
  color: var(--red);
  background: var(--red-soft);
}

.status-unread {
  color: var(--accent-dark);
  background: var(--green-soft);
}

.status-read,
.status-local_fallback {
  color: var(--muted);
  background: var(--gray-soft);
}

.app-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 32, 27, 0.34);
}

.app-modal {
  width: min(440px, 100%);
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(23, 32, 27, 0.18);
}

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

.app-modal-detail {
  width: min(920px, 100%);
  max-height: min(88vh, 820px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.app-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.app-modal h3 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.app-modal p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.modal-input {
  width: 100%;
}

.modal-textarea {
  min-height: 150px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.5;
}

.app-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-detail-body {
  display: grid;
  gap: 12px;
  min-height: 0;
  overflow: auto;
}

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

.detail-item {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.detail-item span {
  color: var(--muted);
  font-size: 12px;
}

.detail-item strong {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.modal-table-wrap {
  margin: 0;
}

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1200;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 36px));
}

.toast {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(23, 32, 27, 0.16);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.toast.success {
  color: var(--accent-dark);
  background: var(--green-soft);
  border-color: #a8d5b5;
}

.toast.error {
  color: var(--red);
  background: var(--red-soft);
  border-color: #e0a3a3;
}

.toast.leaving {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.portable-picker {
  width: min(420px, 100%);
}

.portable-picker-body {
  display: grid;
  gap: 8px;
}

.portable-picker-nav {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.portable-picker-nav .ghost-button {
  min-width: 0;
  padding: 8px;
}

.date-weekdays,
.date-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.date-weekdays {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.date-grid button,
.month-grid button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--text);
  cursor: pointer;
}

.date-grid button:hover,
.month-grid button:hover,
.date-grid button.active,
.month-grid button.active {
  color: #ffffff;
  border-color: var(--accent);
  background: var(--accent);
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.totals,
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.total-item,
.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-strong);
}

.total-item span,
.card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.total-item strong,
.card strong {
  display: block;
  margin-top: 5px;
  font-size: 18px;
  letter-spacing: 0;
}

.result-table .up,
.metric-up {
  color: #1d6b3a;
}

.result-table .down,
.metric-down {
  color: #a23b3b;
}

.risk-high {
  color: var(--red);
  font-weight: 700;
}

.risk-mid {
  color: var(--amber);
  font-weight: 700;
}

.muted {
  color: var(--muted);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 140px;
  max-width: 260px;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #eef7f3;
  color: var(--green-dark);
  font-size: 12px;
  line-height: 1.2;
  white-space: nowrap;
}

.user-level {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.user-level-s {
  background: #174f3b;
  color: #ffffff;
}

.user-level-a {
  background: #dff3ea;
  color: #14613f;
}

.user-level-b {
  background: #fff3cf;
  color: #7b4d00;
}

.user-level-c {
  background: #eef1f4;
  color: #45515d;
}

.action-text {
  min-width: 220px;
  max-width: 380px;
  line-height: 1.45;
  white-space: normal;
}

.sub-panel {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.sub-panel-header h3 {
  margin: 0;
  font-size: 15px;
}

.sub-panel-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.form-grid label,
.check-row {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.check-row {
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  min-height: 36px;
}

.check-row input {
  width: auto;
  min-height: auto;
  accent-color: var(--accent);
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 170px;
}

.permission-editor {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.permission-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.permission-group {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.permission-group legend {
  padding: 0 4px;
  font-weight: 700;
}

.permission-check {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  font-size: 13px;
}

.permission-check input {
  margin-top: 2px;
  accent-color: var(--accent);
}

.permission-check code {
  grid-column: 2;
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.match-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.match-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-strong);
}

.match-item.warning {
  border-color: #dec164;
  background: #fff9e2;
}

.match-item.error {
  border-color: #e1a0a0;
  background: #fff0f0;
}

.match-item h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.match-item p {
  margin: 3px 0;
  color: var(--muted);
  font-size: 13px;
}

.mapping-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.mapping-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.mapping-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-box {
  min-height: 260px;
  max-height: 520px;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--text);
  white-space: pre-wrap;
  line-height: 1.55;
}

svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
    gap: 12px;
  }

  .side-panel .panel {
    padding: 14px 18px;
  }

  .side-panel .panel-header.compact {
    margin-bottom: 8px;
  }

  .nav-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scroll-snap-type: x proximity;
  }

  .nav-item {
    flex: 0 0 auto;
    width: auto;
    min-width: max-content;
    scroll-snap-align: start;
  }
}

@media (max-width: 900px) {
  .panel-header,
  .result-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .toolbar > *,
  .result-actions > * {
    flex: 1 1 180px;
  }
}

@media (max-width: 640px) {
  .topbar {
    height: auto;
    align-items: flex-start;
    padding: 14px;
    flex-direction: column;
  }

  .workspace {
    padding: 12px;
    gap: 12px;
  }

  .panel {
    padding: 14px;
  }

  .side-panel {
    gap: 10px;
  }

  .side-panel .panel {
    padding: 12px;
  }

  .side-panel .panel:first-child .file-line,
  .side-panel .panel:first-child .primary-button.full {
    min-height: 40px;
    margin-top: 8px;
  }

  .side-panel .mini-table th,
  .side-panel .mini-table td {
    padding: 7px 10px;
  }

  .primary-button,
  .ghost-button,
  .link-button {
    width: 100%;
  }

  .toolbar > *,
  .result-actions > *,
  .top-actions > * {
    flex: 1 1 100%;
  }

  .mapping-item {
    grid-template-columns: 1fr;
  }

  .data-table td {
    min-width: 110px;
  }
}
