/* ToolPetal — mobile-first, scannable, tap-friendly */

:root {
  --bg: #f7f2ef;
  --surface: #ffffff;
  --ink: #111111;
  --muted: #444444;
  --faint: #555555;
  --line: #e4d6d2;
  --accent: #c45d78;
  --accent-text: #9e3d58;
  --accent-hover: #8f3550;
  --accent-fill: #b24e68;
  --accent-fill-hover: #9e3d58;
  --accent-soft: #fde8ee;
  --ok: #0b6b34;
  --warn: #9a4a00;
  --bad: #b42318;
  --radius: 12px;
  --header-h: 4.5rem;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --focus: 2px solid var(--ink);
  --focus-offset: 2px;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-top: var(--header-h);
}

img, svg { max-width: 100%; height: auto; }
code, kbd { font-family: var(--mono); font-size: 0.9em; }

a {
  color: var(--accent-text);
  text-decoration: none;
}
a:hover { color: var(--accent-hover); }
p a, .intro a, .lead a, .breadcrumbs a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

:focus { outline: none; }
:focus-visible {
  outline: var(--focus);
  outline-offset: var(--focus-offset);
}

/* Skip link — off-screen until focused */
.skip {
  position: fixed;
  left: 0.75rem;
  top: 0.75rem;
  z-index: 80;
  background: var(--ink);
  color: #fff;
  padding: 0.7rem 1rem;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-200%);
}
.skip:focus,
.skip:focus-visible {
  transform: translateY(0);
  color: #fff;
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ===== Header (sticky on all viewports) ===== */
.site-header {
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 0.5rem 1.15rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: nowrap;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 50;
}

.logo {
  color: var(--ink);
  font-weight: 700;
  letter-spacing: -0.03em;
  text-decoration: none;
  font-size: 1.15rem;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 48px;
  white-space: nowrap;
}
.logo img {
  width: 48px;
  height: 48px;
  display: block;
  flex-shrink: 0;
  object-fit: contain;
  background: transparent;
}
.logo:hover { color: var(--accent-text); }
.logo:focus-visible {
  outline: var(--focus);
  outline-offset: var(--focus-offset);
  border-radius: 8px;
}

.nav-toggle {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 1px 0 rgba(17,17,17,0.04);
  -webkit-appearance: none;
  appearance: none;
}
.nav-toggle:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--ink);
}
.nav-toggle:focus-visible {
  outline: var(--focus);
  outline-offset: var(--focus-offset);
}

.nav-toggle-bars,
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  position: relative;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  content: "";
  position: absolute;
  left: 0;
}
.nav-toggle-bars::before { top: -6px; }
.nav-toggle-bars::after { top: 6px; }

body.nav-open .nav-toggle-bars { background: transparent; }
body.nav-open .nav-toggle-bars::before { transform: translateY(6px) rotate(45deg); }
body.nav-open .nav-toggle-bars::after { transform: translateY(-6px) rotate(-45deg); }

.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(17, 17, 17, 0.32);
  z-index: 19;
}
body.nav-open .nav-backdrop { display: block; }

.site-nav {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex-direction: column;
  padding: 0.4rem 0.65rem 0.65rem;
  z-index: 21;
  box-shadow: 0 16px 32px rgba(80, 40, 50, 0.12);
}
.site-nav.is-open { display: flex; }

.site-nav a {
  color: var(--ink);
  text-decoration: none !important;
  font-size: 1rem;
  font-weight: 650;
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
}
.site-nav a:hover {
  color: var(--accent-text);
  background: var(--accent-soft);
}
.site-nav a:focus-visible {
  outline: var(--focus);
  outline-offset: var(--focus-offset);
}

@media (min-width: 800px) {
  .nav-toggle { display: none; }
  .nav-backdrop { display: none !important; }
  .site-nav,
  .site-nav.is-open {
    display: flex;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 0.1rem;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: transparent;
  }
  .site-nav a {
    font-size: 0.95rem;
    padding: 0.55rem 0.8rem;
    min-height: 48px;
  }
}

