:root {
  --bg: #f4efe6;
  --ink: #112433;
  --muted: #5d6e79;
  --line: rgba(17, 36, 51, 0.12);
  --panel: rgba(255, 252, 247, 0.82);
  --accent: #c96f2d;
  --accent-deep: #8f491b;
  --secondary: #1c5f67;
  --danger: #8d3940;
  --shadow: 0 30px 80px rgba(17, 36, 51, 0.12);
  --radius: 28px;
  --radius-sm: 18px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(201, 111, 45, 0.08), transparent 24%),
    radial-gradient(circle at right 20%, rgba(28, 95, 103, 0.1), transparent 24%),
    linear-gradient(180deg, #faf7f1 0%, #f4efe7 48%, #f2ece3 100%);
  color: var(--ink);
  font-family: "Inter", "Avenir Next", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
}

.ambient {
  position: fixed;
  inset: auto;
  pointer-events: none;
  z-index: 0;
  filter: blur(40px);
  opacity: 0.7;
}

.ambient-a {
  top: 6rem;
  right: 8vw;
  width: 14rem;
  height: 14rem;
  background: rgba(201, 111, 45, 0.15);
  animation: drift 9s ease-in-out infinite;
}

.ambient-b {
  left: 5vw;
  bottom: 10rem;
  width: 18rem;
  height: 18rem;
  background: rgba(28, 95, 103, 0.12);
  animation: drift 11s ease-in-out infinite reverse;
}

.hero,
.workspace {
  position: relative;
  z-index: 1;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.9fr);
  gap: 1rem;
  padding: 1rem clamp(1.2rem, 3vw, 3rem) 0.4rem;
  min-height: auto;
  align-items: stretch;
}

.hero-copy,
.hero-panel,
.surface,
.status-card {
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1.15rem 1.35rem;
  border-radius: 22px;
  transform: translateY(0);
  animation: rise 0.9s ease both;
}

.eyebrow {
  margin: 0;
  font-size: 0.74rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--accent-deep);
}

.hero-brand {
  display: grid;
  gap: 0.35rem;
}

.hero h1,
.section-heading h2 {
  margin: 0;
  font-family: "Iowan Old Style", "Georgia", serif;
  font-weight: 600;
  line-height: 0.98;
}

.hero h1 {
  max-width: none;
  font-size: clamp(1.9rem, 3vw, 3rem);
  line-height: 1.04;
}

.hero-text {
  max-width: 42rem;
  margin: 0.7rem 0 0;
  font-size: 0.98rem;
  line-height: 1.65;
  color: var(--muted);
}

.hero-actions,
.download-actions,
.manual-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-top: 1.6rem;
}

.primary-link,
.ghost-link,
.action-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0.85rem 1.2rem;
  border-radius: 999px;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
  font-weight: 600;
  cursor: pointer;
}

.primary-link,
.action-button {
  border: 0;
  background: linear-gradient(135deg, var(--accent) 0%, #dc8b47 100%);
  color: #fff;
  box-shadow: 0 16px 32px rgba(201, 111, 45, 0.24);
}

.ghost-link,
.secondary-button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
}

.primary-link:hover,
.ghost-link:hover,
.action-button:hover,
.secondary-button:hover {
  transform: translateY(-2px);
}

.hero-panel {
  display: grid;
  gap: 0.85rem;
  align-content: center;
  padding: 1rem 1.1rem;
  border-radius: 22px;
  animation: rise 0.9s ease 0.12s both;
}

.hero-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.hero-modes article {
  flex: 1 1 220px;
  padding: 0.85rem 0.95rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(17, 36, 51, 0.08);
}

.hero-modes h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.hero-modes p,
.section-heading p,
.surface-head p,
.status-text {
  color: var(--muted);
  line-height: 1.6;
}

.hero-modes p {
  margin: 0.28rem 0 0;
  font-size: 0.88rem;
}

