/* Sheets: Excel's everyday tools (static/js/sheets_tools.js) - the Sort range and Remove duplicates dialogs, and the
   toolbar's More (⋮) panel for the buttons that don't fit. */

/* the toolbar's More (⋮): the buttons that don't fit, on their own row(s) under it */
.toolbar.sh-toolbar .icon-btn.sh-more { flex: none; margin-left: auto; }
.toolbar.sh-toolbar .icon-btn.sh-more[hidden] { display: none; }
.sh-more-pop.toolbar { position: fixed; z-index: 650; margin: 0; flex-wrap: wrap; overflow: visible; row-gap: 4px;
  max-width: min(640px, calc(100vw - 16px)); border-radius: 12px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-2, 0 6px 24px rgba(0, 0, 0, .18)); }
.sh-more-pop.toolbar > .sep:first-child { display: none; }

/* Sort range: levels of column / sort on / order, moved and removed with small buttons */
/* (the dialogs never grow wider than the window for a select's longest option or the preview: on a phone they did) */
.modal:has(.sht-sort), .modal:has(.sht-dupes), .modal:has(.sht-gs) { min-width: 0; }
.sht-sort .sht-levels { display: flex; flex-direction: column; gap: 8px; }
.sht-level { display: grid; grid-template-columns: 64px minmax(140px, 1.6fr) minmax(110px, 1fr) minmax(110px, 1fr) auto; gap: 8px; align-items: center; }
.sht-level .sht-by { font-size: 13px; color: var(--text-2); }
.sht-level .select { width: 100%; min-width: 0; }
.sht-level .sht-moves { display: inline-flex; gap: 2px; }
.sht-level .sht-none { font-size: 12.5px; }
.sht-add { gap: 6px; }
.sht-error { margin: 0; font-size: 13px; color: var(--danger); }
.sht-error[hidden] { display: none; }
.sht-note { margin: 0; font-size: 12.5px; }
.sht-preview { overflow-x: auto; max-width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 6px; }
.sht-preview table { border-collapse: collapse; font-size: 12.5px; }
.sht-preview th, .sht-preview td { border: 1px solid var(--border); padding: 2px 8px; white-space: nowrap; max-width: 160px;
  overflow: hidden; text-overflow: ellipsis; text-align: left; }
.sht-preview th { background: var(--surface-2); color: var(--text-2); font-weight: 500; }
.sht-preview .on { background: var(--accent-weak); }
.sht-preview tr.sht-head td { font-weight: 600; background: var(--surface-2); }
.sht-preview .faint { padding: 4px 2px 0; font-size: 12px; }

/* Remove duplicates: the columns to compare */
.sht-dupes .sht-cols { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow: auto; padding: 4px 0 4px 22px; }
.sht-dupes .sht-count { margin: 0; }

/* row / column groups: the header gutters (Excel's outline) - a line along each open group, its +/- button, and the
   outline level buttons (1, 2, 3 ...) in the corner; sheets.js widens the headers by --sh-gw / --sh-gh */
.sheet-area .corner { position: relative; }
.sheet-area .rh { left: var(--sh-gw, 0px); }
.sheet-area .row-resize { left: var(--sh-gw, 0px); width: auto; right: 0; }
.sheet-area .ch, .sheet-area .col-resize { top: var(--sh-gh, 0px); }
.sheet-area .sh-unhide-c { top: calc(var(--sh-gh, 0px) + 5px); }
.sht-gl { position: absolute; pointer-events: none; border: 0 solid var(--text-2); opacity: .55; }
.sht-gl-r { width: 5px; border-left-width: 1px; border-bottom-width: 1px; }
.sht-gl-r.sht-gl-end { border-bottom-width: 0; border-top-width: 1px; }
.sht-gl-c { height: 5px; border-top-width: 1px; border-right-width: 1px; }
.sht-gl-c.sht-gl-end { border-right-width: 0; border-left-width: 1px; }
.sht-gb, .sht-lv { position: absolute; z-index: 3; display: flex; align-items: center; justify-content: center; padding: 0;
  width: 12px; height: 12px; font: 600 11px/1 var(--font); color: var(--text-2); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 2px; cursor: pointer; }
.sht-lv { width: 13px; height: 13px; font-size: 10px; background: var(--grid-head); }
.sht-gb:hover, .sht-lv:hover { color: var(--accent); border-color: var(--accent); }
.sht-gb:focus-visible, .sht-lv:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* (a finger needs more than 12 px: on a touch screen a +/- button takes taps a little either side of it along its
   rows / columns - not towards the next depth's buttons, 14 px away) */
@media (pointer: coarse) {
  .sht-gb::after { content: ''; position: absolute; inset: -6px -1px; }
  .sht-gb[data-grp^="COLUMNS"]::after { inset: -1px -6px; }
}

/* Goal seek: Set cell / To value / By changing cell, then what it found */
.sht-gs-field { display: grid; grid-template-columns: 130px minmax(0, 1fr); align-items: center; gap: 8px; }
.sht-gs-label { font-size: 13px; color: var(--text-2); }
.sht-gs-status { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; font-size: 13px; }
.sht-gs-status dt { color: var(--text-2); }
.sht-gs-status dd { margin: 0; font-weight: 600; }

@media (max-width: 700px) {
  .sht-level { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .sht-level .sht-by { grid-column: 1 / -1; }
  .sht-level .sht-moves { grid-column: 2; justify-content: flex-end; }
  .sht-gs-field { grid-template-columns: 1fr; gap: 4px; }
}

/* ---- pivot table editor: Group by (dates, number ranges) and calculated fields (sheets_data.js) */
.sd-pv-groupby { display: flex; flex-direction: column; gap: 6px; margin: 2px 0 6px; }
.sd-pv-groupby .sd-input { height: 32px; width: 100%; font-size: 13px; }
.sd-pv-hist { grid-template-columns: 1fr 1fr 1fr; }
.sd-pv-calc { display: flex; flex-direction: column; gap: 6px; }
.sd-pv-calc .sd-input { height: 32px; width: 100%; font-size: 13px; }
.sd-pv-formula-wrap { position: relative; }
.sd-pv-suggest { position: absolute; left: 0; right: 0; top: calc(100% + 2px); z-index: 30; max-height: 220px; overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-3); padding: 4px; }
.sd-pv-suggest-item { padding: 6px 8px; border-radius: 6px; font-size: 13px; color: var(--text); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sd-pv-suggest-item.on, .sd-pv-suggest-item:hover { background: var(--accent-weak); }
.sd-pv-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.sd-pv-chip { height: 24px; max-width: 100%; padding: 0 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  color: var(--text-2); font-size: 12px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sd-pv-chip:hover:not(:disabled), .sd-pv-chip:focus-visible { border-color: var(--accent); color: var(--text); outline: none; }
.sd-pv-chip:disabled { opacity: .6; cursor: default; }
@media (max-width: 560px) { .sd-pv-hist { grid-template-columns: 1fr; } }

/* ---- chart editor: waterfall subtotals; chart trendlines (sheets_charts.js) */
.shc-wf-subs { margin: 0; gap: 8px; }
.shc-wf-sub { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; align-items: center; padding: 8px; border: 1px solid var(--border); border-radius: 8px; }
.shc-wf-sub .select, .shc-wf-sub .input { width: 100%; min-width: 0; height: 30px; font-size: 12.5px; }
.shc-wf-sub .input { grid-column: 1 / 3; }
.shc-wf-sub .icon-btn { grid-row: 1; grid-column: 3; }
.shc-trend-label { pointer-events: none; }