/* ===== Main ===== */
main {
  flex: 1;
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 1.35rem 1.15rem 3.25rem;
}

.breadcrumbs { font-size: 0.875rem; color: var(--muted); margin: 0 0 1.15rem; }
.breadcrumbs ol { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.breadcrumbs li { display: inline-flex; align-items: center; min-height: 48px; }
.breadcrumbs li:not(:last-child)::after { content: "/"; margin-left: 0.35rem; color: var(--faint); }
.breadcrumbs a {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0.25rem 0;
}
.breadcrumbs [aria-current="page"] { color: var(--ink); }

h1 {
  font-size: clamp(1.55rem, 4.2vw, 2.05rem);
  line-height: 1.2;
  letter-spacing: -0.03em;
  margin: 0 0 0.8rem;
}
h2 {
  font-size: 1.2rem;
  margin: 0 0 0.75rem;
  letter-spacing: -0.02em;
}
h3 {
  font-size: 1.05rem;
  margin: 0 0 0.4rem;
  letter-spacing: -0.02em;
}

.lead { font-size: 1.05rem; color: var(--muted); margin: 0 0 0.85rem; max-width: 62ch; }
.intro { margin: 0 0 1.75rem; max-width: 68ch; color: var(--ink); }

/* ===== Tool pages ===== */
.tool {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem 1.1rem;
  margin-bottom: 2rem;
  overflow-x: auto;
}
.tool-grid {
  display: grid;
  gap: 1.15rem;
}

label {
  display: block;
  font-weight: 600;
  font-size: 0.875rem;
  margin: 0 0 0.4rem;
}
.hint { display: block; font-weight: 400; color: var(--faint); font-size: 0.8rem; margin-top: 0.15rem; }

input[type="text"],
input[type="url"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="tel"],
select,
textarea {
  width: 100%;
  max-width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid #bdbdb8;
  border-radius: 10px;
  padding: 0.7rem 0.75rem;
  min-height: 48px;
}
textarea { min-height: 8rem; resize: vertical; font-family: var(--mono); font-size: 0.875rem; line-height: 1.45; }
textarea.plain { font-family: var(--sans); }
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: var(--focus);
  outline-offset: var(--focus-offset);
  border-color: var(--ink);
}

.field { margin-bottom: 1rem; }
.row { display: grid; gap: 0.85rem; }

.checks { display: flex; flex-wrap: wrap; gap: 0.35rem 0.75rem; }
.checks label,
.inline-check,
.radio-row label {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 500;
  font-size: 0.95rem;
  margin: 0;
  min-height: 48px;
  padding: 0.35rem 0.2rem;
  cursor: pointer;
}
.inline-check { margin-top: 0.15rem; }
.checks input,
.inline-check input,
.radio-row input {
  width: 1.2rem;
  height: 1.2rem;
  flex-shrink: 0;
}

.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.9rem; }

