:root {
  --ink: #17343a;
  --muted: #5b7075;
  --primary: #0b6574;
  --primary-dark: #084d59;
  --accent: #15a596;
  --surface: #ffffff;
  --soft: #eef7f6;
  --line: #d6e4e3;
  --danger: #a33b42;
  --shadow: 0 12px 35px rgba(11, 72, 82, .10);
  --base-size: 16px;
}

* { box-sizing: border-box; }
html { font-size: var(--base-size); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(145deg, #eaf6f4 0%, #f7fbfb 45%, #eaf2f5 100%);
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}
button, input { font: inherit; }
button { touch-action: manipulation; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem max(1rem, calc((100vw - 1180px) / 2));
  color: white;
  background: linear-gradient(115deg, var(--primary-dark), var(--primary));
  box-shadow: 0 4px 20px rgba(8, 77, 89, .20);
}
.brand { display: flex; align-items: center; gap: .9rem; }
.brand img {
  width: 64px; height: 64px; object-fit: contain; border-radius: 15px;
  background: white; padding: .25rem;
}
.brand h1 { margin: 0; font-size: clamp(1.4rem, 4vw, 2rem); line-height: 1.1; }
.brand p { margin: .15rem 0 0; opacity: .88; }
.brand .eyebrow { text-transform: uppercase; letter-spacing: .10em; font-size: .7rem; }
.text-controls { display: flex; gap: .35rem; flex: 0 0 auto; }
.icon-button {
  min-width: 42px; min-height: 42px; border: 1px solid rgba(255,255,255,.45);
  border-radius: 10px; color: white; background: rgba(255,255,255,.10); cursor: pointer;
}
.icon-button:hover, .icon-button:focus-visible { background: rgba(255,255,255,.25); }

.layout {
  width: min(1180px, calc(100% - 2rem));
  margin: 1.4rem auto;
  display: grid;
  grid-template-columns: minmax(290px, .78fr) minmax(0, 1.35fr);
  gap: 1rem;
  align-items: start;
}
.card {
  background: var(--surface);
  border: 1px solid rgba(214, 228, 227, .9);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: clamp(1rem, 3vw, 1.4rem);
}
.method-card { grid-column: 1 / -1; }
.section-heading, .section-heading > div { display: flex; align-items: center; gap: .65rem; }
.section-heading { justify-content: space-between; margin-bottom: 1rem; }
.section-heading h2 { margin: 0; font-size: 1.15rem; }
.step {
  display: inline-grid; place-items: center; width: 30px; height: 30px;
  border-radius: 50%; background: var(--primary); color: white; font-weight: 800;
}
.badge { border-radius: 999px; padding: .25rem .65rem; background: var(--soft); color: var(--primary); font-size: .82rem; font-weight: 700; }

form { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
label { font-weight: 700; font-size: .9rem; }
small { color: var(--muted); font-size: .76rem; }
input {
  width: 100%; min-height: 46px; padding: .7rem .75rem; border: 1px solid #b8cccc;
  border-radius: 10px; color: var(--ink); background: #fbfdfd;
}
input:focus { outline: 3px solid rgba(21,165,150,.18); border-color: var(--accent); }
input[aria-invalid="true"] { border-color: var(--danger); background: #fff8f8; }

.button {
  min-height: 46px; border-radius: 11px; border: 1px solid transparent;
  padding: .7rem 1rem; font-weight: 750; cursor: pointer;
}
.button:focus-visible, summary:focus-visible { outline: 3px solid rgba(21,165,150,.3); outline-offset: 2px; }
.button:disabled { opacity: .45; cursor: not-allowed; }
.primary { color: white; background: var(--primary); }
.primary:hover:not(:disabled) { background: var(--primary-dark); }
.secondary { color: var(--primary); border-color: var(--primary); background: white; }
.secondary:hover:not(:disabled) { background: var(--soft); }
.danger-ghost { color: var(--danger); border-color: #e6c7ca; background: white; }

.message { grid-column: 1 / -1; border-radius: 10px; padding: .7rem; font-size: .88rem; }
.error { color: #7d242b; background: #fff0f1; border: 1px solid #edc8cb; }
.empty-state {
  min-height: 150px; display: grid; place-content: center; text-align: center;
  gap: .25rem; border: 1px dashed #b8cccc; border-radius: 13px; color: var(--muted); background: #fbfdfd;
}
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; min-width: 790px; border-collapse: collapse; font-size: .86rem; }
th, td { padding: .68rem .6rem; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: white; background: var(--primary); font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; }
th:first-child, td:first-child { text-align: left; }
tbody tr:nth-child(even) { background: #f7fbfa; }
tbody tr.is-best { background: #dff5ef; font-weight: 700; }
.delete-row {
  min-width: 36px; min-height: 36px; color: var(--danger); border: 0; border-radius: 8px;
  background: transparent; cursor: pointer; font-size: 1.1rem;
}
.delete-row:hover { background: #fff0f1; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.best-result {
  margin-top: 1rem; padding: 1rem; border-left: 5px solid var(--accent);
  border-radius: 12px; background: var(--soft);
}
.best-result h3 { margin: .15rem 0; font-size: 1.35rem; overflow-wrap: anywhere; }
.best-result p { margin: .2rem 0; }
.result-label { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; }
.breakdown { display: grid; grid-template-columns: repeat(4, 1fr); gap: .45rem; margin-top: .8rem; }
.breakdown span { padding: .5rem; border-radius: 8px; background: white; font-size: .78rem; }

details summary { cursor: pointer; color: var(--primary); font-weight: 800; }
.method-content { margin-top: .9rem; }
.method-content p, .method-content ul { margin: .55rem 0; }
.notice { padding: .75rem; border-radius: 10px; background: #fff7df; border: 1px solid #ecdca9; }
footer { padding: .4rem 1rem 1.5rem; text-align: center; color: var(--muted); font-size: .8rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }

@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
  .brand p:not(.eyebrow) { display: none; }
}
@media (max-width: 540px) {
  .layout { width: min(100% - 1rem, 1180px); margin-top: .6rem; }
  .topbar { padding: .75rem; }
  .brand img { width: 49px; height: 49px; }
  .brand .eyebrow { display: none; }
  form { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .actions .button { width: 100%; }
  .breakdown { grid-template-columns: 1fr 1fr; }
}
@media print {
  body { background: white; }
  .topbar { color: var(--ink); background: white; box-shadow: none; border-bottom: 2px solid var(--primary); }
  .text-controls, .input-card, .actions, .delete-row, footer { display: none !important; }
  .layout { display: block; width: 100%; margin: 0; }
  .card { box-shadow: none; border: 0; }
  .results-card, .method-card { display: block; }
  .table-wrap { overflow: visible; }
  table { min-width: 0; font-size: 8pt; }
}
.suite-home-link {
  position: fixed;
  left: max(14px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 10000;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.66rem 1rem;
  border: 1px solid rgba(41, 216, 255, 0.55);
  border-radius: 999px;
  background: rgba(3, 16, 29, 0.95);
  color: #f5f9fc;
  font: 700 0.84rem/1 Arial, sans-serif;
  text-decoration: none;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(12px);
  -webkit-tap-highlight-color: transparent;
}

.suite-home-link:hover {
  border-color: #29d8ff;
  color: #73e8ff;
}

.suite-home-link:focus-visible {
  outline: 3px solid #9eea43;
  outline-offset: 3px;
}
