.editor-shell { max-width: 1950px; }
.editor-drop-zone { padding: 18px; border: 2px dashed var(--border); border-radius: 12px; background: var(--soft); }
.editor-drop-zone.drag-over { border-color: var(--accent); background: #e2eef6; }
.editor-drop-zone input { max-width: 520px; }
.editor-import-dialog, .editor-help-dialog { width: min(640px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 24px; border: 1px solid var(--border); border-radius: 16px; background: var(--card); color: var(--ink); }
.editor-import-dialog::backdrop, .editor-help-dialog::backdrop { background: rgb(0 0 0 / 60%); }
.editor-import-heading, .editor-help-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.editor-import-heading h2, .editor-help-heading h2 { margin: 0; }
.editor-import-section, .editor-import-debug { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--border); }
.editor-import-dialog h3 { margin: 0 0 16px; }
.editor-import-section > :last-child { margin-bottom: 0; }
.editor-import-dialog input { width: 100%; }
.editor-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin: 16px 0; }
#editor-upload-top { margin-left: auto; }
.editor-toolbar h2 { margin: 0; }
.editor-search { flex: 1 1 260px; max-width: 480px; }
.editor-check { display: flex; align-items: center; gap: 9px; margin: 0; }
.editor-check input { width: 18px; height: 18px; flex: 0 0 auto; }
.editor-workspace { margin-top: 22px; }
.editor-bulk .editor-toolbar { align-items: flex-end; }
.editor-bulk .editor-toolbar > div { flex: 1 1 150px; max-width: 220px; }
.editor-bulk input, .editor-bulk select { width: 100%; }
.editor-table select.editor-deferred-select { width: 125px; }
.editor-tabs-panel { margin-top: 22px; }
.editor-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 12px; }
.editor-tabs [role=tab] { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto; align-content: center; align-items: center; gap: 4px; flex: 0 0 auto; min-width: 260px; max-width: 320px; height: 78px; padding: 8px 16px; text-align: left; border: 2px solid var(--border); }
.editor-tabs [role=tab] > span { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.1rem; font-weight: 700; line-height: 1.3; }
.editor-tabs [role=tab][aria-selected=true] { border-color: var(--accent); background: var(--accent-strong); color: var(--card); }
.editor-tabs [role=tab] > small { display: block; white-space: nowrap; font-size: .8rem; font-weight: normal; line-height: 1.3; margin: 0; }
.editor-tabs [role=tab]:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.editor-tab-settings { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 10px; }
.editor-tab-settings > div { flex: 1 1 240px; max-width: 420px; }
.editor-tab-settings input { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: var(--card); color: var(--ink); }
.editor-table-scroll { max-height: 65vh; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.editor-table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .85rem; }
.editor-table th { position: sticky; top: 0; z-index: 2; background: var(--accent-strong); color: white; text-align: left; white-space: nowrap; padding: 10px 8px; }
.editor-table td { padding: 4px; border-bottom: 1px solid var(--border); background: var(--card); }
.editor-table tr:nth-child(even) td { background: var(--soft); }
.editor-table td:first-child { position: sticky; left: 0; z-index: 1; }
.editor-table th:first-child { left: 0; z-index: 3; }
.editor-table input, .editor-table select, .editor-table textarea { min-width: 125px; padding: 7px; font-size: .85rem; border-radius: 5px; background: var(--card); }
.editor-table input[type=number] { min-width: 4em; width: 4em; appearance: textfield; }
.editor-table input[data-field=Name], .editor-table input[data-field=Comment] { min-width: 180px; }
.editor-table input[data-field="Bank Name"] { width: 100px; min-width: 100px; }
.editor-table input:focus, .editor-table select:focus, .editor-table textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.editor-table input:disabled, .editor-table select:disabled { background: #e9ecef; color: #687078; cursor: not-allowed; opacity: .7; }
.editor-arrange-cell { white-space: nowrap; }
.editor-row-tools { display: inline-flex; vertical-align: middle; align-items: center; gap: 4px; }
.editor-table button { padding: 6px 9px; border-radius: 5px; font-size: .85rem; white-space: nowrap; }
.editor-table .editor-drag { cursor: grab; font-size: 1.1rem; padding: 6px 9px; border: 1px solid var(--border); border-radius: 5px; background: var(--soft); color: var(--accent-strong); user-select: none; touch-action: none; -webkit-user-drag: element; }
.editor-table .editor-drag:focus { outline: 2px solid var(--accent); }
.editor-table .editor-drag[aria-disabled=true] { opacity: .5; cursor: default; -webkit-user-drag: none; }
.editor-search input { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; }
.editor-table tr.drag-target td { border-top: 3px solid var(--accent); }
.editor-export { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 16px; margin-top: 22px; }
.editor-export > div { min-width: 280px; }
.editor-shell button:disabled { opacity: .5; cursor: default; transform: none; }
.editor-shell [hidden] { display: none !important; }
@media (max-width: 640px) { .editor-shell { padding: 12px; } .editor-shell .hero { padding: 20px; } .editor-shell h1 { font-size: 1.8rem; } }

.editor-table textarea { min-width: 240px; resize: both; font-family: inherit; vertical-align: middle; }

.editor-table .editor-new-row td { border-top: 2px dashed var(--border); background: #e7f4ea; }

.editor-tone-options { position: fixed; z-index: 20; overflow-y: auto; overscroll-behavior: contain; background: var(--card); border: 1px solid var(--accent); border-radius: 5px; box-shadow: 0 4px 12px #0003; }
.editor-tone-options [role=option] { padding: 8px 12px; cursor: pointer; font-size: .85rem; }
.editor-tone-options [role=option]:hover, .editor-tone-options [aria-selected=true] { background: var(--accent-strong); color: white; }

.editor-drop-zone.drag-over {
    background: #203b4d;
}

.editor-table th {
    background: #1b3040;
    color: var(--accent-strong);
}

.editor-table input:disabled, .editor-table select:disabled {
    background: var(--soft);
    color: var(--muted);
}

.editor-table .editor-new-row td {
    background: var(--good-bg);
}

.editor-tone-options [role=option]:hover,
.editor-tone-options [aria-selected=true] {
    background: #23485e;
    color: var(--ink);
}

/* Keep invalid names readable against a solid error fill. */
.editor-table input[aria-invalid="true"],
.editor-table textarea[aria-invalid="true"] {
    background: #8b1e2d;
    color: #fff;
    border: 1px solid #ff8f99;
    caret-color: #fff;
}

.editor-table input[aria-invalid="true"]:focus,
.editor-table textarea[aria-invalid="true"]:focus {
    outline-color: #ff8f99;
}


/* Keep a real input for selection, typing and accessibility; paint its two
   name segments above it without intercepting pointer or keyboard events. */
.editor-name-field { position: relative; width: 180px; }
.editor-table .editor-name-input,
.editor-name-preview { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; line-height: 1.4; letter-spacing: normal; }
.editor-table .editor-name-input { display: block; width: 100%; box-sizing: border-box; color: transparent; -webkit-text-fill-color: transparent; caret-color: var(--ink); }
.editor-name-preview { position: absolute; inset: 0; box-sizing: border-box; padding: 7px; border: 1px solid transparent; overflow: hidden; pointer-events: none; color: var(--ink); }
.editor-name-preview > span { display: block; white-space: pre; }
.editor-name-overflow { color: #7b858e; }
.editor-name-input:disabled + .editor-name-preview { opacity: .5; }
.editor-table .editor-name-input[aria-invalid="true"] { color: #fff; -webkit-text-fill-color: #fff; }
.editor-name-input[aria-invalid="true"] + .editor-name-preview { visibility: hidden; }
.editor-name-preview { color: #edf4f8; }
.editor-name-overflow { color: #808b94; }
@media (forced-colors: active) {
    .editor-table .editor-name-input { color: CanvasText; -webkit-text-fill-color: CanvasText; }
    .editor-name-preview { display: none; }
}

.editor-table input.editor-compact-offset { width: 80px; min-width: 80px; }

.editor-table input[type=number]::-webkit-inner-spin-button,
.editor-table input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.editor-table input.editor-compact-frequency { width: calc(11ch + 16px); min-width: calc(11ch + 16px); font-variant-numeric: tabular-nums; }
.editor-table select.editor-compact-tx-off { width: 5em; min-width: 5em; }

.editor-upload-log { max-height: 260px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; padding: 12px; background: var(--soft); border: 1px solid var(--border); border-radius: 6px; font-size: .8rem; }

#editor-read-progress { width: 100%; }

.editor-import-debug summary { cursor: pointer; }

.editor-connection-success {
    display: block;
    width: fit-content;
    margin-bottom: 10px;
    padding: 12px 16px;
    border: 2px solid #83ffad;
    border-radius: 16px;
    background: #39ef78;
    color: #07351a;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.4;
}

.editor-upload-success {
    padding: 14px 16px;
    border: 2px solid #83ffad;
    border-radius: 12px;
    background: #39ef78;
    color: #07351a;
    font-weight: 700;
}
#editor-upload-instructions > summary { cursor: pointer; }
