/* =============================================
   网络配置生成器 - 深色科技风格 UI
   ============================================= */

/* --- CSS Variables (Dark Theme - Default) --- */
:root,
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-card: #1e293b;
    --bg-card-alpha: rgba(30, 41, 59, 0.85);
    --bg-hover: #263548;
    --bg-input: #0f172a;
    --bg-overlay-30: rgba(15, 23, 42, 0.3);
    --bg-overlay-40: rgba(15, 23, 42, 0.4);
    --bg-overlay-50: rgba(15, 23, 42, 0.5);

    --accent: #06b6d4;
    --accent-hover: #0891b2;
    --accent-light: rgba(6, 182, 212, 0.12);
    --accent-glow: rgba(6, 182, 212, 0.25);

    --purple: #8b5cf6;
    --purple-hover: #7c3aed;
    --purple-light: rgba(139, 92, 246, 0.12);
    --purple-glow: rgba(139, 92, 246, 0.25);

    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.12);
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.12);
    --warn: #f59e0b;
    --warn-light: rgba(245, 158, 11, 0.12);
    --info: #3b82f6;

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-accent: #06b6d4;

    --border: #334155;
    --border-light: #475569;
    --border-accent: rgba(6, 182, 212, 0.3);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(6, 182, 212, 0.15);

    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Cascadia Code', 'Consolas', 'Monaco', 'Fira Code', monospace;
}

/* --- Light Theme --- */
[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-card: #ffffff;
    --bg-card-alpha: rgba(255, 255, 255, 0.9);
    --bg-hover: #e2e8f0;
    --bg-input: #ffffff;
    --bg-overlay-30: rgba(248, 250, 252, 0.5);
    --bg-overlay-40: rgba(248, 250, 252, 0.6);
    --bg-overlay-50: rgba(248, 250, 252, 0.7);

    --accent: #0891b2;
    --accent-hover: #0e7490;
    --accent-light: rgba(8, 145, 178, 0.1);
    --accent-glow: rgba(8, 145, 178, 0.2);

    --purple: #7c3aed;
    --purple-hover: #6d28d9;
    --purple-light: rgba(124, 58, 237, 0.1);
    --purple-glow: rgba(124, 58, 237, 0.2);

    --success: #059669;
    --success-light: rgba(5, 150, 105, 0.1);
    --danger: #dc2626;
    --danger-light: rgba(220, 38, 38, 0.1);
    --warn: #d97706;
    --warn-light: rgba(217, 119, 6, 0.1);
    --info: #2563eb;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-accent: #0891b2;

    --border: #e2e8f0;
    --border-light: #cbd5e1;
    --border-accent: rgba(8, 145, 178, 0.25);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 20px rgba(8, 145, 178, 0.1);
}

/* --- Auto Theme (follow system) --- */
@media (prefers-color-scheme: light) {
    [data-theme="auto"] {
        --bg-primary: #f8fafc;
        --bg-secondary: #ffffff;
        --bg-tertiary: #f1f5f9;
        --bg-card: #ffffff;
        --bg-card-alpha: rgba(255, 255, 255, 0.9);
        --bg-hover: #e2e8f0;
        --bg-input: #ffffff;
        --bg-overlay-30: rgba(248, 250, 252, 0.5);
        --bg-overlay-40: rgba(248, 250, 252, 0.6);
        --bg-overlay-50: rgba(248, 250, 252, 0.7);

        --accent: #0891b2;
        --accent-hover: #0e7490;
        --accent-light: rgba(8, 145, 178, 0.1);
        --accent-glow: rgba(8, 145, 178, 0.2);

        --purple: #7c3aed;
        --purple-hover: #6d28d9;
        --purple-light: rgba(124, 58, 237, 0.1);
        --purple-glow: rgba(124, 58, 237, 0.2);

        --success: #059669;
        --success-light: rgba(5, 150, 105, 0.1);
        --danger: #dc2626;
        --danger-light: rgba(220, 38, 38, 0.1);
        --warn: #d97706;
        --warn-light: rgba(217, 119, 6, 0.1);
        --info: #2563eb;

        --text-primary: #0f172a;
        --text-secondary: #475569;
        --text-muted: #94a3b8;
        --text-accent: #0891b2;

        --border: #e2e8f0;
        --border-light: #cbd5e1;
        --border-accent: rgba(8, 145, 178, 0.25);

        --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
        --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
        --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);
        --shadow-glow: 0 0 20px rgba(8, 145, 178, 0.1);
    }
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0; padding: 0; box-sizing: border-box;
}
html, body { height: 100%; }
body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

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

