/* ============================
   AppCafe Tools — shared styles
   theme: emerald green
   ============================ */

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

:root {
  --accent:        #10b981;
  --accent-hover:  #059669;
  --accent-light:  #d1fae5;
  --accent-glow:   rgba(16,185,129,0.15);
  --bg:            #f0fdf4;
  --surface:       #ffffff;
  --border:        #d1fae5;
  --text:          #111827;
  --muted:         #6b7280;
  --danger:        #ef4444;
  --warn:          #f59e0b;
  --radius:        14px;
  --shadow:        0 2px 16px rgba(16,185,129,0.08), 0 1px 4px rgba(0,0,0,0.06);
  --shadow-hover:  0 6px 28px rgba(16,185,129,0.18), 0 2px 8px rgba(0,0,0,0.08);
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ───────────────────────── */
header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center;
  padding: 0 1.5rem;
  height: 56px;
  background: var(--accent);
  border-bottom: 1px solid var(--accent-hover);
}
.logo { display: flex; align-items: center; gap: .5rem; text-decoration: none; flex-shrink: 0; }
.logo-icon { display: block; }
.logo-word { font-size: 1.15rem; font-weight: 700; color: #fff; letter-spacing: -.3px; }
.logo-app { color: #064e3b; }
.logo-cafe { color: #fff; }
.logo-sub { font-weight: 700; color: #064e3b; font-size: .9rem; }

/* ── Desktop nav ──────────────────── */
.nav-desktop {
  display: flex; align-items: center; gap: .25rem;
  flex: 1; margin-left: 1.5rem;
}
.nav-desktop .nav-plain {
  font-size: .875rem; font-weight: 600;
  color: #1f2937; text-decoration: none; opacity: .9;
  padding: .3rem .65rem; border-radius: 6px;
  transition: opacity .15s, background .15s;
}
.nav-desktop .nav-plain:hover { opacity: 1; background: rgba(0,0,0,0.1); }

/* category dropdown */
.nav-cat { position: relative; }
.nav-cat-btn {
  display: flex; align-items: center; gap: .25rem;
  background: none; border: none; cursor: pointer;
  font-size: .875rem; font-weight: 600;
  color: #1f2937; opacity: .9; padding: .3rem .65rem;
  border-radius: 6px; transition: opacity .15s, background .15s;
}
.nav-cat-btn:hover,
.nav-cat.open .nav-cat-btn { opacity: 1; background: rgba(0,0,0,0.1); }
.nav-chevron { width: 13px; height: 13px; flex-shrink: 0; transition: transform .2s; }
.nav-cat.open .nav-chevron { transform: rotate(180deg); }

.nav-cat-menu {
  display: none;
  position: absolute; top: calc(100% + 10px); left: 0;
  background: #fff; border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.13), 0 2px 8px rgba(0,0,0,0.07);
  min-width: 210px; padding: .4rem 0;
  z-index: 200; border: 1px solid var(--border);
}
.nav-cat.open .nav-cat-menu { display: block; }

.nav-cat-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .45rem 1rem;
  font-size: .875rem; color: var(--text); text-decoration: none;
  transition: background .12s; white-space: nowrap;
}
.nav-cat-item:hover { background: var(--accent-light); }
.nav-divider { height: 1px; background: var(--border); margin: .3rem 0; }

/* ── Hamburger (mobile only) ──────── */
.nav-hamburger {
  display: none;
  background: none; border: none; cursor: pointer;
  padding: .3rem; color: #1f2937; margin-left: auto;
}
.nav-hamburger svg { display: block; width: 24px; height: 24px; }

/* ── Mobile drawer ────────────────── */
.nav-mobile {
  display: none;
  position: fixed; inset: 56px 0 0 0;
  background: #fff; z-index: 99;
  overflow-y: auto; padding: .75rem 0 2rem;
}
.nav-mobile.open { display: block; }

.mob-section-label {
  font-size: .65rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: var(--accent);
  padding: .75rem 1.25rem .25rem;
}
.mob-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem 1.25rem;
  font-size: .9375rem; font-weight: 500;
  color: var(--text); text-decoration: none;
  transition: background .12s;
}
.mob-item:hover { background: var(--accent-light); }
.mob-divider { height: 1px; background: var(--border); margin: .5rem 1.25rem; }
.mob-plain {
  display: block; padding: .6rem 1.25rem;
  font-size: .9375rem; font-weight: 600;
  color: var(--accent); text-decoration: none;
}

/* ── Back link ────────────────────── */
.header-back {
  display: flex; align-items: center; gap: .4rem;
  font-size: .875rem; font-weight: 600;
  color: #fff; opacity: 0.9; text-decoration: none;
  transition: opacity .15s;
}
.header-back:hover { opacity: 1; }
.header-back svg { width:16px; height:16px; }

/* ── Responsive breakpoint ────────── */
@media (max-width: 768px) {
  .nav-desktop { display: none; }
  .nav-hamburger { display: block; }
}

/* ── Main ─────────────────────────── */
main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 2rem 2rem 3rem; }

/* ── Hero (index) ─────────────────── */
.hero { text-align: center; padding: 2.5rem 0 1.5rem; }
.hero-eyebrow {
  display: inline-block; margin-bottom: .75rem;
  font-size: .75rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent);
}
.hero h1 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 800; line-height: 1.15; margin-bottom: .75rem; }
.hero p { color: var(--muted); font-size: 1.05rem; max-width: 560px; margin: 0 auto 2rem; }

