:root {
  --bg: #f4f8fb;
  --surface: #ffffff;
  --surface-soft: #eef7f6;
  --ink: #12303a;
  --muted: #647780;
  --line: #dbe7ec;
  --primary: #0f766e;
  --primary-dark: #0b5e58;
  --accent: #0ea5e9;
  --warning: #b45309;
  --danger: #b91c1c;
  --good: #047857;
  --shadow: 0 18px 45px rgba(15, 48, 58, 0.12);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(14, 165, 233, 0.13), transparent 35rem),
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.12), transparent 35rem),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
}

button, input, select { font: inherit; }

.app-shell { min-height: 100vh; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem clamp(1rem, 3vw, 2rem);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--ink);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  font-weight: 900;
  letter-spacing: -0.06em;
  box-shadow: 0 12px 24px rgba(15, 118, 110, 0.22);
}

.brand strong { display: block; line-height: 1; letter-spacing: 0.08em; }
.brand small { display: block; color: var(--muted); font-size: 0.76rem; margin-top: 0.2rem; }

.top-actions, .action-ribbon {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  padding: 0.72rem 1rem;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(18, 48, 58, 0.12); border-color: rgba(15, 118, 110, 0.32); }
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--accent)); color: white; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.lang { min-width: 46px; padding-inline: 0.8rem; }
.btn.small { padding: 0.55rem 0.8rem; font-size: 0.88rem; }
.file-btn { display: inline-flex; align-items: center; }

.main-wrap {
  width: min(1500px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0 3rem;
}

.hero-card {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(270px, 0.55fr);
  gap: 1rem;
  align-items: center;
  padding: clamp(1.35rem, 3vw, 2rem);
  border-radius: var(--radius-xl);
  background:
    linear-gradient(135deg, rgba(255,255,255,0.95), rgba(239,250,249,0.92)),
    var(--surface);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.9);
}

.eyebrow, .section-kicker {
  color: var(--primary);
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.76rem;
  margin: 0 0 0.45rem;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 0.95;
  letter-spacing: -0.06em;
  margin-bottom: 0.8rem;
}

h2 { font-size: 1.18rem; margin-bottom: 0; letter-spacing: -0.02em; }

.hero-copy p { max-width: 820px; color: var(--muted); font-size: 1.05rem; line-height: 1.6; }

.hero-tags { display: flex; flex-wrap: wrap; gap: 0.55rem; margin-top: 1rem; }
.hero-tags span, .pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.4rem 0.72rem;
  background: rgba(15, 118, 110, 0.1);
  color: var(--primary-dark);
  font-weight: 800;
  font-size: 0.82rem;
}

.hero-art { width: 100%; max-height: 255px; object-fit: contain; }

.action-ribbon {
  position: sticky;
  top: 76px;
  z-index: 40;
  margin: 1rem 0;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 30px rgba(18, 48, 58, 0.08);
}

.tool-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 1rem;
  align-items: start;
}

.input-panel { display: grid; gap: 1rem; }

.card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 26px rgba(18, 48, 58, 0.06);
}

.compact-card, .result-card, .history-card, .info-card, .disclaimer-card { padding: clamp(1rem, 2vw, 1.25rem); }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

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

.field { display: grid; gap: 0.4rem; }
.field span, .check-field span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

input, select {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 0.72rem 0.78rem;
  color: var(--ink);
  outline: none;
}

input:focus, select:focus { border-color: rgba(14, 165, 233, 0.8); box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.12); }

.input-unit > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 0.45rem;
}

