/* Compare panel, FK relationship graph, comment editor, EXPLAIN ANALYZE extras (prefix: cmp-, fk-, cmt-, xa-). */

#panel-compare {
    flex-direction: column;
}

.cmp-root {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.cmp-bar .cmp-side {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.cmp-bar select {
    max-width: 220px;
}

.cmp-kinds {
    padding-top: 4px;
    padding-bottom: 4px;
    min-height: 34px;
    font-size: 12px;
}

.cmp-kinds .field-inline {
    gap: 4px;
}

.cmp-note {
    font-size: 11px;
    max-width: 520px;
    text-align: right;
}

.cmp-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.cmp-summary {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.cmp-tile {
    cursor: pointer;
}

.cmp-tile.active {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
}

.cmp-tile.ok .mon-card-value {
    color: var(--ok);
}

.cmp-script-tile {
    cursor: default;
    grid-column: span 2;
}

.cmp-tile-actions {
    display: flex;
    gap: 6px;
    margin: 6px 0 4px;
    flex-wrap: wrap;
}

.cmp-warning {
    grid-column: 1 / -1;
    background: var(--warn-soft);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 6px 10px;
    font-size: 12px;
}

.cmp-main {
    display: flex;
    flex: 1;
    min-height: 0;
}

.cmp-list-pane {
    width: 36%;
    min-width: 300px;
    max-width: 520px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.cmp-list-head {
    min-height: 38px;
    padding: 6px 10px;
    gap: 10px;
}

.cmp-list-head .quick-filter {
    flex: 1;
    min-width: 120px;
}

.cmp-list-wrap {
    flex: 1;
    overflow: auto;
    min-height: 0;
}

.cmp-table {
    width: 100%;
}

.cmp-table td {
    cursor: pointer;
}

.cmp-row.selected td {
    background: var(--accent-soft);
}

.cmp-kind {
    color: var(--muted);
    font-size: 11px;
    text-transform: lowercase;
}

.cmp-name {
    font-family: var(--mono);
    font-size: 11.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}

.cmp-status {
    font-size: 10px;
    letter-spacing: 0.03em;
}

.cmp-status.cmp-added {
    background: var(--ok-soft);
    color: var(--ok);
}

.cmp-status.cmp-removed {
    background: var(--danger-soft);
    color: var(--danger);
}

.cmp-status.cmp-changed {
    background: var(--warn-soft);
    color: var(--warn);
}

.cmp-status.cmp-renamed {
    background: var(--accent-soft);
    color: var(--accent);
}

.cmp-status.cmp-same {
    background: var(--surface-3);
    color: var(--muted);
}

.cmp-detail-pane {
    flex: 1;
    min-width: 0;
    overflow: auto;
    padding: 0 16px 24px;
}

.cmp-detail-head {
    padding: 12px 0 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
}

.cmp-detail-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.cmp-detail-title strong {
    font-family: var(--mono);
    font-weight: 600;
}

.cmp-changes {
    width: 100%;
    table-layout: fixed;
}

.cmp-changes th:first-child {
    width: 26%;
}

.cmp-path {
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--text-2);
}

.cmp-val code {
    font-family: var(--mono);
    font-size: 11.5px;
    white-space: pre-wrap;
    word-break: break-word;
}

.cmp-val.del code {
    background: var(--danger-soft);
    border-radius: var(--r-sm);
    padding: 0 3px;
}

.cmp-val.add code {
    background: var(--ok-soft);
    border-radius: var(--r-sm);
    padding: 0 3px;
}

.cmp-val.null {
    color: var(--muted);
}

.cmp-empty {
    padding: 24px 16px;
    font-size: 12.5px;
    line-height: 1.5;
    max-width: 640px;
}

.cmp-hint-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 11.5px;
}

.cmp-hint {
    white-space: pre;
    overflow: auto;
    max-height: 360px;
}

/* ---- side-by-side line diff */

.cmp-diff {
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    overflow: hidden;
    font-family: var(--mono);
    font-size: 11.5px;
    background: var(--surface);
}

.cmp-diff-head {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    font-family: var(--font);
    font-size: 11px;
    color: var(--muted);
}

.cmp-diff-head span {
    padding: 4px 8px;
}

.cmp-diff-head span + span {
    border-left: 1px solid var(--border);
}

.cmp-diff-body {
    max-height: 420px;
    overflow: auto;
}

.cmp-diff-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.cmp-diff-cell {
    display: flex;
    min-width: 0;
    border-left: 1px solid var(--border);
    line-height: 1.5;
}

.cmp-diff-cell:first-child {
    border-left: 0;
}

.cmp-diff-cell.del {
    background: var(--danger-soft);
}

.cmp-diff-cell.add {
    background: var(--ok-soft);
}

.cmp-diff-cell.blank {
    background: var(--surface-2);
}

.cmp-diff-no {
    flex: 0 0 36px;
    text-align: right;
    padding-right: 8px;
    color: var(--muted);
    user-select: none;
    font-size: 10.5px;
}

.cmp-diff-text {
    white-space: pre-wrap;
    word-break: break-word;
    padding-right: 8px;
}

.cmp-diff-empty {
    padding: 10px;
    font-family: var(--font);
}

/* ---- FK relationship graph (Structure → Relationships) */

.fk-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 12px;
}

.fk-scroll {
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    max-height: 520px;
}

.fk-svg {
    display: block;
    font-family: var(--font);
}

.fk-box {
    fill: var(--surface);
    stroke: var(--border-strong);
    stroke-width: 1;
}

.fk-node {
    cursor: pointer;
}

.fk-node.root {
    cursor: default;
}

.fk-node.root .fk-box {
    stroke: var(--accent);
    stroke-width: 1.5;
    fill: var(--accent-soft);
}

.fk-node.far .fk-box {
    stroke-dasharray: 3 3;
}

.fk-node:not(.root):hover .fk-box,
.fk-node:not(.root):focus .fk-box {
    stroke: var(--accent);
    fill: var(--surface-3);
}

.fk-node:focus {
    outline: none;
}

.fk-name {
    fill: var(--text);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--mono);
}

