/* Shared components. Pair with the builders in static/js/core.js. Colours: var(--...) only. */

/* ================= Icons ================= */
.icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 16px; height: 16px; }
.icon.xs { width: 14px; height: 14px; }
.icon.lg { width: 22px; height: 22px; }
.icon.xl { width: 28px; height: 28px; }
.icon.fill { fill: currentColor; stroke: none; }

/* ================= Buttons ================= */
.btn {
  --btn-bg: var(--c-surface); --btn-fg: var(--c-text-2); --btn-bd: var(--c-border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: var(--control-h); padding: 0 var(--sp-4); border-radius: var(--r-md);
  border: 1px solid var(--btn-bd); background: var(--btn-bg); color: var(--btn-fg);
  font-size: var(--fs-md); font-weight: var(--fw-semibold); line-height: 1; white-space: nowrap;
  text-decoration: none !important; box-shadow: var(--shadow-xs);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
  user-select: none;
}
.btn:hover { background: var(--c-surface-3); color: var(--c-text); }
.btn:active { background: var(--c-surface-4); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }
.btn .icon { width: 16px; height: 16px; }

.btn-primary { --btn-bg: var(--c-brand); --btn-fg: var(--c-on-brand); --btn-bd: var(--c-brand); }
.btn-primary:hover { background: var(--c-brand-hover); border-color: var(--c-brand-hover); color: var(--c-on-brand); }
.btn-primary:active { background: var(--c-brand-active); }
.btn-accent { --btn-bg: var(--c-accent); --btn-fg: var(--c-on-accent); --btn-bd: var(--c-accent); }
.btn-accent:hover { background: var(--c-accent-hover); border-color: var(--c-accent-hover); color: var(--c-on-accent); }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--c-surface-3); }
.btn-soft { --btn-bg: var(--c-brand-soft); --btn-fg: var(--c-brand-text); --btn-bd: transparent; box-shadow: none; }
.btn-soft:hover { background: var(--c-brand-soft-2); color: var(--c-brand-text); }
.btn-danger { --btn-bg: var(--c-surface); --btn-fg: var(--c-danger-text); --btn-bd: var(--c-danger-border); }
.btn-danger:hover { background: var(--c-danger-soft); color: var(--c-danger-text); }
.btn-sm { height: var(--control-h-sm); padding: 0 var(--sp-3); font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-lg { height: var(--control-h-lg); padding: 0 var(--sp-5); font-size: var(--fs-lg); }
.btn-block { width: 100%; }
.btn-icon { width: var(--control-h); padding: 0; }
.btn-icon.btn-sm { width: var(--control-h-sm); }

/* ================= Form controls ================= */
.input, .select {
  height: var(--control-h); width: 100%; padding: 0 var(--sp-3);
  border: 1px solid var(--c-border-strong); border-radius: var(--r-md);
  background: var(--c-surface); color: var(--c-text); font-size: var(--fs-md);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
textarea.input { height: auto; min-height: 88px; padding: var(--sp-2) var(--sp-3); resize: vertical; line-height: var(--lh-normal); }
.input::placeholder { color: var(--c-text-4); }
.input:hover, .select:hover { border-color: var(--c-text-4); }
.input:focus, .select:focus, .input:focus-visible, .select:focus-visible { outline: none; border-color: var(--c-brand); box-shadow: var(--ring); }
.input:disabled, .select:disabled { background: var(--c-surface-2); color: var(--c-text-4); }
.input-sm, .select.select-sm { height: var(--control-h-sm); font-size: var(--fs-sm); }
.select {
  appearance: none; -webkit-appearance: none; padding-right: var(--sp-8); cursor: pointer;
  /* Outline chevron drawn with two thin diagonal lines: the same size, weight and place as the chevron-down icon
     of .dd-trigger, so native selects and custom dropdowns look alike (tokens only, works in both themes). */
  background-image:
    linear-gradient(to bottom left, transparent calc(50% - 0.9px), var(--c-icon) calc(50% - 0.3px), var(--c-icon) calc(50% + 0.3px), transparent calc(50% + 0.9px)),
    linear-gradient(to bottom right, transparent calc(50% - 0.9px), var(--c-icon) calc(50% - 0.3px), var(--c-icon) calc(50% + 0.3px), transparent calc(50% + 0.9px));
  background-position: right 20.5px center, right 16px center;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.select option { background: var(--c-surface); color: var(--c-text); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--c-text-3); letter-spacing: 0.02em; text-transform: uppercase; }
.field-hint { font-size: var(--fs-xs); color: var(--c-text-3); }
.field-error { font-size: var(--fs-sm); color: var(--c-danger-text); }
.input-wrap { position: relative; display: flex; align-items: center; min-width: 0; }
.input-wrap > .icon { position: absolute; left: 10px; color: var(--c-icon); pointer-events: none; width: 16px; height: 16px; }
.input-wrap > .input { padding-left: 34px; }
.input-wrap .input-affix { position: absolute; left: 10px; color: var(--c-text-3); font-size: var(--fs-sm); pointer-events: none; }
.input-wrap .input-affix + .input { padding-left: 24px; }
.check { display: inline-flex; align-items: center; gap: var(--sp-2); cursor: pointer; font-size: var(--fs-md); }
.check input { width: 16px; height: 16px; accent-color: var(--c-brand); margin: 0; }

/* Range (min-max) */
.range { display: flex; align-items: center; gap: var(--sp-2); }
.range .input-wrap { flex: 1 1 0; }
.range-sep { color: var(--c-text-4); }

/* ================= Segmented control ================= */
.seg { display: inline-flex; flex-shrink: 0; align-items: stretch; height: var(--control-h); padding: 3px; gap: 2px; background: var(--c-surface-3); border: 1px solid var(--c-border); border-radius: var(--r-md); min-width: 0; }
.seg-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 100%; padding: 0 var(--sp-3); border: 0; border-radius: var(--r-sm); background: transparent;
  color: var(--c-text-3); font-size: var(--fs-sm); font-weight: var(--fw-semibold); white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.seg-btn .icon { width: 15px; height: 15px; }
.seg-btn:hover { color: var(--c-text); }
.seg-btn[aria-pressed="true"], .seg-btn[aria-checked="true"] { background: var(--c-surface); color: var(--c-text); box-shadow: var(--shadow-sm); }
.seg-btn:focus-visible { outline: none; box-shadow: var(--ring); }

/* ================= Chips ================= */
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 var(--sp-3);
  border: 1px solid var(--c-border-strong); border-radius: var(--r-full); background: var(--c-surface);
  color: var(--c-text-2); font-size: var(--fs-sm); font-weight: var(--fw-medium); white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.chip:hover { background: var(--c-surface-3); }
.chip[aria-pressed="true"] { background: var(--c-brand-soft); border-color: var(--c-brand); color: var(--c-brand-text); }
.chip:focus-visible { outline: none; box-shadow: var(--ring); }
.chip-count { font-size: var(--fs-xs); color: var(--c-text-3); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] .chip-count { color: var(--c-brand-text); }

/* ================= Badges, pills, tags ================= */
.badge {
  --b-bg: var(--c-surface-3); --b-fg: var(--c-text-2); --b-bd: var(--c-border);
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 var(--sp-2);
  border-radius: var(--r-full); border: 1px solid var(--b-bd); background: var(--b-bg); color: var(--b-fg);
  font-size: var(--fs-xs); font-weight: var(--fw-semibold); white-space: nowrap; line-height: 1;
}
.badge .icon { width: 12px; height: 12px; }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-brand { --b-bg: var(--c-brand-soft); --b-fg: var(--c-brand-text); --b-bd: var(--c-brand-soft-2); }
.badge-accent { --b-bg: var(--c-accent-soft); --b-fg: var(--c-accent-text); --b-bd: transparent; }
.badge-success { --b-bg: var(--c-success-soft); --b-fg: var(--c-success-text); --b-bd: var(--c-success-border); }
.badge-warn { --b-bg: var(--c-warn-soft); --b-fg: var(--c-warn-text); --b-bd: var(--c-warn-border); }
.badge-danger { --b-bg: var(--c-danger-soft); --b-fg: var(--c-danger-text); --b-bd: var(--c-danger-border); }
.badge-info { --b-bg: var(--c-info-soft); --b-fg: var(--c-info-text); --b-bd: var(--c-info-border); }
.badge-lg { height: 26px; padding: 0 var(--sp-3); font-size: var(--fs-sm); }

/* Score pill: >=80 strong, 60-79 good, <60 weak */
.score {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  min-width: 40px; height: 26px; padding: 0 var(--sp-2); border-radius: var(--r-sm);
  font-size: var(--fs-sm); font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; line-height: 1;
  border: 1px solid transparent;
}
.score-strong { background: var(--c-success-soft); color: var(--c-success-text); border-color: var(--c-success-border); }
.score-good { background: var(--c-warn-soft); color: var(--c-warn-text); border-color: var(--c-warn-border); }
.score-weak { background: var(--c-surface-3); color: var(--c-text-3); border-color: var(--c-border); }
.score-lg { min-width: 56px; height: 40px; font-size: var(--fs-xl); border-radius: var(--r-md); }
.score-xl { min-width: 72px; height: 56px; font-size: var(--fs-3xl); border-radius: var(--r-lg); }

.fits { display: flex; flex-wrap: wrap; gap: var(--sp-1); }
.fit {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 var(--sp-2);
  border-radius: var(--r-sm); font-size: var(--fs-xs); font-weight: var(--fw-semibold); white-space: nowrap;
  background: var(--c-surface-3); color: var(--c-text-2); border: 1px solid var(--c-border);
}
.fit .icon { width: 12px; height: 12px; }
.fit-dropship.is-hl { background: var(--c-brand-soft); color: var(--c-brand-text); border-color: var(--c-brand-soft-2); }
.fit-brand.is-hl { background: var(--c-accent-soft); color: var(--c-accent-text); border-color: transparent; }

.flag { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: var(--fs-sm); color: var(--c-text-2); }
.flag-emoji { font-size: 16px; line-height: 1; }
.flag-code { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--c-text-3); letter-spacing: 0.03em; }

kbd, .kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 5px;
  border: 1px solid var(--c-border-strong); border-bottom-width: 2px; border-radius: var(--r-xs);
  background: var(--c-surface-2); color: var(--c-text-3); font-size: var(--fs-2xs); font-family: var(--font-sans); font-weight: var(--fw-semibold);
}