/* ── Search ───────────────────────── */
.search-wrap { max-width: 480px; margin: 0 auto 2rem; position: relative; }
.search-box {
  display: flex; align-items: center;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 10px; padding: 0 .75rem; gap: .5rem;
  transition: border-color .2s, box-shadow .2s;
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.search-icon { color: var(--muted); font-size: 1rem; flex-shrink: 0; }
.search-input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: .9375rem; padding: .65rem 0; color: var(--text);
}
.search-input::placeholder { color: #9ca3af; }
.search-kbd {
  font-size: .7rem; color: var(--muted);
  border: 1px solid var(--border); border-radius: 5px;
  padding: 1px 5px; font-family: monospace;
  flex-shrink: 0;
}
.search-clear {
  display: none; background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 1rem; padding: 0; line-height: 1;
}
.search-clear.visible { display: block; }
.no-results { display: none; text-align: center; font-size: .875rem; color: var(--muted); margin-top: .75rem; }
.no-results.visible { display: block; }

/* ── Category sections ────────────── */
.section { margin-bottom: 2.5rem; }
.section.empty { display: none; }
.section-label {
  font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 1rem; padding-bottom: .4rem;
  border-bottom: 1.5px solid var(--accent-light);
}

/* ── Cards grid ───────────────────── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: flex; flex-direction: column; gap: .5rem;
  transition: transform .22s cubic-bezier(.34,1.56,.64,1), box-shadow .22s ease, border-color .22s ease;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
/* shimmer sweep on hover */
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(16,185,129,0.12) 50%, transparent 60%);
  transform: translateX(-100%);
  transition: transform .5s ease;
  pointer-events: none;
}
.card:hover::before { transform: translateX(100%); }
.card:hover {
  transform: translateY(-4px) scale(1.015);
  box-shadow: 0 12px 36px rgba(16,185,129,0.18), 0 4px 12px rgba(0,0,0,0.08);
  border-color: var(--accent);
}
.card.hidden { display: none; }
.card-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--accent-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; margin-bottom: .25rem;
  flex-shrink: 0;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
}
.card:hover .card-icon { transform: scale(1.18) rotate(-4deg); }
.card h3 { font-size: .9375rem; font-weight: 700; }
.card p { font-size: .8125rem; color: var(--muted); line-height: 1.5; flex: 1; }
.card-arrow {
  font-size: .75rem; color: var(--accent); font-weight: 600; margin-top: auto;
  display: inline-flex; align-items: center; gap: .25rem;
  transition: gap .2s ease, opacity .2s ease;
}
.card:hover .card-arrow { gap: .5rem; opacity: 1; }

/* ── Tool page wrapper ────────────── */
.tool-wrap { max-width: 100%; margin: 0 auto; }
.tool-wrap .tool-header { max-width: 560px; }
.input-panel { max-width: 560px; }
.tool-header { margin-bottom: 1.75rem; }
.tool-header h1 { font-size: 1.75rem; font-weight: 800; margin-bottom: .35rem; }
.tool-header p { color: var(--muted); font-size: .9375rem; }

