/* /import/ — the three import modes (dive computer, logbook file, CSV).
 *
 * Everything visual comes from dl.css tokens (rule #5), so all five themes
 * work without a branch. Colour rule for this page: --err only for a thing
 * that failed. Instructions are --text-muted, browser-support advice and
 * the re-read warning are --warn, a duplicate dive is neutral.
 */

/* ── Shell ──────────────────────────────────────────────────────────────── */
.imp-shell {
    max-width: 1160px;
    margin-inline: auto;
}
/* Compact shared page header (dl-page-header--photo): title + one line. The
   tabs right under it already name the three ways in, so it stays short. */
.imp-header { margin-bottom: var(--space-4); }

/* ── Mode switch (ARIA tabs) ────────────────────────────────────────────── */
.imp-modes {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-2);
    padding: var(--space-1);
    margin-bottom: var(--space-5);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: color-mix(in srgb, var(--bg-card) 86%, transparent);
}
.imp-mode {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
    min-height: var(--touch-target);
    padding: var(--space-3) var(--space-4);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background var(--duration-normal) var(--ease-standard),
                color var(--duration-normal) var(--ease-standard),
                border-color var(--duration-normal) var(--ease-standard);
}
.imp-mode:hover { color: var(--text); background: var(--bg-subtle); }
.imp-mode[aria-selected="true"] {
    color: var(--text);
    background: var(--accent-soft);
    border-color: color-mix(in srgb, var(--accent) 55%, transparent);
}
.imp-mode[aria-selected="true"] .imp-mode__icon { color: var(--accent); }
.imp-mode:focus-visible {
    outline: var(--focus-width) solid var(--focus-ring);
    outline-offset: var(--focus-offset);
}
.imp-mode__icon { width: var(--icon-lg); height: var(--icon-lg); flex: 0 0 auto; }
.imp-mode__text { display: flex; flex-direction: column; min-width: 0; }
.imp-mode__title { font-weight: 600; line-height: var(--line-tight); overflow-wrap: anywhere; }
.imp-mode__sub {
    margin-top: 2px;
    font-size: var(--font-size-xs);
    color: var(--text-subtle);
    overflow-wrap: anywhere;
}
/* Work left in a background mode: a worded badge, never a bare dot. */
.imp-mode__pending {
    margin-left: auto;
    flex: 0 0 auto;
    padding: 2px var(--space-2);
    border: 1px solid color-mix(in srgb, var(--warn) 55%, transparent);
    border-radius: var(--radius-pill);
    background: var(--warn-soft);
    color: var(--text);
    font-size: var(--font-size-xs);
    font-weight: 600;
    line-height: var(--line-tight);
    white-space: nowrap;
}
.imp-mode__pending[hidden] { display: none; }

/* ── Panel + stage ──────────────────────────────────────────────────────── */
.imp-panel {
    padding: var(--panel-padding);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    box-shadow: var(--shadow-xs);
}
.imp-panel[hidden], .imp-stage[hidden] { display: none; }
.imp-enter { animation: imp-enter 220ms var(--ease-standard) both; }
@keyframes imp-enter {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

.imp-step-head { margin-bottom: var(--space-4); }
.imp-step-title {
    margin: 0;
    font-size: var(--font-size-xl);
    line-height: var(--line-tight);
}
.imp-step-title:focus { outline: none; }
.imp-step-sub {
    margin: var(--space-1) 0 0;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    max-width: 68ch;
}
/* "Name this computer" under the review sub-line (native/08). */
.imp-devname {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-2);
}
.imp-devname[hidden] { display: none; }
.imp-devname__hint,
.imp-devname__note {
    margin: 0;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    max-width: 68ch;
}
.imp-devname__note { flex-basis: 100%; color: var(--text-subtle); }
.imp-msg-host:empty { display: none; }
.imp-msg-host { margin-bottom: var(--space-4); }
.imp-muted { color: var(--text-subtle); }