/* ================= Cards ================= */
.card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--shadow-xs); min-width: 0; }
.card-pad { padding: var(--sp-5); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--c-border); }
.card-head h2, .card-head h3 { font-size: var(--fs-lg); }
/* Actions (small buttons, notes) never make a header taller than a title-only header, so card titles line up. */
.card-head > .row { margin-block: calc(-1 * var(--sp-2)); }
.card-body { padding: var(--sp-5); }
.card-foot { padding: var(--sp-3) var(--sp-5); border-top: 1px solid var(--c-border); background: var(--c-surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.card-link { display: block; color: inherit; text-decoration: none !important; transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease); cursor: pointer; }
.card-link:hover { border-color: var(--c-border-strong); box-shadow: var(--shadow-md); }
.card-link:focus-visible { outline: none; box-shadow: var(--ring); }

.grid-cards { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--min, 240px)), 1fr)); }

/* Metric card */
.metrics { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.metric { padding: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-2); }
.metric-top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.metric-label { font-size: var(--fs-sm); color: var(--c-text-3); font-weight: var(--fw-medium); }
.metric-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-md); background: var(--c-brand-soft); color: var(--c-brand-text); }
.metric-icon .icon { width: 16px; height: 16px; }
.metric-value { font-size: var(--fs-4xl); font-weight: var(--fw-bold); letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--c-text); }
.metric-hint { font-size: var(--fs-xs); color: var(--c-text-3); }

