:root {
    --bg-main: #f8fafc;
    --sidebar-bg: #1e293b;
    --sidebar-accent: #334155;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --white: #ffffff;
    --success: #10b981;
    --danger: #ef4444;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --grid-color: #e2e8f0;
}

* { box-sizing: border-box; }

body, html {
    margin: 0; padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    height: 100%; width: 100%;
    color: var(--text-main);
    overflow: hidden;
}

/* Landing Page & Marketing */
.landing-page {
    height: 100vh;
    overflow-y: auto;
    background: var(--bg-main);
    scroll-behavior: smooth;
}

.landing-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 5%;
    background: var(--white);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-links {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.header-links a {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.header-links a:hover { color: var(--primary); }

.btn-login-scroll {
    background: var(--sidebar-bg);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

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

.lang-selector-inline {
    display: flex;
    gap: 0.75rem;
    margin-right: 1rem;
}
.lang-selector-inline a {
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    padding: 2px 5px;
    border-radius: 4px;
    transition: all 0.2s;
}
.lang-selector-inline a.active {
    background: var(--primary);
    color: white;
}
.lang-selector-inline a:hover:not(.active) {
    color: var(--primary);
}

.lang-selector-sidebar {
    padding: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    border-top: 1px solid var(--sidebar-accent);
}
.lang-selector-sidebar a {
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 700;
    color: #94a3b8;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--sidebar-accent);
    transition: all 0.2s;
}
.lang-selector-sidebar a.active {
    background: var(--primary);
    color: white;
}
.lang-selector-sidebar a:hover:not(.active) {
    background: #475569;
    color: white;
}

.hero-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 5rem 5%;
    align-items: center;
    gap: 4rem;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

.hero-content h1 {
    font-size: 3.5rem;
    line-height: 1.1;
    margin-bottom: 1.5rem;
    color: var(--sidebar-bg);
}

.hero-content h1 span { color: var(--primary); }

.hero-content p {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 2.5rem;
    line-height: 1.6;
}

.btn-primary-large {
    background: var(--primary);
    color: white;
    border: none;
    padding: 1.2rem 2.5rem;
    border-radius: 0.75rem;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.3);
    transition: all 0.2s;
}

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

.hero-image {
    perspective: 1000px;
}

.mockup-canvas {
    background: white;
    height: 400px;
    border-radius: 1.5rem;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border-color);
    transform: rotateY(-10deg) rotateX(5deg);
}

.mockup-grid {
    position: absolute; width: 100%; height: 100%;
    background-size: 30px 30px;
    background-image: linear-gradient(to right, #f1f5f9 1px, transparent 1px), linear-gradient(to bottom, #f1f5f9 1px, transparent 1px);
}

.mockup-node {
    position: absolute; width: 50px; height: 50px;
    background: white; border: 2px solid var(--primary);
    border-radius: 12px; display: flex; align-items: center; justify-content: center;
    color: var(--primary); font-size: 1.2rem; box-shadow: var(--shadow);
    z-index: 2;
}

.mockup-lines { position: absolute; width: 100%; height: 100%; z-index: 1; }

.features-section {
    padding: 6rem 5%;
    text-align: center;
}

.features-section h2 {
    font-size: 2.5rem;
    margin-bottom: 4rem;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2.5rem;
}

.feature-card {
    background: white;
    padding: 3rem 2rem;
    border-radius: 1.5rem;
    box-shadow: var(--shadow);
    transition: transform 0.3s;
}

.feature-card:hover { transform: translateY(-10px); }

.feature-card i {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 1.5rem;
}

.feature-card h3 { margin-bottom: 1rem; }
.feature-card p { color: var(--text-muted); line-height: 1.5; font-size: 0.95rem; }

.login-auth-section {
    padding: 6rem 5%;
    display: flex;
    justify-content: center;
    background: var(--sidebar-bg);
}

.login-auth-section .login-card {
    background: white;
    margin: 0;
}

.landing-footer {
    background: white;
    padding: 4rem 5% 2rem;
    border-top: 1px solid var(--border-color);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    margin-bottom: 3rem;
    flex-wrap: wrap;
    gap: 3rem;
}

.footer-info h3 { font-size: 1.5rem; margin-bottom: 1rem; }
.footer-info p { color: var(--text-muted); }
.hosting-note { margin-top: 1.5rem; font-weight: 600; font-size: 0.85rem; color: var(--success) !important; }

.footer-imprint h4 { margin-bottom: 1.2rem; text-transform: uppercase; letter-spacing: 0.1em; }
.footer-imprint p { margin-bottom: 0.5rem; color: var(--text-muted); font-size: 0.9rem; }
.footer-imprint a { color: var(--primary); text-decoration: none; }

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Login Page (Legacy compat for modal login) */
.login-container {
    display: flex; justify-content: center; align-items: center;
    height: 100vh; background: radial-gradient(circle at top right, #1e293b, #0f172a);
}
.login-card {
    background: var(--white);
    padding: 2.5rem; border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    width: 100%; max-width: 400px;
    display: flex; flex-direction: column;
}
.login-header {
    text-align: center; margin-bottom: 2rem;
}
.login-header i { font-size: 3rem; color: var(--primary); margin-bottom: 0.5rem; }
.login-header h1 { margin: 0; font-size: 1.5rem; font-weight: 700; color: var(--text-main); }
.login-header h1 span { color: var(--primary); }
.login-card h2 { font-size: 1.1rem; margin-top: 0; color: var(--text-muted); text-align: center; margin-bottom: 1.5rem; }

.input-group {
    position: relative; margin-bottom: 1rem;
}
.input-group i {
    position: absolute; left: 1rem; top: 1rem; color: var(--text-muted);
}
.input-group input {
    width: 100%; padding: 0.875rem 1rem 0.875rem 2.75rem;
    border: 1px solid var(--border-color); border-radius: 0.5rem;
    font-size: 1rem; transition: border-color 0.2s;
}
.input-group input:focus { outline: none; border-color: var(--primary); }

.btn-primary {
    background: var(--primary); color: white; border: none;
    padding: 0.875rem; border-radius: 0.5rem; cursor: pointer;
    font-size: 1rem; font-weight: 600; transition: background 0.2s;
    margin-top: 0.5rem;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-danger {
    background: var(--danger); color: white; border: none;
    padding: 0.875rem; border-radius: 0.5rem; cursor: pointer;
    font-size: 1rem; font-weight: 600; transition: background 0.2s;
    width: 100%;
}
.btn-danger:hover { background: #dc2626; }

.error-msg {
    background: #fef2f2; color: var(--danger);
    padding: 0.75rem; border-radius: 0.5rem; margin-bottom: 1rem;
    font-size: 0.875rem; display: flex; align-items: center; gap: 0.5rem;
}

/* App Layout */
.app-layout {
    display: flex; height: 100vh; width: 100vw;
}

/* Sidebars */
.sidebar {
    background: var(--sidebar-bg); color: var(--white);
    display: flex; flex-direction: column; z-index: 50;
}
.left-sidebar { width: 240px; border-right: 1px solid var(--sidebar-accent); }
.right-sidebar { width: 280px; border-left: 1px solid var(--sidebar-accent); }

.sidebar-header {
    padding: 1.25rem; font-weight: 600; font-size: 0.875rem;
    text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted);
    border-bottom: 1px solid var(--sidebar-accent);
    display: flex; align-items: center; gap: 0.75rem;
}

.sidebar-content {
    padding: 1.5rem;
    flex-grow: 1;
    overflow-y: auto;
}

.empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 100%; text-align: center; color: var(--text-muted); gap: 1rem;
}
.empty-state i { font-size: 2.5rem; opacity: 0.5; }
.empty-state p { font-size: 0.875rem; margin: 0; line-height: 1.5; }

.sidebar-form {
    display: flex; flex-direction: column; gap: 1.25rem;
}
.sidebar-form .form-group label {
    color: #94a3b8; /* Light gray for dark sidebar */
    margin-bottom: 0.4rem;
}
.sidebar-form input, .sidebar-form textarea {
    background: var(--sidebar-accent);
    border: 1px solid #475569;
    color: var(--white);
    padding: 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
}
.sidebar-form input[type="color"] {
    height: 45px;
    padding: 5px;
    cursor: pointer;
}
.sidebar-form input:focus, .sidebar-form textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: #3d4d63;
}
.sidebar-form textarea { resize: vertical; }

.logo-area {
    padding: 1.5rem; display: flex; align-items: center; gap: 1rem;
    border-bottom: 1px solid var(--sidebar-accent);
}
.logo-circle {
    width: 40px; height: 40px; background: var(--primary);
    border-radius: 0.75rem; display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem; color: white !important; /* Always white icon */
}
.logo-text { font-size: 1.25rem; font-weight: 700; color: white; }
.logo-text span { color: var(--primary); }

.landing-header .logo-area { padding: 0; border: none; }
.landing-header .logo-text { color: var(--text-main); }

.main-nav { padding: 1rem; flex-grow: 1; }
.nav-section {
    padding: 0.5rem 0.75rem; font-size: 0.75rem; font-weight: 600;
    text-transform: uppercase; color: var(--text-muted); margin-top: 1rem;
}
.nav-item {
    width: 100%; display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem; margin-top: 0.25rem;
    background: transparent; border: none; color: #cbd5e1;
    cursor: pointer; border-radius: 0.5rem; font-size: 0.9375rem;
    text-align: left; transition: all 0.2s;
}
.nav-item:hover { background: var(--sidebar-accent); color: var(--white); }
.nav-item.active-admin { color: #f8fafc; font-weight: 600; background: rgba(59, 130, 246, 0.1); border: 1px solid rgba(59, 130, 246, 0.2); }

.sidebar-footer { padding: 1rem; border-top: 1px solid var(--sidebar-accent); }
.logout-link {
    display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem;
    color: #fca5a5; text-decoration: none; font-size: 0.9375rem;
    border-radius: 0.5rem; transition: background 0.2s;
}
.logout-link:hover { background: rgba(239, 68, 68, 0.1); }

/* Main Content */
.main-content {
    flex-grow: 1; display: flex; flex-direction: column;
    background: var(--bg-main); position: relative;
}

.top-bar {
    height: 64px; background: var(--white); border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; padding: 0 1.5rem; justify-content: space-between;
}
.tabs-container { display: flex; align-items: center; gap: 0.5rem; }
.tabs { display: flex; gap: 0.25rem; }
.tab {
    padding: 0.5rem 1rem; border-radius: 0.5rem; background: var(--bg-main);
    font-size: 0.875rem; font-weight: 500; cursor: pointer; border: 1px solid transparent;
}
.tab.active { background: white; border-color: var(--border-color); box-shadow: 0 1px 2px rgba(0,0,0,0.05); color: var(--primary); }
.add-tab-btn {
    width: 32px; height: 32px; border-radius: 0.5rem; border: 1px dashed var(--border-color);
    background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
}
.add-tab-btn:hover { background: var(--border-color); }

.tab input {
    border: none; background: #f1f5f9; padding: 2px 5px; border-radius: 4px;
    font-size: 0.875rem; font-weight: 600; width: 100px; outline: 1px solid var(--primary);
}

/* Custom Context Menu */
.context-menu {
    position: fixed; display: none; background: white; border-radius: 0.75rem;
    box-shadow: var(--shadow-lg); border: 1px solid var(--border-color);
    padding: 0.5rem; z-index: 2000; min-width: 150px;
}
.menu-item {
    padding: 0.625rem 1rem; font-size: 0.875rem; font-weight: 500; cursor: pointer;
    border-radius: 0.5rem; display: flex; align-items: center; gap: 0.75rem;
    transition: background 0.2s;
}
.menu-item:hover { background: var(--bg-main); color: var(--primary); }
.menu-item.danger:hover { background: #fef2f2; color: var(--danger); }

/* Canvas Container */
.canvas-viewport { 
    flex-grow: 1; 
    position: relative; 
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none; /* Safari support */
}
.grid-background {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background-size: 20px 20px;
    background-image:
      linear-gradient(to right, var(--grid-color) 1px, transparent 1px),
      linear-gradient(to bottom, var(--grid-color) 1px, transparent 1px);
}

/* Picker */
.floating-picker {
    position: absolute; top: 1.5rem; right: 1.5rem; width: 200px;
    background: var(--white); border-radius: 1rem; box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color); z-index: 100;
    max-height: calc(100% - 3rem); display: flex; flex-direction: column;
}
.picker-header {
    padding: 1rem; font-weight: 700; font-size: 0.875rem; border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0;
}
.picker-items { padding: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; overflow-y: auto; }

.picker-group-title {
    font-size: 0.7rem; font-weight: 800; text-transform: uppercase;
    color: var(--text-muted); margin-top: 0.5rem; margin-bottom: 0.25rem;
    letter-spacing: 0.05em;
}
.picker-separator {
    height: 1px; background: var(--border-color); margin: 0.5rem 0;
}

.picker-item {
    padding: 0.75rem; background: var(--bg-main); border-radius: 0.5rem;
    display: flex; align-items: center; gap: 0.75rem; cursor: grab;
    font-size: 0.875rem; font-weight: 500; border: 1px solid transparent; transition: all 0.2s;
}
.picker-item:hover { border-color: var(--primary); background: #eff6ff; }
.picker-item i { width: 20px; text-align: center; color: var(--primary); }

/* Nodes & SVGs */
#nodes-container { 
    position: absolute; 
    z-index: 10; 
    pointer-events: none;
    transform-origin: 0 0;
    overflow: visible;
}
#connections-svg { 
    position: absolute; 
    width: 100%; 
    height: 100%; 
    z-index: 5; 
    pointer-events: none;
    transform-origin: 0 0;
    overflow: visible;
}

.conn-line {
    cursor: pointer;
    pointer-events: auto; /* Re-enable for lines */
    transition: filter 0.2s, stroke 0.2s;
    stroke-linecap: round;
}

/* Invisible wide path for easier clicking */
.conn-ghost {
    fill: none;
    stroke: transparent;
    stroke-width: 15;
    cursor: pointer;
    pointer-events: stroke;
}
.conn-ghost:hover + .conn-line {
    filter: drop-shadow(0 0 4px var(--primary));
    stroke-width: 3 !important;
}

.conn-line:hover {
    filter: drop-shadow(0 0 4px var(--primary));
    stroke-width: 3 !important;
}
.conn-line.selected {
    stroke-width: 4 !important;
    filter: drop-shadow(0 0 6px var(--primary));
}

/* Reconnect Handles */
.conn-handle {
    width: 16px; height: 14px;
    background: #f39c12; /* Bright Orange */
    border: 2px solid var(--white);
    box-shadow: 0 0 5px rgba(0,0,0,0.3);
    border-radius: 4px;
    position: absolute;
    cursor: grab;
    z-index: 1000;
    pointer-events: auto;
    transform: translate(-50%, -50%);
}
.conn-handle:hover {
    background: #e67e22;
    transform: translate(-50%, -50%) scale(1.2);
}

.sidebar-form select {
    width: 100%;
    padding: 0.75rem;
    background: var(--sidebar-accent);
    border: 1px solid #475569;
    color: var(--white);
    border-radius: 0.5rem;
    font-size: 0.875rem;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    cursor: pointer;
}
.sidebar-form select:focus {
    outline: none;
    border-color: var(--primary);
}

.node {
    position: absolute; background: var(--white); padding: 1rem;
    border-radius: 1rem; box-shadow: var(--shadow); border: 2px solid transparent;
    cursor: move; min-width: 100px; text-align: center; pointer-events: auto;
    user-select: none; transform: translate(-50%, -50%); transition: box-shadow 0.2s, border-color 0.2s;
    display: flex; align-items: center; justify-content: center; gap: 15px;
}
.node:hover { box-shadow: var(--shadow-lg); }
.node.selected { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1); }
.node .node-main { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.node i { font-size: 1.5rem; color: var(--primary); margin-bottom: 0.5rem; }

/* Color Palette (Tuschkasten) */
.color-palette {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-top: 5px;
}
.color-swatch {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.1s, border-color 0.2s;
}
.color-swatch:hover {
    transform: scale(1.1);
}
.color-swatch.active {
    border-color: #ef4444; /* Rot umrandet wenn aktiv */
    transform: scale(1.1);
}
.node .node-label { font-size: 0.75rem; font-weight: 600; color: var(--text-main); }
.node .node-ip { font-size: 0.65rem; color: var(--text-muted); margin-top: 2px; font-family: monospace; }

/* Server Module Dots */
.server-modules {
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: auto;
    align-items: flex-start;
}
.module-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid white;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    flex-shrink: 0;
}
.module-item-row {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.module-text {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
}
.module-dot:hover { transform: scale(1.3); }
.module-dot.docker { background: #2496ed; }
.module-dot.ssh { background: #48c774; }
.module-dot.virtualbox { background: #3498db; } /* Lighter blue */
.module-dot.iobroker_mod { background: #ff6600; }
.module-dot.database_mod { background: #00758f; }
.module-dot.language_mod { background: #f1e05a; }
.module-dot.ai_mod { background: #8e44ad; }
.module-dot.mailserver_mod { background: #e74c3c; }
.module-dot.domain_mod { background: #1abc9c; } /* Turquoise/Lighter green-blue */
.module-dot.firewall_mod { background: #f87171; }
.module-dot.other_mod { background: #94a3b8; }

.module-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
    padding: 10px;
    background: #1e293b;
    border-radius: 0.5rem;
}
.module-opt {
    flex: 0 0 calc(33.33% - 10px);
    text-align: center;
    font-size: 0.65rem;
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    border-radius: 6px;
}
.module-opt:hover {
    background: rgba(255,255,255,0.05);
    opacity: 0.8;
}
.module-opt i { font-size: 1.1rem; display: block; margin-bottom: 5px; }
.module-opt.active { opacity: 1; font-weight: 700; background: rgba(255,255,255,0.08); }
.module-opt span { display: block; line-height: 1; }

.node.type-internet { border-radius: 50%; width: 90px; height: 90px; display: flex; flex-direction: column; align-items: center; justify-content: center; }

/* Connection points */
.conn-point {
    width: 12px; height: 12px;
    background: var(--primary);
    border: 2px solid var(--white);
    border-radius: 50%;
    position: absolute;
    cursor: crosshair;
    z-index: 100;
    opacity: 0; /* Hidden by default */
    transition: opacity 0.2s, transform 0.2s;
}
.node:hover .conn-point, .node.selected .conn-point, .is-connecting .conn-point {
    opacity: 1;
}
.conn-point:hover, .is-connecting .conn-point:hover {
    transform: scale(1.3);
    background: var(--success);
}

.conn-point.top { top: -6px; left: calc(50% - 6px); }
.conn-point.bottom { bottom: -6px; left: calc(50% - 6px); }
.conn-point.left { left: -6px; top: calc(50% - 6px); }
.conn-point.right { right: -6px; top: calc(50% - 6px); }

.history-filters {
    padding: 1.5rem 2rem;
    background: var(--bg-main);
    display: flex;
    gap: 1.5rem;
    align-items: flex-end;
    border-bottom: 1px solid var(--border-color);
}
.filter-group { display: flex; flex-direction: column; gap: 0.4rem; }
.filter-group label { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }
.filter-group input, .filter-group select {
    padding: 0.625rem 1rem; border: 1px solid var(--border-color); border-radius: 0.5rem; background: white;
    font-size: 0.875rem; color: var(--text-main); transition: border-color 0.2s;
}
.filter-group select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
    cursor: pointer;
    min-width: 150px;
}
.filter-group input:focus, .filter-group select:focus {
    outline: none;
    border-color: var(--primary);
}
.history-table-scroll { 
    flex-grow: 1; 
    overflow-y: auto !important; /* Force scrolling */
    overflow-x: hidden;
    border: none; 
    border-radius: 0;
    min-height: 0;
    display: block; /* Ensure it behaves as a block for scrolling */
    background: var(--white);
}

.history-table-scroll table {
    border-collapse: separate; 
    border-spacing: 0;
    width: 100%;
    table-layout: fixed; /* Better for performance and scrolling */
}

.history-table-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 20; /* Higher than badges */
    background: #f8fafc;
    box-shadow: inset 0 -1px 0 var(--border-color);
    padding: 1rem;
}

.history-table-scroll td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.history-table-scroll td:last-child {
    white-space: normal; /* Details should wrap */
}

/* Admin Modal */
.modal {
    display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.75); backdrop-filter: blur(4px);
}
.admin-modal-wide {
    background: var(--white); width: 90%; max-width: 1100px; height: 80vh;
    margin: 5vh auto; border-radius: 1.5rem; box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column; overflow: hidden;
}

.modal-small {
    background: var(--white); width: 100%; max-width: 400px;
    margin: 20vh auto; border-radius: 1rem; padding: 2rem;
    box-shadow: var(--shadow-lg); text-align: center;
}

.modal-medium {
    background: var(--white); width: 100%; max-width: 700px;
    margin: 10vh auto; border-radius: 1.5rem;
    box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column; overflow: hidden;
}

.modal-small h3 { margin-top: 0; margin-bottom: 0.5rem; }
.modal-small p { color: var(--text-muted); margin-bottom: 1.5rem; font-size: 0.9rem; }

.modal-actions-vertical { display: flex; flex-direction: column; gap: 0.75rem; }

.btn-secondary {
    background: #f1f5f9; color: var(--text-main); border: 1px solid var(--border-color);
    padding: 0.75rem; border-radius: 0.5rem; cursor: pointer; font-weight: 600;
}
.btn-secondary:hover { background: #e2e8f0; }

.btn-note-item:hover {
    filter: brightness(1.2);
    transform: translateY(-1px);
}

.modal-header {
    padding: 1.5rem 2rem; border-bottom: 1px solid var(--border-color);
    display: flex; justify-content: space-between; align-items: center;
}
.modal-header h2 { margin: 0; font-size: 1.25rem; display: flex; align-items: center; gap: 0.75rem; }
.close-btn { font-size: 1.5rem; cursor: pointer; color: var(--text-muted); }

.admin-layout { display: flex; flex-grow: 1; overflow: hidden; }
.admin-sidebar {
    width: 240px; background: var(--bg-main); border-right: 1px solid var(--border-color);
    padding: 1.5rem; display: flex; flex-direction: column; gap: 0.5rem;
}
.admin-nav-btn {
    padding: 0.75rem 1rem; border-radius: 0.75rem; border: none; background: transparent;
    text-align: left; font-size: 0.9375rem; font-weight: 500; cursor: pointer;
    display: flex; align-items: center; gap: 0.75rem; transition: all 0.2s;
}
.admin-nav-btn:hover { background: var(--border-color); }
.admin-nav-btn.active { background: var(--primary); color: white; }

.admin-tab-content { display: none; }
.admin-tab-content.active { display: block; }

.admin-main { flex-grow: 1; padding: 2rem; overflow-y: auto; background: var(--white); }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.section-header h3 { margin: 0; font-size: 1.125rem; }

.quick-add { display: flex; gap: 0.75rem; }
.quick-add input {
    padding: 0.625rem 1rem; border: 1px solid var(--border-color); border-radius: 0.5rem; width: 300px;
}
.btn-success {
    background: var(--success); color: white; border: none; padding: 0.625rem 1.25rem;
    border-radius: 0.5rem; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 0.5rem;
}

/* Tables */
.table-container { width: 100%; border: 1px solid var(--border-color); border-radius: 0.75rem; overflow: hidden; }
.modern-table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.modern-table th { background: var(--bg-main); padding: 1rem; text-align: left; font-weight: 600; border-bottom: 1px solid var(--border-color); }
.modern-table td { padding: 1rem; border-bottom: 1px solid var(--border-color); }
.modern-table tr:last-child td { border-bottom: none; }
.modern-table tr:hover { background: #f8fafc; }

.action-btn-danger {
    background: transparent;
    color: var(--danger);
    border: none;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background 0.2s;
    font-size: 1rem;
}
.action-btn-danger:hover {
    background: #fee2e2;
}

.badge { padding: 0.25rem 0.625rem; border-radius: 1rem; font-size: 0.75rem; font-weight: 600; }
.badge-admin { background: #eff6ff; color: var(--primary); }
.badge-user { background: #f1f5f9; color: var(--text-muted); }
.badge-success { background: #ecfdf5; color: var(--success); }
.badge-danger { background: #fef2f2; color: var(--danger); }

/* Forms */
.card { padding: 1.5rem; border: 1px solid var(--border-color); border-radius: 1rem; background: var(--bg-main); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 1.5rem; }
.form-group { display: flex; flex-direction: column; gap: 0.5rem; }
.form-group label { font-size: 0.875rem; font-weight: 600; color: var(--text-muted); }
.form-group input, .form-group select { padding: 0.625rem; border: 1px solid var(--border-color); border-radius: 0.5rem; }
.form-group select {
    appearance: none;
    background-color: var(--white);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
    cursor: pointer;
    font-size: 0.9375rem;
    color: var(--text-main);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.check-group { flex-direction: row !important; align-items: center; gap: 1rem !important; }

/* Canvas Controls */
.canvas-controls { position: absolute; bottom: 1.5rem; left: 1.5rem; display: flex; flex-direction: row; gap: 0.5rem; }
.canvas-controls button {
    width: 40px; height: 40px; border-radius: 0.75rem; border: 1px solid var(--border-color);
    background: var(--white); cursor: pointer; box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center;
}
.canvas-controls button:hover { background: var(--bg-main); }

/* Scrollbars */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
