:root {
  --bg-start: #f6f3ec;
  --bg-end: #e5efe8;
  --panel: rgba(255, 252, 246, 0.9);
  --ink: #1f2a20;
  --ink-soft: #4a554c;
  --accent: #0f7b6c;
  --accent-strong: #0a5f53;
  --danger: #b53939;
  --ok: #1f8f4e;
  --edge: #c7d0c6;
  --ring: rgba(15, 123, 108, 0.25);
  --shadow: 0 20px 50px rgba(21, 42, 27, 0.14);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 10%, #fffaf0 0%, transparent 45%),
    radial-gradient(circle at 90% 85%, #d9f0e6 0%, transparent 40%),
    linear-gradient(145deg, var(--bg-start), var(--bg-end));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.app-shell {
  width: min(980px, 100%);
  background: var(--panel);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(199, 208, 198, 0.8);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: riseIn 380ms ease-out;
}

.hero {
  background: linear-gradient(120deg, #173d36, #1f5b51 65%, #2d7f70);
  color: #f7fff8;
  padding: 30px 28px;
}

.hero h1 {
  margin: 0;
  font-family: "Fraunces", serif;
  font-weight: 800;
  font-size: clamp(1.6rem, 3vw, 2.3rem);
  letter-spacing: 0.02em;
}

.hero p {
  margin: 10px 0 0;
  color: #d7f0e8;
  max-width: 68ch;
  line-height: 1.45;
}

.content {
  padding: 24px;
  display: grid;
  gap: 22px;
}

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

.tab-btn {
  background: #e7efea;
  border: 1px solid var(--edge);
  color: var(--ink);
}

.tab-btn.active {
  background: var(--accent);
  color: #f2fffa;
}

.panel {
  border: 1px solid var(--edge);
  border-radius: 14px;
  padding: 16px;
  background: #fffefb;
}

.panel.hidden {
  display: none;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.table-wrap {
  overflow: auto;
}

.panel-actions {
  margin-top: 12px;
}

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

th,
td {
  border-bottom: 1px solid #e1e8e2;
  text-align: left;
  padding: 10px 8px;
  font-size: 0.9rem;
}

th {
  color: #345146;
  font-weight: 700;
  background: #f4f8f4;
}

td {
  color: #27362f;
}

form {
  display: grid;
  gap: 18px;
}

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

.field {
  display: grid;
  gap: 8px;
  opacity: 0;
  animation: fadeUp 480ms ease forwards;
}

.field:nth-child(1) { animation-delay: 40ms; }
.field:nth-child(2) { animation-delay: 80ms; }
.field:nth-child(3) { animation-delay: 120ms; }
.field:nth-child(4) { animation-delay: 160ms; }
.field:nth-child(5) { animation-delay: 200ms; }
.field:nth-child(6) { animation-delay: 240ms; }
.field:nth-child(7) { animation-delay: 280ms; }
.field:nth-child(8) { animation-delay: 320ms; }
.field:nth-child(9) { animation-delay: 360ms; }

.span-2 {
  grid-column: span 2;
}

label {
  font-weight: 700;
  color: var(--ink);
  font-size: 0.95rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--edge);
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
  color: var(--ink);
  background: #fffefa;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--ring);
}

.help {
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin-top: -2px;
}

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 4px;
}

.switch input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

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

button {
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 130ms ease, filter 130ms ease;
}

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

.primary {
  background: var(--accent);
  color: #f2fffa;
}

.secondary {
  background: #ebf1ec;
  color: var(--ink);
  border: 1px solid var(--edge);
}

button.small {
  font-size: 0.78rem;
  padding: 3px 8px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 24, 18, 0.44);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(680px, 100%);
  background: #fffefb;
  border: 1px solid var(--edge);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.summary-grid {
  display: grid;
  gap: 10px;
}

.compact-summary {
  margin-top: 14px;
}

.summary-row {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(120px, 1fr);
  gap: 10px;
  align-items: center;
  border: 1px solid #e1e8e2;
  border-radius: 12px;
  background: #f8fbf8;
  padding: 10px 12px;
}

.summary-label {
  font-weight: 700;
  color: #345146;
  word-break: break-word;
}

.summary-value {
  color: var(--ink);
  text-align: right;
  font-weight: 600;
}

.summary-empty {
  border: 1px dashed var(--edge);
  border-radius: 12px;
  padding: 16px;
  color: var(--ink-soft);
  background: #f7faf7;
}

.breakdown-stack {
  display: grid;
  gap: 16px;
  margin-top: 14px;
}

.breakdown-section {
  border: 1px solid #dbe4dc;
  border-radius: 14px;
  padding: 14px;
  background: linear-gradient(180deg, #fbfdfb, #f4f9f4);
}

.breakdown-section h3 {
  margin: 0 0 12px;
  font-size: 1rem;
  color: #26483d;
}

.breakdown-note {
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

#status {
  min-height: 1.2em;
  font-weight: 600;
}

#status.ok {
  color: var(--ok);
}

#status.error {
  color: var(--danger);
}

@media (max-width: 760px) {
  body {
    padding: 12px;
  }

  .content,
  .hero {
    padding: 18px;
  }

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

  .span-2 {
    grid-column: span 1;
  }

  .panel-head {
    flex-direction: column;
    align-items: flex-start;
  }

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

  .summary-value {
    text-align: left;
  }
}

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

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