:root {
    --bg-app: #0F172A;
    --bg-panel: #1E293B;
    --bg-hover: #334155;
    --bg-grid: rgba(59, 130, 246, 0.1);

    --border-color: #334155;
    --border-focus: #3B82F6;

    --text-main: #F8FAFC;
    --text-muted: #94A3B8;

    --color-primary: #3B82F6;
    --color-primary-hover: #2563EB;
    --color-secondary: #475569;
    --color-secondary-hover: #334155;
    --color-accent: #10B981;
    --color-danger: #EF4444;

    --type-int: #3B82F6;
    --type-char: #10B981;
    --type-time: #F59E0B;
    --type-bool: #8B5CF6;
    --type-other: #94A3B8;

    --font-ui: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

body {
    font-family: var(--font-ui);
    background-color: var(--bg-app);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Utilities */
.hidden {
    display: none !important;
}

.block {
    display: block !important;
}

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

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

.w-full {
    width: 100%;
}

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

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

.flex {
    display: flex;
}

.gap-2 {
    gap: 0.5rem;
}

.justify-end {
    justify-content: flex-end;
}

.flex-1 {
    flex: 1;
}

/* Buttons */
.btn {
    font-family: inherit;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: var(--color-primary-hover);
}

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--color-secondary);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-danger);
}

.btn-danger:hover {
    background: var(--color-danger);
    color: #fff;
}

.btn-sm {
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
}

.btn-icon {
    background: transparent;
    color: var(--text-muted);
    border: none;
    border-radius: 4px;
    padding: 0.4rem;
    cursor: pointer;
    display: flex;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.form-select,
.form-input {
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: 6px;
    padding: 0.5rem;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    outline: none;
}

.form-select:focus,
.form-input:focus {
    border-color: var(--border-focus);
}

/* Header */
.navbar {
    height: 56px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    flex-shrink: 0;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--color-primary);
}

.brand h1 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
}

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

.divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 0.5rem;
}

/* Layout */
.app-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 5;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.table-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* List Items */
.list-table-item {
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.75rem;
    cursor: pointer;
    transition: border-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.list-table-item:hover {
    border-color: var(--border-focus);
}

.list-table-item.active {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px var(--color-primary);
}

.lti-name {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 500;
}

.lti-cols {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Canvas */
.canvas-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    background-color: var(--bg-app);
    /* Blueprint Grid generated via JS or CSS */
    background-image: linear-gradient(var(--bg-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
    background-size: 20px 20px;
}

#diagram-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
}

#diagram-canvas:active {
    cursor: grabbing;
}

.canvas-controls {
    position: absolute;
    bottom: 24px;
    right: 24px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

.zoom-level {
    font-size: 0.8rem;
    font-family: var(--font-mono);
    width: 48px;
    text-align: center;
    pointer-events: none;
}

/* Properties Panel */
.properties-panel {
    border-right: none;
    border-left: 1px solid var(--border-color);
}

.prop-section {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.prop-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.col-item {
    background: var(--bg-hover);
    border-radius: 4px;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.col-header {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.col-header input[type="text"] {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 1px dashed var(--border-color);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    outline: none;
}

.col-header input[type="text"]:focus {
    border-bottom-color: var(--border-focus);
}

.col-type {
    width: 90px;
    font-size: 0.8rem;
    padding: 0.2rem;
}

.col-flags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.75rem;
}

.flag-label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
}

/* Modals */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.btn-close-modal {
    font-size: 1.5rem;
    width: 32px;
    height: 32px;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    background: rgba(0, 0, 0, 0.1);
}

.export-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.xtab-btn {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -0.5rem;
}

.xtab-btn.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.code-editor {
    width: 100%;
    height: 300px;
    background: #0f172a;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: #e2e8f0;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 1rem;
    resize: vertical;
    outline: none;
}

.code-editor:focus {
    border-color: var(--border-focus);
}