/* Thumbnail */
.thumb { position: relative; flex-shrink: 0; width: var(--size, 44px); height: var(--size, 44px); border-radius: var(--r-md); background: var(--c-white); border: 1px solid var(--c-border); overflow: hidden; display: grid; place-items: center; color: var(--c-text-4); }
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.thumb.is-empty { background: var(--c-surface-3); }

/* ================= Page header & sections ================= */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-6); }
.page-header-text { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
.page-eyebrow { font-size: var(--fs-xs); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: 0.06em; color: var(--c-brand-text); }
.page-title { font-size: var(--fs-3xl); font-weight: var(--fw-bold); letter-spacing: -0.02em; }
.page-subtitle { color: var(--c-text-3); font-size: var(--fs-md); max-width: 720px; text-wrap: balance; }
.page-actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); color: var(--c-text-3); margin-bottom: var(--sp-2); }
.back-link:hover { color: var(--c-text); text-decoration: none; }

.section { margin-top: var(--sp-8); }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); flex-wrap: wrap; }
.section-title { font-size: var(--fs-xl); font-weight: var(--fw-semibold); }
.section-subtitle { font-size: var(--fs-sm); color: var(--c-text-3); margin-top: 2px; text-wrap: pretty; }

/* ================= Filter bar ================= */
.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--sp-3); padding: var(--sp-4); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--shadow-xs); margin-bottom: var(--sp-4); }
.filter-bar .field { flex: 0 1 180px; }
.filter-bar .field.f-wide { flex: 1 1 260px; }
.filter-bar .field.f-chips { flex: 1 1 100%; }
.filter-bar-actions { display: flex; gap: var(--sp-2); margin-left: auto; align-self: flex-end; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.result-count { font-size: var(--fs-sm); color: var(--c-text-3); }
.result-count b { color: var(--c-text); font-weight: var(--fw-semibold); }

/* Dropdown trigger used by multiSelect / country picker */
.dd-trigger {
  display: inline-flex; align-items: center; gap: var(--sp-2); width: 100%; height: var(--control-h); padding: 0 var(--sp-3);
  border: 1px solid var(--c-border-strong); border-radius: var(--r-md); background: var(--c-surface); color: var(--c-text);
  font-size: var(--fs-md); text-align: left; box-shadow: var(--shadow-xs); min-width: 0;
}
.dd-trigger:hover { border-color: var(--c-text-4); }
.dd-trigger:focus-visible, .dd-trigger[aria-expanded="true"] { outline: none; border-color: var(--c-brand); box-shadow: var(--ring); }
.dd-trigger .dd-value { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-trigger .icon { width: 16px; height: 16px; color: var(--c-icon); }

/* ================= Popover / menu ================= */
.popover {
  position: fixed; z-index: var(--z-dropdown); min-width: 200px; max-width: min(360px, calc(100vw - 16px));
  background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); padding: var(--sp-1); display: flex; flex-direction: column;
  animation: pop-in var(--dur-fast) var(--ease);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.popover-search { padding: var(--sp-1) var(--sp-1) var(--sp-2); border-bottom: 1px solid var(--c-border); margin-bottom: var(--sp-1); }
.popover-list { overflow-y: auto; max-height: min(360px, 60vh); display: flex; flex-direction: column; }
.popover-group { padding: var(--sp-2) var(--sp-3) var(--sp-1); font-size: var(--fs-2xs); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: 0.06em; color: var(--c-text-4); }
.menu-item {
  display: flex; align-items: center; gap: var(--sp-2); width: 100%; min-height: 34px; padding: 0 var(--sp-3);
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--c-text-2);
  font-size: var(--fs-md); text-align: left; text-decoration: none !important; cursor: pointer;
}
.menu-item .icon { width: 16px; height: 16px; color: var(--c-icon); }
.menu-item:hover, .menu-item.is-active { background: var(--c-surface-3); color: var(--c-text); }
.menu-item:focus-visible { outline: none; background: var(--c-surface-3); box-shadow: var(--ring-inset); }
.menu-item[aria-selected="true"], .menu-item[aria-checked="true"] { color: var(--c-brand-text); font-weight: var(--fw-semibold); }
.menu-item > .truncate, .menu-item > .menu-label { flex: 1 1 auto; min-width: 0; }
.menu-item .menu-meta { margin-left: auto; padding-left: var(--sp-2); font-size: var(--fs-xs); color: var(--c-text-4); font-variant-numeric: tabular-nums; }
.menu-item .menu-check { display: inline-flex; align-items: center; justify-content: center; width: 16px; flex-shrink: 0; margin-left: var(--sp-2); color: var(--c-brand-text); }
.menu-item.danger { color: var(--c-danger-text); }
.menu-item.danger .icon { color: var(--c-danger-text); }
.menu-sep { height: 1px; background: var(--c-border); margin: var(--sp-1) 0; }
.menu-head { padding: var(--sp-2) var(--sp-3) var(--sp-3); border-bottom: 1px solid var(--c-border); margin-bottom: var(--sp-1); }
.menu-empty { padding: var(--sp-4) var(--sp-3); text-align: center; color: var(--c-text-3); font-size: var(--fs-sm); }

/* ================= Data table ================= */
.dt { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--shadow-xs); overflow: hidden; min-width: 0; }
.dt-scroll { overflow: auto; max-height: var(--dt-max-h, none); -webkit-overflow-scrolling: touch; }
.dt table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-md); }
.dt th {
  position: sticky; top: 0; z-index: 2; background: var(--c-surface-2); color: var(--c-text-3);
  font-size: var(--fs-xs); font-weight: var(--fw-semibold); text-transform: uppercase; letter-spacing: 0.04em;
  text-align: left; padding: 0 var(--sp-4); height: 40px; border-bottom: 1px solid var(--c-border); white-space: nowrap;
}
.dt td { padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--c-border); vertical-align: middle; color: var(--c-text-2); }
.dt tbody tr:last-child td { border-bottom: 0; }
.dt tbody tr { transition: background var(--dur-fast) var(--ease); }
.dt tbody tr:hover td { background: var(--c-surface-2); }
.dt tr.is-click { cursor: pointer; }
.dt tr.is-click:focus-visible { outline: 2px solid var(--c-brand); outline-offset: -2px; }
.dt tr.is-click:focus-visible td { background: var(--c-brand-soft); }
.dt .al-right { text-align: right; }
.dt .al-center { text-align: center; }
.dt th.al-right .th-btn { justify-content: flex-end; }
.dt th.al-center .th-btn { justify-content: center; }
.dt .th-btn { display: inline-flex; align-items: center; gap: 4px; width: 100%; height: 100%; border: 0; background: none; padding: 0; color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; }
.dt .th-btn:hover { color: var(--c-text); }
.dt .th-btn .icon { width: 13px; height: 13px; opacity: 0.45; }
.dt th[aria-sort="ascending"], .dt th[aria-sort="descending"] { color: var(--c-brand-text); }
.dt th[aria-sort="ascending"] .th-btn .icon, .dt th[aria-sort="descending"] .th-btn .icon { opacity: 1; }
.dt .col-sticky { position: sticky; left: 0; z-index: 1; background: var(--c-surface); }
.dt th.col-sticky { z-index: 3; background: var(--c-surface-2); }
.dt tbody tr:hover td.col-sticky { background: var(--c-surface-2); }
.dt td.is-hl { background: var(--c-brand-soft); }
.dt tbody tr:hover td.is-hl { background: var(--c-brand-soft-2); }
.dt th.is-hl { color: var(--c-brand-text); }
.dt-title { font-weight: var(--fw-medium); color: var(--c-text); line-height: 1.35; }
.dt-sub { font-size: var(--fs-xs); color: var(--c-text-3); margin-top: 2px; }
.dt-empty { padding: var(--sp-8) var(--sp-4); }