.hero-actions {
  margin-top: 0;
}

.workspace {
  padding: 0 clamp(1.2rem, 3vw, 3rem) 3rem;
}

.workbench,
.results-shell {
  padding-top: 1rem;
}

.section-heading {
  max-width: 40rem;
  margin-bottom: 1.4rem;
}

.section-heading h2 {
  font-size: clamp(2rem, 4vw, 3.6rem);
}

.section-heading.tight h2 {
  font-size: clamp(1.8rem, 3vw, 2.8rem);
}

.workbench-grid,
.result-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.surface,
.status-card {
  padding: 1.35rem;
  border-radius: var(--radius);
}

.surface-head {
  margin-bottom: 1rem;
}

.surface-head h3,
.status-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
}

.stack-form {
  display: grid;
  gap: 1rem;
}

.dropzone {
  display: grid;
  place-items: center;
  gap: 0.6rem;
  min-height: 12rem;
  padding: 1.6rem;
  border: 1px dashed rgba(17, 36, 51, 0.2);
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.65), rgba(245, 239, 230, 0.92));
  text-align: center;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease,
    box-shadow 160ms ease;
}

.dropzone:hover {
  transform: translateY(-2px);
  border-color: rgba(201, 111, 45, 0.35);
}

.dropzone.is-dragover {
  border-color: rgba(201, 111, 45, 0.65);
  background:
    linear-gradient(135deg, rgba(255, 249, 241, 0.95), rgba(255, 240, 224, 0.92));
  box-shadow: 0 18px 30px rgba(201, 111, 45, 0.14);
}

.dropzone.has-file {
  border-color: rgba(28, 95, 103, 0.35);
  background:
    linear-gradient(135deg, rgba(247, 252, 251, 0.95), rgba(233, 246, 244, 0.9));
}

.dropzone input {
  display: none;
}

.dropzone-title {
  font-weight: 700;
  font-size: 1.05rem;
}

.dropzone-subtitle {
  max-width: 22rem;
  color: var(--muted);
  line-height: 1.7;
}

.dropzone-meta {
  font-size: 0.88rem;
  color: var(--secondary);
}

.catalog-overview {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.overview-banner,
.overview-stat,
.category-panel {
  border-radius: 22px;
  border: 1px solid rgba(17, 36, 51, 0.08);
  background: rgba(255, 255, 255, 0.7);
}

.overview-banner {
  display: grid;
  gap: 0.22rem;
  padding: 0.95rem 1rem;
  background: rgba(255, 255, 255, 0.72);
}

.overview-kicker,
.category-chip,
.category-meta,
.category-description,
.manual-empty {
  color: var(--muted);
}

.overview-kicker {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: none;
}

.overview-banner h4 {
  margin: 0;
  font-family: inherit;
  font-size: 1.15rem;
}

.overview-banner p:last-child {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.6;
}

.overview-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.overview-stat {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.68rem 0.85rem;
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.overview-stat span,
.overview-stat em {
  font-size: 0.8rem;
  color: var(--muted);
}

.overview-stat strong {
  font-family: inherit;
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--ink);
}

.overview-stat.is-active,
.category-tab.is-active {
  border-color: rgba(17, 36, 51, 0.18);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 8px 16px rgba(17, 36, 51, 0.06);
}

.quote-studio {
  display: grid;
  gap: 0.8rem;
}

.category-nav-shell {
  padding: 0.15rem 0;
  border-bottom: 1px solid rgba(17, 36, 51, 0.08);
}

.category-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.category-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  padding: 0.65rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(17, 36, 51, 0.08);
  background: rgba(255, 255, 255, 0.75);
  text-align: center;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.category-tab:hover,
.overview-stat:hover {
  transform: translateY(-1px);
}

.category-tab-title {
  font-weight: 600;
  color: var(--ink);
}

.category-tab-meta {
  display: none;
}

.category-stage {
  min-height: 20rem;
}

.category-panel {
  padding: 1rem;
  background: rgba(255, 255, 255, 0.78);
}

.category-panel-head,
.manual-row-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
}

