/* =============================================================
   Shared components for the newer tools
   (punto de cruz, dividir gastos, cuadrante de turnos).
   Loaded after styles.css, reuses its tokens.
   ============================================================= */
.btn-sm { padding: .5rem .9rem; font-size: .85rem; }
.btn-xs { padding: .3rem .65rem; font-size: .78rem; border-radius: 999px; }
.icon-btn { width: 32px; height: 32px; flex-shrink: 0; border-radius: 50%; border: 1.5px solid var(--border); background: var(--surface); color: var(--text-muted); font-size: .85rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { border-color: var(--bad); color: var(--bad); }

.tool-split { display: grid; grid-template-columns: 1fr; gap: 1.6rem; }
@media (min-width: 900px) { .tool-split { grid-template-columns: minmax(280px, 340px) 1fr; align-items: start; } }
.tool-split > * { min-width: 0; }
.tool-split-wide { display: grid; grid-template-columns: 1fr; gap: 1.6rem; }
@media (min-width: 900px) { .tool-split-wide { grid-template-columns: 1fr 1fr; align-items: start; } }
.tool-split-wide > * { min-width: 0; }

.drop-zone {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem; text-align: center;
  padding: 1.6rem 1rem; border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface-2);
  cursor: pointer; transition: border-color .15s var(--ease-out), background .15s var(--ease-out);
}
.drop-zone:hover, .drop-zone.is-over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface-2)); }
.drop-zone strong { font-size: .98rem; }
.drop-zone small { color: var(--text-muted); font-size: .82rem; }
.drop-zone-emoji { font-size: 2rem; }
.drop-zone input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.drop-zone-thumb { max-height: 110px; border-radius: 8px; margin-top: .3rem; }