/* Locked rows */
.dt tr.is-locked td { color: var(--c-text-4); }
.lock-bar { display: inline-block; height: 10px; width: var(--w, 80px); max-width: 100%; border-radius: var(--r-full); background: var(--c-surface-4); filter: blur(2px); vertical-align: middle; }
.blur { filter: blur(5px); user-select: none; pointer-events: none; }
.lock-cta { display: inline-flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; color: var(--c-text-3); font-size: var(--fs-sm); }
.lock-cta .icon { width: 15px; height: 15px; color: var(--c-accent-text); }

.lock-wrap { position: relative; border-radius: var(--r-lg); overflow: hidden; }
.lock-overlay {
  position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-2); padding: var(--sp-5); text-align: center; background: var(--c-lock-veil); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.lock-overlay .lock-icon, .lock-card .lock-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-full); background: var(--c-accent-soft); color: var(--c-accent-text); }
.lock-overlay b, .lock-card b { font-size: var(--fs-lg); color: var(--c-text); }
.lock-overlay p, .lock-card p { font-size: var(--fs-sm); color: var(--c-text-3); max-width: 320px; }
.lock-card { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-2); text-align: center; padding: var(--sp-6); min-height: 220px; border-style: dashed; background: var(--c-surface-2); }

/* ================= Pagination ================= */
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; padding: var(--sp-3) 0; }
.pager-info { font-size: var(--fs-sm); color: var(--c-text-3); }
.pager-info b { color: var(--c-text); font-weight: var(--fw-semibold); }
.pager-nav { display: flex; align-items: center; gap: var(--sp-1); }
.pager-page { min-width: 32px; height: 32px; padding: 0 var(--sp-2); border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; color: var(--c-text-2); font-size: var(--fs-sm); font-weight: var(--fw-medium); font-variant-numeric: tabular-nums; }
.pager-page:hover { background: var(--c-surface-3); }
.pager-page[aria-current="page"] { background: var(--c-brand-soft); color: var(--c-brand-text); border-color: var(--c-brand-soft-2); font-weight: var(--fw-semibold); }
.pager-page:focus-visible { outline: none; box-shadow: var(--ring); }
.pager-gap { min-width: 24px; text-align: center; color: var(--c-text-4); }
@media (max-width: 640px) { .pager-page.is-far { display: none; } }

