:root {
  color-scheme: light;
  --bg: #f4f6f7;
  --surface: #ffffff;
  --surface-soft: #eef2f1;
  --ink: #17201f;
  --muted: #66716f;
  --border: #d8dfdd;
  --accent: #13795b;
  --accent-dark: #0c5c43;
  --accent-soft: #e7f3ee;
  --blue: #4169a5;
  --danger: #a23f3f;
  --shadow: 0 12px 28px rgba(25, 41, 37, 0.07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0;
}

button, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }

.app-header {
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
}

.header-inner, .app-main, footer {
  width: min(1180px, calc(100% - 40px));
  margin-inline: auto;
}

.header-inner {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand-block { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px; height: 40px; display: grid; place-items: center;
  background: var(--ink); color: white; border-radius: 7px; font-weight: 750; font-size: 20px;
}
.brand-block h1 { margin: 0; font-size: 19px; line-height: 1.2; }
.brand-block p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.engine-status {
  display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.engine-status.offline .status-dot { background: var(--danger); }

.app-main {
  display: grid;
  grid-template-columns: minmax(0, 0.88fr) minmax(0, 1.12fr);
  gap: 18px;
  padding-block: 28px 48px;
}

.workspace, .editor, .summary {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
}
.summary { grid-column: 1 / -1; }

.section-heading {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px;
}
.step-label { display: block; color: var(--accent); font-size: 11px; font-weight: 750; margin-bottom: 5px; }
.section-heading h2 { margin: 0; font-size: 20px; line-height: 1.25; }
.privacy-note { margin: 3px 0 0; color: var(--muted); font-size: 12px; text-align: right; }

.upload-zone {
  min-height: 204px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1.5px dashed #aebbb7;
  border-radius: 8px;
  background: var(--surface-soft);
  text-align: center;
  transition: border-color 150ms ease, background 150ms ease;
  cursor: pointer;
}
.upload-zone:hover, .upload-zone.dragging { border-color: var(--accent); background: var(--accent-soft); }
.upload-symbol {
  width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--border);
  border-radius: 50%; background: var(--surface); color: var(--accent); font-size: 24px; margin-bottom: 12px;
}
.upload-title { font-size: 16px; font-weight: 700; }
.upload-copy { color: var(--muted); font-size: 12px; margin-top: 4px; }

.file-list { display: grid; gap: 8px; margin-top: 12px; }
.file-item {
  min-height: 54px; display: grid; grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center; gap: 10px; padding: 7px 8px; border: 1px solid var(--border); border-radius: 6px;
}
.file-thumb { width: 42px; height: 42px; object-fit: cover; border-radius: 4px; background: var(--surface-soft); }
.file-info { min-width: 0; }
.file-name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; font-weight: 650; }
.file-state { color: var(--muted); font-size: 11px; }
.file-state.success { color: var(--accent); }
.file-state.error { color: var(--danger); }
.remove-file {
  width: 32px; height: 32px; border: 0; background: transparent; color: var(--muted); font-size: 20px;
}
.remove-file:hover { color: var(--danger); }

.text-button, .secondary-button, .primary-button {
  border-radius: 6px; min-height: 40px; padding: 0 15px; font-weight: 650;
}
.text-button { border: 0; background: transparent; color: var(--blue); min-height: 28px; padding: 0; }
.text-button.danger { color: var(--danger); }
.secondary-button { border: 1px solid var(--border); background: var(--surface); color: var(--ink); }
.primary-button { width: 100%; border: 0; background: var(--accent); color: white; }
.primary-button:hover { background: var(--accent-dark); }

form label { position: relative; display: block; color: var(--muted); font-size: 12px; font-weight: 650; }
input {
  width: 100%; height: 43px; margin-top: 6px; padding: 0 34px 0 11px;
  border: 1px solid var(--border); border-radius: 5px; background: white; color: var(--ink); outline: none;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(19, 121, 91, 0.11); }