.category-panel-head h4,
.manual-row-head strong {
  margin: 0.18rem 0 0;
  font-size: 1rem;
}

.category-chip,
.category-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.8rem;
  padding: 0.15rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(17, 36, 51, 0.1);
  background: rgba(255, 255, 255, 0.78);
  font-size: 0.8rem;
}

.category-meta {
  margin: 0;
  text-align: right;
  font-size: 0.82rem;
  line-height: 1.6;
}

.category-description {
  margin: 0.55rem 0 0.85rem;
  line-height: 1.65;
  max-width: 42rem;
}

.category-grid,
.row-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.2rem 1rem;
}

.category-grid label,
.row-grid label {
  display: grid;
  gap: 0.45rem;
}

.category-grid label.wide,
.row-grid label.wide {
  grid-column: 1 / -1;
}

.category-grid span,
.row-grid span {
  font-size: 0.88rem;
  color: var(--muted);
}

.category-grid input,
.category-grid select,
.row-grid input,
.row-grid select {
  width: 100%;
  min-height: 2.8rem;
  padding: 0.75rem 0.85rem;
  border-radius: 14px;
  border: 1px solid rgba(17, 36, 51, 0.12);
  background: rgba(255, 255, 255, 0.95);
  color: var(--ink);
}

.category-grid select,
.row-grid select {
  appearance: none;
}

.category-grid input[readonly] {
  background: rgba(244, 239, 230, 0.9);
  color: var(--secondary);
}

.category-panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.category-panel-actions .category-add,
.category-panel-actions .category-add-and-quote {
  flex: 1 1 220px;
}

.surface-divider {
  margin: 1rem 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(17, 36, 51, 0.12), transparent);
}

.compact-head {
  margin-bottom: 0.7rem;
}

.manual-empty {
  margin: 0 0 0.9rem;
  line-height: 1.7;
}

.manual-list {
  display: grid;
  gap: 1rem;
}

.manual-row {
  padding: 1rem;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid rgba(17, 36, 51, 0.08);
}

.manual-hint {
  margin: 0.8rem 0 0;
  color: var(--secondary);
  font-size: 0.88rem;
}

.remove-row {
  margin-top: 0.8rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--danger);
  font-weight: 700;
  cursor: pointer;
}

.action-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.66;
  transform: none;
}

.status-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.status-card.loading {
  border-color: rgba(28, 95, 103, 0.22);
}

.status-card.success {
  border-color: rgba(201, 111, 45, 0.26);
}

.status-card.error {
  border-color: rgba(141, 57, 64, 0.24);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.summary-grid article {
  padding: 1rem;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(17, 36, 51, 0.08);
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
}

.summary-grid strong {
  display: block;
  margin-top: 0.45rem;
  font-family: "Iowan Old Style", "Georgia", serif;
  font-size: 2rem;
}

.result-surface {
  min-height: 24rem;
}

.table-wrap {
  overflow: auto;
  border-radius: 18px;
  border: 1px solid rgba(17, 36, 51, 0.08);
  background: rgba(255, 255, 255, 0.84);
}

.table-wrap::-webkit-scrollbar {
  height: 8px;
}
.table-wrap::-webkit-scrollbar-track {
  background: transparent;
}
.table-wrap::-webkit-scrollbar-thumb {
  background: rgba(17, 36, 51, 0.15);
  border-radius: 4px;
}
.table-wrap::-webkit-scrollbar-thumb:hover {
  background: rgba(17, 36, 51, 0.25);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 42rem;
}

th,
td {
  padding: 1.1rem 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(17, 36, 51, 0.06);
  vertical-align: middle;
}

tbody tr {
  transition: background 150ms ease;
}

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

th {
  position: sticky;
  top: 0;
  background: rgba(244, 239, 230, 0.96);
  backdrop-filter: blur(8px);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--secondary);
}