.editable { background: #fffefa; }
.calculated { background: #f0f9ff; }

.check-field {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem;
  background: var(--surface-soft);
  border-radius: 14px;
  border: 1px solid rgba(15, 118, 110, 0.15);
}
.check-field input { width: auto; }

.volume-builder { margin-top: 1rem; }
.volume-builder summary {
  cursor: pointer;
  font-weight: 900;
  color: var(--primary-dark);
  margin-bottom: 0.75rem;
}

.table-wrap { width: 100%; overflow-x: auto; border-radius: 14px; border: 1px solid var(--line); }
.data-table { width: 100%; border-collapse: collapse; min-width: 760px; background: #fff; }
.data-table th, .data-table td { padding: 0.68rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.data-table th { background: #f7fbfd; color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; }
.data-table td input, .data-table td select { padding: 0.55rem; border-radius: 10px; }
.data-table tr:last-child td { border-bottom: 0; }
.row-subtotal { font-weight: 900; color: var(--primary-dark); border-radius: 10px; white-space: nowrap; }

.icon-btn {
  border: 0;
  background: #fee2e2;
  color: var(--danger);
  border-radius: 999px;
  width: 34px;
  height: 34px;
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 900;
}

.results-panel { min-width: 0; }
.sticky-card { position: sticky; top: 158px; }
.status-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 6px rgba(100,119,128,0.12); }
.status-dot.ok { background: var(--good); box-shadow: 0 0 0 6px rgba(4,120,87,0.12); }
.status-dot.warn { background: var(--warning); box-shadow: 0 0 0 6px rgba(180,83,9,0.12); }
.status-dot.error { background: var(--danger); box-shadow: 0 0 0 6px rgba(185,28,28,0.12); }

.summary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.metric {
  border-radius: 18px;
  padding: 0.9rem;
  border: 1px solid rgba(14, 165, 233, 0.16);
}
.metric span { display: block; color: var(--muted); font-weight: 800; font-size: 0.8rem; }
.metric strong { display: block; margin-top: 0.25rem; font-size: 1.45rem; letter-spacing: -0.04em; }
.metric small { display: block; margin-top: 0.2rem; color: var(--muted); line-height: 1.35; }

.result-list { display: grid; gap: 0.45rem; margin-top: 1rem; }
.result-list div {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.64rem 0.75rem;
  background: #f8fbfc;
  border-radius: 12px;
  border: 1px solid #edf4f7;
}
.result-list span { color: var(--muted); font-size: 0.86rem; font-weight: 700; }
.result-list strong { text-align: right; }

.warnings { display: grid; gap: 0.5rem; margin-top: 1rem; }
.warning-item, .error-item, .ok-item {
  border-radius: 12px;
  padding: 0.75rem;
  font-weight: 750;
  font-size: 0.9rem;
  line-height: 1.4;
}
.warning-item { color: #7c2d12; background: #ffedd5; border: 1px solid #fed7aa; }
.error-item { color: #7f1d1d; background: #fee2e2; border: 1px solid #fecaca; }
.ok-item { color: #064e3b; background: #d1fae5; border: 1px solid #a7f3d0; }

.history-card, .info-grid { margin-top: 1rem; }
.history-table td { white-space: nowrap; }
.history-actions { display: flex; gap: 0.4rem; }
.history-actions .btn { padding: 0.45rem 0.65rem; font-size: 0.8rem; }

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}
.info-card p, .disclaimer-card p, .info-card li { color: var(--muted); line-height: 1.65; }
.formula-box { display: grid; gap: 0.5rem; margin-top: 1rem; }
.formula-box code { display: block; padding: 0.75rem; border-radius: 12px; background: #0f172a; color: #d1fae5; overflow-x: auto; }
.disclaimer-card { background: linear-gradient(135deg, #fff7ed, #ffffff); border-color: #fed7aa; }

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 1180px) {
  .tool-layout { grid-template-columns: 1fr; }
  .sticky-card { position: static; }
  .results-panel { order: -1; }
}

@media (max-width: 820px) {
  .main-wrap { width: min(100% - 1rem, 1500px); padding-top: 0.75rem; }
  .topbar { position: static; align-items: flex-start; }
  .brand small { display: none; }
  .top-actions { justify-content: flex-end; }
  .top-actions .btn { padding: 0.62rem 0.75rem; font-size: 0.86rem; }
  .hero-card { grid-template-columns: 1fr; padding: 1rem; }
  h1 { font-size: 2.15rem; }
  .hero-art { max-height: 180px; }
  .action-ribbon { position: sticky; top: 0; overflow-x: auto; flex-wrap: nowrap; border-radius: 0 0 18px 18px; margin-inline: -0.5rem; }
  .action-ribbon .btn { white-space: nowrap; padding: 0.62rem 0.78rem; font-size: 0.86rem; }
  .grid.two, .summary-grid, .info-grid { grid-template-columns: 1fr; }
  .input-unit > div { grid-template-columns: minmax(0, 1fr) 82px; }
  .compact-card, .result-card, .history-card, .info-card, .disclaimer-card { padding: 0.9rem; }
}

@media print {
  body { background: #fff; }
  .no-print, .topbar, .action-ribbon { display: none !important; }
  .main-wrap { width: 100%; padding: 0; }
  .hero-card, .card { box-shadow: none; border-color: #cbd5e1; break-inside: avoid; }
  .tool-layout, .info-grid { display: block; }
  .results-panel { margin: 1rem 0; }
  .hero-art { max-width: 260px; }
  .data-table { min-width: 0; font-size: 0.78rem; }
}
