:root {
  --bg: #f3eee6;
  --bg-accent: radial-gradient(circle at top left, rgba(208, 112, 71, 0.24), transparent 30%), radial-gradient(circle at top right, rgba(35, 91, 94, 0.18), transparent 28%), linear-gradient(180deg, #f8f3ec 0%, #efe7dc 100%);
  --panel: rgba(255, 250, 243, 0.92);
  --panel-strong: #fffaf4;
  --text: #221d18;
  --muted: #6d6358;
  --line: rgba(34, 29, 24, 0.12);
  --primary: #c8663c;
  --secondary: #1f5b5c;
  --soft: #ece0d1;
  --shadow: 0 26px 70px rgba(73, 47, 29, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg-accent);
  color: var(--text);
  font-family: 'Noto Sans SC', sans-serif;
}

.app-layout {
  width: min(1420px, calc(100% - 28px));
  margin: 0 auto;
  padding: 30px 0 50px;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.content-area {
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: 24px;
}

.sidebar-card,
.sidebar-link,
.hero-card,
.panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.sidebar-card {
  padding: 22px;
}

.sidebar-card h2 {
  margin: 10px 0 8px;
  font-family: 'Space Grotesk', 'Noto Sans SC', sans-serif;
  letter-spacing: -0.04em;
}

.sidebar-tag {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.74rem;
  color: var(--muted);
}

.sidebar-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 14px;
}

.sidebar-link {
  display: block;
  padding: 16px 18px;
  color: var(--text);
  text-decoration: none;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.sidebar-link:hover {
  transform: translateY(-1px);
  border-color: rgba(200, 102, 60, 0.24);
}

.sidebar-link.active {
  border-color: rgba(200, 102, 60, 0.24);
  background: rgba(200, 102, 60, 0.12);
}

.sidebar-link-title {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
}

.sidebar-link-desc {
  display: block;
  color: var(--muted);
  line-height: 1.5;
}

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

.hero-card h1,
.section-head h2 {
  margin: 8px 0 10px;
  font-family: 'Space Grotesk', 'Noto Sans SC', sans-serif;
  letter-spacing: -0.04em;
}

.hero-card h1 {
  font-size: clamp(2rem, 3vw, 3.2rem);
  line-height: 1.05;
}

.subtitle,
.hint,
.rule-note,
.summary-text,
.upload-subtitle,
.upload-name,
.metric-label {
  color: var(--muted);
}

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

.stack-panel {
  padding: 24px;
  margin-top: 18px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.meta-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 10px;
}

.single-column {
  grid-template-columns: 1fr;
}

.field-label {
  display: block;
  margin: 10px 0 8px;
  font-weight: 700;
}

.text-input,
.text-area {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  border-radius: 18px;
  padding: 14px 16px;
  font: inherit;
  color: var(--text);
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.text-input:focus,
.text-area:focus,
.file-input:focus {
  outline: none;
  border-color: rgba(200, 102, 60, 0.55);
  box-shadow: 0 0 0 4px rgba(200, 102, 60, 0.08);
}

.text-area {
  min-height: 300px;
  resize: vertical;
  line-height: 1.65;
}

.rule-note,
.summary-text {
  margin: 14px 2px 0;
  font-size: 0.95rem;
}

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

.button {
  border: 0;
  border-radius: 999px;
  padding: 13px 20px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

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

.button.primary {
  background: linear-gradient(135deg, var(--primary), #db885d);
  color: #fff;
  box-shadow: 0 12px 26px rgba(200, 102, 60, 0.25);
}

.button.secondary {
  background: #eadbc9;
  color: var(--text);
}

.button.ghost {
  background: transparent;
  color: var(--secondary);
  border: 1px solid rgba(31, 91, 92, 0.18);
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(31, 91, 92, 0.12);
  color: var(--secondary);
  font-weight: 700;
}

.badge.soft {
  background: var(--soft);
  color: var(--text);
}

.empty-state {
  margin-top: 14px;
  border: 1px dashed rgba(31, 91, 92, 0.22);
  border-radius: 22px;
  padding: 42px 20px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.38);
}

.table-wrap {
  overflow: auto;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.56);
  max-height: 520px;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

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

th {
  position: sticky;
  top: 0;
  background: #f5ebde;
  font-family: 'Space Grotesk', 'Noto Sans SC', sans-serif;
}

td {
  white-space: normal;
  word-break: break-all;
  overflow-wrap: anywhere;
  line-height: 1.5;
}

tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.45);
}

.hidden {
  display: none;
}

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

.upload-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  border-radius: 22px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
}

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

.file-input {
  width: 100%;
  font: inherit;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.metric-card {
  padding: 16px 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
}

.metric-card.accent {
  background: rgba(200, 102, 60, 0.08);
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  font-size: 1.5rem;
  font-family: 'Space Grotesk', 'Noto Sans SC', sans-serif;
}

.bill-form {
  margin-top: 6px;
}

.preview-card {
  min-height: 112px;
  padding: 16px 18px;
  border-radius: 22px;
  background: rgba(31, 91, 92, 0.09);
  border: 1px solid rgba(31, 91, 92, 0.16);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.preview-card strong {
  margin-top: 10px;
  font-family: 'Space Grotesk', 'Noto Sans SC', sans-serif;
  font-size: 1.05rem;
  line-height: 1.45;
  word-break: break-all;
}

.token-metric-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.compact-panel {
  margin-top: 0;
}

.compact-head {
  margin-bottom: 10px;
}

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

  .result-grid,
  .upload-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .app-layout {
    width: min(100% - 18px, 1420px);
    padding-top: 18px;
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

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

  .section-head {
    flex-direction: column;
  }

  .actions {
    flex-direction: column;
  }

  .button {
    width: 100%;
  }
}
