:root {
    --cn-bg: #eef2f7;
    --cn-panel: #ffffff;
    --cn-border: #cbd5e1;
    --cn-text: #172033;
    --cn-muted: #64748b;
    --cn-red: #c91f2b;
    --cn-green: #16a34a;
    --cn-blue: #2563eb;
    --cn-process: #475569;
    --cn-teal: #0f8b83;
    --cn-purple: #7c3aed;
}

#tab-connection-network {
    padding: 0;
    overflow: hidden;
    background: var(--cn-bg);
}

#tab-connection-network.active {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#cn-app {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    color: var(--cn-text);
}

.cn-command-bar {
    min-height: 66px;
    display: grid;
    grid-template-columns: minmax(290px, .9fr) minmax(350px, 1.1fr) auto;
    align-items: center;
    gap: 16px;
    padding: 8px 14px;
    background: #fff;
    border-bottom: 1px solid var(--cn-border);
    box-shadow: 0 2px 8px rgba(15, 23, 42, .05);
    z-index: 8;
}

.cn-title-block {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.cn-title-icon {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    color: #fff;
    background: linear-gradient(135deg, #cc2027, #8f1118);
    font-size: 20px;
    font-weight: 900;
}

.cn-title-block h1 {
    margin: 0;
    font-size: 17px;
    line-height: 1.15;
}

.cn-title-block p {
    margin: 3px 0 0;
    color: var(--cn-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .025em;
    text-transform: uppercase;
}

.cn-search-block {
    position: relative;
    display: grid;
    gap: 3px;
}

.cn-search-block > label,
.cn-compact-select > span {
    color: var(--cn-muted);
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.cn-search-control {
    height: 38px;
    display: grid;
    grid-template-columns: 30px 1fr 30px;
    align-items: center;
    border: 1px solid #aebaca;
    border-radius: 7px;
    background: #fff;
}

.cn-search-control:focus-within {
    border-color: var(--cn-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}

.cn-search-control > span {
    text-align: center;
    color: var(--cn-muted);
    font-size: 18px;
}

.cn-search-control input {
    min-width: 0;
    width: 100%;
    height: 34px;
    border: 0;
    outline: 0;
    font-size: 13px;
    font-weight: 650;
}

.cn-search-control button {
    border: 0;
    background: transparent;
    color: var(--cn-muted);
    cursor: pointer;
    font-size: 18px;
}

.cn-search-results {
    position: absolute;
    left: 0;
    right: 0;
    top: 56px;
    max-height: 330px;
    overflow: auto;
    padding: 5px;
    border: 1px solid var(--cn-border);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 18px 40px rgba(15, 23, 42, .2);
    z-index: 80;
}

.cn-search-result {
    width: 100%;
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr);
    gap: 8px;
    padding: 8px;
    border: 0;
    border-bottom: 1px solid #edf0f4;
    background: #fff;
    text-align: left;
    cursor: pointer;
}

.cn-search-result:last-child {
    border-bottom: 0;
}

.cn-search-result:hover,
.cn-search-result:focus {
    background: #f3f7fc;
}

.cn-search-result i {
    width: 9px;
    height: 9px;
    margin-top: 3px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, .2);
}

.cn-search-result strong,
.cn-search-result small {
    display: block;
}

.cn-search-result strong {
    overflow: hidden;
    color: var(--cn-text);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cn-search-result small {
    margin-top: 2px;
    color: var(--cn-muted);
    font-size: 9px;
}

.cn-command-actions {
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 6px;
}

.cn-compact-select {
    display: grid;
    gap: 2px;
}

.cn-compact-select select {
    height: 34px;
    min-width: 68px;
    padding: 0 8px;
    border: 1px solid var(--cn-border);
    border-radius: 6px;
    background: #fff;
}

.cn-btn,
.cn-tool {
    min-height: 34px;
    padding: 0 11px;
    border: 1px solid #94a3b8;
    border-radius: 6px;
    background: #fff;
    color: #334155;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
}

.cn-btn:hover,
.cn-tool:hover {
    border-color: #475569;
    background: #f8fafc;
}

.cn-btn:disabled {
    cursor: not-allowed;
    opacity: .45;
}

.cn-btn-primary {
    border-color: var(--cn-red);
    background: var(--cn-red);
    color: #fff;
}

.cn-btn-primary:hover {
    border-color: #991b1b;
    background: #ad1721;
}

.cn-full {
    width: 100%;
}

.cn-metric-strip {
    min-height: 42px;
    display: grid;
    grid-template-columns: repeat(5, minmax(100px, 1fr));
    background: #f8fafc;
    border-bottom: 1px solid var(--cn-border);
}

.cn-metric-strip article {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 3px 10px;
    padding: 5px 14px;
    border-right: 1px solid #dbe2eb;
}

.cn-metric-strip article:last-child {
    border-right: 0;
}

.cn-metric-strip small {
    color: var(--cn-muted);
    font-size: 8px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.cn-metric-strip strong {
    grid-row: 1 / span 2;
    grid-column: 2;
    color: var(--cn-text);
    font-size: 16px;
}

.cn-metric-strip em {
    color: var(--cn-muted);
    font-size: 8px;
    font-style: normal;
}

.cn-metric-strip .cn-metric-warning.has-warning {
    background: #fff7ed;
}

.cn-metric-strip .cn-metric-warning.has-warning strong,
.cn-metric-strip .cn-metric-warning.has-warning em {
    color: #b45309;
}

.cn-shell {
    display: grid;
    grid-template-columns: 224px minmax(0, 1fr) 250px;
    flex: 1;
    min-height: 0;
}

.cn-filter-panel,
.cn-detail-panel {
    min-height: 0;
    overflow: auto;
    background: #fff;
}

.cn-filter-panel {
    border-right: 1px solid var(--cn-border);
}

.cn-detail-panel {
    padding: 10px;
    border-left: 1px solid var(--cn-border);
}

.cn-filter-panel section,
.cn-diagnostics {
    padding: 10px;
    border-bottom: 1px solid #e2e8f0;
}

.cn-filter-panel h2,
.cn-detail-panel > h2,
.cn-diagnostics h2 {
    margin: 0 0 8px;
    color: #475569;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.cn-filter-panel label {
    display: grid;
    gap: 3px;
    margin: 7px 0;
}

.cn-filter-panel label > span {
    color: #64748b;
    font-size: 8px;
    font-weight: 900;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.cn-filter-panel select {
    width: 100%;
    min-width: 0;
    height: 31px;
    padding: 0 7px;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    background: #fff;
    color: #1e293b;
    font-size: 10px;
}

.cn-two-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.cn-filter-panel label.cn-check {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 5px 0;
    cursor: pointer;
}

.cn-filter-panel label.cn-check input {
    width: 15px;
    height: 15px;
    accent-color: #cc2027;
}

.cn-filter-panel label.cn-check span {
    color: #334155;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
}

.cn-focus-card {
    min-height: 86px;
    margin-bottom: 8px;
    padding: 9px;
    border: 1px solid #cbd5e1;
    border-left: 5px solid #64748b;
    border-radius: 7px;
    background: #f8fafc;
}

.cn-focus-card span,
.cn-focus-card strong,
.cn-focus-card small {
    display: block;
}

.cn-focus-card span {
    color: #64748b;
    font-size: 8px;
    font-weight: 900;
    letter-spacing: .05em;
}

.cn-focus-card strong {
    margin: 5px 0 4px;
    font-size: 11px;
    line-height: 1.25;
}

.cn-focus-card small {
    color: #64748b;
    font-size: 9px;
    line-height: 1.3;
}

.cn-legend {
    display: grid;
    grid-template-columns: 34px 1fr;
    align-items: center;
    gap: 7px;
    margin: 7px 0;
}

.cn-legend span {
    height: 0;
    border-top: 3px solid;
}

.cn-legend span.cause { border-color: var(--cn-red); }
.cn-legend span.solve { border-color: var(--cn-green); }
.cn-legend span.process { border-color: var(--cn-process); }
.cn-legend span.dependency { border-color: var(--cn-blue); border-top-style: dashed; }
.cn-legend span.related { border-color: var(--cn-purple); border-top-style: dotted; }

.cn-legend b {
    color: #475569;
    font-size: 9px;
}

.cn-workspace {
    display: flex;
    min-width: 0;
    min-height: 0;
    flex-direction: column;
    background: #e8edf4;
}

.cn-canvas-toolbar {
    min-height: 38px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 4px 8px;
    border-bottom: 1px solid #cbd5e1;
    background: #fff;
}

.cn-canvas-toolbar > div:first-child {
    display: flex;
    align-items: center;
    gap: 4px;
}

.cn-tool {
    min-width: 31px;
    min-height: 28px;
    padding: 0 7px;
}

#cn-zoom-label {
    width: 46px;
    color: #475569;
    font-size: 10px;
    font-weight: 800;
    text-align: center;
}

.cn-canvas-instruction {
    overflow: hidden;
    color: #64748b;
    font-size: 9px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cn-canvas-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background-color: #f8fafc;
    background-image:
        linear-gradient(rgba(100, 116, 139, .08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(100, 116, 139, .08) 1px, transparent 1px);
    background-size: 24px 24px;
    cursor: grab;
}

.cn-canvas-wrap.is-panning {
    cursor: grabbing;
}

#cn-svg {
    width: 100%;
    height: 100%;
    display: block;
    user-select: none;
}

.cn-loading,
.cn-empty {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 9px;
    padding: 30px;
    background: rgba(248, 250, 252, .92);
    color: #475569;
    text-align: center;
    z-index: 4;
}

.cn-loading[hidden],
.cn-empty[hidden] {
    display: none;
}

.cn-empty > span {
    font-size: 38px;
}

.cn-empty small {
    max-width: 420px;
    color: #64748b;
}

.cn-spinner {
    width: 26px;
    height: 26px;
    border: 3px solid #dbe3ec;
    border-top-color: #cc2027;
    border-radius: 50%;
    animation: cn-spin .8s linear infinite;
}

@keyframes cn-spin {
    to { transform: rotate(360deg); }
}

.cn-status-bar {
    min-height: 25px;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 5px 9px;
    border-top: 1px solid #cbd5e1;
    background: #fff;
    color: #64748b;
    font-size: 8px;
    font-weight: 750;
}

.cn-details-empty {
    min-height: 170px;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 7px;
    padding: 20px;
    color: #64748b;
    text-align: center;
}

.cn-details-empty > span {
    font-size: 30px;
    color: #94a3b8;
}

.cn-details-empty strong {
    color: #475569;
    font-size: 11px;
}

.cn-details-empty p {
    margin: 0;
    font-size: 9px;
    line-height: 1.4;
}

.cn-detail-header {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 5px;
    background: #64748b;
    color: #fff;
    font-size: 8px;
    font-weight: 900;
}

#cn-node-details h3,
#cn-edge-details h3 {
    margin: 10px 0 6px;
    font-size: 13px;
    line-height: 1.25;
}

#cn-detail-body,
#cn-edge-label,
#cn-edge-notes {
    margin: 0 0 10px;
    color: #475569;
    font-size: 9px;
    line-height: 1.45;
}

#cn-node-details dl {
    margin: 0 0 12px;
}

#cn-node-details dl > div {
    display: grid;
    grid-template-columns: 78px 1fr;
    gap: 6px;
    padding: 5px 0;
    border-bottom: 1px solid #edf1f5;
}

#cn-node-details dt {
    color: #64748b;
    font-size: 8px;
    font-weight: 800;
}