/* ── Panel ────────────────────────── */
.panel {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}

/* ── Form elements ────────────────── */
.field { margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }
label {
  display: block; font-size: .8125rem; font-weight: 600;
  color: var(--muted); margin-bottom: .35rem;
}
input[type="text"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%; border: 1.5px solid var(--border); border-radius: 8px;
  padding: .6rem .75rem; font-size: .9375rem; color: var(--text);
  background: var(--bg); outline: none;
  transition: border-color .2s, box-shadow .2s;
}
input[type="text"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.input-group {
  display: flex; align-items: center;
  border: 1.5px solid var(--border); border-radius: 8px;
  background: var(--bg); overflow: hidden;
  transition: border-color .2s, box-shadow .2s;
}
.input-group:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.input-group input {
  border: none; border-radius: 0; flex: 1; background: transparent;
  box-shadow: none !important;
}
.input-group .affix {
  padding: 0 .75rem; font-size: .8125rem; font-weight: 600;
  color: var(--muted); white-space: nowrap; background: var(--accent-light);
  border: none; border-radius: 0;
  align-self: stretch; display: flex; align-items: center;
}
.affix-left { border-right: 1.5px solid var(--border); }
.affix-right { border-left: 1.5px solid var(--border); }

/* ── Buttons ──────────────────────── */
.btn-row { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .6rem 1.25rem; border-radius: 8px;
  font-size: .9375rem; font-weight: 600; cursor: pointer;
  border: none; transition: background .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline {
  background: transparent; color: var(--accent);
  border: 1.5px solid var(--accent);
}
.btn-outline:hover { background: var(--accent-light); }
.btn-ghost { background: var(--accent-light); color: var(--accent); }
.btn-ghost:hover { background: #bbf7d0; }

/* ── Result box ───────────────────── */
.result-box {
  background: var(--accent-light); border: 1.5px solid #6ee7b7;
  border-radius: 10px; padding: 1.25rem 1.5rem;
  margin-top: 1.25rem;
}
.result-box.hidden { display: none; }
.result-label { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--accent-hover); margin-bottom: .25rem; }
.result-value { font-size: 2rem; font-weight: 800; color: var(--accent-hover); line-height: 1.1; }
.result-sub { font-size: .8125rem; color: #047857; margin-top: .25rem; }
.result-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem;
  margin-top: 1.25rem;
}
.result-cell {
  background: var(--accent-light); border: 1.5px solid #6ee7b7;
  border-radius: 10px; padding: 1rem;
}
.result-cell .result-label { margin-bottom: .15rem; }
.result-cell .result-value { font-size: 1.35rem; }

/* ── Note / disclaimer ────────────── */
.note {
  font-size: .8rem; color: var(--muted); line-height: 1.6;
  background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px;
  padding: .75rem 1rem; margin-top: 1rem;
}
.note strong { color: #92400e; }

/* ── Calculator display ───────────── */
.calc-display {
  background: #022c22; border-radius: 10px;
  padding: 1rem 1.25rem; margin-bottom: 1rem; text-align: right;
  min-height: 80px; display: flex; flex-direction: column; justify-content: flex-end;
}
.calc-expr { font-size: .8125rem; color: #6ee7b7; min-height: 1.2em; word-break: break-all; }
.calc-num { font-size: 2.25rem; font-weight: 700; color: #fff; word-break: break-all; letter-spacing: -.5px; }
.calc-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem;
}
.calc-btn {
  padding: .9rem .5rem; border-radius: 9px; border: none; cursor: pointer;
  font-size: 1.05rem; font-weight: 600;
  transition: filter .12s, transform .1s;
}
.calc-btn:active { transform: scale(.94); filter: brightness(.88); }
.calc-btn-num { background: #f0fdf4; color: var(--text); }
.calc-btn-num:hover { background: #d1fae5; }
.calc-btn-op  { background: var(--accent-light); color: var(--accent-hover); }
.calc-btn-op:hover { background: #a7f3d0; }
.calc-btn-eq  { background: var(--accent); color: #fff; }
.calc-btn-eq:hover { background: var(--accent-hover); }
.calc-btn-clear { background: #fee2e2; color: var(--danger); }
.calc-btn-clear:hover { background: #fecaca; }
.calc-btn-fn  { background: #e0f2fe; color: #0369a1; font-size: .85rem; }
.calc-btn-fn:hover { background: #bae6fd; }
.calc-btn-wide { grid-column: span 2; }

/* ── Tip splitter layout ──────────── */
.tip-layout {
  display: flex; gap: 1.5rem; align-items: flex-start;
}
.tip-results-col {
  flex: 1; min-width: 0;
  position: sticky; top: 72px;
}
@media (max-width: 640px) {
  .tip-layout { flex-direction: column; }
  .tip-results-col { position: static; width: 100%; }
}

/* ── Tip splitter specifics ───────── */
.people-row { display: flex; align-items: center; gap: .75rem; }
.people-row input { flex: 1; }
.stepper { display: flex; }
.stepper button {
  width: 36px; height: 36px; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--text); font-size: 1.1rem;
  cursor: pointer; transition: background .12s;
  display: flex; align-items: center; justify-content: center;
}
.stepper button:first-child { border-radius: 8px 0 0 8px; border-right: none; }
.stepper button:last-child  { border-radius: 0 8px 8px 0; border-left: none; }
.stepper button:hover { background: var(--accent-light); }
.stepper .stepper-val {
  width: 44px; text-align: center; border: 1.5px solid var(--border);
  font-size: .9375rem; font-weight: 700; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.tip-presets { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }
.tip-preset-btn {
  padding: .3rem .75rem; border-radius: 20px;
  border: 1.5px solid var(--border); background: var(--surface);
  font-size: .8125rem; font-weight: 600; cursor: pointer; color: var(--muted);
  transition: all .15s;
}
.tip-preset-btn.active,
.tip-preset-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Unit converter tabs ──────────── */
.tabs { display: flex; gap: .25rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tab-btn {
  padding: .45rem 1rem; border-radius: 8px; border: 1.5px solid var(--border);
  background: var(--surface); font-size: .8125rem; font-weight: 600;
  color: var(--muted); cursor: pointer; transition: all .15s;
}
.tab-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tab-btn:hover:not(.active) { background: var(--accent-light); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── BMI meter ────────────────────── */
.bmi-bar-wrap { margin: 1rem 0; }
.bmi-bar {
  height: 12px; border-radius: 6px; position: relative;
  background: linear-gradient(to right, #60a5fa 0%, #34d399 18.5%, #fbbf24 25%, #f97316 30%, #ef4444 40%, #ef4444 100%);
}
.bmi-marker {
  position: absolute; top: -5px;
  width: 4px; height: 22px; background: #111;
  border-radius: 2px; transform: translateX(-50%);
  transition: left .4s cubic-bezier(.4,0,.2,1);
}
.bmi-labels { display: flex; justify-content: space-between; margin-top: .4rem; font-size: .7rem; color: var(--muted); }

/* ── Amortisation table ───────────── */
.amort-table-wrap { overflow-x: auto; margin-top: 1rem; max-height: 320px; overflow-y: auto; border-radius: 8px; border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: .8rem; }
th, td { padding: .5rem .75rem; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: var(--accent-light); font-weight: 700; color: var(--accent-hover); position: sticky; top: 0; text-align: right; }
th:first-child, td:first-child { text-align: left; }
tr:last-child td { border-bottom: none; }

/* ── Footer ───────────────────────── */
footer {
  text-align: center; padding: 1.25rem;
  font-size: .8125rem; color: rgba(255,255,255,0.85);
  background: var(--accent);
  border-top: 1px solid var(--accent-hover);
}
footer a { color: #fff; text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ── Responsive ───────────────────── */
@media (max-width: 600px) {
  main { padding: 1.25rem .75rem 2.5rem; }
  .input-panel, .panel { width: 100%; max-width: 100%; }
  .calc-grid { gap: .35rem; }
  .calc-btn { padding: .75rem .4rem; font-size: .95rem; }
  .result-value { font-size: 1.5rem; }
}
