:root {
  --bg: #f6f1e8;
  --panel: rgba(255, 252, 247, 0.92);
  --ink: #1f1a17;
  --muted: #63584f;
  --line: rgba(63, 48, 39, 0.12);
  --accent: #b4472d;
  --accent-dark: #7d2c18;
  --chip: #efe2d2;
  --success: #136f63;
  --shadow: 0 24px 60px rgba(72, 50, 36, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Noto Serif SC", "Source Han Serif SC", serif;
  background:
    radial-gradient(circle at top left, rgba(180, 71, 45, 0.18), transparent 30%),
    radial-gradient(circle at top right, rgba(19, 111, 99, 0.12), transparent 28%),
    linear-gradient(180deg, #f3ede2 0%, var(--bg) 100%);
}

.loading-mask {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(31, 26, 23, 0.26);
  backdrop-filter: blur(6px);
  z-index: 1000;
}

.loading-mask.hidden {
  display: none;
}

.loading-card {
  min-width: 220px;
  padding: 24px 28px;
  border-radius: 20px;
  background: rgba(255, 252, 247, 0.96);
  box-shadow: var(--shadow);
  text-align: center;
}

.loading-spinner {
  width: 38px;
  height: 38px;
  margin: 0 auto 12px;
  border: 3px solid rgba(180, 71, 45, 0.18);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

button,
input,
select {
  font: inherit;
}

.page-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 36px 0 48px;
}

.hero-card,
.panel {
  background: var(--panel);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.workspace {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 22px;
}

.main-panel {
  min-width: 0;
}

.sidebar {
  align-self: start;
  position: sticky;
  top: 20px;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar h2 {
  margin: 0;
  font-size: 28px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 60px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--chip);
  color: var(--ink);
  font-size: 13px;
}

.hero-card {
  padding: 28px 30px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent);
  font-size: 12px;
}

h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 52px);
  line-height: 1;
}

.subtitle {
  max-width: 700px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

.build-banner {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 0;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(180, 71, 45, 0.1);
  color: var(--accent-dark);
  font-size: 14px;
}

.panel {
  padding: 22px;
}

.add-bar,
.toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 14px;
  align-items: end;
}

.add-bar {
  grid-template-columns: minmax(0, 1.5fr) auto;
}

.import-form {
  margin-top: 18px;
}

.sidebar-actions {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

.sidebar-actions > button {
  flex: 1;
}

.import-form textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.85);
  min-height: 140px;
}

.add-input {
  max-width: 360px;
}

.feedback {
  min-height: 24px;
  margin: 10px 2px 0;
  color: var(--muted);
}

.feedback.error {
  color: var(--accent-dark);
}

.feedback.success {
  color: var(--success);
}

label span {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--muted);
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.85);
}

button {
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: transform 160ms ease, background 160ms ease;
}

button:hover {
  transform: translateY(-1px);
  background: var(--accent-dark);
}

button.ghost {
  background: var(--chip);
  color: var(--ink);
}

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

.watchlist-items {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.watchlist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.68);
}

.watchlist-code {
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
  font-size: 13px;
  letter-spacing: 0.04em;
}

.watchlist-remove {
  padding: 8px 12px;
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid rgba(125, 44, 24, 0.16);
}

.watchlist-empty {
  margin: 18px 0 0;
  color: var(--muted);
}

.status-bar,
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
  color: var(--muted);
}

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

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

thead {
  background: rgba(239, 226, 210, 0.55);
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.5);
}

.sort-btn {
  padding: 0;
  background: transparent;
  color: inherit;
  border-radius: 0;
}

.sort-btn:hover {
  transform: none;
  background: transparent;
  color: var(--accent-dark);
}

.metric-positive {
  color: var(--success);
  font-weight: 600;
}

.metric-empty {
  color: #9a8f84;
}

.table-action {
  padding: 8px 12px;
  background: var(--chip);
  color: var(--ink);
}

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

  .sidebar {
    position: static;
  }

  .add-bar,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .actions,
  .status-bar,
  .pagination {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
}