/* ================= Skeleton ================= */
.sk { display: block; border-radius: var(--r-sm); background: linear-gradient(90deg, var(--c-skeleton) 0%, var(--c-skeleton-shine) 50%, var(--c-skeleton) 100%); background-size: 200% 100%; animation: sk-shine 1.4s ease-in-out infinite; }
@keyframes sk-shine { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.sk-line { height: 12px; }
.sk-title { height: 22px; width: 40%; }
.sk-thumb { width: 44px; height: 44px; border-radius: var(--r-md); flex-shrink: 0; }
.sk-pill { width: 40px; height: 24px; }
.sk-block { height: 160px; border-radius: var(--r-md); }
.sk-table .sk-row { display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--c-border); }
.sk-table .sk-row:last-child { border-bottom: 0; }
.sk-table .sk-head { height: 40px; background: var(--c-surface-2); border-bottom: 1px solid var(--c-border); }
.sk-card { padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); }

/* ================= Empty / error states ================= */
.state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: var(--sp-3); padding: var(--sp-12) var(--sp-6); }
.state.card { padding: var(--sp-12) var(--sp-6); }
.state-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: var(--r-full); background: var(--c-brand-soft); color: var(--c-brand-text); box-shadow: 0 0 0 8px var(--c-surface-2); margin-bottom: var(--sp-2); }
.state-icon .icon { width: 24px; height: 24px; }
.state.is-error .state-icon { background: var(--c-danger-soft); color: var(--c-danger-text); }
.state-title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); color: var(--c-text); }
.state-text { max-width: 440px; color: var(--c-text-3); font-size: var(--fs-md); }
.state-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; justify-content: center; margin-top: var(--sp-2); }
.state-detail { font-size: var(--fs-xs); color: var(--c-text-4); font-family: var(--font-mono); }