/* --- Auth Page --- */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}
/* Animated background grid */
.auth-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        linear-gradient(rgba(6, 182, 212, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(6, 182, 212, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    animation: gridMove 30s linear infinite;
}
/* Floating orbs */
.auth-container::after {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.08) 0%, transparent 70%);
    border-radius: 50%;
    top: -200px;
    right: -200px;
    animation: orbFloat 10s ease-in-out infinite;
}
@keyframes gridMove {
    0% { transform: translate(0, 0); }
    100% { transform: translate(60px, 60px); }
}
@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-40px, 40px) scale(1.1); }
}

.auth-card {
    background: var(--bg-card-alpha);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border);
    padding: 40px;
    border-radius: var(--radius-xl);
    width: 420px;
    position: relative;
    z-index: 1;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    animation: cardEnter 0.5s ease-out;
}
@keyframes cardEnter {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
/* Top accent bar */
.auth-card::before {
    content: '';
    position: absolute;
    top: 0; left: 24px; right: 24px;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--purple), var(--accent));
    background-size: 200% 100%;
    border-radius: 0 0 3px 3px;
    animation: accentSlide 4s ease infinite;
}
@keyframes accentSlide {
    0%, 100% { background-position: 0% 0; }
    50% { background-position: 100% 0; }
}
.auth-card h2 {
    text-align: center;
    margin-bottom: 32px;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

/* Auth Tabs */
.auth-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: var(--bg-primary);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}
.auth-tab {
    flex: 1;
    padding: 10px 16px;
    text-align: center;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    user-select: none;
}
.auth-tab:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}
.auth-tab.active {
    color: white;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    box-shadow: 0 2px 8px var(--purple-glow);
}

/* Forgot Password */
.forgot-password {
    text-align: right;
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-accent);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}
.forgot-password:hover { color: var(--purple); }

/* --- Buttons --- */
.btn {
    padding: 10px 20px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    border: none;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    user-select: none;
    letter-spacing: 0.2px;
    font-family: inherit;
}
.btn:active { transform: scale(0.97); }
.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #0e7490);
    color: white;
    box-shadow: 0 2px 12px var(--accent-glow);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-hover), #0e7490);
    box-shadow: 0 4px 20px var(--accent-glow);
    transform: translateY(-1px);
}

.btn-default {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-default:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #059669);
    color: white;
    box-shadow: 0 2px 12px rgba(16, 185, 129, 0.2);
}
.btn-success:hover {
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.3);
    transform: translateY(-1px);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: white;
    box-shadow: 0 2px 12px rgba(239, 68, 68, 0.2);
}
.btn-danger:hover {
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.3);
    transform: translateY(-1px);
}

.btn-small {
    padding: 6px 14px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

/* --- Form Elements --- */
.form-field { margin-bottom: 16px; }
.form-field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.form-field.checkbox-form-field label,
.form-field label:has(input[type="checkbox"]) {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0;
    text-transform: none;
    letter-spacing: normal;
    font-size: 13px;
    color: var(--text-primary);
}
.form-field input[type="checkbox"] {
    width: auto;
    margin: 0;
    accent-color: var(--accent);
}

.form-field input,
.form-field textarea,
.form-field select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: inherit;
    transition: var(--transition);
}
.form-field input:hover,
.form-field textarea:hover,
.form-field select:hover {
    border-color: var(--border-light);
}
.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}
.form-field input::placeholder,
.form-field textarea::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}
.form-field textarea {
    min-height: 100px;
    resize: vertical;
    font-family: inherit;
    line-height: 1.6;
}
.form-field select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    cursor: pointer;
}
.form-field select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.checkbox-field {
    display: flex;
    align-items: center;
    gap: 8px;
}
.checkbox-field input { width: auto; }

/* --- App Layout --- */
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Header */
.app-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    flex-shrink: 0;
    position: relative;
    z-index: 100;
}
.app-header::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), var(--purple), transparent);
    opacity: 0.4;
}
.app-header h1 {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.3px;
}
.header-right {
    display: flex;
    gap: 8px;
    align-items: center;
}
.header-right > span {
    padding: 6px 14px;
    background: var(--accent-light);
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-accent);
    border: 1px solid var(--border-accent);
    margin-right: 4px;
}
.header-right .btn {
    padding: 7px 16px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}
