/* 数据图表 */
.ct-shell {
    padding: 14px 16px 16px;
}

.ct-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.ct-head h1, .ct-head h2 {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0 0 4px;
}
.ct-head-text { min-width: 0; }
.ct-head-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex: 0 0 auto;
}

.ct-body {
    display: grid;
    grid-template-columns: 366px minmax(0, 1fr);
    gap: 14px;
    margin-top: 14px;
}
/* Excel 图表 / 地图图表：画布在左、操作栏在右（热力图保持原布局） */
.ct-shell:not(.hm-shell) .ct-body { grid-template-columns: minmax(0, 1fr) 366px; }
.ct-shell:not(.hm-shell) .ct-preview { order: 1; }
.ct-shell:not(.hm-shell) .ct-side { order: 2; }

/* 配置栏 */
.ct-side {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    /* 四个详细设置是手风琴，一次只展开一个，页面自然滚动即可 */
    min-height: 0;
}
.ct-block {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px 11px;
    background: #fcfcfd;
}
.ct-block h4 {
    font-size: .8rem;
    font-weight: 700;
    color: var(--text-dim);
    letter-spacing: .3px;
    margin: 0 0 8px;
}

.ct-types {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
}
.ct-type-group {
    grid-column: 1 / -1;
    font-size: .72rem;
    color: #98a1ad;
    margin: 6px 0 1px;
}
.ct-type-group:first-child { margin-top: 0; }
.ct-type-btn {
    border: 1px solid var(--border-strong);
    background: #fff;
    border-radius: 7px;
    padding: 6px 2px;
    font-size: .76rem;
    line-height: 1.25;
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ct-type-btn:hover { border-color: var(--accent); color: var(--accent); }
.ct-type-btn.active {
    border-color: var(--accent);
    background: #fff4ef;
    color: var(--accent);
    font-weight: 600;
}
.ct-type-btn:focus-visible { outline: 2px solid rgba(255, 106, 61, .35); outline-offset: 1px; }

.ct-row {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.ct-row:last-of-type { margin-bottom: 0; }
.ct-row label { font-size: .78rem; color: var(--text-dim); margin: 0; }

.ct-swatch {
    width: 66px;
    height: 30px;
    padding: 2px;
    /* 边框略深一点，否则值为纯白时色块和页面底色融在一起，看不出是可点的取色器 */
    border: 1px solid #b9c0c9;
    border-radius: 7px;
    background: #fff;
    cursor: pointer;
}

/* 配色方案：每个选项都带样例色块；默认折叠，标题右侧显示当前方案 */
.ct-fold {
    margin-bottom: 9px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #fff;
}
.ct-fold > summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 9px;
    font-size: .78rem;
    color: var(--text-dim);
    cursor: pointer;
    user-select: none;
}
.ct-fold > summary::-webkit-details-marker { display: none; }
.ct-fold > summary::before {
    content: '▸';
    font-size: .68rem;
    color: #98a1ad;
    transition: transform .15s;
}
.ct-fold[open] > summary::before { transform: rotate(90deg); }
.ct-fold[open] > summary { border-bottom: 1px solid var(--border); }
.ct-fold-cur {
    margin-left: auto;
    color: var(--text);
    font-weight: 600;
}
.ct-fold .ct-palettes { padding: 8px 9px 9px; }
.ct-palette-row { margin-bottom: 9px; }
.ct-palette-row > label {
    display: block;
    font-size: .78rem;
    color: var(--text-dim);
    margin-bottom: 5px;
}
.ct-palettes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
}
.ct-palette {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    padding: 3px 6px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    text-align: left;
}
.ct-palette:hover { border-color: var(--border-strong); background: #fafbfc; }
.ct-palette.active {
    border-color: var(--accent);
    background: #fff7f4;
    box-shadow: inset 0 0 0 1px var(--accent);
}
.ct-palette-bar {
    display: flex;
    flex: 0 0 46px;
    height: 13px;
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid rgba(15, 23, 42, .06);
}
.ct-palette-bar i { flex: 1 1 auto; display: block; }
.ct-palette-name {
    font-size: .72rem;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ct-palette.active .ct-palette-name { color: var(--accent); font-weight: 600; }

.ct-checks {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px 8px;
    margin-top: 9px;
}
.ct-checks .form-check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .8rem;
    color: var(--text);
    margin: 0;
    min-height: 20px;
}
.ct-checks .form-check-input { margin: 0; flex: 0 0 auto; }
.ct-checks .form-check.is-off { opacity: .42; }

/* ---------- 四组详细设置（折叠块） ---------- */
.ct-acc {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fcfcfd;
    padding: 0;
}
.ct-acc > summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 12px;
    font-size: .82rem;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    user-select: none;
}
.ct-acc > summary::-webkit-details-marker { display: none; }
.ct-acc > summary::before {
    content: '▸';
    font-size: .7rem;
    font-weight: 400;
    color: #98a1ad;
    transition: transform .15s;
}
.ct-acc[open] > summary::before { transform: rotate(90deg); }
.ct-acc[open] > summary { border-bottom: 1px solid var(--border); }
.ct-acc[open] > summary::before { color: var(--accent); }
.ct-acc.is-off > summary { opacity: .5; }
.ct-acc-cur {
    margin-left: auto;
    font-size: .73rem;
    font-weight: 400;
    color: #98a1ad;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 46%;
}
.ct-acc-body { padding: 10px 12px 12px; }
.ct-acc-body.is-off { opacity: .45; pointer-events: none; }