/* Inline notice / banner */
.notice { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); border: 1px solid var(--c-info-border); background: var(--c-info-soft); color: var(--c-text-2); font-size: var(--fs-sm); }
.notice .icon { width: 18px; height: 18px; color: var(--c-info-text); margin-top: 1px; }
.notice-accent { border-color: var(--c-warn-border); background: var(--c-accent-soft); }
.notice-accent .icon { color: var(--c-accent-text); }
.notice-brand { border-color: var(--c-brand-soft-2); background: var(--c-brand-soft); }
.notice-brand .icon { color: var(--c-brand-text); }
.notice-danger { border-color: var(--c-danger-border); background: var(--c-danger-soft); }
.notice-danger .icon { color: var(--c-danger-text); }
.notice .grow > b { color: var(--c-text); }

/* ================= Modal ================= */
.modal-backdrop { position: fixed; inset: 0; z-index: var(--z-modal); background: var(--c-overlay); display: grid; place-items: center; padding: var(--sp-4); animation: fade-in var(--dur) var(--ease); overflow-y: auto; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal { width: 100%; max-width: 480px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-xl); box-shadow: var(--shadow-xl); animation: modal-in var(--dur) var(--ease); }
.modal-sm { max-width: 400px; }
.modal-lg { max-width: 720px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-5) var(--sp-5) var(--sp-3); }
.modal-title { font-size: var(--fs-xl); font-weight: var(--fw-semibold); }
.modal-subtitle { font-size: var(--fs-sm); color: var(--c-text-3); margin-top: 4px; }
.modal-body { padding: var(--sp-2) var(--sp-5) var(--sp-5); overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--c-border); flex-wrap: wrap; }