.header-right .btn-default {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.header-right .btn-default:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border-color: var(--border-light);
}

/* Active nav button highlight */
.header-right .btn.nav-active {
    color: var(--accent);
    border-color: var(--border-accent);
    background: var(--accent-light);
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* --- My Templates View --- */
#main-view {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.sidebar-header {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}
.sidebar-header .btn-primary {
    width: 100%;
    padding: 10px;
    font-size: 13px;
}
.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
}
.sidebar-footer .btn {
    flex: 1;
    padding: 8px 10px;
    font-size: 12px;
}

/* Template Item */
.template-item {
    padding: 12px;
    cursor: pointer;
    border-radius: var(--radius-md);
    margin-bottom: 4px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: var(--transition);
    border: 1px solid transparent;
    background: transparent;
}
.template-item:hover {
    background: var(--bg-hover);
    border-color: var(--border);
}
.template-item.active {
    background: var(--accent-light);
    border-color: var(--border-accent);
    box-shadow: inset 0 0 0 1px rgba(6, 182, 212, 0.08);
}
.template-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.template-meta {
    font-size: 11px;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    align-items: center;
}
.template-owner { color: var(--text-muted); }

/* Tags */
.meta-tag {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.tag-vendor {
    background: rgba(59, 130, 246, 0.12);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.2);
}
.tag-platform {
    background: var(--success-light);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2);
}
.tag-public {
    background: var(--warn-light);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Content Area */
.content-area {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Left Panel */
.left-panel {
    width: 360px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.panel-section {
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.panel-section:first-child {
    flex: 0 1 auto;
}
.panel-section:last-child {
    flex: 1 1 auto;
    border-bottom: none;
}
.panel-header {
    padding: 10px 14px;
    background: var(--bg-overlay-50);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
}
.panel-header strong {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

/* Right Panel */
.right-panel {
    flex: 1;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg-secondary);
}
.tab {
    padding: 10px 20px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    user-select: none;
}
.tab:hover {
    color: var(--text-secondary);
    background: var(--bg-hover);
}
.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: rgba(6, 182, 212, 0.05);
}

/* Code Editor */
.code-editor {
    font-family: var(--font-mono);
    padding: 16px;
    border: none;
    resize: none;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.6;
    height: 100%;
    width: 100%;
    box-sizing: border-box;
}
.code-editor:focus { outline: none; }

/* Preview Panel */
#preview-panel {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 13px;
}

/* --- Instance Table --- */
.instance-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.instance-table th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 10px 8px;
    text-align: left;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.5px;
    border: none;
    position: sticky;
    top: 0;
}
.instance-table td {
    padding: 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}
.instance-table tbody tr {
    transition: var(--transition);
    cursor: pointer;
}
.instance-table tbody tr:hover {
    background: var(--accent-light);
}
.instance-table tbody tr:nth-child(even) {
    background: var(--bg-overlay-30);
}
.instance-table tbody tr:nth-child(even):hover {
    background: var(--accent-light);
}

/* --- Dropdown --- */
.dropdown {
    position: relative;
    display: inline-block;
}
.dropdown-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 160px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: var(--transition);
    overflow: hidden;
    margin-top: 4px;
}
.dropdown:hover .dropdown-menu,
.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.dropdown-item {
    padding: 10px 14px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.dropdown-item:hover {
    background: var(--accent-light);
    color: var(--accent);
}
.dropdown-item:first-child {
    border-bottom: 1px solid var(--border);
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-overlay.show { display: flex; }
.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 1100px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    animation: modalEnter 0.3s ease-out;
}
@keyframes modalEnter {
    from { opacity: 0; transform: scale(0.96) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    background: var(--bg-overlay-40);
}
.modal-header h2, .modal-header h3 {
    font-size: 15px;
    color: var(--text-primary);
    font-weight: 700;
}
.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}
.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
    background: var(--bg-overlay-40);
}
.close-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
    padding: 4px;
    line-height: 1;
}
.close-btn:hover { color: var(--text-primary); }