#cn-node-details dd {
    margin: 0;
    color: #1e293b;
    font-size: 9px;
    font-weight: 750;
}

#cn-node-details h4 {
    margin: 12px 0 6px;
    color: #64748b;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.cn-direct-relation {
    display: grid;
    grid-template-columns: 7px 1fr;
    gap: 6px;
    padding: 6px 0;
    border-bottom: 1px solid #edf1f5;
    cursor: pointer;
}

.cn-direct-relation i {
    width: 7px;
    height: 7px;
    margin-top: 3px;
    border-radius: 50%;
}

.cn-direct-relation b,
.cn-direct-relation small {
    display: block;
}

.cn-direct-relation b {
    color: #334155;
    font-size: 8px;
}

.cn-direct-relation small {
    margin-top: 2px;
    color: #64748b;
    font-size: 8px;
}

.cn-edge-kind {
    display: inline-flex;
    padding: 3px 6px;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    color: #475569;
    font-size: 8px;
    font-weight: 900;
    text-transform: uppercase;
}

.cn-edge-endpoints {
    display: grid;
    grid-template-columns: 1fr 20px 1fr;
    align-items: center;
    gap: 5px;
    margin: 10px 0;
    padding: 8px;
    border: 1px solid #dbe2eb;
    border-radius: 6px;
    background: #f8fafc;
    font-size: 8px;
    line-height: 1.3;
    text-align: center;
}

