:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1b1f24;
  --muted: #68717d;
  --line: #d9dee7;
  --accent: #1769aa;
  --accent-strong: #0f4f82;
  --danger: #b42318;
  --shadow: 0 8px 24px rgba(27, 31, 36, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #eef2f6;
}

.login-shell {
  width: min(420px, calc(100vw - 32px));
}

.login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-title {
  margin-bottom: 22px;
}

.login-title h1 {
  color: var(--text);
}

.login-title p {
  margin-top: 6px;
  color: var(--muted);
}

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

.login-status {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
}

.login-status.error {
  color: var(--danger);
}

.topbar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 22px 28px;
  background: #0f2438;
  color: #fff;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 700;
}

.topbar p {
  margin-top: 4px;
  color: #c9d5e2;
  font-size: 14px;
}

.status {
  min-width: 180px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #e6edf5;
  text-align: center;
  font-size: 13px;
}

.layout {
  width: calc(100vw - 32px);
  min-width: 0;
  margin: 20px auto 40px;
  display: grid;
  gap: 16px;
}

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

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 14px;
}

.section-title h2 {
  font-size: 18px;
  font-weight: 700;
}

.section-title span,
.hint {
  color: var(--muted);
  font-size: 13px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-size: 13px;
  font-weight: 600;
}

.wide {
  margin-top: 12px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #cfd6df;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 9px 10px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.12);
}

input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.14);
}

.calc-settings {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #edf0f4;
}

.upload-row,
.table-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

button,
.file-button,
.download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid transparent;
  padding: 8px 14px;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
}

.file-button input {
  display: none;
}

.primary,
.download {
  background: var(--accent);
  color: #fff;
}

.primary:hover,
.download:hover {
  background: var(--accent-strong);
}

.secondary,
.file-button {
  background: #eef5fb;
  color: var(--accent-strong);
  border-color: #bfd4e8;
}

.secondary.saved {
  background: #ecfdf3;
  color: #027a48;
  border-color: #75c59b;
}

.ghost {
  background: #fff;
  color: #394553;
  border-color: #cfd6df;
}

.file-name {
  max-width: 420px;
  color: #394553;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.draft-status {
  margin-top: 8px;
  color: #536170;
  font-size: 12px;
}

.draft-status.saved {
  color: #027a48;
  font-weight: 650;
}

.draft-status.error {
  color: var(--danger);
  font-weight: 650;
}

.usage-guide {
  margin-top: 14px;
  border: 1px solid #d8e3ef;
  background: #f8fbfe;
  display: grid;
  grid-template-columns: 92px 1fr;
  align-items: center;
}

.guide-title {
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid #d8e3ef;
  background: #eaf0f6;
  color: #24435e;
  font-size: 13px;
  font-weight: 700;
}

.guide-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 12px;
  color: #536170;
  font-size: 12px;
}

.guide-list span {
  white-space: nowrap;
}

.legal-footer {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 18px;
  border: 1px solid #ccd6e2;
  background: #f8fafc;
  color: #3d4854;
  box-shadow: none;
}

.legal-footer h2 {
  margin-bottom: 8px;
  color: #26313d;
  font-size: 15px;
}

.legal-footer p {
  color: #536170;
  font-size: 12px;
  line-height: 1.7;
}

.legal-footer p + p {
  margin-top: 8px;
}

.table-panel {
  padding-bottom: 8px;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  height: clamp(560px, 72vh, 820px);
  min-height: 560px;
}

table {
  width: 100%;
  min-width: 2120px;
  border-collapse: collapse;
  table-layout: fixed;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eaf0f6;
  border-bottom: 1px solid var(--line);
  color: #26313d;
  text-align: left;
  font-size: 13px;
  padding: 10px;
}

tbody td {
  border-bottom: 1px solid #edf0f4;
  padding: 6px;
  vertical-align: top;
}

tbody tr:hover {
  background: #f9fbfd;
}

.col-index {
  width: 54px;
}

.col-config {
  width: 380px;
}

.col-num {
  width: 108px;
}

.col-params {
  width: 820px;
}

.col-unit {
  width: 128px;
}

.col-amount {
  width: 140px;
}

.col-action {
  width: 56px;
}

.col-remark {
  width: 190px;
  min-width: 190px;
}

.col-status {
  width: 230px;
}

.row-index {
  color: #3d4854;
  font-variant-numeric: tabular-nums;
}