/* ── Stepper (progress indicator, not navigation) ───────────────────────── */
.imp-stepper { margin-bottom: var(--space-5); }
.imp-stepper__list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-5);
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: none;
}
.imp-stepper__item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--text-subtle);
    font-size: var(--font-size-sm);
}
.imp-stepper__item + .imp-stepper__item::before {
    content: "";
    width: 28px;
    height: 1px;
    margin-right: var(--space-2);
    background: var(--border-strong);
}
.imp-stepper__dot {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid var(--border-strong);
    font-size: var(--font-size-xs);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    transition: background var(--duration-slow) var(--ease-standard),
                border-color var(--duration-slow) var(--ease-standard);
}
.imp-stepper__tick { display: none; width: 14px; height: 14px; stroke-width: 2.5; }
.imp-stepper__item.is-current { color: var(--text); font-weight: 600; }
.imp-stepper__item.is-current .imp-stepper__dot {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--text-on-accent);
}
.imp-stepper__item.is-done { color: var(--text-muted); }
.imp-stepper__item.is-done .imp-stepper__dot {
    border-color: var(--ok);
    color: var(--ok);
    background: var(--ok-soft);
}
.imp-stepper__item.is-done .imp-stepper__num { display: none; }
.imp-stepper__item.is-done .imp-stepper__tick { display: block; }
/* Compact form, phone only: "Step 2 of 3 · Read dives" + a thin bar. */
.imp-stepper__compact, .imp-stepper__bar { display: none; }
.imp-stepper__compact {
    margin: 0 0 var(--space-2);
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text);
}
.imp-stepper__bar {
    height: 4px;
    border-radius: var(--radius-pill);
    background: var(--bg-elev);
    overflow: hidden;
}
.imp-stepper__bar > span {
    display: block;
    height: 100%;
    background: var(--accent);
    border-radius: inherit;
    transition: width var(--duration-slow) var(--ease-standard);
}

/* ── Notices ────────────────────────────────────────────────────────────── */
.imp-notice {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}
.imp-notice + .imp-notice { margin-top: var(--space-2); }
.imp-notice__icon { margin-top: 1px; }
.imp-notice__body { min-width: 0; flex: 1; }
.imp-notice__title { margin: 0 0 2px; font-weight: 600; color: var(--text); }
.imp-notice__title:focus { outline: none; }
.imp-notice__text { margin: 0; overflow-wrap: anywhere; }
.imp-notice__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-3);
}
.imp-notice--info  { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 45%, transparent); color: var(--text); }
.imp-notice--info  .imp-notice__icon { color: var(--info); }
.imp-notice--ok    { background: var(--ok-soft);   border-color: color-mix(in srgb, var(--ok) 50%, transparent);   color: var(--text); }
.imp-notice--ok    .imp-notice__icon { color: var(--ok); }
.imp-notice--warn  { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 55%, transparent); color: var(--text); }
.imp-notice--warn  .imp-notice__icon { color: var(--warn); }
.imp-notice--err   { background: var(--err-soft);  border-color: color-mix(in srgb, var(--err) 55%, transparent);  color: var(--text); }
.imp-notice--err   .imp-notice__icon { color: var(--err); }
.imp-notice--ok { padding: var(--space-4) var(--space-5); }
.imp-notice--ok .imp-notice__title { font-size: var(--font-size-lg); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
/* Every button is the shared .dl-btn; only link-looking text buttons live here. */
.imp-panel a.dl-btn { text-decoration: none; }
.imp-linkbtn {
    appearance: none;
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}
.imp-linkbtn:hover { color: var(--accent-hover); }
.imp-linkbtn:focus-visible { outline: var(--focus-width) solid var(--focus-ring); outline-offset: var(--focus-offset); }

/* ── BLE step 1 ─────────────────────────────────────────────────────────── */
/* Form on the left, "How it works" on the right: the card is used edge to
   edge and the first screen explains the flow. */
.imp-pick {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(16rem, 1fr);
    gap: var(--space-6);
    align-items: start;
}
.imp-pick__form { min-width: 0; }
.imp-pick__fields { min-width: 0; margin: 0; padding: 0; border: 0; }
/* No Web Bluetooth: the picker is switched off as a whole and reads so. */
.imp-pick__fields.is-off { opacity: .55; }
.imp-pick__fields.is-off .dl-disclosure__summary { pointer-events: none; cursor: default; }
.imp-device {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-2);
}
.imp-device .dlf-field, .imp-more .dlf-field { margin-bottom: 0; }
.imp-more { margin-top: var(--space-3); border-bottom: 1px solid var(--border); }
.imp-how {
    padding: var(--space-4) var(--space-5);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}