.cn-diagnostics {
    margin: 12px -10px -10px;
    border-top: 1px solid #e2e8f0;
    border-bottom: 0;
}

.cn-diagnostic-item {
    display: grid;
    grid-template-columns: 18px 1fr;
    gap: 5px;
    padding: 5px 0;
    border-bottom: 1px solid #edf1f5;
    color: #475569;
    font-size: 8px;
    line-height: 1.35;
}

.cn-diagnostic-item.ok span {
    color: #16a34a;
}

.cn-diagnostic-item.warn span {
    color: #b45309;
}

/* SVG typography is explicit so exported SVG files keep the industrial layout. */
#cn-svg .cn-node-card {
    cursor: pointer;
}

#cn-svg .cn-node-card:focus {
    outline: none;
}

#cn-svg .cn-node-title {
    fill: #172033;
    font-size: 12px;
    font-weight: 800;
}

#cn-svg .cn-node-body {
    fill: #475569;
    font-size: 9px;
    font-weight: 500;
}

#cn-svg .cn-node-meta {
    font-size: 8px;
    font-weight: 800;
}

#cn-svg .cn-edge-path {
    fill: none;
    stroke-linejoin: round;
    stroke-linecap: square;
    cursor: pointer;
}

#cn-svg .cn-edge-path:hover {
    stroke-width: 5px !important;
}

