:root {
    /* Colors - Minimalist Palette */
    --bg-body: #FAFAFA;
    --bg-surface: #FFFFFF;
    --bg-surface-hover: #F4F4F5;
    
    --border-color: #E4E4E7;
    --border-focus: #18181B;
    
    --text-main: #09090B;
    --text-muted: #71717A;
    
    --primary: #18181B; /* Pure Black / Dark Gray */
    --primary-hover: #27272A;
    --primary-fg: #FFFFFF;
    
    --danger: #EF4444;
    --danger-bg: #FEF2F2;
    --danger-hover: #DC2626;

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    /* Layout */
    --radius-lg: 12px;
    --radius-md: 8px;
    --radius-sm: 6px;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    --transition: 0.2s ease;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    height: 100vh;
    overflow: hidden;
}

h1, h2, h3, h4 {
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text-main);
}

/* Views */
.view {
    display: none;
    height: 100%;
    width: 100%;
}
.view.active {
    display: flex;
}

/* Typography Helpers */
.subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Auth View */
#auth-view {
    align-items: center;
    justify-content: center;
}

.auth-card {
    background: var(--bg-surface);
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}
.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}
.auth-header .logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}
.auth-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}
.auth-header p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Form Elements (Minimal UX) */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}
.input-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
}
input, select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-family: inherit;
    font-size: 0.875rem;
    color: var(--text-main);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    outline: none;
    box-shadow: var(--shadow-sm);
}
input:focus, select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 1px var(--border-focus);
}
input::placeholder {
    color: #A1A1AA;
}

/* Password Wrapper */
.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.input-wrapper input {
    padding-right: 2.5rem;
}
.input-wrapper .btn-icon {
    position: absolute;
    right: 0.5rem;
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    width: 100%; /* Default block */
}
.btn-primary {
    background: var(--primary);
    color: var(--primary-fg);
}
.btn-primary:hover {
    background: var(--primary-hover);
}
.btn-secondary {
    background: var(--bg-surface);
    border-color: var(--border-color);
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
}
.btn-secondary:hover {
    background: var(--bg-surface-hover);
}
.btn-sm {
    padding: 0.375rem 0.75rem;
    width: auto;
    font-size: 0.8125rem;
}
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.375rem;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
}
.btn-icon:hover {
    background: var(--bg-surface-hover);
    color: var(--text-main);
}
.btn-icon.danger:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

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

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1000;
}
.sidebar-header {
    padding: 1.5rem;
}
.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 1.125rem;
}
.sidebar-search {
    padding: 0 1.25rem 1rem;
}
.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.search-input-wrapper .material-symbols-outlined {
    position: absolute;
    left: 0.75rem;
    color: var(--text-muted);
    font-size: 1.125rem;
}
.search-input-wrapper input {
    padding-left: 2.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 0;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 1rem 1rem;
}
.user-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.user-item {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}
.user-item:hover {
    background: var(--bg-body);
}
.user-item.active {
    background: var(--bg-surface-hover);
    border-color: var(--border-color);
}
.user-item h4 {
    font-size: 0.875rem;
    margin-bottom: 0.125rem;
    word-break: break-all;
    font-weight: 500;
}
.user-item p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sidebar-footer {
    padding: 1.25rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.email-text {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-body);
    overflow: hidden;
}
.editor-header {
    padding: 2rem 3rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-surface);
}
.header-actions {
    display: flex;
    gap: 0.75rem;
}
.header-actions .btn {
    width: auto;
}

.editor-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 3rem;
}

.config-form {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    max-width: 900px;
}

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card-header {
    padding: 1.5rem 1.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
}
.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}
.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.card-actions {
    display: flex;
    gap: 0.5rem;
}
.card-body {
    padding: 1.5rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0 1.5rem;
}
.form-grid .input-group {
    margin-bottom: 1rem;
}

/* Color Picker Minimal */
.color-picker-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.375rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    width: 100%;
}
.color-picker-container input[type="color"] {
    -webkit-appearance: none;
    border: none;
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: 4px;
    cursor: pointer;
    box-shadow: none;
}
.color-picker-container input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}
.color-picker-container input[type="color"]::-webkit-color-swatch {
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 4px;
}
.color-value {
    font-size: 0.875rem;
    font-family: monospace;
}

/* Dynamic Components */
.components-layout {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.component-item {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-body);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.comp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}
.comp-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
}
.comp-title span.material-symbols-outlined {
    font-size: 1.125rem;
    color: var(--text-muted);
}
.comp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0 1rem;
}
.comp-grid .input-group {
    margin-bottom: 0.5rem;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-body);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--primary);
    color: var(--primary-fg);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    font-size: 0.875rem;
    font-weight: 500;
    opacity: 0;
    transform: translateY(10px);
    transition: var(--transition);
}
.toast.show {
    opacity: 1;
    transform: translateY(0);
}
.toast.error {
    background: var(--danger);
}

/* Mobile Responsiveness */
.mobile-topbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    z-index: 990;
}
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 995;
    opacity: 0;
    transition: opacity 0.3s;
}

@media (max-width: 768px) {
    .auth-card {
        padding: 1.5rem;
        margin: 1rem;
    }
    
    .layout-app {
        flex-direction: column;
        height: 100vh;
    }
    
    .mobile-topbar {
        display: flex;
    }

    .sidebar-overlay.show {
        display: block;
        opacity: 1;
    }
    
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        height: 100vh;
        max-height: none;
        width: 280px;
        transition: left 0.3s ease;
        border-right: 1px solid var(--border-color);
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .editor-header {
        padding: 1.5rem;
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .header-actions {
        width: 100%;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .header-actions .btn {
        width: 100%;
    }
    
    .editor-content {
        padding: 1.5rem 1rem;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .card-actions {
        width: 100%;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .card-actions .btn {
        width: 100%;
    }
    
    .comp-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .comp-header .btn-icon {
        align-self: flex-end;
    }
}