.imp-how__title {
    margin: 0 0 var(--space-3);
    font-size: var(--font-size-md);
    color: var(--text);
}
.imp-how__list { display: grid; gap: var(--space-3); margin: 0; padding: 0; list-style: none; }
.imp-how__list li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-3); align-items: start; }
.imp-how__list .dl-icon { color: var(--accent); margin-top: 1px; }
.imp-how__alt { margin: var(--space-4) 0 0; padding-top: var(--space-3); border-top: 1px solid var(--border); }
.imp-more__body {
    display: grid;
    gap: var(--space-4);
    padding: var(--space-2) var(--space-1) var(--space-4);
    max-width: 640px;
}
.imp-more__body #force-warning:empty { display: none; }
.imp-connect {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3) var(--space-5);
    margin-top: var(--space-5);
}
.imp-connect__hint {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}
.imp-connect__hint[hidden] { display: none; }
.imp-diag-host:empty { display: none; }
#pick-diag-host { margin-top: var(--space-4); }

/* Toggle rows read as "switch + label" rather than a stacked form field. */
.imp-optbox { display: grid; gap: var(--space-3); margin-bottom: var(--space-4); }
.imp-more .dlf-field[data-name="force"],
.imp-optbox .dlf-field {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: var(--space-3);
    margin: 0;
}
.imp-more .dlf-field[data-name="force"] .dlf-label,
.imp-optbox .dlf-field .dlf-label { grid-column: 2; grid-row: 1; margin: 0; }
.imp-more .dlf-field[data-name="force"] .dlf-toggle-row,
.imp-optbox .dlf-field .dlf-toggle-row { grid-column: 1; grid-row: 1; }
.imp-more .dlf-field[data-name="force"] .dlf-hint,
.imp-optbox .dlf-field .dlf-hint { grid-column: 2; }
.imp-more .dlf-error:empty, .imp-optbox .dlf-error:empty,
.imp-device .dlf-error:empty, .imp-map .dlf-error:empty,
.imp-settings .dlf-error:empty { display: none; }
.imp-optbox .dlf-field.is-disabled { opacity: .5; }
.imp-optbox .dlf-field.is-disabled .dlf-toggle { pointer-events: none; }

/* ── BLE step 2: live panel ─────────────────────────────────────────────── */
.imp-live {
    padding: var(--space-5);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
}
.imp-live__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2) var(--space-3);
}
.imp-live__count {
    margin: var(--space-4) 0 var(--space-2);
    font-size: var(--font-size-2xl);
    font-weight: 700;
    letter-spacing: -.01em;
    font-variant-numeric: tabular-nums;
}
.imp-live__latest {
    margin: var(--space-3) 0 0;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    font-variant-numeric: tabular-nums;
}
.imp-live__latest[hidden] { display: none; }
.imp-live__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: var(--space-2);
    margin-top: var(--space-4);
}
.imp-progress {
    position: relative;
    height: 8px;
    border-radius: var(--radius-pill);
    background: var(--bg-elev);
    overflow: hidden;
}
.imp-progress__bar {
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: var(--accent);
    transition: width var(--duration-slow) var(--ease-standard);
}
.imp-progress.is-indeterminate .imp-progress__bar {
    width: 35%;
    animation: imp-indeterminate 1.4s var(--ease-standard) infinite;
}
@keyframes imp-indeterminate {
    from { transform: translateX(-100%); }
    to   { transform: translateX(290%); }
}
.imp-received { margin-top: var(--space-5); }
.imp-received[hidden] { display: none; }
.imp-received__title {
    margin: 0 0 var(--space-2);
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-muted);
}
.imp-received__list { margin: 0; padding: 0; list-style: none; }
.imp-received__list li {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: var(--space-1) var(--space-4);
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border);
    font-size: var(--font-size-sm);
    font-variant-numeric: tabular-nums;
}
.imp-received__list li:first-child { animation: imp-enter 260ms var(--ease-standard) both; }
.imp-received__meta { color: var(--text-muted); white-space: nowrap; }
.imp-received__more { margin: var(--space-2) 0 0; color: var(--text-subtle); font-size: var(--font-size-sm); }
.imp-received__more[hidden] { display: none; }