#cn-svg .cn-edge-label-text {
    font-size: 8px;
    font-weight: 900;
    pointer-events: none;
}

body.cn-fullscreen-mode .sidebar,
body.cn-fullscreen-mode .tabs-header,
body.cn-fullscreen-mode .mobile-header,
body.cn-fullscreen-mode .cn-filter-panel,
body.cn-fullscreen-mode .cn-detail-panel,
body.cn-fullscreen-mode .cn-metric-strip,
body.cn-fullscreen-mode .cn-command-bar,
body.cn-fullscreen-mode .cn-canvas-toolbar,
body.cn-fullscreen-mode .cn-status-bar {
    display: none !important;
}

body.cn-fullscreen-mode,
body.cn-fullscreen-mode .main-content,
body.cn-fullscreen-mode #tab-connection-network,
body.cn-fullscreen-mode #cn-app,
body.cn-fullscreen-mode .cn-shell,
body.cn-fullscreen-mode .cn-workspace,
body.cn-fullscreen-mode .cn-canvas-wrap {
    width: 100vw !important;
    height: 100vh !important;
    min-height: 100vh !important;
    overflow: hidden !important;
}

body.cn-fullscreen-mode .cn-shell {
    display: block;
}

@media (max-width: 1250px) {
    .cn-command-bar {
        grid-template-columns: minmax(250px, .8fr) minmax(300px, 1fr);
    }

    .cn-command-actions {
        grid-column: 1 / -1;
    }

    .cn-shell {
        grid-template-columns: 210px minmax(0, 1fr);
    }

    .cn-detail-panel {
        display: none;
    }
}

@media (max-width: 780px) {
    .cn-command-bar {
        display: flex;
        align-items: stretch;
        flex-direction: column;
    }

    .cn-command-actions {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .cn-metric-strip {
        grid-template-columns: repeat(3, 1fr);
    }

    .cn-shell {
        display: block;
    }

    .cn-filter-panel {
        display: none;
    }

    .cn-workspace {
        height: 100%;
    }
}

@media print {
    body.cn-printing {
        display: block !important;
        width: auto !important;
        height: auto !important;
        overflow: visible !important;
        background: #fff !important;
    }

    body.cn-printing > .sidebar,
    body.cn-printing > .mobile-header,
    body.cn-printing > .sidebar-overlay,
    body.cn-printing .tabs-header,
    body.cn-printing .tab-content:not(#tab-connection-network),
    body.cn-printing .cn-filter-panel,
    body.cn-printing .cn-detail-panel,
    body.cn-printing .cn-command-bar,
    body.cn-printing .cn-metric-strip,
    body.cn-printing .cn-canvas-toolbar,
    body.cn-printing .cn-status-bar,
    body.cn-printing .cn-loading,
    body.cn-printing .cn-empty {
        display: none !important;
    }

    body.cn-printing .main-content,
    body.cn-printing #tab-connection-network,
    body.cn-printing #cn-app,
    body.cn-printing .cn-shell,
    body.cn-printing .cn-workspace,
    body.cn-printing .cn-canvas-wrap {
        display: block !important;
        width: 100% !important;
        height: 100% !important;
        min-height: 0 !important;
        overflow: visible !important;
        border: 0 !important;
        background: #fff !important;
    }

    body.cn-printing #cn-svg {
        display: block !important;
        width: 100% !important;
        height: 100% !important;
        overflow: visible !important;
    }
}