.fk-sub {
    fill: var(--muted);
    font-size: 10.5px;
}

.fk-edge {
    fill: none;
    stroke: var(--border-strong);
    stroke-width: 1.4;
}

.fk-edge.cascade {
    stroke: var(--warn);
}

.fk-edge:hover {
    stroke: var(--accent);
    stroke-width: 2;
}

.fk-arrowhead {
    fill: var(--border-strong);
}

.fk-edge-label {
    fill: var(--text-2);
    font-size: 10px;
    font-family: var(--mono);
    paint-order: stroke;
    stroke: var(--surface-2);
    stroke-width: 3px;
    stroke-linejoin: round;
}

.fk-edge-action {
    fill: var(--warn);
    font-size: 9.5px;
    paint-order: stroke;
    stroke: var(--surface-2);
    stroke-width: 3px;
    stroke-linejoin: round;
}

.fk-legend {
    display: flex;
    gap: 14px;
    font-size: 11px;
    color: var(--muted);
    margin-top: 6px;
    flex-wrap: wrap;
}

.fk-legend i {
    display: inline-block;
    width: 18px;
    height: 0;
    border-top: 2px solid var(--border-strong);
    vertical-align: middle;
    margin-right: 4px;
}

.fk-legend i.cascade {
    border-top-color: var(--warn);
}

.fk-legend i.dashed {
    border-top-style: dashed;
}

/* ---- comment editor */

.cmt-host {
    display: inline-flex;
    align-items: flex-start;
    gap: 6px;
    max-width: 100%;
}

.cmt-text {
    white-space: pre-wrap;
    word-break: break-word;
}

.cmt-pencil {
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    padding: 1px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    color: var(--muted);
    opacity: 0.55;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cmt-pencil svg {
    width: 13px;
    height: 13px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.cmt-host:hover .cmt-pencil,
.cmt-pencil:focus {
    opacity: 1;
    color: var(--accent);
    border-color: var(--border);
    background: var(--surface-3);
}

.cmt-form {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 260px;
    width: 100%;
}

.cmt-input {
    width: 100%;
    box-sizing: border-box;
    font: inherit;
    font-size: 12px;
    padding: 4px 6px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--text);
    resize: vertical;
}

.cmt-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cmt-error {
    font-size: 11px;
}

.meta-comment.cmt-host {
    display: flex;
}

/* ---- EXPLAIN ANALYZE plan extras */

.xp-head-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    font-size: 11px;
    color: var(--muted);
    align-items: center;
}

.xp-head-stats strong {
    color: var(--text);
    font-weight: 600;
}

.xp-prev {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
}

.xp-prev select {
    font-size: 11px;
    padding: 2px 4px;
}

.xp-rollback {
    background: var(--warn-soft);
    border-radius: var(--r-sm);
    padding: 2px 8px;
    font-size: 11px;
    color: var(--text);
}

.xp-pill {
    display: inline-block;
    padding: 0 6px;
    border-radius: var(--r-pill);
    font-size: 10px;
    font-weight: 600;
    line-height: 16px;
    vertical-align: middle;
}

.xp-pill.mis {
    background: var(--warn-soft);
    color: var(--warn);
}

.xp-pill.mis.bad {
    background: var(--danger-soft);
    color: var(--danger);
}

.xp-pill.top {
    background: var(--danger-soft);
    color: var(--danger);
}

.xp-pill.top.t2 {
    background: var(--warn-soft);
    color: var(--warn);
}

.xp-pill.top.t3 {
    background: var(--accent-soft);
    color: var(--accent);
}

.xp-top1 > .xp-summary {
    background: var(--danger-bg);
}

.xp-top2 > .xp-summary {
    background: var(--warn-soft);
}

.xp-top3 > .xp-summary {
    background: var(--accent-soft);
}

.xp-actual {
    color: var(--text);
}

.xp-bufs {
    font-size: 10.5px;
    color: var(--muted);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 2px 0 2px 6px;
}

.xp-bufs .bad {
    color: var(--danger);
}

#compare-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.xp-head > strong,
.xp-prev {
    white-space: nowrap;
}

.xp-head {
    flex-wrap: wrap;
}
