/* Shared controls for every tool. Loaded on /tools pages only. Uses site.css tokens — no new colours.
   Rules: one flat surface per group, rows ≥44px, square chips (8px), states named in words. */

.tool-app{--tf-h:46px}
.tf-stack{display:flex;flex-direction:column;gap:18px}
.tf-group{display:flex;flex-direction:column;gap:8px}
.tf-label{font-size:13px;font-weight:800;letter-spacing:.06em;text-transform:uppercase;color:var(--mut)}
html[lang="he"] .tf-label{letter-spacing:.01em}
.tf-hint{font-size:13.5px;color:var(--mut);margin:0}

.tf-input,.tf-select{
  width:100%;min-height:var(--tf-h);padding:10px 12px;border-radius:10px;
  border:1px solid var(--line-2);background:var(--bg);color:var(--ink);
  font:inherit;font-size:16px;font-weight:600;
  transition:border-color .12s var(--ease),box-shadow .12s var(--ease);
}
.tf-input:focus,.tf-select:focus{outline:none;border-color:var(--brand);box-shadow:0 0 0 3px rgba(240,80,46,.18)}
.tf-input::placeholder{color:var(--mut);font-weight:500}
.tf-input--amount{font-variant-numeric:tabular-nums;direction:ltr;text-align:start}
html[dir="rtl"] .tf-input--amount{text-align:right}
.tf-select{appearance:none;padding-inline-end:36px;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%238A7D75' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");background-repeat:no-repeat;background-size:12px 8px;background-position:right 14px center}
html[dir="rtl"] .tf-select{background-position:left 14px center}

.tf-row{display:flex;gap:8px;align-items:center}
.tf-row > .tf-input,.tf-row > .tf-select{flex:1;min-width:0}
.tf-row > .tf-grow{flex:1;min-width:0}

/* Buttons */
.tf-btn{
  display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:var(--tf-h);
  padding:0 16px;border-radius:10px;border:1px solid var(--line-2);background:var(--surface);color:var(--ink);
  font:inherit;font-weight:800;font-size:15px;cursor:pointer;white-space:nowrap;
}
.tf-btn:hover{border-color:var(--brand);color:var(--brand-ink)}
.tf-btn--primary{background:var(--grad);border-color:transparent;color:#fff}
.tf-btn--primary:hover{color:#fff;box-shadow:var(--sh-brand)}
.tf-btn--quiet{border-color:transparent;background:transparent;color:var(--mut);padding:0 10px}
.tf-btn--block{width:100%}
.tf-icon{width:var(--tf-h);padding:0;flex:0 0 auto;font-size:20px;color:var(--mut)}
.tf-actions{display:flex;flex-wrap:wrap;gap:8px}

/* Square toggle chips (who took part, templates) */
.tf-chips{display:flex;flex-wrap:wrap;gap:6px}
.tf-chip{
  min-height:36px;padding:0 12px;border-radius:8px;border:1px solid var(--line-2);background:var(--surface);
  color:var(--mut);font:inherit;font-size:14px;font-weight:700;cursor:pointer;
}
.tf-chip[aria-pressed="true"]{background:var(--ink);border-color:var(--ink);color:var(--bg)}

/* Segmented control */
.tf-seg{display:flex;background:var(--bg-2);border:1px solid var(--line);border-radius:10px;padding:3px;gap:3px}
.tf-seg button{flex:1;min-height:38px;border:0;border-radius:8px;background:transparent;color:var(--mut);font:inherit;font-weight:800;font-size:14px;cursor:pointer}
.tf-seg button[aria-pressed="true"]{background:var(--surface);color:var(--ink);box-shadow:var(--sh-1)}

/* Lists of rows (people, expenses, items) */
.tf-list{list-style:none;margin:0;padding:0;border:1px solid var(--line);border-radius:12px;overflow:hidden;background:var(--surface)}
.tf-list > li{margin:0;display:flex;align-items:center;gap:10px;min-height:48px;padding:8px 12px;border-top:1px solid var(--line)}
.tf-list > li:first-child{border-top:0}
.tf-list .tf-main{flex:1;min-width:0}
.tf-list .tf-title{font-weight:700;color:var(--ink);overflow-wrap:anywhere}
.tf-list .tf-sub{font-size:13.5px;color:var(--mut)}
.tf-list .tf-amt{font-weight:800;color:var(--ink);font-variant-numeric:tabular-nums}
/* An input that IS the row (names, list items): the list draws the surface, the field stays flat. */
.tf-list > li > .tf-input{border-color:transparent;background:transparent;padding-inline:4px;min-height:40px}
.tf-list > li > .tf-input:focus{border-color:var(--brand);background:var(--bg)}
.tf-list > li:has(> .tf-input){padding-block:4px}
.tf-empty{padding:16px;color:var(--mut);font-size:15px;text-align:center;border:1px dashed var(--line-2);border-radius:12px}

/* A two-line row: title and value on the first line, detail under them. */
.tf-list > li.tf-li2{flex-direction:column;align-items:stretch;gap:2px;padding-block:10px}
.tf-line{display:flex;align-items:baseline;justify-content:space-between;gap:12px}
.tf-line .tf-amt{text-align:end}

/* Results */
.tf-result{border-top:1px solid var(--line);padding-top:18px;margin-top:4px}
.tf-result h3{font-size:18px;margin:22px 0 10px}
.tf-big{font-size:clamp(30px,6vw,40px);font-weight:900;color:var(--ink);line-height:1.1;font-variant-numeric:tabular-nums}
.tf-transfer .tf-title{display:flex;flex-wrap:wrap;gap:6px;align-items:center}
.tf-pos{color:var(--teal)}
.tf-neg{color:var(--brand-ink)}
.tf-note{font-size:14px;color:var(--mut);margin:10px 0 0}

/* Toast */
.tf-toast{position:fixed;left:50%;bottom:20px;transform:translate(-50%,20px);opacity:0;z-index:120;background:var(--ink);color:var(--bg);font-weight:700;font-size:15px;padding:12px 18px;border-radius:12px;pointer-events:none;transition:opacity .18s var(--ease),transform .18s var(--ease)}
.tf-toast[data-show="true"]{opacity:1;transform:translate(-50%,0)}

@media(max-width:420px){
  .tool-app{--tf-h:48px}
  .tf-actions .tf-btn{flex:1}
  /* Row controls give the text more room so a normal item or name stays on one line. */
  .tf-list > li{gap:6px;padding-inline:10px}
  .tf-list .tf-icon{width:40px;min-height:40px}
  .tf-list .tf-chip{padding:0 8px;font-size:13px}
}
@media print{
  .tool-app button,.tf-actions,.tf-toast{display:none !important}
  .tool-app{border:0;padding:0}
}