/* Folder chooser (save picker) */
.pick-list { display: flex; flex-direction: column; gap: var(--sp-1); max-height: 280px; overflow-y: auto; margin: 0 calc(var(--sp-1) * -1); padding: var(--sp-1); }
.pick-item { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); border: 1px solid var(--c-border); border-radius: var(--r-md); cursor: pointer; transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease); }
.pick-item:hover { background: var(--c-surface-2); }
.pick-item:has(input:checked) { border-color: var(--c-brand); background: var(--c-brand-soft); }
.pick-item input { accent-color: var(--c-brand); margin: 0; width: 16px; height: 16px; }
.pick-item .icon { color: var(--c-icon); }
.pick-item .pick-name { flex: 1 1 auto; min-width: 0; font-weight: var(--fw-medium); color: var(--c-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-item .pick-count { font-size: var(--fs-xs); color: var(--c-text-3); }

/* ================= Toast ================= */
.toasts { position: fixed; z-index: var(--z-toast); right: var(--sp-6); bottom: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-2); align-items: flex-end; pointer-events: none; max-width: calc(100vw - 32px); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: var(--sp-3); min-width: 260px; max-width: 420px; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-lg); background: var(--c-text); color: var(--c-surface); box-shadow: var(--shadow-lg); font-size: var(--fs-md); animation: toast-in var(--dur) var(--ease); }
:root[data-theme="dark"] .toast { background: var(--c-surface-4); color: var(--c-text); border: 1px solid var(--c-border-strong); }
.toast .icon { width: 18px; height: 18px; }
.toast-success .icon { color: var(--c-success); }
.toast-error .icon { color: var(--c-danger); }
.toast-info .icon { color: var(--c-info); }
.toast-msg { flex: 1 1 auto; min-width: 0; }
.toast-action { border: 0; background: none; color: var(--c-brand-hover); font-weight: var(--fw-semibold); font-size: var(--fs-sm); padding: 0; text-decoration: none; white-space: nowrap; }
:root[data-theme="dark"] .toast-action { color: var(--c-brand-text); }
.toast-close { border: 0; background: none; color: inherit; opacity: 0.6; padding: 2px; display: grid; place-items: center; border-radius: var(--r-xs); }
.toast-close:hover { opacity: 1; }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (max-width: 640px) { .toasts { left: var(--sp-4); right: var(--sp-4); bottom: var(--sp-4); align-items: stretch; } .toast { min-width: 0; max-width: none; } }

/* ================= Misc ================= */
.divider { height: 1px; background: var(--c-border); margin: var(--sp-4) 0; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--c-border-strong); border-top-color: var(--c-brand); animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--sp-4); }
.dl-item { display: flex; flex-direction: column; gap: 2px; }
.dl-item dt { font-size: var(--fs-xs); color: var(--c-text-3); }
.dl-item dd { margin: 0; font-weight: var(--fw-semibold); color: var(--c-text); }
.progress { height: 6px; border-radius: var(--r-full); background: var(--c-surface-4); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--c-brand); }
.progress.is-warn > span { background: var(--c-accent); }
.row > .select, .toolbar .select, .row > .input-wrap { width: auto; flex: 0 1 auto; }
.row > .select { min-width: 140px; }
.popover-notice { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-3); margin-bottom: var(--sp-1); border-radius: var(--r-md); background: var(--c-warn-soft); color: var(--c-text-2); font-size: var(--fs-sm); }
.popover-notice > .icon { width: 16px; height: 16px; color: var(--c-warn-text); }
