:root {
    /* Cyber Orange Palette */
    --primary: #E17055;
    --primary-hover: #d16248;
    --secondary: #FAB1A0;
    --accent: #FFEAA7;
    --accent-hover: #f1d98a;
    --background: #1A0F0A;
    --surface: #2D1A12;
    --surface-hover: #3c2419;

    /* TF Action Colors */
    --action-create: #00b894;
    /* Green */
    --action-update: #fdcb6e;
    /* Yellow/Orange */
    --action-delete: #ff7675;
    /* Red */
    --action-replace: #e84393;
    /* Pink */
    --action-noop: #636e72;
    /* Gray */

    --glass-bg: rgba(45, 26, 18, 0.65);
    --glass-border: rgba(250, 177, 160, 0.15);

    --text-main: #f5f6fa;
    --text-muted: #a4b0be;

    --radius: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--background);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    /* App-like layout */
}

.glass-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: radial-gradient(circle at 10% 20%, rgba(225, 112, 85, 0.08), transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(255, 234, 167, 0.05), transparent 40%);
}

.app-container {
    display: flex;
    height: 100vh;
    padding: 1rem;
    gap: 1rem;
}

/* Glass Panels */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

/* Sidebar */
.sidebar {
    width: 320px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    overflow-y: auto;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.02em;
}

/* Main View */
.main-view {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.5rem;
}

.toolbar-stats {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.toolbar-actions {
    display: flex;
    gap: 0.5rem;
}

.graph-container {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
}

#graph-network {
    width: 100%;
    height: 100%;
    outline: none;
}

.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    transition: opacity 0.3s;
}

.empty-state.hidden {
    opacity: 0;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.8;
}

/* Detail Panel */
.detail-panel {
    width: 350px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    overflow-y: auto;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s;
}

.detail-panel.hidden {
    transform: translateX(120%);
    opacity: 0;
    position: absolute;
    /* Remove from flow to not break layout when hidden */
    right: 1rem;
    height: calc(100vh - 2rem);
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.detail-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.icon-btn:hover {
    color: #fff;
}

.detail-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgba(255, 255, 255, 0.1);
}

.detail-badge.create {
    background: rgba(0, 184, 148, 0.2);
    color: var(--action-create);
}

.detail-badge.update {
    background: rgba(253, 203, 110, 0.2);
    color: var(--action-update);
}

.detail-badge.delete {
    background: rgba(255, 118, 117, 0.2);
    color: var(--action-delete);
}

.detail-badge.replace {
    background: rgba(232, 67, 147, 0.2);
    color: var(--action-replace);
}

.detail-badge.noop {
    background: rgba(99, 110, 114, 0.2);
    color: var(--text-muted);
}

.detail-group {
    margin-bottom: 1.25rem;
}

.detail-group label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}

.detail-value {
    font-size: 0.9rem;
    word-break: break-all;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Diff Viewer */
.diff-viewer {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.diff-item {
    font-size: 0.8rem;
    padding: 0.4rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.diff-item:last-child {
    border-bottom: none;
}

.diff-key {
    font-weight: 600;
    color: var(--secondary);
    margin-bottom: 0.2rem;
}

.diff-old {
    color: var(--action-delete);
    text-decoration: line-through;
}

.diff-new {
    color: var(--action-create);
}

.diff-arrow {
    color: var(--text-muted);
    margin: 0 0.5rem;
}

/* Utilities & Forms */
.mt-1 {
    margin-top: 0.25rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-3 {
    margin-top: 1rem;
}

.mt-4 {
    margin-top: 1.5rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-3 {
    margin-bottom: 1rem;
}

.pt-4 {
    padding-top: 1.5rem;
}

.mt-auto {
    margin-top: auto;
}

.hidden {
    display: none !important;
}

.full-width {
    width: 100%;
}

.block {
    display: block;
}

.text-muted {
    color: var(--text-muted);
}

.text-sm {
    font-size: 0.85rem;
}

.text-xs {
    font-size: 0.75rem;
}

.font-mono {
    font-family: 'Fira Code', monospace;
}

.font-bold {
    font-weight: 700;
}

.tracking-wide {
    letter-spacing: 0.05em;
}

.uppercase {
    text-transform: uppercase;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.input-control {
    width: 100%;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border-radius: 8px;
    outline: none;
    transition: 0.2s;
    font-size: 0.9rem;
}

.input-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(225, 112, 85, 0.2);
}

textarea.input-control {
    resize: vertical;
    line-height: 1.4;
    white-space: pre;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.25rem;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn.small {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
}

.primary-btn {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(225, 112, 85, 0.3);
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.outline-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.outline-btn:hover {
    border-color: var(--secondary);
    background: rgba(250, 177, 160, 0.1);
}

/* Custom Checkboxes */
.filter-toggles {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.custom-checkbox {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
}

.custom-checkbox input {
    display: none;
}

.checkmark {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 2px solid var(--text-muted);
    position: relative;
    transition: 0.2s;
}

.custom-checkbox input:checked+.checkmark {
    border-color: transparent;
}

.custom-checkbox input:checked+.checkmark.create {
    background-color: var(--action-create);
}

.custom-checkbox input:checked+.checkmark.update {
    background-color: var(--action-update);
}

.custom-checkbox input:checked+.checkmark.delete {
    background-color: var(--action-delete);
}

.custom-checkbox input:checked+.checkmark.replace {
    background-color: var(--action-replace);
}

.custom-checkbox input:checked+.checkmark.noop {
    background-color: var(--action-noop);
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.custom-checkbox input:checked+.checkmark:after {
    display: block;
}

/* Cost */
.cost-value {
    font-size: 1.5rem;
    color: var(--accent);
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 234, 167, 0.1);
    text-align: center;
}

.cost-value .text-xs {
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-main);
    color: #000;
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    font-weight: 600;
    font-size: 0.95rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    transition: opacity 0.3s;
}

@media (max-width: 1000px) {
    .app-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        overflow: auto;
    }

    .sidebar {
        width: 100%;
        max-height: 50vh;
    }

    .main-view {
        height: 60vh;
    }

    .detail-panel {
        position: static;
        width: 100%;
        height: auto;
        transform: none;
        display: none;
    }

    .detail-panel:not(.hidden) {
        display: flex;
    }
}