.ct-sub {
    font-size: .74rem;
    font-weight: 700;
    color: #98a1ad;
    margin: 10px 0 6px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
}
.ct-acc-body > .ct-sub:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.ct-sub-note { font-weight: 400; font-size: .7rem; margin-left: 4px; }
.ct-checks-top { margin-top: 0; margin-bottom: 8px; }

.ct-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex-wrap: wrap;
}
.ct-inline > .form-select { flex: 1 1 84px; min-width: 84px; width: auto; }
.ct-inline > .form-control { flex: 1 1 70px; min-width: 70px; width: auto; }
.ct-num {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--field-border);
    border-radius: 7px;
    background: #fff;
    overflow: hidden;
    flex: 0 0 auto;
}
.ct-num input {
    width: 48px;
    border: 0;
    background: transparent;
    padding: 4px 3px 4px 7px;
    font-size: .78rem;
    color: var(--text);
    outline: none;
}
.ct-num input:focus { background: #fff8f5; }
/* 数字框直接放在 .ct-row 第二列时不要被网格拉伸成整行宽 */
.ct-row > .ct-num { justify-self: start; }
.ct-num span {
    font-size: .7rem;
    color: #98a1ad;
    padding: 0 6px 0 2px;
    white-space: nowrap;
}
.ct-swatch-sm { width: 40px; height: 28px; border-color: #b9c0c9; }
.ct-mini {
    border: 1px solid var(--border-strong);
    background: #fff;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: .72rem;
    color: var(--text-dim);
    cursor: pointer;
    white-space: nowrap;
}
.ct-mini:hover { border-color: var(--accent); color: var(--accent); }
.ct-mini-wide { width: 100%; margin-top: 9px; }
.ct-mini-input { min-width: 0 !important; }

.ct-colors { display: flex; flex-direction: column; gap: 5px; }
.ct-color-row {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 3px 5px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
}
.ct-color-row .ct-color-name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: .76rem;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ct-color-row input[type="color"] {
    width: 34px; height: 24px; padding: 1px;
    border: 1px solid var(--field-border);
    border-radius: 5px; background: #fff; cursor: pointer;
}
.ct-color-row .ct-color-reset {
    border: 0; background: transparent; color: #b6bcc6;
    font-size: .95rem; line-height: 1; padding: 2px 4px; cursor: pointer;
}
.ct-color-row .ct-color-reset:hover { color: #dc3545; }
.ct-color-row.is-custom { border-color: var(--accent); background: #fff8f5; }

.ct-seg { display: inline-flex; border: 1px solid var(--field-border); border-radius: 7px; overflow: hidden; }
.ct-seg button {
    border: 0;
    border-right: 1px solid var(--border);
    background: #fff;
    padding: 4px 13px;
    font-size: .76rem;
    color: var(--text-dim);
    cursor: pointer;
}
.ct-seg button:last-child { border-right: 0; }
.ct-seg button:hover { background: #fafbfc; }
.ct-seg button.active { background: #fff4ef; color: var(--accent); font-weight: 700; }

/* 右侧预览 */
.ct-preview {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}
.ct-chart-wrap {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    padding: 10px;
    height: clamp(340px, 60vh, 620px);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.ct-chart {
    width: 100%;
    height: 100%;
}
.ct-tip {
    font-size: .72rem;
    color: #98a1ad;
    text-align: center;
    min-height: 16px;
}
.ct-tip.warn { color: #d97706; }

/* 数据表 */
.ct-data {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.ct-data-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.ct-data-title {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    min-width: 0;
}
.ct-data-head h4 {
    font-size: .9rem;
    font-weight: 700;
    margin: 0;
}
.ct-io-note {
    font-size: .76rem;
    color: #98a1ad;
}
.ct-ops-sep {
    width: 1px;
    height: 20px;
    background: var(--border);
    align-self: center;
    margin: 0 2px;
}
.ct-data-ops { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.ct-table-wrap {
    overflow: auto;
    max-height: 258px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}
.ct-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: .82rem;
}
.ct-table th,
.ct-table td {
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
    padding: 0;
}
.ct-table tr:last-child td { border-bottom: 0; }
.ct-table th:last-child,
.ct-table td:last-child { border-right: 0; }
.ct-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f6f7f9;
    font-weight: 600;
}
.ct-table th.cat-head { background: #f0f2f5; }
.ct-table input {
    width: 100%;
    min-width: 96px;
    border: 0;
    background: transparent;
    padding: 6px 8px;
    font-size: .82rem;
    color: var(--text);
    outline: none;
}
.ct-table th input { font-weight: 600; min-width: 110px; }
.ct-table td.cat-cell input { min-width: 118px; }
.ct-table th input:focus,
.ct-table td input:focus {
    background: #fff8f5;
    box-shadow: inset 0 0 0 1px var(--accent);
}
.ct-table input[type="number"] { -moz-appearance: textfield; }
.ct-table input::-webkit-outer-spin-button,
.ct-table input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ct-table .row-del {
    width: 30px;
    text-align: center;
    color: #b6bcc6;
}
.ct-table .row-del button {
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 1rem;
    line-height: 1;
    padding: 6px 4px;
    cursor: pointer;
}
.ct-table .row-del button:hover { color: #dc3545; }

.ct-paste { margin-top: 10px; }
.ct-paste summary {
    cursor: pointer;
    font-size: .82rem;
    color: var(--accent-2);
    user-select: none;
}
.ct-paste-tip {
    font-size: .76rem;
    color: var(--text-dim);
    margin: 7px 0 6px;
}
.ct-paste textarea {
    font-family: Consolas, "Courier New", monospace;
    font-size: .78rem;
    line-height: 1.5;
}

@media (max-width: 1000px) {
    .ct-body, .ct-shell:not(.hm-shell) .ct-body { grid-template-columns: 1fr; }
    .ct-preview { order: 1; }
    /* 侧栏移到下方后不再限高，设置项可以完整展开 */
    .ct-side { order: 2; max-height: none; overflow: visible; padding-right: 0; }
    .ct-types { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .ct-palettes { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
    .ct-shell { padding: 12px; }
    .ct-head { flex-direction: column; gap: 10px; }
    .ct-head-actions { width: 100%; }
    .ct-head-actions .btn { flex: 1; }
    .ct-types { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .ct-palettes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ct-chart-wrap { height: 340px; }
    .ct-checks { grid-template-columns: 1fr 1fr; }
}