/* ── Technical log ──────────────────────────────────────────────────────── */
/* A link-weight disclosure that sits in the current step's status area. */
#read-diag-host { margin-top: var(--space-3); }
.imp-diag[hidden] { display: none; }
.imp-diag__summary {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    min-height: var(--touch-target);
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    cursor: pointer;
    list-style: none;
}
.imp-diag__summary::-webkit-details-marker { display: none; }
.imp-diag__summary:hover { color: var(--accent); }
.imp-diag__summary span { text-decoration: underline; text-underline-offset: 2px; }
.imp-diag__summary:focus-visible { outline: var(--focus-width) solid var(--focus-ring); outline-offset: var(--focus-offset); border-radius: var(--radius-sm); }
.imp-diag[open] { flex-basis: 100%; }
.imp-diag__body { padding-bottom: var(--space-3); }
.imp-step-head--split {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-2) var(--space-4);
}
.imp-step-head--split > div:first-child { min-width: 0; }
#review-diag-host { margin-left: auto; }
/* Opened, the log takes its own full-width row under the title. */
#review-diag-host:has(.imp-diag[open]) { flex-basis: 100%; margin-left: 0; }
.imp-log {
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--space-3);
    max-height: 220px;
    overflow-y: auto;
    margin: var(--space-2) 0 var(--space-3);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.imp-log-err { color: var(--err); }
.imp-log-ok  { color: var(--ok); }

/* ── Summary line ───────────────────────────────────────────────────────── */
/* Plain text, not pills: pills look like filters, and these counts are not. */
.imp-stats {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) 0;
    margin: 0 0 var(--space-4);
    padding: 0;
    list-style: none;
    font-size: var(--font-size-md);
}
.imp-stat {
    display: inline-flex;
    align-items: baseline;
    gap: var(--space-1);
    color: var(--text-muted);
}
.imp-stat + .imp-stat::before {
    content: "·";
    margin: 0 var(--space-3);
    color: var(--text-subtle);
}
.imp-stat__value { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.imp-stat--ok  .imp-stat__value { color: var(--ok); }
.imp-stat--err .imp-stat__value { color: var(--err); }

.imp-file-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin: 0 0 var(--space-3);
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}
.imp-file-meta__name { font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.imp-file-meta .dl-chip { gap: 4px; }
.imp-facts {
    margin: 0 0 var(--space-4);
    padding: 0;
    list-style: none;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}
.imp-facts li + li { margin-top: 2px; }
.imp-site { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); }
.imp-chip-new { font-size: var(--font-size-xs); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }

/* ── Review list (table on wide screens, record cards on phones) ────────── */
.imp-review { margin-bottom: var(--space-2); }
/* Counter and the selection shortcuts sit together, on the same side as
   the header checkbox that does the same job. */