button, .btn {
  font: inherit;
  font-weight: 650;
  font-size: 0.95rem;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.7rem 1.15rem;
  min-height: 48px;
  cursor: pointer;
  background: var(--accent-fill);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 1px 0 rgba(17,17,17,0.08);
}
button:hover, .btn:hover {
  background: var(--accent-fill-hover);
  color: #fff;
}
button:focus-visible, .btn:focus-visible {
  outline: var(--focus);
  outline-offset: var(--focus-offset);
}
button.secondary, .btn.secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: #cfc6c2;
  box-shadow: none;
}
button.secondary:hover, .btn.secondary:hover { background: #f3eeeb; color: var(--ink); }
button.ghost {
  background: transparent;
  color: var(--accent-text);
  border-color: transparent;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
  box-shadow: none;
  min-width: 48px;
}
button.ghost:hover { background: var(--accent-soft); color: var(--accent-hover); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

.output, pre.output {
  background: #111111;
  color: #f2f2f0;
  border-radius: 10px;
  padding: 0.9rem;
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.45;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 6rem;
}
.output.empty { color: #9a9a96; }

.status {
  font-size: 0.85rem;
  margin: 0.45rem 0 0;
  color: var(--muted);
}
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.status.bad { color: var(--bad); }

.counter {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.95rem;
}
.counter.ok { color: var(--ok); }
.counter.warn { color: var(--warn); }
.counter.bad { color: var(--bad); }

.pair {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.85rem;
  margin-bottom: 0.75rem;
  background: #fafafa;
}
.pair-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
  font-size: 0.85rem;
  font-weight: 700;
}

/* ===== Homepage cards ===== */
.cards {
  display: grid;
  gap: 1.05rem;
  grid-template-columns: 1fr;
}
.card {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.2rem 1.2rem 1.3rem;
  min-height: 48px;
  color: inherit;
  text-decoration: none;
  box-shadow: 0 1px 0 rgba(196,93,120,0.06);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.card:hover {
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(196,93,120,0.12);
  transform: translateY(-1px);
  color: inherit;
}
.card:focus-visible {
  outline: var(--focus);
  outline-offset: 3px;
  border-color: var(--ink);
}
.card h3 { margin: 0 0 0.4rem; font-size: 1.08rem; color: var(--ink); }
.card p { margin: 0; color: var(--muted); font-size: 0.92rem; }
.kicker {
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  margin: 0 0 0.35rem;
}

.section {
  margin: 2.75rem 0 0.5rem;
  scroll-margin-top: calc(var(--header-h) + 0.75rem);
}
.section h2 { font-size: 1.35rem; margin-bottom: 0.4rem; }
.section > p { margin: 0 0 1.1rem; color: var(--muted); max-width: 62ch; }

.home-intro {
  margin: 0.35rem 0 1.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.home-intro .hero-logo {
  width: 96px;
  height: 96px;
  display: block;
  margin: 0 0 0.7rem;
  object-fit: contain;
  background: transparent;
  filter: drop-shadow(0 8px 18px rgba(196,93,120,0.18));
}
.home-intro h1 {
  font-size: clamp(2.05rem, 6vw, 2.75rem);
  margin-bottom: 0.4rem;
  letter-spacing: -0.04em;
}
.home-intro p {
  max-width: 42ch;
  color: var(--muted);
  margin: 0;
  font-size: 1.05rem;
}

.related { margin-top: 0.75rem; }
.related ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.related a {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  min-height: 48px;
  text-decoration: none;
  color: var(--ink);
}
.related a:hover { border-color: var(--accent); color: var(--accent-text); }
.related a:focus-visible {
  outline: var(--focus);
  outline-offset: var(--focus-offset);
}
.related a span { display: block; color: var(--muted); font-size: 0.85rem; font-weight: 400; }

.preview-iframe {
  width: 100%;
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.15rem 1.15rem 1.4rem;
  text-align: center;
  color: var(--faint);
  font-size: 0.85rem;
  background: var(--surface);
}
.site-footer p { margin: 0; }
.footer-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.15rem 0.35rem;
  margin-top: 0.55rem;
}
.footer-nav a {
  color: var(--faint);
  font-size: 0.85rem;
  font-weight: 600;
  min-height: 48px;
  padding: 0.35rem 0.7rem;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.footer-nav a:hover { color: var(--accent-text); }
.footer-nav a:focus-visible {
  outline: var(--focus);
  outline-offset: var(--focus-offset);
  border-radius: 8px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.pill {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent-text);
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
}

table.csv-preview {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  overflow: auto;
  display: block;
  max-width: 100%;
}
table.csv-preview th, table.csv-preview td {
  border: 1px solid var(--line);
  padding: 0.45rem 0.55rem;
  text-align: left;
  white-space: nowrap;
}
table.csv-preview th { background: #eee; }

.ad-slot {
  margin: 1.5rem 0;
  min-height: 90px;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--faint);
  font-size: 0.8rem;
}
.ad-slot.live {
  border-style: solid;
  min-height: 0;
  background: transparent;
  display: block;
}

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

table.flow-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.flow-table th,
table.flow-table td {
  border-bottom: 1px solid var(--line);
  padding: 0.45rem 0.35rem;
  text-align: left;
  vertical-align: middle;
}
table.flow-table th {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 700;
}
table.flow-table td:last-child { width: 5.5rem; }
.xirr-result {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  margin: 0.35rem 0 0.15rem;
}
.next-runs {
  list-style: none;
  padding: 0;
  margin: 0.35rem 0 0;
  font-family: var(--mono);
  font-size: 0.85rem;
}
.next-runs li { padding: 0.35rem 0; border-bottom: 1px solid var(--line); }
.preset-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }

table.breakup {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  margin-top: 0.85rem;
}
table.breakup th,
table.breakup td {
  border-bottom: 1px solid var(--line);
  padding: 0.55rem 0.35rem;
  text-align: left;
  vertical-align: top;
}
table.breakup td:last-child,
table.breakup th:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: 0.85rem;
  white-space: nowrap;
}
table.breakup tr.total td { font-weight: 700; border-bottom: none; }
table.breakup tr.win td { color: var(--ok); font-weight: 700; }
table.breakup .sub { color: var(--faint); font-size: 0.8rem; font-weight: 400; }

.kpi-row {
  display: grid;
  gap: 0.85rem;
  margin-top: 1.15rem;
}
.kpi {
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.9rem;
}
.kpi .lbl { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.kpi .val {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  margin-top: 0.15rem;
}
.kpi.win { border-color: #b7dcc4; background: #f3faf5; }
.kpi.win .val { color: var(--ok); }

.fy-tag {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-text);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  margin-left: 0.35rem;
  vertical-align: middle;
}
.disclaimer { font-size: 0.85rem; color: var(--muted); max-width: 68ch; }
.radio-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  margin: 0.35rem 0 0.95rem;
}

.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 1.4rem 1rem;
  text-align: center;
  background: #fafafa;
  color: var(--muted);
  cursor: pointer;
  position: relative;
  min-height: 48px;
}
.dropzone.drag {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}
.dropzone:focus-visible {
  outline: var(--focus);
  outline-offset: var(--focus-offset);
}
.dropzone input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}
.file-list {
  list-style: none;
  padding: 0;
  margin: 0.85rem 0 0;
}
.file-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}
.file-list button,
.file-list a,
.file-list .btn {
  min-height: 48px;
}
.file-list .hint { display: block; margin-top: 0.1rem; }
.svg-preview {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: repeating-conic-gradient(#eee 0% 25%, #fff 0% 50%) 50% / 16px 16px;
  min-height: 8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 0.5rem;
}
.svg-preview img, .svg-preview canvas { max-width: 100%; height: auto; }

/* Wider screens — cards & forms */
@media (min-width: 600px) {
  main { padding: 1.75rem 1.25rem 3.75rem; }
  .cards { grid-template-columns: 1fr 1fr; gap: 1.15rem; }
  .row.cols-2 { grid-template-columns: 1fr 1fr; }
  .row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
  .kpi-row.cols-2 { grid-template-columns: 1fr 1fr; }
  .kpi-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
  .section { margin: 3.4rem 0 0.75rem; }
  .home-intro { margin: 0.6rem 0 1.75rem; }
  .home-intro .hero-logo { width: 104px; height: 104px; }
  .tool { padding: 1.45rem 1.5rem; margin-bottom: 2.25rem; }
}

@media (min-width: 720px) {
  .tool-grid.split { grid-template-columns: 1fr 1fr; }
  .row.cols-5 { grid-template-columns: repeat(5, 1fr); }
}

@media (min-width: 960px) {
  .cards { grid-template-columns: 1fr 1fr 1fr; gap: 1.25rem; }
  .section { margin: 3.75rem 0 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card,
  .nav-toggle-bars,
  .nav-toggle-bars::before,
  .nav-toggle-bars::after {
    transition: none;
  }
  .card:hover { transform: none; }
}
