/* ==========================================================================
   SmartWot — shared tool-page components
   Loaded alongside ../style.css, which owns the brand, header, footer and
   tint system. This file only adds what a tool page needs.
   ========================================================================== */

.tool-shell { max-width: 62rem; }

/* Grid and flex children default to min-width:auto, so a wide element inside
   one (an amortisation table at min-width:30rem) stretches the whole column
   and pushes the page sideways on mobile. The tables already scroll inside
   .tbl-wrap; this lets that container actually shrink to the column. */
main .grid > *, .panel { min-width: 0; }
.tbl-wrap { max-width: 100%; }

/* ---------- page head ---------- */
.tool-head { display: flex; align-items: flex-start; gap: 1rem; }
.tool-head .th-icon {
  display: grid; place-items: center; flex: none;
  height: 3.5rem; width: 3.5rem; border-radius: 1.15rem;
  background: var(--tint-bg); color: var(--tint-fg);
}
.tool-head .th-icon svg { height: 1.75rem; width: 1.75rem; }
.tool-head h1 { font-size: 2rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; }
@media (min-width: 640px) { .tool-head h1 { font-size: 2.4rem; } }
.tool-head p { margin-top: .5rem; font-size: 1.02rem; color: rgb(var(--sw-muted)); }

/* ---------- panels ---------- */
.panel {
  border-radius: 1.35rem; border: 1px solid rgb(15 23 42 / .08);
  background: #fff; padding: 1.35rem;
  box-shadow: 0 1px 2px rgb(16 12 40 / .04), 0 10px 30px -22px rgb(16 12 40 / .3);
}
.dark .panel { background: rgb(255 255 255 / .035); border-color: rgb(255 255 255 / .09); }
@media (min-width: 640px) { .panel { padding: 1.6rem; } }

.panel-title {
  font-size: .78rem; font-weight: 800; letter-spacing: .1em;
  text-transform: uppercase; color: rgb(var(--sw-muted));
}

/* ---------- form controls ---------- */
.field { display: block; }
.field + .field { margin-top: 1rem; }
.field > .lbl {
  display: flex; align-items: baseline; justify-content: space-between; gap: .5rem;
  margin-bottom: .4rem; font-size: .85rem; font-weight: 700;
}
.field .hint { font-size: .75rem; font-weight: 500; color: rgb(var(--sw-muted)); }