.amount {
  padding-right: 24px;
  color: #3d4854;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.calcStatus {
  width: 230px;
  min-width: 230px;
  padding-left: 24px;
  color: #1f7a3f;
  font-size: 13px;
}

.calcStatus.review {
  color: #b54708;
}

.breakdown {
  width: 198px;
  max-height: 118px;
  margin-top: 6px;
  overflow: auto;
  white-space: pre-wrap;
  color: #5f6b78;
  font-size: 12px;
  line-height: 1.45;
}

.config-cell {
  width: 380px;
}

.config {
  field-sizing: content;
  min-width: 360px;
  min-height: 132px;
  max-height: 320px;
  overflow-y: auto;
  resize: none;
  line-height: 1.45;
}

.remark-cell {
  width: 190px;
  min-width: 190px;
}

.remark {
  field-sizing: content;
  min-width: 172px;
  min-height: 88px;
  max-height: 220px;
  overflow-y: auto;
  resize: vertical;
  line-height: 1.45;
}

.params-cell {
  width: 820px;
  padding-right: 12px;
}

.param-grid {
  display: grid;
  grid-template-columns: 150px 340px 280px;
  grid-template-rows: minmax(132px, auto) minmax(92px, auto);
  grid-template-areas:
    "basic film size"
    "process process extra";
  gap: 8px;
  align-items: stretch;
}

.param-group {
  min-width: 0;
  margin: 0;
  padding: 18px 7px 7px;
  border: 1px solid #d8dee7;
  background: #fbfcfe;
  position: relative;
  display: grid;
  height: 100%;
  align-content: start;
  gap: 5px;
}

.param-group legend {
  position: absolute;
  top: -1px;
  left: -1px;
  padding: 2px 7px;
  border: 1px solid #d8dee7;
  background: #eaf0f6;
  color: #334155;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
}

.param-basic {
  grid-area: basic;
  grid-template-columns: minmax(0, 1fr);
}

.glass-pane-controls {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
}

.glass-pane-controls[hidden] {
  display: none;
}

.glass-pane-controls .glass-pane-empty {
  grid-column: 1 / -1;
  margin: 0;
  color: #7b8794;
  font-size: 11px;
}

.param-film {
  grid-area: film;
  grid-template-columns: repeat(5, minmax(46px, 1fr)) 72px;
}

.param-size {
  grid-area: size;
  grid-template-columns: 72px minmax(140px, 1fr);
}

.param-size label:not(.check) {
  min-width: 140px;
}

.param-process {
  grid-area: process;
  grid-template-columns: repeat(4, minmax(58px, 72px)) minmax(110px, 1fr);
}

.param-extra {
  grid-area: extra;
  grid-template-columns: minmax(160px, 1fr) 92px;
}

.param-grid label {
  align-content: start;
  gap: 3px;
  font-size: 11px;
  color: #536170;
}

.param-grid input,
.param-grid select {
  height: 30px;
  min-height: 30px;
  padding: 4px 6px;
  font-size: 12px;
}

.param-grid .check {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 30px;
  min-height: 30px;
  padding: 4px 6px;
  border: 1px solid #d8dee7;
  background: #fff;
  color: #344054;
  white-space: nowrap;
}

.param-grid .check input {
  width: auto;
  min-height: auto;
  padding: 0;
}

.source {
  margin-top: 4px;
  color: #84909d;
  font-size: 12px;
}

.unit-cell {
  padding-left: 10px;
}

.unitPrice {
  min-width: 104px;
}

.delete-row {
  width: 32px;
  min-height: 32px;
  padding: 0;
  border-color: #f1c7c3;
  background: #fff7f6;
  color: var(--danger);
  font-size: 18px;
}

.output-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

@media (max-width: 900px) {
  .topbar,
  .section-title,
  .output-panel {
    align-items: stretch;
    flex-direction: column;
  }

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

  .calc-settings {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .layout {
    width: calc(100vw - 20px);
    margin-top: 10px;
  }

  .usage-guide {
    grid-template-columns: 1fr;
  }

  .guide-title {
    justify-content: flex-start;
    min-height: 34px;
    padding: 0 12px;
    border-right: 0;
    border-bottom: 1px solid #d8e3ef;
  }

  .guide-list span {
    white-space: normal;
  }

  .legal-footer {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 14px;
  }

  .table-wrap {
    height: 65vh;
    min-height: 420px;
  }
}