/* --- Template Store --- */
.store-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.store-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    padding: 16px;
    overflow-y: auto;
}
.store-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    transition: var(--transition);
}
.store-card:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.store-card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 10px;
}
.store-card-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}
.store-card-meta {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.store-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

/* --- Admin --- */
.admin-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.admin-content {
    flex: 1;
    padding: 32px 40px;
    overflow-y: auto;
    background: var(--bg-primary);
}

/* Admin Stats */
.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.stat-card::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 60px;
    height: 60px;
    border-radius: 0 var(--radius-md) 0 60px;
    opacity: 0.1;
}
.stat-card:nth-child(1)::after { background: var(--accent); }
.stat-card:nth-child(2)::after { background: var(--purple); }
.stat-card:nth-child(3)::after { background: var(--success); }
.stat-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.stat-icon {
    font-size: 28px;
    margin-bottom: 10px;
}
.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* Admin Card */
.admin-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 16px;
}
.admin-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}
.admin-card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Admin Table */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.admin-table th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 12px 10px;
    text-align: left;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.5px;
    border: none;
}
.admin-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}
.admin-table tbody tr {
    transition: var(--transition);
}
.admin-table tbody tr:hover {
    background: var(--accent-light);
}
.admin-table tbody tr:nth-child(even) {
    background: var(--bg-overlay-30);
}
.admin-table tbody tr:nth-child(even):hover {
    background: var(--accent-light);
}

/* Badges */
.admin-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.badge-admin {
    background: var(--purple-light);
    color: #a78bfa;
    border: 1px solid rgba(139, 92, 246, 0.2);
}
.badge-user {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.badge-active {
    background: var(--success-light);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.2);
}
.badge-inactive {
    background: var(--danger-light);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.badge-public {
    background: var(--warn-light);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.2);
}
.badge-private {
    background: var(--bg-tertiary);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

/* Admin Form */
.admin-form-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 28px 36px;
    max-width: 1000px;
    margin: 0 auto;
    box-shadow: var(--shadow-md);
}
.admin-form-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.admin-input-group {
    margin-bottom: 16px;
}
.admin-input-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.admin-input-group input,
.admin-input-group select,
.admin-input-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: inherit;
    transition: var(--transition);
}
.admin-input-group textarea {
    min-height: 80px;
    resize: vertical;
    line-height: 1.6;
}
.admin-input-group input:focus,
.admin-input-group select:focus,
.admin-input-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}
.admin-info-box {
    background: linear-gradient(135deg, var(--accent-light), var(--purple-light));
    color: var(--text-primary);
    padding: 14px 16px;
    border-radius: var(--radius-md);
    margin: 16px 0;
    border: 1px solid var(--border-accent);
}
.admin-info-box h4 {
    margin: 0 0 6px 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-accent);
}
.admin-info-box p {
    margin: 3px 0;
    font-size: 12px;
    color: var(--text-secondary);
}

/* --- Toast --- */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    color: white;
    z-index: 2000;
    opacity: 0;
    transform: translateX(20px);
    transition: var(--transition);
    pointer-events: none;
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    max-width: 360px;
}
.toast.show {
    opacity: 1;
    transform: translateX(0);
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--info); }
.toast-warn { background: var(--warn); color: #1a1a2e; }

/* --- Footer --- */
footer {
    text-align: center;
    padding: 16px;
    color: var(--text-muted);
    font-size: 12px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

/* --- Store/Search Inputs (inline styles override) --- */
#store-search,
#store-filter-vendor,
#store-filter-platform {
    padding: 7px 12px !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    font-size: 12px !important;
    background: var(--bg-input) !important;
    color: var(--text-primary) !important;
    font-family: var(--font-sans) !important;
}
#store-search:focus,
#store-filter-vendor:focus,
#store-filter-platform:focus {
    outline: none;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px var(--accent-light);
}

/* --- Log Panel --- */
#log-panel > div {
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.8;
}
#log-panel > div[style] {
    color: var(--text-muted);
    padding: 16px !important;
}

/* --- Store panel header sticky fix --- */
.store-view .panel-header,
.admin-view .panel-header {
    background: var(--bg-secondary);
}

/* --- Modal dark code editors --- */
#ui-schema,
#template-content,
#command-input {
    caret-color: var(--accent);
}

/* --- Theme Toggle --- */
.theme-toggle-btn {
    gap: 6px;
    padding: 7px 12px !important;
}
.theme-menu {
    min-width: 120px;
    right: 0;
    left: auto;
}
.theme-menu .dropdown-item {
    gap: 8px;
    justify-content: flex-start;
}