.inp, select.inp {
  width: 100%; border-radius: .85rem;
  border: 1px solid rgb(15 23 42 / .12); background: #fff;
  padding: .7rem .85rem; font-size: 1rem; font-weight: 600; color: inherit;
  transition: border-color .16s ease, box-shadow .16s ease;
  -moz-appearance: textfield;
}
.inp::-webkit-outer-spin-button, .inp::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.inp:focus { outline: none; border-color: rgb(130 71 245 / .65); box-shadow: 0 0 0 3.5px rgb(130 71 245 / .14); }
.dark .inp, .dark select.inp { background: rgb(255 255 255 / .05); border-color: rgb(255 255 255 / .13); color: #fff; }
.dark .inp::placeholder { color: rgb(148 163 184); }
select.inp { cursor: pointer; }
.dark select.inp option { background: #171226; color: #fff; }

.inp-group { display: flex; }
.inp-group .inp { border-radius: .85rem 0 0 .85rem; }
.inp-group .addon {
  display: grid; place-items: center; flex: none; min-width: 3rem; padding: 0 .8rem;
  border: 1px solid rgb(15 23 42 / .12); border-left: 0; border-radius: 0 .85rem .85rem 0;
  background: rgb(15 23 42 / .035); font-size: .9rem; font-weight: 700; color: rgb(var(--sw-muted));
}
.dark .inp-group .addon { background: rgb(255 255 255 / .06); border-color: rgb(255 255 255 / .13); }
.inp-group select.addon { cursor: pointer; min-width: 5.2rem; }

/* segmented control */
.seg { display: inline-flex; gap: .25rem; padding: .25rem; border-radius: .9rem; background: rgb(15 23 42 / .05); }
.dark .seg { background: rgb(255 255 255 / .07); }
.seg button {
  border-radius: .68rem; padding: .45rem .85rem;
  font-size: .82rem; font-weight: 700; color: rgb(var(--sw-muted));
  transition: all .16s ease; white-space: nowrap;
}
.seg button[aria-pressed="true"] {
  background: #fff; color: #6218c9;
  box-shadow: 0 1px 3px rgb(16 12 40 / .12);
}
.dark .seg button[aria-pressed="true"] { background: rgb(255 255 255 / .16); color: #e9d5ff; }

/* pill choices (GST slabs etc.) */
.pill-row { display: flex; flex-wrap: wrap; gap: .45rem; }
.pill-opt {
  border-radius: 999px; border: 1px solid rgb(15 23 42 / .1);
  background: #fff; padding: .38rem .8rem; font-size: .82rem; font-weight: 700;
  color: rgb(51 65 85); transition: all .16s ease;
}
.pill-opt:hover { border-color: rgb(130 71 245 / .5); color: #6218c9; }
.pill-opt[aria-pressed="true"] { background: var(--sw-grad); border-color: transparent; color: #fff; box-shadow: 0 5px 14px -5px rgb(115 37 232 / .7); }
.dark .pill-opt { background: rgb(255 255 255 / .05); border-color: rgb(255 255 255 / .12); color: rgb(203 213 225); }

/* ---------- results ---------- */
.result {
  position: relative; overflow: hidden;
  border-radius: 1.35rem; padding: 1.5rem;
  background: var(--sw-grad); color: #fff;
  box-shadow: 0 16px 38px -18px rgb(115 37 232 / .8);
}
.result::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(22rem 12rem at 90% 0%, rgb(255 255 255 / .22), transparent 62%);
}
.result .r-label { position: relative; font-size: .74rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; opacity: .82; }
.result .r-value { position: relative; margin-top: .3rem; font-size: 2.1rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; word-break: break-word; }
@media (min-width: 640px) { .result .r-value { font-size: 2.5rem; } }
.result .r-sub { position: relative; margin-top: .35rem; font-size: .9rem; opacity: .88; }

.kpi-grid { display: grid; gap: .6rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 640px) { .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.kpi {
  border-radius: 1rem; border: 1px solid rgb(15 23 42 / .07);
  background: rgb(248 250 252 / .8); padding: .8rem .9rem;
}
.dark .kpi { background: rgb(255 255 255 / .04); border-color: rgb(255 255 255 / .09); }
.kpi dt { font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: rgb(var(--sw-muted)); }
.kpi dd { margin-top: .15rem; font-size: 1.15rem; font-weight: 800; letter-spacing: -.02em; }
.kpi dd small { font-size: .8rem; font-weight: 600; color: rgb(var(--sw-muted)); }

/* split bar (principal vs interest) */
.splitbar { display: flex; height: .8rem; border-radius: 999px; overflow: hidden; background: rgb(15 23 42 / .07); }
.dark .splitbar { background: rgb(255 255 255 / .1); }
.splitbar span { display: block; height: 100%; transition: width .35s cubic-bezier(.16,1,.3,1); }
.splitbar .s-a { background: linear-gradient(90deg, #7325e8, #9333ea); }
.splitbar .s-b { background: linear-gradient(90deg, #f472b6, #fb923c); }
.legend { display: flex; flex-wrap: wrap; gap: 1rem; font-size: .82rem; font-weight: 600; }
.legend i { display: inline-block; height: .6rem; width: .6rem; border-radius: 999px; margin-right: .35rem; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; border-radius: 1rem; border: 1px solid rgb(15 23 42 / .09); }
.dark .tbl-wrap { border-color: rgb(255 255 255 / .1); }
table.tbl { width: 100%; min-width: 30rem; border-collapse: collapse; font-size: .87rem; }
table.tbl thead th {
  position: sticky; top: 0; background: rgb(248 250 252); text-align: right;
  padding: .6rem .8rem; font-size: .7rem; font-weight: 800; letter-spacing: .05em;
  text-transform: uppercase; color: rgb(71 85 105); border-bottom: 1px solid rgb(15 23 42 / .09);
}
table.tbl thead th:first-child { text-align: left; }
.dark table.tbl thead th { background: #1b1530; color: rgb(203 213 225); border-color: rgb(255 255 255 / .1); }
table.tbl td { padding: .55rem .8rem; text-align: right; border-top: 1px solid rgb(15 23 42 / .06); font-variant-numeric: tabular-nums; }
table.tbl td:first-child { text-align: left; font-weight: 600; }
.dark table.tbl td { border-color: rgb(255 255 255 / .07); }
table.tbl tbody tr:nth-child(odd) td { background: rgb(248 250 252 / .55); }
.dark table.tbl tbody tr:nth-child(odd) td { background: rgb(255 255 255 / .02); }
table.tbl tr.is-best td { background: rgb(5 150 105 / .1) !important; }

/* ---------- calculator keypad ---------- */
.calc-screen {
  border-radius: 1.1rem; background: rgb(15 23 42 / .04);
  padding: 1rem 1.1rem; text-align: right; overflow: hidden;
}
.dark .calc-screen { background: rgb(255 255 255 / .05); }
.calc-expr {
  min-height: 1.5rem; font-size: .95rem; font-weight: 600; color: rgb(var(--sw-muted));
  word-break: break-all; font-variant-numeric: tabular-nums;
}
.calc-out {
  margin-top: .2rem; font-size: 2.1rem; font-weight: 800; letter-spacing: -.03em;
  word-break: break-all; font-variant-numeric: tabular-nums;
}
@media (min-width: 640px) { .calc-out { font-size: 2.5rem; } }

.pad { display: grid; gap: .5rem; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.pad.sci { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.key {
  border-radius: .9rem; border: 1px solid rgb(15 23 42 / .07);
  background: #fff; padding: .85rem .25rem;
  font-size: 1.02rem; font-weight: 700; color: inherit;
  box-shadow: 0 1px 2px rgb(16 12 40 / .05);
  transition: transform .12s ease, background-color .16s ease, box-shadow .16s ease;
}
.key:hover { background: rgb(15 23 42 / .04); }
.key:active { transform: scale(.95); }
.dark .key { background: rgb(255 255 255 / .05); border-color: rgb(255 255 255 / .09); }
.dark .key:hover { background: rgb(255 255 255 / .11); }
.key.fn { font-size: .88rem; color: #6218c9; }
.dark .key.fn { color: #c4b5fd; }
.key.op { color: #6218c9; }
.dark .key.op { color: #c4b5fd; }
.key.eq { background: var(--sw-grad); border-color: transparent; color: #fff; box-shadow: 0 8px 20px -8px rgb(115 37 232 / .75); }
.key.eq:hover { filter: brightness(1.06); }
.key.warn { color: #e11d48; }
.dark .key.warn { color: #fda4af; }

.hist { max-height: 12rem; overflow-y: auto; display: grid; gap: .35rem; }
.hist button {
  width: 100%; text-align: right; border-radius: .6rem; padding: .45rem .6rem;
  font-size: .85rem; font-variant-numeric: tabular-nums;
  transition: background-color .16s ease;
}
.hist button:hover { background: rgb(15 23 42 / .05); }
.dark .hist button:hover { background: rgb(255 255 255 / .07); }
.hist .h-expr { color: rgb(var(--sw-muted)); font-size: .78rem; }
.hist .h-val { font-weight: 700; }

/* ---------- misc ---------- */
.rowset { display: grid; gap: .6rem; }
.rowcard {
  display: grid; gap: .5rem; align-items: end;
  grid-template-columns: 1fr; padding: .8rem;
  border-radius: 1rem; border: 1px solid rgb(15 23 42 / .08); background: rgb(248 250 252 / .7);
}
.dark .rowcard { background: rgb(255 255 255 / .035); border-color: rgb(255 255 255 / .09); }
@media (min-width: 560px) { .rowcard { grid-template-columns: 1.1fr 1fr 1fr auto; } }
.rowcard.is-best { border-color: rgb(5 150 105 / .5); background: rgb(5 150 105 / .07); }

.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border-radius: .8rem; border: 1px solid rgb(15 23 42 / .1);
  padding: .6rem 1rem; font-size: .87rem; font-weight: 700; color: rgb(51 65 85);
  transition: all .16s ease;
}
.btn-ghost:hover { border-color: rgb(130 71 245 / .5); color: #6218c9; background: #f8f6ff; }
.dark .btn-ghost { border-color: rgb(255 255 255 / .12); color: rgb(226 232 240); }
.dark .btn-ghost:hover { background: rgb(255 255 255 / .08); color: #e9d5ff; }
.btn-ghost svg { height: 1rem; width: 1rem; }

.note {
  border-radius: .9rem; border-left: 3px solid #7325e8;
  background: rgb(115 37 232 / .06); padding: .75rem 1rem;
  font-size: .87rem; line-height: 1.6;
}
.dark .note { background: rgb(167 139 250 / .12); border-left-color: #a78bfa; }

/* related tools */
.rel-grid { display: grid; gap: .6rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 768px) { .rel-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.rel {
  display: block; border-radius: 1rem; border: 1px solid rgb(15 23 42 / .07);
  background: #fff; padding: .85rem;
  transition: transform .2s cubic-bezier(.16,1,.3,1), box-shadow .2s ease, border-color .2s ease;
}
.dark .rel { background: rgb(255 255 255 / .035); border-color: rgb(255 255 255 / .08); }
.rel:hover { transform: translateY(-3px); border-color: var(--tint-line); box-shadow: 0 16px 30px -20px var(--tint-shadow); }
.rel .r-ic { display: grid; place-items: center; height: 2.1rem; width: 2.1rem; border-radius: .7rem; background: var(--tint-bg); color: var(--tint-fg); }
.rel .r-ic svg { height: 1.1rem; width: 1.1rem; }
.rel .r-nm { margin-top: .55rem; font-size: .85rem; font-weight: 700; }
.rel .r-ds { margin-top: .1rem; font-size: .74rem; color: rgb(var(--sw-muted)); }

/* long-form info block (reuses .legal rhythm but lighter) */
.info { font-size: .96rem; line-height: 1.7; color: rgb(51 65 85); }
.dark .info { color: rgb(203 213 225); }
.info h2 { margin-top: 1.6rem; font-size: 1.2rem; font-weight: 800; letter-spacing: -.02em; color: rgb(15 23 42); }
.dark .info h2 { color: #fff; }
.info h2:first-child { margin-top: 0; }
.info p { margin-top: .7rem; }
.info ul { margin-top: .7rem; display: grid; gap: .45rem; list-style: none; padding: 0; }
.info li { position: relative; padding-left: 1.35rem; }
.info li::before { content: ""; position: absolute; left: .2rem; top: .62em; height: .38rem; width: .38rem; border-radius: 999px; background: #a855f7; }
.info code { border-radius: .35rem; background: rgb(15 23 42 / .06); padding: .1rem .35rem; font-size: .88em; font-family: ui-monospace, Menlo, monospace; color: #6218c9; }
.dark .info code { background: rgb(255 255 255 / .09); color: #ddd6fe; }
.info strong { color: rgb(15 23 42); font-weight: 700; }
.dark .info strong { color: #fff; }

/* ==========================================================================
   PRINT
   Used by the Markdown editor and Invoice maker, whose "Save as PDF" goes
   through the browser's own print dialogue rather than a bundled PDF library.
   ========================================================================== */
@media print {
  header, footer, .breadcrumb, .tool-head + div, .info, #related,
  #toast, .no-print, #bar, .seg, #panes .panel > .panel-title,
  #pane-write, .btn-ghost, .btn-primary, .btn-download { display: none !important; }

  body { background: #fff !important; color: #000 !important; }
  main { padding-top: 0 !important; }
  .tool-shell { max-width: none !important; padding: 0 !important; }
  .panel, #paper {
    border: 0 !important; box-shadow: none !important;
    background: #fff !important; padding: 0 !important;
  }
  #paper { color: #000 !important; }
  .tbl-wrap { border-color: #cbd5e1 !important; overflow: visible !important; }
  table.tbl { min-width: 0 !important; }
  table.tbl thead th { background: #f1f5f9 !important; color: #000 !important; }
  a { text-decoration: none !important; color: #000 !important; }
  h1, h2, h3 { break-after: avoid; }
  tr, li, blockquote, pre { break-inside: avoid; }
  #out { font-size: 11pt; }
}