.imp-review__bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: var(--space-2) var(--space-4);
    margin-bottom: var(--space-2);
}
.imp-review__count { font-size: var(--font-size-sm); font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.imp-review__tools { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.imp-review__tools [hidden] { display: none; }
.imp-review__scroll {
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.imp-rtable { width: 100%; border-collapse: collapse; font-size: var(--font-size-sm); }
.imp-rtable th, .imp-rtable td {
    padding: var(--space-2) var(--space-3);
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}
.imp-rtable thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--bg-elev);
    color: var(--text-muted);
    font-size: var(--font-size-xs);
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    white-space: nowrap;
}
.imp-rtable tbody tr:last-child td { border-bottom: 0; }
.imp-rtable__row { cursor: pointer; transition: background var(--duration-fast); }
.imp-rtable__row:hover { background: var(--bg-subtle); }
.imp-rtable__row.is-dup td:not(.imp-rtable__status):not(.imp-rtable__check) { color: var(--text-muted); }
.imp-rtable__row.is-error { cursor: default; }
.imp-rtable .is-num { text-align: right; font-variant-numeric: tabular-nums; }
.imp-rtable .is-nowrap { white-space: nowrap; }
.imp-rtable__cell.is-primary { font-weight: 600; }
.imp-rtable__check { width: 44px; }
.imp-rtable input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
    vertical-align: middle;
}
.imp-rtable input[type="checkbox"]:disabled { cursor: not-allowed; }
.imp-rtable__break { display: none; }
/* Desktop column order: status last, after the meta columns. */
.imp-rtable tbody tr { }
.imp-rtable__status { white-space: nowrap; }

.imp-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px var(--space-2);
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    font-size: var(--font-size-xs);
    font-weight: 600;
    white-space: nowrap;
}
.imp-status .dl-icon { width: .9rem; height: .9rem; stroke-width: 2.25; }
.imp-status--new     { color: var(--ok);  background: var(--ok-soft);  border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.imp-status--dup     { color: var(--text-muted); background: var(--bg-subtle); }
.imp-status--error   { color: var(--err); background: var(--err-soft); border-color: color-mix(in srgb, var(--err) 45%, transparent); }
.imp-status--pending { color: var(--text-subtle); background: transparent; border-style: dashed; }
.imp-status-wrap { display: inline-flex; flex-direction: column; gap: 2px; white-space: normal; }
.imp-status__reason { font-size: var(--font-size-xs); color: var(--text-muted); max-width: 32ch; overflow-wrap: anywhere; }

/* ── Drop zone ──────────────────────────────────────────────────────────── */
.imp-drop {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-6);
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--bg-subtle);
    cursor: pointer;
    transition: border-color var(--duration-normal), background var(--duration-normal);
}
.imp-drop:hover, .imp-drop.is-over {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.imp-drop:focus-within {
    outline: var(--focus-width) solid var(--focus-ring);
    outline-offset: var(--focus-offset);
}
.imp-drop__art {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
}
.imp-drop__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.imp-drop__title { font-weight: 600; color: var(--text); }
.imp-drop__hint { font-size: var(--font-size-sm); color: var(--text-muted); }
.imp-drop__busy {
    display: none;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-size-sm);
    color: var(--text);
}
.imp-drop.is-busy { cursor: progress; }
.imp-drop.is-busy .imp-drop__text { display: none; }
.imp-drop.is-busy .imp-drop__busy { display: inline-flex; }
.imp-spinner {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
    border-radius: 50%;
    border: 2px solid var(--border-strong);
    border-top-color: var(--accent);
    animation: imp-spin .7s linear infinite;
}
@keyframes imp-spin { to { transform: rotate(360deg); } }

.imp-formats { margin-top: var(--space-4); border-bottom: 1px solid var(--border); }
.imp-formats__list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: var(--space-2) var(--space-4);
    margin: 0;
    padding: var(--space-1) var(--space-1) var(--space-4);
    list-style: none;
    font-size: var(--font-size-sm);
}
.imp-formats__list li { display: flex; flex-direction: column; }
.imp-formats__ext { color: var(--text-subtle); font-size: var(--font-size-xs); }
#file-host > .imp-msg-host, #csv-host > .imp-msg-host { margin-top: var(--space-4); }