input.field-low { border-color: #bd8a43; background: #fffaf0; }
.input-suffix { position: absolute; right: 11px; bottom: 11px; color: var(--muted); font-weight: 500; }

.identity-grid { display: grid; grid-template-columns: 1fr 1fr 0.8fr; gap: 10px; }
.dimension-header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 24px 0 10px; }
.dimension-header h3 { margin: 0; font-size: 14px; }
.dimension-header span { color: var(--muted); font-size: 11px; }
.dimension-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.totals-band {
  display: grid; grid-template-columns: 1fr 1fr; margin: 20px 0 14px;
  border: 1px solid var(--border); border-radius: 6px; overflow: hidden;
}
.totals-band > div { padding: 14px 16px; background: var(--surface-soft); }
.totals-band > div + div { border-left: 1px solid var(--border); background: var(--ink); color: white; }
.totals-band span { display: block; font-size: 11px; color: var(--muted); }
.totals-band > div + div span { color: #b9c4c1; }
.totals-band strong { display: block; font-size: 26px; margin-top: 2px; line-height: 1.2; }
.form-message { min-height: 22px; color: var(--muted); font-size: 12px; }
.form-message.error { color: var(--danger); }
.form-message.success { color: var(--accent); }

.summary-heading { align-items: center; }
.count {
  display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 7px;
  border-radius: 12px; background: var(--surface-soft); color: var(--muted); font-size: 12px; vertical-align: 2px;
}
.data-status { display: flex; align-items: center; gap: 6px; min-height: 20px; margin-top: 5px; color: var(--muted); font-size: 11px; }
.data-status-dot { width: 7px; height: 7px; border-radius: 50%; background: #bd8a43; }
.data-status.connected .data-status-dot { background: var(--accent); }
.data-status.error .data-status-dot { background: var(--danger); }
.summary-actions { display: flex; align-items: center; gap: 16px; }
.summary-actions[hidden], .access-panel[hidden], .access-unlocked[hidden], #summaryContent[hidden] { display: none; }
.access-panel {
  min-height: 150px; display: grid; place-content: center; justify-items: center;
  border-top: 1px solid var(--border); text-align: center;
}
.access-copy { display: grid; gap: 3px; margin-bottom: 14px; }
.access-copy strong { font-size: 15px; }
.access-copy span { color: var(--muted); font-size: 12px; }
.access-form { display: grid; grid-template-columns: minmax(180px, 260px) 100px; gap: 8px; }
.access-form input { height: 40px; margin: 0; padding-right: 11px; }
.access-form .primary-button { min-height: 40px; }
.access-message { min-height: 20px; margin-top: 7px; color: var(--muted); font-size: 12px; }
.access-message.error { color: var(--danger); }
.access-unlocked {
  min-height: 45px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 0; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px;
}
.access-unlocked strong { color: var(--ink); font-size: 14px; margin-left: 4px; }
.empty-state { min-height: 138px; display: grid; place-content: center; text-align: center; border-top: 1px solid var(--border); }
.empty-state[hidden] { display: none; }
.empty-state span { font-weight: 700; }
.empty-state p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.table-wrap { max-width: 100%; overflow-x: auto; border-top: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; white-space: nowrap; font-size: 13px; }
th, td { padding: 13px 10px; text-align: right; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 11px; font-weight: 650; }
th:first-child, td:first-child { text-align: left; padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
.member-name { font-weight: 700; }
.member-alliance { display: block; color: var(--muted); font-size: 11px; font-weight: 400; }
.rank {
  display: inline-grid; place-items: center; min-width: 24px; height: 24px; margin-right: 8px;
  border-radius: 4px; background: var(--surface-soft); color: var(--muted); font-size: 11px; font-weight: 750;
}
.row-delete { width: 28px; height: 28px; border: 0; background: transparent; color: var(--muted); font-size: 18px; }
.row-delete:hover { color: var(--danger); }

footer { padding-bottom: 26px; color: var(--muted); font-size: 11px; text-align: center; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 840px) {
  .app-main { grid-template-columns: 1fr; }
  .summary { grid-column: auto; }
}

@media (max-width: 560px) {
  .header-inner, .app-main, footer { width: min(100% - 24px, 1180px); }
  .header-inner { min-height: 68px; }
  .brand-block p { display: none; }
  .app-main { padding-top: 16px; gap: 12px; }
  .workspace, .editor, .summary { padding: 17px; }
  .privacy-note { display: none; }
  .upload-zone { min-height: 170px; }
  .identity-grid { grid-template-columns: 1fr 1fr; }
  .identity-grid label:last-child { grid-column: 1 / -1; }
  .dimension-grid { grid-template-columns: 1fr 1fr; }
  .dimension-header { align-items: flex-end; }
  .dimension-header span { max-width: 150px; text-align: right; }
  .summary-heading { align-items: flex-start; }
  .summary-actions { gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
  .access-form { grid-template-columns: minmax(0, 1fr) 96px; width: min(100%, 340px); }
  .secondary-button { min-height: 36px; padding: 0 10px; }
  .totals-band strong { font-size: 23px; }
}

@media (max-width: 360px) {
  .engine-status span:last-child { display: none; }
  .dimension-grid { grid-template-columns: 1fr; }
}