.placeholder-row td {
  color: var(--muted);
}

.hidden {
  display: none;
}

@keyframes drift {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(0, -16px, 0) scale(1.04);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1080px) {
  .hero,
  .workbench-grid,
  .catalog-overview,
  .result-panels,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .hero {
    padding-top: 0.8rem;
  }

  .hero h1 {
    max-width: none;
  }
}

@media (max-width: 1280px) {
  .category-grid,
  .row-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .hero-copy,
  .hero-panel,
  .surface,
  .status-card {
    border-radius: 22px;
  }

  .hero h1 {
    font-size: clamp(1.7rem, 10vw, 2.2rem);
  }

  .category-grid,
  .row-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .hero-actions,
  .hero-modes,
  .overview-stats,
  .category-nav,
  .category-panel-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .workspace {
    padding-bottom: 2rem;
  }

  table {
    min-width: 34rem;
  }
}

/* ===========================
   LOGIN OVERLAY
   =========================== */
#login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 30%, rgba(201, 111, 45, 0.18) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(28, 95, 103, 0.15) 0%, transparent 50%),
    linear-gradient(160deg, #faf7f1 0%, #f2ece3 100%);
  padding: 1rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: rgba(255, 252, 247, 0.88);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(201, 111, 45, 0.18);
  border-radius: 28px;
  padding: 2.5rem 2rem;
  box-shadow:
    0 40px 100px rgba(17, 36, 51, 0.14),
    0 0 0 1px rgba(255, 255, 255, 0.6) inset;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  animation: loginFadeIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes loginFadeIn {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes shake {
  0%,100% { transform: translateX(0); }
  15%      { transform: translateX(-8px); }
  30%      { transform: translateX(8px); }
  45%      { transform: translateX(-6px); }
  60%      { transform: translateX(6px); }
  75%      { transform: translateX(-3px); }
  90%      { transform: translateX(3px); }
}

.login-card.shake {
  animation: shake 0.5s ease both;
}

.login-logo {
  margin-bottom: 0.75rem;
  filter: drop-shadow(0 4px 12px rgba(201, 111, 45, 0.35));
}

.login-brand {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--accent);
  text-transform: uppercase;
  margin: 0;
  opacity: 0.85;
}

.login-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0.3rem 0 0;
  letter-spacing: -0.02em;
}

.login-subtitle {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0.25rem 0 1.5rem;
}

.login-field {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.login-field label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.02em;
}

.login-field input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1.5px solid rgba(17, 36, 51, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  font-size: 0.95rem;
  color: var(--ink);
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(201, 111, 45, 0.15);
  background: #fff;
}

.pw-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.pw-wrap input {
  padding-right: 2.8rem;
}

#toggle-pw {
  position: absolute;
  right: 0.75rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  display: flex;
  align-items: center;
  transition: color 0.2s;
}

#toggle-pw:hover {
  color: var(--accent);
}

.login-error {
  width: 100%;
  min-height: 1.2rem;
  font-size: 0.8rem;
  color: var(--danger);
  margin: -0.5rem 0 0.5rem;
  text-align: center;
  font-weight: 500;
}

.login-submit {
  width: 100%;
  padding: 0.85rem;
  background: linear-gradient(135deg, #c97a2a 0%, #a85e1a 100%);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: transform 0.15s, box-shadow 0.15s, background 0.3s;
  box-shadow: 0 6px 20px rgba(201, 111, 45, 0.38);
  margin-top: 0.25rem;
}

.login-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(201, 111, 45, 0.45);
}

.login-submit:active {
  transform: translateY(0);
}

.login-footer {
  font-size: 0.7rem;
  color: var(--muted);
  margin: 1.25rem 0 0;
  opacity: 0.6;
}