/* ── CSV: column mapping ────────────────────────────────────────────────── */
.imp-map-progress {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: var(--space-2) 0 var(--space-3);
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}
.imp-map-progress__bar {
    flex: 0 1 180px;
    height: 4px;
    border-radius: var(--radius-pill);
    background: var(--bg-elev);
    overflow: hidden;
}
.imp-map-progress__bar > span {
    display: block;
    height: 100%;
    background: var(--accent);
    transition: width var(--duration-slow) var(--ease-standard);
}
.imp-map { margin: 0 0 var(--space-4); padding: 0; list-style: none; }
.imp-map__head, .imp-map__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, .8fr) minmax(14rem, 1.3fr);
    gap: var(--space-3);
    align-items: center;
}
.imp-map__head {
    padding: 0 var(--space-3) var(--space-2);
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: var(--font-size-xs);
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.imp-map__row {
    padding: var(--space-1) var(--space-3);
    border-bottom: 1px solid var(--border);
    transition: background var(--duration-normal);
}
.imp-map__row:not(.is-mapped) .imp-map__name { color: var(--text-muted); font-weight: 500; }
.imp-map__name { font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.imp-map__sample {
    min-width: 0;
    color: var(--text-subtle);
    font-size: var(--font-size-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.imp-map__sample-label { display: none; }
.imp-map__target { min-width: 0; }
.imp-map__field { min-width: 0; margin: 0; }
.imp-map__field .dlf-label { display: none; }
.imp-map__field .dlf-hint:empty { display: none; }
.imp-map__unit:empty { display: none; }
.imp-map__unit {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    margin-top: 2px;
    color: var(--text-muted);
    font-size: var(--font-size-xs);
}
.imp-map__unit .dl-icon { color: var(--accent); flex: 0 0 auto; }
.imp-map__unit.is-warn .dl-icon { color: var(--warn); }

.imp-settings { margin-bottom: var(--space-4); border-bottom: 1px solid var(--border); }
.imp-settings .dl-disclosure__count {
    max-width: 50%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.imp-settings__body { padding: var(--space-2) var(--space-1) var(--space-4); }
.imp-settings__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: var(--space-3);
}
.imp-settings__opt { min-width: 0; }
.imp-settings__opt .dlf-label { display: block; margin-bottom: var(--space-1); }
.imp-settings__opt .dlf-field { margin: 0; }
.imp-settings .imp-optbox { margin: var(--space-4) 0 0; }

/* ── Sticky footer ──────────────────────────────────────────────────────── */
/* Sticks to the bottom of the viewport while its step is longer than the
   screen, so the primary action is never a scroll away. A self-contained
   bar rather than a flush panel edge: on the BLE review the technical-log
   disclosure follows it. */
.imp-footer {
    position: sticky;
    /* Clears the fixed global footer (desktop); phones override below. */
    bottom: calc(var(--space-2) + 44px);
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    margin-top: var(--space-4);
    padding: var(--space-3);
    padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--bg-elev) 90%, transparent);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-xs);
}
.imp-footer__left, .imp-footer__right { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.imp-footer__right { margin-left: auto; }

/* ── Phone / tablet ─────────────────────────────────────────────────────── */
@media (max-width: 720px) {
    .imp-modes { gap: var(--space-1); }
    .imp-mode {
        flex-direction: column;
        align-items: center;
        gap: var(--space-1);
        padding: var(--space-2) var(--space-1);
        text-align: center;
    }
    .imp-mode__sub { display: none; }
    .imp-mode__title { font-size: var(--font-size-sm); }
    .imp-panel { padding: var(--space-4); border-radius: var(--radius-md); }
    .imp-device { grid-template-columns: minmax(0, 1fr); }
    .imp-connect .dl-btn--lg { width: 100%; }
    .imp-mode__pending {
        margin-left: 0;
        max-width: 100%;
        padding: 1px var(--space-1);
        white-space: normal;
        text-align: center;
        overflow-wrap: anywhere;
    }
    .imp-live { padding: var(--space-4); }
    .imp-live__actions .dl-btn { flex: 1 1 auto; }
    .imp-pick { grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
    .imp-how { padding: var(--space-3) var(--space-4); }

    .imp-stepper__list { display: none; }
    .imp-stepper__compact, .imp-stepper__bar { display: block; }
    .imp-stepper { margin-bottom: var(--space-4); }

    .imp-drop { flex-direction: column; text-align: center; padding: var(--space-5) var(--space-4); }
    .imp-drop__text { align-items: center; }

    .imp-map__head { display: none; }
    /* One compact row per column: name + sample on one line, the
       dropdown under it — no card chrome, no repeated "Maps to" label. */
    .imp-map__row {
        grid-template-columns: minmax(0, auto) minmax(0, 1fr);
        gap: 2px var(--space-2);
        padding: var(--space-2) 0;
    }
    .imp-map__name { grid-column: 1; }
    .imp-map__sample { grid-column: 2; font-size: var(--font-size-xs); align-self: baseline; }
    .imp-map__target { grid-column: 1 / -1; }
    .imp-settings .dl-disclosure__count { display: none; }

    .imp-footer { bottom: var(--space-2); }
    .imp-footer .dl-btn { flex: 1 1 auto; }
    .imp-footer__right { margin-left: 0; flex: 1 1 60%; }
    .imp-footer__left { flex: 1 1 30%; }
}

/* Review list → record cards. Wider than the phone breakpoint: a seven-
   column file preview no longer fits a portrait tablet either. */
@media (max-width: 900px) {
    /* Record cards: checkbox at left, date + status on top, the rest as a
       wrapped meta line below — no seven squeezed columns. */
    .imp-review__scroll { border: 0; border-radius: 0; overflow: visible; max-height: none !important; }
    .imp-rtable, .imp-rtable tbody { display: block; }
    .imp-rtable thead { display: none; }
    .imp-rtable__row {
        position: relative;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: var(--space-1) var(--space-2);
        margin-bottom: var(--space-2);
        padding: var(--space-3) var(--space-3) var(--space-3) 52px;
        border: 1px solid var(--border);
        border-radius: var(--radius-md);
        background: var(--bg-subtle);
    }
    .imp-rtable__row td { display: block; padding: 0; border: 0; }
    .imp-rtable__check {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 48px !important;
        display: grid !important;
        place-items: center;
    }
    .imp-rtable input[type="checkbox"] { width: 22px; height: 22px; }
    .imp-rtable__cell.is-primary { flex: 1 1 auto; min-width: 0; }
    .imp-rtable__status { flex: 0 0 auto; }
    .imp-rtable__break { display: block !important; flex-basis: 100%; height: 0; }
    .imp-rtable__cell.is-meta { color: var(--text-muted); font-size: var(--font-size-sm); }
    .imp-rtable__cell.is-meta.is-empty { display: none; }
    .imp-rtable__cell.is-meta:not(.is-meta-first)::before { content: "·"; margin-right: var(--space-2); color: var(--text-subtle); }
    .imp-rtable .is-num { text-align: left; }
    .imp-status__reason { max-width: none; }

}

@media (prefers-reduced-motion: reduce) {
    .imp-enter, .imp-received__list li:first-child { animation: none; }
    .imp-progress.is-indeterminate .imp-progress__bar {
        animation: none;
        width: 100%;
        opacity: .45;
    }
    .imp-spinner { animation-duration: 2s; }
    .imp-mode, .imp-stepper__dot, .imp-stepper__bar > span,
    .imp-progress__bar, .imp-map__row, .imp-drop { transition: none; }
}

/* The "How it works" aside moves under the form before the two dropdowns
   get cramped (portrait tablets). */
@media (max-width: 960px) {
    .imp-pick { grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
}
