:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #667085;
  --line: #d8e0ea;
  --page: #f5f7fb;
  --panel: #ffffff;
  --navy: #18324c;
  --blue: #2563eb;
  --blue-soft: #eef5ff;
  --amber: #fff5d7;
  --amber-line: #ead693;
  --green: #146c43;
  --green-soft: #e9f7ef;
  --red: #b42318;
  --red-soft: #fff1f0;
  --shadow: 0 14px 38px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1380px, calc(100% - 32px));
  margin: 24px auto 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 88px;
  padding: 20px 24px;
  color: #fff;
  background: var(--navy);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin-bottom: 4px;
  color: #b7d4ff;
  font-size: 13px;
  font-weight: 700;
}

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

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
}

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

.top-meta span {
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  padding: 8px 10px;
  color: #e9f2ff;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 700;
}

.top-meta .account-badge {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #17324d;
  background: #fff;
  border-color: rgba(255, 255, 255, 0.7);
}

.top-action {
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 8px;
  padding: 8px 12px;
  color: #fff;
  background: var(--blue);
  cursor: pointer;
  font-weight: 800;
}

.top-action-secondary {
  color: #17324d;
  background: #fff;
  border-color: rgba(255, 255, 255, 0.7);
}

.top-action-subtle {
  color: #e9f2ff;
  background: rgba(255, 255, 255, 0.1);
}

.top-action:active {
  transform: translateY(1px);
}

#licensePill {
  background: rgba(255, 255, 255, 0.16);
}

#licensePill.is-trial {
  color: var(--red);
  background: #fff1f0;
  border-color: #ffccc7;
}

#licensePill.is-license {
  color: var(--green);
  background: #ecfdf3;
  border-color: #b7e4c7;
}

#licensePill.is-locked {
  color: #fff;
  background: var(--red);
  border-color: rgba(255, 255, 255, 0.36);
}

body.auth-locked .result-panel,
body.auth-locked .comparison-panel,
body.auth-locked .settings-panel {
  position: relative;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 18, 32, 0.52);
}

.auth-screen[hidden] {
  display: none;
}

.auth-card {
  width: min(460px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(10, 18, 32, 0.22);
}

.auth-card h2 {
  margin-bottom: 8px;
  font-size: 24px;
}

.auth-card p {
  margin: 0 0 18px;
  color: var(--muted);
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  min-height: 42px;
  margin-bottom: 16px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.auth-tab {
  min-width: 0;
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-weight: 800;
}

.auth-tab.is-active {
  color: #fff;
  background: var(--blue);
}

.auth-panel {
  display: grid;
  gap: 12px;
}

.auth-panel[hidden] {
  display: none;
}

.auth-actions[hidden],
.auth-card .field[hidden] {
  display: none;
}

.auth-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.auth-message {
  margin-top: 14px;
  min-height: 38px;
  padding: 9px 11px;
  border-radius: 8px;
  color: var(--muted);
  background: #f2f4f7;
  font-weight: 700;
}

.auth-message.ok {
  color: var(--green);
  background: var(--green-soft);
}

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

.calculator-grid {
  display: grid;
  grid-template-columns: minmax(420px, 0.9fr) minmax(520px, 1.1fr);
  gap: 16px;
  margin-top: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.input-panel,
.result-panel,
.comparison-panel,
.settings-panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head span {
  color: var(--muted);
  font-size: 13px;
}

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

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field span,
.dimension-title {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--amber-line);
  border-radius: 8px;
  background: var(--amber);
  color: var(--ink);
  padding: 9px 10px;
  outline: none;
}

.auth-card .field input {
  border-color: var(--line);
  background: #fff;
}

.field input:focus,
.field select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-height: 42px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.segmented-control label {
  min-width: 0;
  display: grid;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control span {
  display: grid;
  place-items: center;
  min-height: 34px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.segmented-control input:checked + span {
  color: #fff;
  background: var(--blue);
}

.segmented-control input:focus-visible + span {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.muted-field input {
  background: #f9fafb;
  border-color: var(--line);
}

.dimension-block {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.dimension-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.dimension-block.is-disabled {
  opacity: 0.5;
}

.dimension-block.is-disabled input {
  background: #f2f4f7;
  border-color: var(--line);
}

.primary-button,
.ghost-button {
  min-height: 38px;
  border-radius: 8px;
  padding: 8px 13px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 800;
}

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

.ghost-button {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.primary-button:active,
.ghost-button:active {
  transform: translateY(1px);
}

.price-output {
  display: grid;
  gap: 6px;
  padding: 18px;
  border-radius: 8px;
  background: var(--blue-soft);
  border: 1px solid #cfe0ff;
}

.price-output span,
.price-output small {
  color: var(--muted);
  font-weight: 700;
}

.price-output strong {
  font-size: 38px;
  line-height: 1.15;
  letter-spacing: 0;
  color: var(--navy);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-top: 14px;
}

.metric {
  min-height: 78px;
  padding: 13px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: grid;
  align-content: center;
  gap: 5px;
}

.metric:nth-child(3n) {
  border-right: 0;
}

.metric:nth-last-child(-n + 3) {
  border-bottom: 0;
}

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

.metric strong {
  font-size: 20px;
  letter-spacing: 0;
}

.status-line {
  margin-top: 14px;
  min-height: 40px;
  display: flex;
  align-items: center;
  border-radius: 8px;
  padding: 9px 12px;
  font-weight: 800;
  background: #f2f4f7;
  color: var(--muted);
}

.status-line.ok {
  background: var(--green-soft);
  color: var(--green);
}

.status-line.error {
  background: var(--red-soft);
  color: var(--red);
}

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

.comparison-panel {
  margin-top: 16px;
}

.settings-panel {
  margin-top: 16px;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  background: var(--navy);
  color: #fff;
  font-size: 13px;
}

th:first-child,
td:first-child,
th:nth-child(2),
td:nth-child(2),
th:nth-child(8),
td:nth-child(8) {
  text-align: left;
}

tbody tr:nth-child(even) {
  background: #fbfcfe;
}

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

.price-copy-cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.price-copy-cell span {
  min-width: 92px;
}

.copy-chip {
  min-width: 46px;
  min-height: 28px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 4px 9px;
  color: var(--blue);
  background: #eff6ff;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.copy-chip.is-copied {
  color: var(--green);
  background: var(--green-soft);
  border-color: #b7e4c7;
}

.copy-chip:active {
  transform: translateY(1px);
}

.status-ok {
  color: var(--green);
  font-weight: 800;
}

.status-error {
  color: var(--red);
  font-weight: 800;
}

.settings-table {
  min-width: 1180px;
}

.settings-table th,
.settings-table td {
  padding: 8px;
}

.settings-table td:nth-child(1),
.settings-table td:nth-child(2),
.settings-table td:nth-child(3) {
  text-align: left;
}

.settings-table input {
  width: 92px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 8px;
  color: var(--ink);
  background: #fff;
  text-align: right;
}

.settings-table input:focus {
  border-color: var(--blue);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.settings-table input[data-rate="true"] {
  background: #f8fbff;
}

.site-footer {
  margin-top: 16px;
  padding: 14px 18px;
  color: var(--muted);
  font-size: 13px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1380px);
    margin-top: 10px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: 24px;
  }

  .form-grid,
  .dimension-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .metric,
  .metric:nth-child(3n),
  .metric:nth-last-child(-n + 3) {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metric:last-child {
    border-bottom: 0;
  }

  .price-output strong {
    font-size: 31px;
  }
}
