:root {
  --ink: #18211f;
  --muted: #687471;
  --line: #d9dfdc;
  --surface: #ffffff;
  --soft: #f7f1e9;
  --soft-2: #edf5f1;
  --accent: #216e62;
  --accent-2: #c16b4b;
  --danger: #b94c3f;
  --shadow: 0 18px 45px rgba(24, 33, 31, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(135deg, #f6f8f6 0%, #edf4f1 42%, #fbf2ea 100%);
  font-family: Arial, Helvetica, sans-serif;
}

.tool-shell {
  width: min(940px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 22px 0 40px;
}

.tool-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 72px;
  padding: 12px 16px;
  background: #17211f;
  color: #ffffff;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  color: #dbeaf0;
  letter-spacing: 2px;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.logo-word {
  font-size: 26px;
  font-weight: 700;
}

.logo-script {
  position: relative;
  top: -1px;
  margin: 0 -1px 0 1px;
  color: #4a91b3;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 50px;
  font-style: italic;
  font-weight: 400;
  letter-spacing: 0;
}

.tool-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-nav span {
  max-width: 220px;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.76);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-button,
.mini-icon-button {
  min-height: 36px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.nav-button {
  display: inline-flex;
  align-items: center;
  padding: 7px 11px;
}

.tool-nav .nav-button {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.tool-intro {
  margin: 26px 0 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 6vw, 54px);
  line-height: 1;
}

.tool-card {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.tool-card-body {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.field-grid,
.drawer-entry-grid,
.drawer-assumptions-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input {
  width: 100%;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  font: inherit;
}

.tool-button {
  min-height: 44px;
  padding: 9px 14px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.dialog-result {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid rgba(33, 110, 98, 0.32);
  background: var(--soft-2);
}

.result-main {
  font-size: clamp(24px, 5vw, 40px);
  font-weight: 800;
  line-height: 1.05;
}

.result-detail,
.muted,
.helper-line {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.helper-line {
  margin-top: -4px;
  color: #3a5f56;
  font-size: 13px;
  font-weight: 700;
}

.drawer-assumptions-card,
.manual-drawer-stack {
  padding: 14px;
  border: 1px solid var(--line);
  background: #fbfdfb;
}

.drawer-assumptions-card h2,
.stack-list h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.drawer-entry-grid {
  grid-template-columns: 1.1fr repeat(4, minmax(90px, 1fr)) auto;
  align-items: end;
}

.stack-list {
  display: grid;
  gap: 10px;
}

.manual-drawer-stack {
  display: grid;
  gap: 10px;
}

.manual-drawer-stack.warning {
  border-color: rgba(185, 76, 63, 0.5);
  background: #fff2f0;
}

.manual-drawer-stack-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.drawer-stack-title {
  font-size: 18px;
  font-weight: 800;
}

.drawer-stack-meta {
  color: var(--muted);
  font-size: 13px;
}

.drawer-stack-review {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.drawer-total {
  padding: 7px 9px;
  background: #173d36;
  color: #ffffff;
  font-weight: 800;
}

.height-warning-pill {
  padding: 7px 9px;
  background: var(--danger);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.manual-drawer-height-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.stack-actions {
  display: flex;
  gap: 8px;
}

.mini-icon-button {
  width: 38px;
  min-width: 38px;
  padding: 0;
}

.danger-icon-button {
  color: var(--danger);
}

@media (max-width: 760px) {
  .tool-shell {
    width: 100%;
    padding: 0 0 24px;
  }

  .tool-header {
    min-height: 62px;
    padding: 9px 10px;
  }

  .logo-word {
    font-size: 19px;
  }

  .logo-script {
    font-size: 34px;
  }

  .tool-nav span {
    display: none;
  }

  .tool-intro {
    margin: 18px 14px 12px;
  }

  .tool-card {
    margin: 0 14px;
    border-radius: 8px;
  }

  .tool-card-body {
    gap: 12px;
    padding: 14px;
  }

  .field-grid,
  .drawer-entry-grid,
  .drawer-assumptions-grid {
    grid-template-columns: 1fr;
  }

  .manual-drawer-stack-header,
  .manual-drawer-height-row {
    grid-template-columns: 1fr;
  }

  .drawer-stack-review {
    justify-content: flex-start;
  }
}
