:root {
  --bg: #070b12;
  --surface: #1a2332;
  --surface-2: #243044;
  --surface-3: rgba(255, 255, 255, 0.03);
  --border: #334155;
  --border-soft: rgba(148, 163, 184, 0.15);
  --text: #e8edf5;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --success: #22c55e;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --warning: #f59e0b;
  --radius: 10px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100vh;
  background: #070b12;
  color: var(--text);
  font-family: var(--font);
}

body {
  background:
    radial-gradient(ellipse 90% 60% at 6% -8%, rgba(59, 130, 246, 0.28), transparent 52%),
    radial-gradient(ellipse 80% 50% at 110% 112%, rgba(34, 197, 94, 0.14), transparent 50%),
    #070b12;
}

* {
  scrollbar-width: thin;
  scrollbar-color: #475569 transparent;
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-thumb {
  background: #475569;
  border-radius: 999px;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: rgba(12, 18, 28, 0.78);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #3b82f6, #2563eb);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-text strong {
  font-size: 15px;
}

.brand-text span {
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.language-switch {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}

.language-switch button {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 7px 9px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}

.language-switch button:hover,
.language-switch button.active {
  color: #fff;
  border-color: var(--primary);
  background: var(--primary);
}

.nav a {
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--muted);
  border: 1px solid transparent;
}

.nav a:hover {
  background: rgba(59, 130, 246, 0.12);
  color: var(--text);
}

.nav a.active {
  background: rgba(59, 130, 246, 0.22);
  color: var(--text);
  border-color: rgba(59, 130, 246, 0.35);
}

.nav a.nav-extra {
  color: #1d4ed8;
  border: 1px solid rgba(59, 130, 246, 0.35);
  background: rgba(59, 130, 246, 0.08);
  font-weight: 600;
}

.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 24px 48px;
  width: 100%;
}

.page-lead {
  color: var(--muted);
  margin: 0 0 16px;
  line-height: 1.6;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.card-body {
  padding: 20px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 16px;
  align-items: start;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  color: var(--muted);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.input,
.select,
.search-input,
.combo-input {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  outline: none;
}

.input:focus,
.select:focus,
.search-input:focus,
.combo-input:focus {
  border-color: var(--primary);
}

.input:disabled,
.select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.combo {
  position: relative;
}

.combo-list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 280px;
  overflow: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  z-index: 20;
  display: none;
}

.combo-list.open {
  display: block;
}

.combo-option {
  padding: 9px 12px;
  cursor: pointer;
  color: var(--text);
}

.combo-option:hover,
.combo-option.active {
  background: rgba(59, 130, 246, 0.18);
}

.combo-empty {
  padding: 12px;
  color: var(--muted);
}

.price-types {
  display: flex;
  flex-wrap: wrap;
  width: 100%;
}

.price-types label {
  flex: 1 1 25%;
  min-width: 72px;
}

.price-types input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.price-types span {
  display: block;
  text-align: center;
  padding: 9px 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
}

.price-types label:first-child span {
  border-radius: 8px 0 0 8px;
}

.price-types label:last-child span {
  border-radius: 0 8px 8px 0;
}

.price-types input:checked + span {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.preview-box {
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface-3);
  border: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.kv .muted {
  color: var(--muted);
}

.total-value {
  color: var(--success);
  font-size: 1.2rem;
  font-weight: 700;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  border-color: #64748b;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-danger {
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.12);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.22);
}

.btn-ghost {
  background: transparent;
}

.btn-block {
  width: 100%;
}

.btn-lg {
  min-height: 42px;
  font-size: 15px;
}

.btn-sm {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 13px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.table-wrap {
  overflow-x: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table.data th,
table.data td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
  vertical-align: middle;
}

table.data th {
  color: var(--muted);
  font-weight: 600;
  background: var(--surface-2);
  white-space: nowrap;
}

table.data td.num,
table.data th.num {
  text-align: right;
}

table.data tr.dirty {
  background: rgba(59, 130, 246, 0.08);
}

table.data input.cell {
  min-height: 34px;
  width: 100%;
  min-width: 88px;
}

.empty {
  padding: 36px 12px;
  text-align: center;
  color: var(--muted);
}

.badge[hidden] {
  display: none !important;
}

.hint {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid #64748b;
  color: #94a3b8;
  font-size: 11px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  position: relative;
}

.hint[data-open]::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  transform: translateX(-50%);
  min-width: 180px;
  white-space: pre-line;
  background: #0f172a;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.5;
  z-index: 30;
}

.cart-item {
  padding: 14px;
  border-radius: 10px;
  background: var(--surface-3);
  border: 1px solid var(--border-soft);
  margin-bottom: 12px;
}

.cart-item-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
}

.cart-summary {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast-root {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  min-width: 220px;
  max-width: 360px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.toast.success {
  border-color: rgba(34, 197, 94, 0.5);
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.5);
}

.toast.warn {
  border-color: rgba(245, 158, 11, 0.5);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(15, 20, 25, 0.72);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px;
  overflow: auto;
}

.modal {
  width: min(960px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.modal-head,
.modal-foot {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-head {
  border-bottom: 1px solid var(--border-soft);
}

.modal-foot {
  border-top: 1px solid var(--border-soft);
  justify-content: flex-end;
}

.modal-body {
  padding: 20px;
}

.desc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 12px 0 16px;
}

.desc-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.desc-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width: 991px) {
  .app-header {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 14px;
  }

  .page {
    padding: 16px 14px 40px;
  }

  .language-switch {
    width: 100%;
    margin: 4px 0 0;
    padding: 10px 0 0;
    border-left: 0;
    border-top: 1px solid var(--border);
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .desc-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .card-body {
    padding: 16px;
  }

  .desktop-only {
    display: none !important;
  }
}

@media (min-width: 992px) {
  .mobile-only {
    display: none !important;
  }
}