.range-field { display: flex; flex-direction: column; gap: .3rem; }
.range-field-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.range-field-head .field-label { margin: 0; }
.range-value { font-family: var(--mono); font-size: .8rem; color: var(--text); background: var(--surface-2); padding: .1rem .55rem; border-radius: 999px; white-space: nowrap; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.field-help { font-size: .78rem; color: var(--text-muted); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .6rem; }
.stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: .7rem .85rem; }
.stat-label { display: block; font-size: .72rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-value { display: block; font-size: 1.15rem; font-weight: 800; margin-top: .15rem; font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.data-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.data-table th, .data-table td { padding: .5rem .7rem; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); background: var(--surface-2); font-weight: 700; }
.data-table tr:last-child td { border-bottom: none; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.swatch { display: inline-block; width: 22px; height: 22px; border-radius: 5px; border: 1px solid rgba(0,0,0,.18); vertical-align: middle; }
.sym-badge { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 5px; font-family: var(--mono); font-size: .8rem; font-weight: 700; border: 1px solid rgba(0,0,0,.18); }

.empty-state { text-align: center; color: var(--text-muted); font-size: .92rem; padding: 2.4rem 1rem; background: var(--surface-2); border-radius: var(--radius); }
.empty-state-emoji { font-size: 2.2rem; display: block; margin-bottom: .4rem; }

.toast {
  position: fixed; left: 50%; bottom: 1.4rem; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 100;
  background: var(--text); color: var(--bg); padding: .65rem 1.1rem; border-radius: 999px; font-size: .9rem; font-weight: 700;
  transition: opacity .2s var(--ease-out), transform .2s var(--ease-out); box-shadow: var(--shadow);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---- Cross-stitch ---- */
.xs-toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between; }
.xs-canvas-wrap { overflow: auto; max-height: 75vh; background: var(--surface-2); border-radius: var(--radius); border: 1px solid var(--border); padding: .8rem; }
.xs-canvas-wrap canvas { display: block; margin: 0 auto; max-width: none; }
.xs-canvas-wrap.is-fit canvas { max-width: 100%; height: auto; }

/* ---- Split expenses ---- */
.chip-list { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .3rem .35rem .3rem .75rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: .88rem; font-weight: 600; }
.chip-dot { width: 10px; height: 10px; border-radius: 50%; }
.chip button { width: 22px; height: 22px; border-radius: 50%; border: none; background: transparent; color: var(--text-muted); line-height: 1; }
.chip button:hover { background: var(--bad); color: #fff; }
.inline-form { display: flex; gap: .5rem; }
.inline-form .text-input { flex: 1; min-width: 0; }
.expense-form { display: grid; gap: .8rem; padding: 1rem; background: var(--surface-2); border-radius: var(--radius); }
.checks-row { display: flex; flex-wrap: wrap; gap: .4rem; }
.check-pill { display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .7rem; border-radius: 999px; border: 1.5px solid var(--border); background: var(--surface); font-size: .84rem; font-weight: 600; cursor: pointer; user-select: none; }
.check-pill:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.check-pill input { accent-color: var(--accent); }
.expense-list { display: flex; flex-direction: column; gap: .5rem; }
.expense-item { display: grid; grid-template-columns: auto 1fr auto auto; gap: .1rem .8rem; align-items: center; padding: .7rem .9rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.expense-item-icon { font-size: 1.3rem; grid-row: span 2; }
.expense-item-title { font-weight: 700; font-size: .95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.expense-item-meta { grid-column: 2; font-size: .8rem; color: var(--text-muted); }
.expense-item-amount { grid-row: 1 / span 2; grid-column: 3; font-weight: 800; font-variant-numeric: tabular-nums; }
.expense-item .icon-btn { grid-row: 1 / span 2; grid-column: 4; }
.expense-item.is-transfer { background: var(--surface-2); border-style: dashed; }
.balance-list { display: flex; flex-direction: column; gap: .5rem; }
.balance-row { display: grid; grid-template-columns: minmax(70px, 120px) 1fr auto; gap: .7rem; align-items: center; font-size: .9rem; }
.balance-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.balance-bar { position: relative; height: 12px; background: var(--surface-2); border-radius: 999px; }
.balance-bar::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; margin-left: -1px; background: var(--border); }
.balance-bar span { position: absolute; top: 0; bottom: 0; border-radius: 999px; }
.balance-amt { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 80px; }
.is-pos { color: var(--ok); }
.is-neg { color: var(--bad); }
.transfer-list { display: flex; flex-direction: column; gap: .5rem; }
.transfer-item { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .7rem; padding: .8rem 1rem; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--accent); }
.transfer-who { font-weight: 700; }
.transfer-arrow { color: var(--accent); font-weight: 800; }
.transfer-amt { margin-left: auto; font-weight: 800; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.share-box { display: flex; flex-direction: column; gap: .6rem; padding: 1rem; border-radius: var(--radius); background: color-mix(in srgb, var(--accent) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border)); }
.share-box p { font-size: .86rem; color: var(--text-muted); }
.share-box .inline-form .text-input { font-family: var(--mono); font-size: .78rem; }

/* ---- Shift roster ---- */
.shift-types { display: flex; flex-direction: column; gap: .45rem; }
.shift-type-row { display: grid; grid-template-columns: 50px 1fr 88px 88px 42px 32px; gap: .4rem; align-items: center; }
.shift-type-row .text-input { padding: .45rem .5rem; font-size: .88rem; }
.shift-type-row input[type="color"] { width: 42px; height: 36px; border: 1.5px solid var(--border); border-radius: 8px; padding: 2px; background: var(--surface); }
.shift-type-head { font-size: .72rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
@media (max-width: 600px) {
  .shift-type-row { grid-template-columns: 46px 1fr 1fr 42px 32px; }
  .shift-type-row [data-f="c"] { grid-row: 1 / span 2; grid-column: 1; align-self: stretch; }
  .shift-type-row [data-f="n"] { grid-row: 1; grid-column: 2 / 4; }
  .shift-type-row [data-f="s"] { grid-row: 2; grid-column: 2; }
  .shift-type-row [data-f="e"] { grid-row: 2; grid-column: 3; }
  .shift-type-row [data-f="k"] { grid-row: 1; grid-column: 4; }
  .shift-type-row .icon-btn { grid-row: 1; grid-column: 5; }
  .shift-type-row:not(.shift-type-head) { padding-bottom: .5rem; border-bottom: 1px dashed var(--border); }
  .shift-type-head { display: none; }
}
.pattern-preview { display: flex; flex-wrap: wrap; gap: 3px; }
.pattern-cell { min-width: 26px; height: 26px; padding: 0 4px; border-radius: 5px; display: inline-flex; align-items: center; justify-content: center; font-size: .74rem; font-weight: 800; }
.people-rows { display: flex; flex-direction: column; gap: .4rem; }
.person-row { display: grid; grid-template-columns: 1fr 112px 32px; gap: .4rem; align-items: center; }
.person-row .text-input, .person-row .select-input { padding: .45rem .55rem; font-size: .88rem; }
.roster-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.roster { border-collapse: separate; border-spacing: 0; font-size: .8rem; min-width: 100%; }
.roster th, .roster td { text-align: center; padding: 0; height: 34px; min-width: 30px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.roster thead th { background: var(--surface-2); font-weight: 700; font-size: .74rem; line-height: 1.15; padding: .25rem 0; }
.roster thead th small { display: block; font-weight: 600; color: var(--text-muted); font-size: .66rem; }
.roster thead th.is-weekend { background: color-mix(in srgb, var(--accent) 16%, var(--surface-2)); }
.roster thead th.is-today { box-shadow: inset 0 -3px 0 var(--accent); }
.roster .roster-name { position: sticky; left: 0; z-index: 2; background: var(--surface); text-align: left; padding: 0 .7rem; min-width: 120px; max-width: 160px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.roster thead .roster-name { background: var(--surface-2); }
.roster td.shift-cell { cursor: pointer; font-weight: 800; user-select: none; }
.roster td.shift-cell:hover { filter: brightness(.9); }
.roster td.shift-cell.is-override { box-shadow: inset 0 0 0 2px var(--text); }
.roster tfoot td { font-size: .7rem; color: var(--text-muted); height: 24px; background: var(--surface-2); }
.roster tfoot .roster-name { font-weight: 600; font-size: .74rem; color: var(--text-muted); background: var(--surface-2); }
.roster-month-title { font-size: 1.02rem; margin: .4rem 0 .5rem; }
.roster-month + .roster-month { margin-top: 1.4rem; }
.legend-row { display: flex; flex-wrap: wrap; gap: .5rem .9rem; font-size: .82rem; color: var(--text-muted); }
.legend-row span { display: inline-flex; align-items: center; gap: .35rem; }

@media print {
  .site-header, .site-footer, .ad-slot, .ad-corner, .hero, .no-print, .content-section, .skip-link, .toast { display: none !important; }
  body::before { display: none; }
  body { background: #fff; color: #000; }
  .tool-card { box-shadow: none; border: none; padding: 0; }
}

.link-btn { background: none; border: none; padding: 0; }
[hidden] { display: none !important; }
.shift-type-row > *, .person-row > * { min-width: 0; }
