:root {
  --bg: #eefafa;
  --panel: #ffffff;
  --panel-soft: #f8fbfb;
  --text: #172033;
  --muted: #6b7789;
  --line: #dfe7ec;
  --line-strong: #cfdbe2;
  --teal: #12a898;
  --teal-dark: #0b8e82;
  --teal-soft: #e5fbf6;
  --blue: #2f75d6;
  --blue-soft: #eaf2ff;
  --amber: #d9871c;
  --amber-soft: #fff4df;
  --danger: #c94141;
  --shadow: 0 16px 38px rgba(41, 72, 92, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1120px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0) 260px),
    var(--bg);
  color: var(--text);
  font-family: Inter, "SF Pro Display", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1760px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.brand {
  display: inline-flex;
  align-items: center;
  height: 28px;
  margin-bottom: 8px;
  padding: 0 10px;
  border: 1px solid rgba(18, 168, 152, 0.22);
  border-radius: 8px;
  background: rgba(229, 251, 246, 0.8);
  color: var(--teal-dark);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

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

h2 {
  font-size: 17px;
  line-height: 1.35;
}

p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-pill,
.provider-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.unlocked {
  border-color: rgba(18, 168, 152, 0.28);
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 18px;
}

.settings-panel,
.add-panel,
.table-panel {
  padding: 20px;
}

.panel-head,
.table-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel.is-collapsed .collapsible-content,
.panel.is-collapsed .panel-actions .primary-button {
  display: none;
}

.panel.is-collapsed .panel-head {
  margin-bottom: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: 2fr repeat(4, minmax(138px, 1fr));
  gap: 14px;
}

.model-form-grid {
  display: grid;
  grid-template-columns: 150px minmax(220px, 1.4fr) 170px repeat(3, 130px) minmax(170px, 1fr);
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
}

label span {
  color: #4d5b6d;
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #ffffff;
  color: var(--text);
  outline: none;
  padding: 0 12px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

input:focus,
select:focus {
  border-color: rgba(18, 168, 152, 0.68);
  box-shadow: 0 0 0 3px rgba(18, 168, 152, 0.12);
}

input:disabled {
  background: var(--panel-soft);
  color: var(--muted);
}

.key-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 76px;
  gap: 8px;
}

button {
  height: 42px;
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 750;
  transition: transform 0.12s ease, background-color 0.16s ease, border-color 0.16s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  transform: none;
}

.primary-button {
  min-width: 100px;
  padding: 0 16px;
  background: var(--teal);
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(18, 168, 152, 0.22);
}

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

.secondary-button,
.ghost-button {
  min-width: 82px;
  padding: 0 14px;
  border-color: var(--line-strong);
  background: var(--panel);
  color: #39465a;
}

.ghost-button {
  background: rgba(255, 255, 255, 0.72);
}

.quote-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: start;
}

.quote-layout-full {
  grid-template-columns: 1fr;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

table {
  width: 100%;
  min-width: 1220px;
  border-collapse: separate;
  border-spacing: 0;
  background: #ffffff;
}

th,
td {
  height: 48px;
  padding: 0 12px;
  border-bottom: 1px solid #edf1f4;
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f7fafb;
  color: #667386;
  font-weight: 800;
}

td {
  color: #263247;
}

.group-row td {
  height: 38px;
  background: #fbfdfd;
  color: #5d697a;
  font-weight: 800;
}

.provider-badge.gpt {
  border-color: rgba(47, 117, 214, 0.2);
  background: var(--blue-soft);
  color: var(--blue);
}

.provider-badge.claude {
  border-color: rgba(217, 135, 28, 0.24);
  background: var(--amber-soft);
  color: var(--amber);
}

.price {
  font-variant-numeric: tabular-nums;
  font-weight: 740;
}

.discount-price {
  color: var(--teal-dark);
  font-weight: 850;
}

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

.row-actions {
  display: flex;
  gap: 8px;
}

.text-button,
.danger-button {
  height: 30px;
  min-width: auto;
  padding: 0 9px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: #526075;
  font-size: 12px;
}

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

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: 360px;
  padding: 12px 14px;
  border: 1px solid rgba(18, 168, 152, 0.24);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 14px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

body.locked .add-panel,
body.locked #settingsForm .primary-button,
body.locked #modelForm .primary-button {
  opacity: 0.62;
}

body.screenshot-mode {
  min-width: 1040px;
  background: #f4fbfb;
}

body.screenshot-mode .app-shell {
  width: min(1500px, calc(100vw - 44px));
}

body.screenshot-mode .admin-only,
body.screenshot-mode .topbar-actions,
body.screenshot-mode th.admin-only,
body.screenshot-mode td.admin-only {
  display: none !important;
}

body.screenshot-mode .quote-layout {
  grid-template-columns: 1fr;
}

body.screenshot-mode .topbar {
  margin-bottom: 16px;
}

body.screenshot-mode .table-panel {
  padding: 24px;
}

@media (max-width: 1100px) {
  body {
    min-width: 980px;
  }

  .app-shell {
    width: calc(100vw - 28px);
  }

  .field-grid,
  .model-form-grid,
  .quote-layout {
    grid-template-columns: 1fr;
  }
}
